function init() {
	//presetPages();
	renderFooter();
}

var intervalId = 0;

function renderWithDelay() {
	document.getElementById( "imageCreditDiv" ).style.display = "none"
	intervalId = setInterval("renderFooter()",500 );
}

function renderFooter() {
	
	clearInterval(intervalId);
	
	var myDiv = document.getElementById( "imageCreditDiv" );
	
	myDiv.style.display = "none"
	myDiv.style.top = 0;
	
	iHeight = 0;
	if( typeof window.innerHeight != "undefined" ) {
		iHeight = window.innerHeight;
	}
	if( typeof document.documentElement.clientHeight != "undefined" ) {
		iHeight = ( document.documentElement.clientHeight > iHeight ) ? document.documentElement.clientHeight : iHeight;
	}
	if( typeof document.getElementsByTagName( "body" )[ 0 ].clientHeight != "undefined" ) {
		iHeight = ( document.getElementsByTagName( "body" )[ 0 ].clientHeight > iHeight ) ? document.getElementsByTagName( "body" )[ 0 ].clientHeight : iHeight;
	}
	
	
	
	iTop = myDiv.offsetTop;
	d = myDiv;
	while( d = d.offsetParent ) {
		iTop += d.offsetTop;
	}
	
	//myDiv = document.getElementById( "imageCreditDiv" );
	myDiv.style.position = "absolute";
	if( iHeight > iTop ) {
		myDiv.style.top = ( iHeight - ( 29 + myDiv.style.height ) ) + "px";
	/* where 29 is some constant that works for my page but that you can determine for yourself by playing around */
	}
	
	
	//check frame height
	/*var leftFrame =  document.getElementById( "contentFrameLeft")
	var leftFrameHeight = findPosY(leftFrame) + parseInt(leftFrame.style.height);

	
	if( parseInt(myDiv.style.top) <  leftFrameHeight) {
		myDiv.style.top = leftFrameHeight + "px";
	}
	*/
	
	myDiv.style.display = "block";	
}

function switchLanguage( language ) {
	
	var strTo="";
	//var strQuery="?";
	
	var leftFrame = document.getElementById( "contentFrameLeft");
	var rightFrame = document.getElementById( "contentFrameRight");
	
	if( language != "eng") {		
		strTo = language + "/default.aspx"
	}
	else {
		strTo = "../default.aspx"
	}
	
	/*if( leftFrame.style.visibility == "visible" ) {
		strQuery += "left=" + leftFrame.document.location;
	}

	if( rightFrame.style.visibility == "visible" ) {
		
		if( strQuery.length > 1 ) strQuery += "&"; 
		
		strQuery += "right=" + rightFrame.document.location;
	}*/
	
	document.location = strTo //+ strQuery;
		
}

function presetPages(  ) {
	
	var leftFrame = document.getElementById( "contentFrameLeft");
	var rightFrame = document.getElementById( "contentFrameRight");

	leftQuery = location.href.substring(location.href.indexOf("left") + 5, location.href.indexOf)

	if(  location.href.indexOf("left") != -1 ) {		
		leftFrame.src = 
		rightFrame.src = language + "/" + rightFrame.src
	}
	else {
		leftFrame.src = "../" + leftFrame.document.location
		rightFrame.src = "../" + leftFrame.document.location
	}
}

function hideFrame( frame ) {
	
	var strFrame  = frame.charAt(0).toUpperCase() + frame.substring(1,frame.length).toLowerCase()
	var frameEl = document.getElementById( "contentFrame" + strFrame)
	var buttonEl = document.getElementById( "closeButton" + strFrame )
	
	
	frameEl.style.visibility = "hidden";
	buttonEl.style.visibility = "hidden";
	frameEl.src = "";
	
	if( strFrame == "left") {
		document.getElementById("flashDiv").style.visibility = "visible"
	}
}

function showFrame( frame ) {

	var strFrame  = frame.charAt(0).toUpperCase() + frame.substring(1,frame.length).toLowerCase()
	var frameEl = document.getElementById( "contentFrame" + strFrame)
	var buttonEl = document.getElementById( "closeButton" + strFrame )
	
	frameEl.style.visibility = "visible";
	buttonEl.style.visibility = "visible";
	
	if( strFrame == "Left") {
		document.getElementById("flashDiv").style.visibility = "hidden"
		hideFrame("right")
	}
}

function hideAllFrames() {
	hideFrame("left");
	hideFrame("right");
	
	document.getElementById("flashDiv").style.visibility = "visible"
}

function gotoUrl(strUrl,strTarget) {
	document.getElementById(strTarget).src = strUrl;
	showFrame("left")
	hideFrame("right"); 
}

function mouseOver( index ) {
	var el = document.getElementById("menuItem"+index)
	
	el.firstChild.style.background = "#9eb9ca";
}

function mouseOut( index ) {
	var el = document.getElementById("menuItem"+index)
	
	el.firstChild.style.background = "none";
}

function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
		while(1)
		{
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}