// JavaScript Document
var isLoaded = false;

function centerContent(animate){
	if(window.location.search.indexOf("page_mode") == -1){
		
		var avail_height=window.innerHeight?window.innerHeight:getBody(window).clientHeight;
		var contentHeight = 531;
		var newPadding = Math.round((avail_height-contentHeight)/2);
		
		if(isLoaded == true){
			if(newPadding > 0){
				document.body.style.marginTop = newPadding + "px";
			}	
		}
		else{
			
			if(newPadding > 0){
				var str = "<style type=\"text/css\">";
				str+= "body  {padding-top: "+newPadding+"px}";
				if(typeof($) == "function" && animate){
					str+= "#mainContainer	{display: none}";
				}
				str+= "</style>"
				
				document.write(str);
			}
			if(typeof($) == "function"){
				$(document).ready(function () {
					isLoaded = true;	
					showEnter(newPadding);
				});	
			}
			

				
			
			window.onresize = function(){
				centerContent();
			}	
		}
		
	
	}
	
}

function animateImg(){
	$("#startImage").animate({
		left : '0px'				 
		},1000,"linear",function(){showContent()});
}

function showContent(){
	//$("#mainContainer").css({"visibility":"visible","opacity":"0"});
	$("#mainContainer").fadeIn("def");	
	//$("#mainContainer").fadeIn("def",function(){$("#startImage").fadeOut("fast");});	

}



function showEnter(bodyTop){
	var img = document.createElement("img");	
	img.src = "shared/images/startImage.jpg";
	var div = document.createElement("div");	
	div.id = "startImage";
	div.style.top = bodyTop - 6 + "px";
	div.style.left = (700 - 300)/2 + "px";
	div.onclick = function(){
		animateImg();
	}
	
	div.appendChild(img);
	
	document.body.appendChild(div);
}

function getBody(w){
    return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
} 
