﻿var homepath="http://www.voodoomedia.it/";
if (location.href == homepath) {var ishomepath=true;}

$(document).ready(function() 
{ 
	$(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook',opacity: 0.00,showTitle:false,modal:false,callback:goBlack});
		
	$(window).resize(onResize);
	onResize();
	
	
	goBlack(500);
	if(ishomepath)
	{
		$("body").css({"background-color":"#171717"});
		$("#corpo").css({"background-image":"none"});
	}
});

isWhite = true;
targetUrl="";
millis=800;
transitioning=false;


function doMagic()
{
	if (transitioning==true){return};
	if (isWhite == false){goWhite(onWhiteComplete);}else{goBlack();}
}


function goWhite(callback) 
{
	transitioning=true;
	isWhite=true;
	$("html").css({overflow:"hidden"});
	$("#expander").animate({ height: ($("body").height() - $("#head").height() -25) +"px"},{easing:"easeInOutSine",duration:millis, complete:function(){onWhiteComplete();callback;}});
	
}

function goBlack(wait) 
{	
	if (wait == undefined) (wait=0);
	transitioning=true;
	isWhite=false;
		
	var H=0;
	
	if (ishomepath)
	{
		H = parseInt(($("body").height()/2) - $("#head").height());
	}
	
	$("#expander").delay(wait).animate({ height: H+"px"},{easing:"easeInOutSine",duration:millis, complete:onBlackComplete});
}


function onWhiteComplete() 
{
	transitioning=false;
	onResize();
	$(window).resize(onResize);
}

function onBlackComplete() 
{	
	$("#expander").css({'background-image':'none'});
	transitioning=false;
	$("html").css({overflow:"auto"});
	if(!ishomepath)$(window).unbind("resize",onResize);
}
function onResize() 
{
	var multi=1;
	if (ishomepath && !isWhite){ multi=2 ;}
	var H=(($("body").height()/multi) - $("#head").height()-25) ;
	
	$("#expander").css({ height: H +"px" });

} 

function requestPage(url) 
{
	if (url==null || url== undefined) {return;};
	targetUrl=url;
	if (isWhite==false || location.href == homepath)
	{ 
		$("html").css({overflow:"hidden"});
		
		$("#expander").animate({ height: ($("body").height() - $("#head").height() -25) +"px"},{easing:"easeInOutSine",duration:millis, complete:redirect}); 
	} 
	else 
	{
		redirect();
	}
}

function redirect() 
{
	location.href="http://www.voodoomedia.it/"+targetUrl;
}



