var lcId = new Date().getTime();
var flashProxy = new FlashProxy(lcId, "JavaScriptFlashGateway.swf");

function talkToFlash() {
	document.getElementById("status").innerHTML = 123
	flashProxy.call("inputFromJS", 1859);
}
function sizeUpdate() {
	
	var totalWidth = document.body.clientWidth;
	var totalHeight = document.body.clientHeight;
	var rightAvailWidth = (totalWidth / 2) - 46 // 17 + 18 for the frame, 1 to be sure, 10 for padding right
	var rightAvailHeight = totalHeight - 50 // 15 + 14 for frame, 1 for sure, 20 for padding bottom and top
	
	if (siteOpen || smallerFlash) {
		rightAvailHeight = totalHeight - 169
	}
//	document.getElementById("status").innerHTML = rightAvailWidth + " / " + rightAvailHeight
//	document.getElementById("flashMovieObject").style.width = rightAvailWidth + "px";
//	document.getElementById("flashMovieObject").style.height = rightAvailHeight + "px";

	
	if (usesFlash) {
		// In Internet Explorer, the proxy call from flash to function returnSize will not work unless the flash movie is visible.
		// so on first entrance to the page, we make the flash frame visible, but at the same time 0x0 small. 
		// returnSize then gives it the proper size.
		if (document.getElementById("rightColumn").style.visibility == "hidden" && isIE) {
			returnSize(0, 0)
		}
		//document.getElementById("rightColumn").style.visibility = "visible";
		flashProxy.call("getSizeInfo", rightAvailWidth, rightAvailHeight);
	
	} else {
		returnSize(rightAvailWidth - 140, rightAvailHeight);
	}
}

