/**
 * @author Terry Wooton
 * @desc Adds a background layer to an element
 * @version 1.1
 * @example
 * $("#element").add_background("url('/test.gif') bottom left no-repeat");
 * @license free
 * @param background css
 *
 */
$(document).ready(function() {
  $.fn.add_layer = function(bg,params) {
    $(this).each(function() {
  
      s = $(this).extend({},params || {});      
      
      $last = ($(this).find('.add_background:last').length > 0 ? $(this).find('.add_background:last') : $(this));
  		$last.html('<div class="add_background"><div>'+$last.html()+'</div></div>');
  		$last = $(this).find('.add_background:last');
  		$last.css({'background':bg,'width':'100%','height':'100%'});

      $last = $(this).find('.add_background div:last');
            
      if(s.insideCss){
   		  $last.css(s.insideCss);
  		}
      if(s.insideClass)
  		  $last.addClass(s.insideClass);  		  
    });
  }      
});



//以下サイト用諸設定

$(function(){
	$('.body').add_layer("url('img2/common/body_back.jpg') repeat-y");
	$('.body').add_layer("url('img2/common/body_top.jpg') no-repeat center top");
	$('.body').add_layer("url('img2/common/body_bottom.jpg') no-repeat center bottom");
})
/*
$(function(){
	$('.content_a').add_layer("url('img2/common/a_back.jpg') repeat-y");
	$('.content_a').add_layer("url('img2/common/a_top.jpg') no-repeat center top");
	$('.content_a').add_layer("url('img2/common/a_bottom.jpg') no-repeat center bottom");
})
*/
$(function(){
	$('.content_b').add_layer("url('img2/common/b_back.gif') repeat-y");
	$('.content_b').add_layer("url('img2/common/b_top.gif') no-repeat center top");
	$('.content_b').add_layer("url('img2/common/b_bottom.gif') no-repeat center bottom");
})

$(function(){
	$('.sub').add_layer("#e8e8e8");
	$('.sub').add_layer("url('img2/common/sub/line_l.gif') repeat-y left");
	$('.sub').add_layer("url('img2/common/sub/line_r.gif') repeat-y right");
	$('.sub').add_layer("url('img2/common/sub/line_top.gif') repeat-x top");
	$('.sub').add_layer("url('img2/common/sub/line_bottom.gif') repeat-x bottom");
	$('.sub').add_layer("url('img2/common/sub/l_top.gif') no-repeat left top");
	$('.sub').add_layer("url('img2/common/sub/l_bottom.gif') no-repeat left bottom");
	$('.sub').add_layer("url('img2/common/sub/r_top.gif') no-repeat right top");
	$('.sub').add_layer("url('img2/common/sub/r_bottom.gif') no-repeat right bottom");
})

$(function(){
	$('#arrow').add_layer("url('img2/common/arrow-trans.png') no-repeat 24px 4px");
})

$(function(){
	$('.news').add_layer("url('img2/index/news/back.jpg') repeat-x top");
	$('.news').add_layer("url('img2/index/news/line_l.gif') repeat-y left top");
	$('.news').add_layer("url('img2/index/news/line_r.gif') repeat-y right top");
	$('.news').add_layer("url('img2/index/news/bottom.gif') no-repeat bottom");
})


