jQuery(function(){
	var $ = jQuery;
	
	// home photo show
	if($('.home_photo_container').length){
		startPhotoShow();
	}
	
	bodyResize();
	setTimeout("bodyResize()",1000);
	$(window).resize(function(){
		bodyResize();
	});
});

function bodyResize(){
	var $ = jQuery;
	$('#background').height(0);
	$('#main').css("margin-left","0px");
	$('#footer').css("top",0+"px").css("margin-left","0px");
	$('#headerImage').css("margin-left",'0px');
	
	var winW = $(window).width();
	var docH = $(document).height();
	var docW = $(document).width();
	
	var offsetM = ((docW - $('#main').width()) / 2);
	$('#main').css("margin-left",offsetM+"px");
	var offset = $('#main').offset();
	$('#background').height(docH).css("left",offset.left+'px');
	var offsetF = ((docW - $('#footer').width()) / 2);
	$('#footer').css("top",(docH - 80)+"px").css("margin-left",offsetF+"px");
	
	// set menu location
	var menuW = $('.sf-menu','.menu').width();
	$('.sf-menu','.menu').css("margin-left",((960 - menuW)/2)+"px");
	$('#headerImage').css("margin-left",offset.left+'px');
}

function startPhotoShow(){
	setTimeout("photoShow()",6000);
}

function photoShow(){
	var $ = jQuery;
	var photo = $('.home_photo_container').children('div').last();
	photo.fadeOut(1000,function(){
		photo.prependTo('.home_photo_container').show();
		startPhotoShow();
	});
}
