(function($) {
  $.fn.background2 = function(){
    var bgImg2 = $(this);		

    function resizeImg2() {
     var imgwidth = bgImg2.width();
      var imgheight = bgImg2.height();
       var winwidth = $(window).width();
      var winheight = $(window).height();
	  
  
	  var imageratio = imgwidth / imgheight;  
	  var winratio = winwidth / winheight;
	  
/*	 
	  bgImg2.css({  width: winwidth+'px' });
	 bgImg2.css({  height: (winratio * winwidth)+'px', });*/
	  
	    var imageratio2 = imgwidth / imgheight;
	  
	  	  var widthcalc = imgwidth / winwidth;
	  var heightcalc = imgheight / winheight;
	  
	  
	  
/*	   if(imageratio2<winratio) {alert('width');}
	  if(imageratio2==winratio) {alert('euqal');}
	  if(imageratio2>winratio) {alert('height');}*/
	  
	  
	  
	  /*if(imageratio2==winratio) {$(".min").html("equal");}*/
	  if(imageratio2>winratio) {
		/*  $(".min").html("first");*/
		   bgImg2.css({  height: winheight, });
		   bgImg2.css({  width: (imageratio * winheight), });
	 }
	  if(imageratio2<winratio) {
		 /* $(".min").html("second");*/
		   /*bgImg2.css({  width: winwidth+'px', });
		   bgImg2.css({  height: (imageratio * winwidth)+'px', });*/
		   
		   		   bgImg2.css({  height: (imageratio * winheight), });
		   bgImg2.css({  width: winwidth, });
		   
		  }
		  

	  
	/*if(heightcalc > 1){
			 			 bgImg2.css({  height: winheight+'px', });
						 bgImg2.css({  width: (imageratio * winwidth)+'px', });
						   alert('height = '+heightcalc);
		 }	*/
		 /* if(widthcalc > 1 ){
						  bgImg2.css({  width: winwidth+'px', });
						  
						   alert('width = '+widthcalc);
		 }  */

 }  
 
 
	doneLoading();
    resizeImg2();
    $(window).resize(function() {
		doneLoading();
      resizeImg2();
    }); 
  };



  $.fn.background = function(){
    var bgImg = $(this);		
 
    function resizeImg() {

      var winheight = $(document).height();
	  var winheight_index = $(window).height();
	  bgImg.css({
		 height: (winheight_index+200)+'px',
	/*	 width: (($(window).width())*0.3)+'px'*/
	});

    } 
    resizeImg();
    $(window).resize(function() {
      resizeImg();
    }); 
  };

})(jQuery)


function doneLoading(){
		
		
		$(".loading").hide();
		$("body").css('overflow','auto');
		$("body").css('overflow-x','hidden');
		$(".main_wrapper_b").animate({opacity:1},2000);
		
		
			
}
