/*
include file containing the functions to be used in the javascripting
*/
function pausecomp(millis)
{
	var date = new Date();
	var curDate = null;			
	do { curDate = new Date(); }
	while(curDate-date < millis);
}

function getStyle(obj,cAttribute)
{
	//if IE
	if (obj.currentStyle)	var curVal=eval('obj.currentStyle.'+cAttribute)
	else
	{
		//if Mozilla/FF
		var curVal=eval('document.defaultView.getComputedStyle(obj, null).'+cAttribute)
	}
return(curVal);
}

function retrieveAmount(InputString)
{
	return(InputString.substring(0,InputString.indexOf("px",0)));
}

function retrievePercentage(InputString)
{
	return(InputString.substring(0,InputString.indexOf("%",0))/100);
} 

function getNextPageId(pageId, amount, componentName)
{
	var retVal = 0;
	if (contentPages[componentName].length > pageId+amount) retVal = ++pageId;
	else 
	{
		retVal = (pageId+amount-contentPages[componentName].length);
	}
	return(retVal);
}

function setInfoContent(pageId, componentName)
{
	var radioContent = "";
	for (cnt=0; cnt<pageAmount[componentName]; ++cnt)
	{
		radioContent = radioContent + "<input onclick=\"pageId="+ cnt +";setInfoContent(" + cnt +",'" + componentName +"');\"";
		if (pageId == cnt) radioContent = radioContent + " CHECKED ";
		radioContent = radioContent + "type=\"radio\" id=\"radioPager"+ componentName +"\" value=\""+cnt+"\"/>";
	}
	temp = " <div id=\"pager"+componentName+"\">" + radioContent +" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+(pageId+1) + ".</div>";
	document.getElementById("dia1"+componentName).left = (retrieveAmount(getStyle(document.getElementById("dia1"+componentName), "left")) - 100) + "px";
	document.getElementById("dia1"+componentName).top = (retrieveAmount(getStyle(document.getElementById("dia1"+componentName), "top")) - 100) + "px";
	document.getElementById(componentName).innerHTML = contentPages[componentName][pageId] + temp;
	setTimeout("document.getElementById(\"dia1"+componentName+"\").innerHTML = contentPages['"+componentName+"'][getNextPageId("+pageId+",1,'"+componentName+"')];",450);
	setTimeout("document.getElementById(\"dia2"+componentName+"\").innerHTML = contentPages['"+componentName+"'][getNextPageId(getNextPageId("+pageId+",1,'"+componentName+"'),1,'"+componentName+"')];",550);
}



function showBlur(componentName,componentImageName, widthy, heighty, toppy, lefty, zIndexy)
{
	addOn = "";
	widthyString = new String(widthy);
	leftyString = new String(lefty);
	toppyString = new String(toppy);
	heightyString = new String(heighty);
	withy = Math.round(widthy);
	if (widthy != "") document.getElementById(componentImageName).width = widthy;
	heighty = Math.round(heighty);
	if (heighty!= "") document.getElementById(componentImageName).height = heighty;
	addOn = "";
	if (toppyString.indexOf("%") == -1 && toppyString.indexOf("px") == -1) 
	{
		addOn = "px";
		toppy = Math.round(toppy);
	}
	if (toppy != "") document.getElementById(componentName).style.top = toppy + addOn;
	addOn = "";
	if (leftyString.indexOf("%") == -1 && leftyString.indexOf("px") == -1) 
	{
		addOn = "px";
		lefty = Math.round(lefty);
	}
	if (lefty != "") document.getElementById(componentName).style.left = lefty + addOn;
	if (zIndexy != "") document.getElementById(componentName).style.zIndex = zIndexy;
	showDiv(componentName);
}

function showDiv(componentName)
{
	document.getElementById(componentName).style.display = "block";	
}

function hideDiv(componentName)
{
	document.getElementById(componentName).style.display = "none";	
}

function setDiv(componentName,widthy, heighty, toppy, lefty, zIndexy)
{
	addOn = "";
	widthyString = new String(widthy);
	leftyString = new String(lefty);
	toppyString = new String(toppy);
	heightyString = new String(heighty);
	if (widthyString.indexOf("%") == -1 && widthyString.indexOf("px") == -1) 
	{
		addOn = "px"; 
		withy = Math.round(widthy);
	}
	if (widthy != "") document.getElementById(componentName).style.width = widthy + addOn;
	addOn = "";
	if (heightyString.indexOf("%") == -1 && heightyString.indexOf("px") == -1) 
	{
		addOn = "px";
		heighty = Math.round(heighty);
	}
	if (heighty!= "") document.getElementById(componentName).style.height = heighty + addOn;
	addOn = "";
	if (toppyString.indexOf("%") == -1 && toppyString.indexOf("px") == -1) 
	{
		addOn = "px";
		toppy = Math.round(toppy);
	}
	if (toppy != "") document.getElementById(componentName).style.top = toppy + addOn;
	addOn = "";
	if (leftyString.indexOf("%") == -1 && leftyString.indexOf("px") == -1) 
	{
		addOn = "px";
		lefty = Math.round(lefty);
	}
	if (lefty != "") document.getElementById(componentName).style.left = lefty + addOn;
	if (zIndexy != "") document.getElementById(componentName).style.zIndex = zIndexy;
}

function setInnerDiv(componentName, innerPart)
{
	document.getElementById(componentName).innerHTML = innerPart;	
}

function getWindowHeight() 
{
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number')
	windowHeight = window.innerHeight;
	else {
	if (document.documentElement && document.documentElement.clientHeight)
	windowHeight = document.documentElement.clientHeight;
	else {
	if (document.body && document.body.clientHeight)
	windowHeight = document.body.clientHeight; }; };
	return windowHeight;
}

function getWindowWidth()
{
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number')
	windowWidth = window.innerWidth;
	else {
	if (document.documentElement && document.documentElement.clientWidth)
	windowWidth = document.documentElement.clientWidth;
	else {
	if (document.body && document.body.clientWidth)
	windowWidth = document.body.clientWidth; }; };
	return windowWidth;
}