function returnSize(movieWidth, movieHeight) { // called from the flash movie

	if (movieWidth == null) {
		return false
	}

	if (usesFlash) {
		document.getElementById("flashMovieObject").style.width = movieWidth + "px";
		document.getElementById("flashMovieObject").style.height = movieHeight + "px";
	} else { // set the non-flash disclaimer or picture of the fkbb house
		if (!siteOpen) { // disclaimer
			document.getElementById("flashContent").style.width = (movieWidth) + "px";
			document.getElementById("flashContent").style.height = movieHeight + "px";
			document.getElementById("disclaimer").style.paddingTop = ((movieHeight - 159) / 2) + "px";
			document.getElementById("disclaimer").style.width = (movieWidth) + "px";
		} else { // user has clicked 'yes'
			document.getElementById("flashContent").style.width = (movieWidth) + "px";
			document.getElementById("flashContent").style.height = movieHeight + "px";

			var widthRatio = movieWidth / 327
			var heightRatio = movieHeight / 434
//			document.getElementById("adviceDivText").innerHTML = "widthRatio = " + widthRatio + "/ heightRatio = " + heightRatio + "<br>movieWidth = " + movieWidth + " / movieHeight = " + movieHeight
			if (widthRatio > 1 && heightRatio > 1) {
				document.images["fkbbhouse"].width = 327
				document.images["fkbbhouse"].height = 434
			} else {
				if (widthRatio < heightRatio) { // user widthratio
					document.images["fkbbhouse"].width = 327 * widthRatio;
					document.images["fkbbhouse"].height = 434 * widthRatio;
					setTimeout("setImageSize('" + (327 * widthRatio) + "','" + (434 * widthRatio) + "')", 1);
//					document.getElementById("adviceDivText").innerHTML += "<br> taking width ratio; <li>fkbbhouse.width " + document.images["fkbbhouse"].width	+ "<li>fkbbhouse.height " + document.images["fkbbhouse"].height	
				} else {
					document.images["fkbbhouse"].width = 327 * heightRatio;
					document.images["fkbbhouse"].height = 434 * heightRatio;
					setTimeout("setImageSize('" + (327 * heightRatio) + "','" + (434 * heightRatio) + "')", 1);
//					document.getElementById("adviceDivText").innerHTML += "<br> taking height ratio; <li>fkbbhouse.width " + document.images["fkbbhouse"].width	+ "<li>fkbbhouse.height " + document.images["fkbbhouse"].height	
				}
			}
			

			document.getElementById("flashContent").style.textAlign = "left";
			document.getElementById("disclaimer").style.width = movieWidth + "px"
			document.getElementById("disclaimer").style.textAlign = "center";
			document.getElementById("disclaimer").style.height = document.images["fkbbhouse"].height + "px"
			
/*			document.getElementById("disclaimer").style.padding = "0px";
			document.getElementById("disclaimer").style.margin = "0px";
			document.getElementById("disclaimer").style.border = "1px solid #ffff00";
			document.getElementById("disclaimer").style.backgroundColor = "#f0f0f0";
*/
			document.getElementById("disclaimer").style.paddingTop = ((movieHeight - document.images["fkbbhouse"].height) / 2) + "px";

		}
	}
	
	var totalWidth = document.body.clientWidth;
	var rightWidth = movieWidth + 46 // 17 + 18 for the frame, 1 to be sure, 10 for padding
	var leftWidth = totalWidth - rightWidth
	var leftHTMLwidths = leftWidth - 68 // 22 left, 46 right, 20 padding (10 each side)
	
	var totalHeight = document.body.clientHeight;
	var leftHeight = totalHeight - 20 // for padding
	var rightHeight = totalHeight - 20 // for padding
	var objectsWidth = leftHTMLwidths
	if (siteOpen || smallerFlash) {
		if (isIE) { // 22.09.2006; back to 68 when flash goes full height.
			objectsWidth = totalWidth - 30 
		} else {
			objectsWidth = totalWidth - 20
		}
		rightHeight = totalHeight - 139
	}

	
	// resize left column
	document.getElementById("leftColumn").style.width = leftWidth + "px";
	document.getElementById("leftColumn").style.height = totalHeight + "px";
	if (isIE) {
		document.getElementById("htmlDivWrap").style.height = (totalHeight - 284) + "px";
		document.getElementById("adviceDiv").style.width = leftHTMLwidths + "px";
		document.getElementById("htmlDiv").style.width = leftHTMLwidths + "px";
		document.getElementById("htmlDivBackground").style.width = leftHTMLwidths + "px";
		document.getElementById("objectsDiv").style.width = objectsWidth + "px";
		//document.getElementById("objectsTextDiv").style.width = objectsWidth + "px";
		document.getElementById("objectsDivBackground").style.width = objectsWidth + "px";
		
	} else {
		document.getElementById("htmlDivWrap").style.height = (totalHeight - 264) + "px";
		document.getElementById("adviceDiv").style.width = (leftHTMLwidths - 10) + "px";
		document.getElementById("htmlDiv").style.width = (leftHTMLwidths - 10) + "px";
		document.getElementById("htmlDivBackground").style.width = (leftHTMLwidths - 10) + "px";
		document.getElementById("objectsDiv").style.width = (objectsWidth - 10) + "px";
		//document.getElementById("objectsTextDiv").style.width = (objectsWidth - 10) + "px";
		document.getElementById("objectsDivBackground").style.width = (objectsWidth - 10) + "px";
		
	}
	document.getElementById("objectsDivWrap").style.width = (objectsWidth + 20) + "px" // 68 -- 22.09.2006; back to 68 when flash goes full height.

	// realign the menu buttons
	
	var divWidth = parseInt((objectsWidth)/ 10);
	var movePixels = parseInt((divWidth - 103)) // purposely 2 extra (to stop IE from kicking links off the first line)
	var nodes = document.getElementsByTagName('div');
	var nodeID
	var menuCount = 0
//	alert("objectsWidth = " + objectsWidth + "\nmovePixels = " + movePixels)
	for (var i = 0; i < nodes.length; i ++) {
		if (nodes[i].className == 'menuIcon') {
			nodes[i].style.marginLeft = parseInt(movePixels / 2) + "px"
			nodes[i].style.marginRight = movePixels - (parseInt(movePixels / 2)) + "px"
			
		}
	}

	// resize announcement poster
	if (document.getElementById("announcementDiv")) {
		if (document.getElementById("announcementDiv").innerHTML != "") {
			if (totalHeight < 572) {
				document.images["announcementImage"].height = (totalHeight - 20)
				document.images["announcementImage"].width = ((totalHeight - 20) / 572) * 409
			}
			document.getElementById("announcementDiv").style.left = ((leftHTMLwidths - document.images["announcementImage"].width) / 2) + "px"
			document.getElementById("announcementDiv").style.top = ((totalHeight - document.images["announcementImage"].height) / 2) + "px"
			document.getElementById("announcementDiv").style.visibility = "visible"
		} 
	}
	
	// resize right column
	document.getElementById("rightColumn").style.width = rightWidth + "px";
	document.getElementById("rightColumn").style.height = rightHeight + "px";
	document.getElementById("flashTableLeft").style.height = (rightHeight - 30) + "px";
	document.getElementById("flashTableRight").style.height = (rightHeight - 30) + "px";

	if (isIE) {
		rightHeight -= 30
	}
	document.getElementById("flashTable").style.height = rightHeight + "px";

	
	if (siteOpen == false) {
		document.getElementById("rightColumn").style.visibility = "visible";
		document.getElementById("adviceDivText").style.visibility = "visible";
		if (getDocWidth() <= 1024) {
			if (usesFlash) {
				document.getElementById("adviceDivText").innerHTML = '<p style="margin-top:0px;">Come on... knock the bleedin\' DOOR!</p>'
			} else {
				document.getElementById("adviceDivText").innerHTML = '<p>Can I suggest you download and install the latest Flash player from the <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Adobe website</a>?</p>'
			}
			document.getElementById("adviceDivText").innerHTML += '<p>It may also interest you to know that this group of youngsters have so much to say that you\'d really benefit from a screen width of 1024 pixels.</p>'
		} else {
			if (usesFlash) {
				document.getElementById("adviceDivText").innerHTML = '<p>Come on... knock the bleedin\' DOOR!</p>'
			} else {
				document.getElementById("adviceDivText").innerHTML = '<p>Can I suggest you download and install the latest Flash player from the <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Adobe website</a>?</p>'
			}

		} 
	}
//	document.getElementById("status").innerHTML = "totalHeight = " + totalHeight + " / rightHeight = " + rightHeight

}
function setImageSize(thisWidth, thisHeight) {
	document.images["fkbbhouse"].width = thisWidth;
	document.images["fkbbhouse"].height = thisHeight;
}