var windowWidth;
var windowHeight;
var pageWidth;
var pageHeight;
var scrollWidth;
var scrollHeight;
var originalHeight;



/* Initialize float */
function initFloat()
{
	myfloat = document.getElementById("floatlayer");
	myfloatmid = document.getElementById("floatmid");
	
	/* Position float */
	moveFloat();
	
	/* Move content (if any) */
	var contentdiv = document.getElementById('floatcontent');
	
	if(contentdiv)
	{
		var html = contentdiv.innerHTML;
		myfloatmid.innerHTML = html;	
	}
	
	
	/* Display float */
	//myfloat.style.display = 'block';
	Effect.BlindDown('floatlayer');
	
	
	
	
	/* Save original height */
	originalHeight = pageHeight;
	
}


/* Reposition float */
function moveFloat()
{
	var width 	= 247;
	var height 	= 524;
	
	/* Freshen dimensions */
	getWindowDimensions();
	
	/* Define position from left */
	var left = Math.round(  (windowWidth-1000)/2+720  );
	
	/* Define position from top */
	var top = scrollHeight + 120;
	
	/* Check if top doesn't exceed pageheight */
	if(originalHeight)
	{
		var check = originalHeight - height;
		if(top > check) { top = check; } 
		
	}
	
	/* Apply styles */
	myfloat = document.getElementById("floatlayer");	
	myfloat.style.left = left+"px";
	myfloat.style.top = top+"px";
	
}


/* Fill content */
function newFloatContent(layerId)
{		
	if(document.getElementById('floatcontent'+layerId).innerHTML != document.getElementById('floatmid').innerHTML)
	{
 	Effect.Fade('floatmid',{duration: 0.1,  afterFinish: function(){setFloatContent(document.getElementById('floatcontent'+layerId).innerHTML);}});
	}
}


function setFloatContent(content)
{
	document.getElementById('floatmid').innerHTML = content;
	Effect.Appear('floatmid',{duration: 0.2});
}




/* Restore content */
function restoreFloatContent()
{
	/* Restore original content */	
	var html = "&nbsp;";
	var contentdiv = document.getElementById('floatcontent');
	
	if(contentdiv)
	{
		var html = contentdiv.innerHTML;
	}

	Effect.Fade('floatmid',{duration: 0.1, afterFinish: function(){setFloatContent(html);}});
	//	document.getElementById('floatmid').innerHTML = document.getElementById('floatsave').innerHTML;
	
	
	
}



/* Get window props */
function getWindowDimensions()
{

	if (self.innerHeight) // all except Explorer
	{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else // Explorer Mac;
	     //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		pageWidth = document.body.offsetWidth;
		pageHeight = document.body.offsetHeight;
	}
	


		if (self.pageYOffset) // all except Explorer
	{
		scrollWidth = self.pageXOffset;
		scrollHeight = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		scrollWidth = document.documentElement.scrollLeft;
		scrollHeight = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		scrollWidth = document.body.scrollLeft;
		scrollHeight = document.body.scrollTop;
	}
	
}