function onAfter(curr, next, opts) {
}

function onBefore(curr, next, opts) {
	var index = opts.currSlide;
	if(document.getElementById("footercontent")!=null){
		document.getElementById("footercontent").innerHTML=$(this).attr("rel");
	}
	windowheight=$(document).height();
	if(document.getElementById("footercontent")!=null){
		$("#footer").css("top",(windowheight)+"px");
		$("#footer").show();
		$("#footerbackground").css("opacity", 0.6);
		$("#footer").delay("1000").animate({ 
			top: ($(window).height()-$("#header").height())+"px"
		}, 1500);	
	}
	$(this).attr("style","");
}

$(document).ready(function(){
	windowheight=$(document).height();
	windowwidth=$(document).width();
	
	heightadjusted=$("#content").height();
	if(heightadjusted<document.body.scrollHeight)
		heightadjusted=document.body.scrollHeight;
	if(heightadjusted<document.body.offsetHeight)
		heightadjusted=document.body.offsetHeight;
	$("#content").hide();
	$("#footer").hide();

	$(".slideshowbgimg").each(
		function(){
			$(this).fullBg();
		}
	);

	$('.slideshowbg').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speedIn:  2000, 
		speedOut: 500, 
		speed: 20000, //later on will be set for 20 second animation
		after: onAfter,
		before: onBefore
	});
	if($("#backgroundstarter").attr("id")=="backgroundstarter"){
		$('.slideshowbg').hide();
	}

//	$("#header").css("opacity",0.8);
//	if(heightadjusted>0 && heightadjusted>windowheight){
//		$("#backgroundstarter").css("height",(heightadjusted+$("#header").height()+1)+"px");
//	}
//	else
//		$("#backgroundstarter").css("height",(windowheight-$("#header").height()-1)+"px");
//

	$("#backgroundstarter").css("height", '1400px');
	$("#backgroundstarter").css("top",(windowheight-$("#header").height()-1)+"px");
	
	subMenuAnim = 500;
	if ($('#header-wrapper').attr('dontanimate') == "true"){
		subMenuAnim = 0;
	}

	if ($('#submenubar').length === 0){
		$("#backgroundstarter").animate({ 
			top: "62px",
			opacity: 0.6
		}, 0, function() {
			// Animation complete.
			$('.slideshowbg').show();
			$('#content').fadeIn(2000);
			//$("#content").fadeIn(1000);
		});	
	} else {
		$("#backgroundstarter").animate({ 
			top: "88px",
			opacity: 0.6
		}, 0, function() {
			// Animation complete.
			$('.slideshowbg').show();
			$('#content').fadeIn(2000);
			//$("#content").fadeIn(1000);
		});	
		$("#submenubar").animate({ 
			top: "62px",
			opacity: 1.0 //
		}, subMenuAnim);
		
		$('#header-wrapper').css("height", "89px");
	}

	$("#footer").css("top",(windowheight)+"px");
	$(".slideshowbgimg").fullBg();
});
