function init(){
	
	$w_width=$j(window).width();
	$w_height=$j(window).height();
	
	$img_width=1024;
	$img_height=728;
	
	$current_width=$j('div#bg img').css('width');
	
	if($w_width > $img_width){
		$new_h=($img_height * ($w_width/$img_width));
		$j('div#bg img').css('height',$new_h);
		
		$j('div#bg img').css('width',$w_width);
		
		
	}else{
		$j('div#bg img').css('height',$img_height);
		$j('div#bg img').css('width',$img_width);
	}
	
	
//	$j('div#bg img').bind('load readystatechange', function(){
//  		if (this.complete)
//    		 $j("#bg img").fadeIn('slow');
//	});
	
	$j("#bg img").fadeIn('slow');
	
	
	$d_height=$j(document).height();
	
	$j(".wrapper").css('height',$w_height);
	
}


function slideshow(){
	var live_src=$bg_path;
	
	var BGs=[];
	
	BGs[1]= live_src+"1.jpg";
	BGs[2]= live_src+"2.jpg";
	BGs[3]= live_src+"3.jpg";
	BGs[4]= live_src+"4.jpg";
	BGs[5]= live_src+"5.jpg";
	BGs[6]= live_src+"6.jpg";
	
	
	var current_img=parseInt($j("#bg img").attr('rel'));
	
	if(current_img+1 >= BGs.length){
		current_img=0;
	}
	
	var next_img=parseInt(current_img +1); 
	
	//alert(next_img);
	
	
	
	
	$j("#bg img").animate({ opacity: 0}, 1500 , function() { 
		$j("#bg img").attr({ src: BGs[next_img] , rel: next_img});
		$j("#bg img").animate({ opacity: 100}, 1500);
	});
	
	
}


$j(document).ready(function(){
		
		init();	
		
		if($is_home){
			//setInterval ( "slideshow()", 6000 );
		}
});

$j(window).resize(function(){
		init();	
});
