window.onload = writeMessage;

var rotatorTopPix = new Array("images/rotator_top/flashbar_top_02.jpg","images/rotator_top/flashbar_top_03.jpg","images/rotator_top/flashbar_top_04.jpg","images/rotator_top/flashbar_top_05.jpg");
var thisRotatorTopPic = 0;
var rotatorLeftPix = new Array("images/rotator_left/flashbar_left_02.jpg","images/rotator_left/flashbar_left_03.jpg","images/rotator_left/flashbar_left_04.jpg","images/rotator_left/flashbar_left_05.jpg");
var thisRotatorLeftPic = 0;

function rotate() {
	document.getElementById("rotatorTop").src = rotatorTopPix[thisRotatorTopPic];
		document.getElementById("rotatorLeft").src = rotatorLeftPix[thisRotatorLeftPic];
	thisRotatorTopPic++;
	thisRotatorLeftPic++;
	if (thisRotatorTopPic == rotatorTopPix.length) {
		thisRotatorTopPic = 0;
	}
	if (thisRotatorLeftPic == rotatorLeftPix.length) {
		thisRotatorLeftPic = 0;
	}	
	var rotatorTimer=setTimeout("rotate()",5000);
}

function writeMessage() {
	if (document.getElementById) {
		doIt();
		initMenu();
		rotate();
	}
	else {
		return false;
	}
}

function getPixelsFromTop(obj){
	var objFromTop = obj.offsetTop;
	while(obj.offsetParent!=null) {
		var objParent = obj.offsetParent;
		objFromTop += objParent.offsetTop;
		var obj = objParent;
		}
	return objFromTop;
	}
	
function getTDHeight(topID,bottomID){
	var contentTopDiv = document.getElementById(topID);
	var contentBotDiv = document.getElementById(bottomID);
	var contentTop = getPixelsFromTop(contentTopDiv);
	var contentBottom = getPixelsFromTop(contentBotDiv);
	contentHeight = contentBottom - contentTop;
	return contentHeight;
}

function setClass(htID,classType) {
	document.getElementById(htID).className = classType;
}

function doIt() {
	var heightUpper = getTDHeight("content_top1","content_bottom1");
	if (heightUpper >= 540) {
		setClass("contentbox1","content");
	}
	else {
		setClass("contentbox1","contentsmall");
	}
	var heightLower = getTDHeight("content_top2","content_bottom2");
	if (heightLower >= 540)  {
		setClass("contentbox2","content");
	}
	else {
		setClass("contentbox2","contentsmall");
	}	
}

function initMenu() {
	var rtrn1 = returnDocument();
	var strip1 = ".html";
	var mentype = leftFromSubStringToBeginningOfFullString(rtrn1, strip1);
	if (mentype == "") {
		document.getElementById("index").className="currentmenu";
	}
	else {
		document.getElementById(mentype).className="currentmenu";
	}
}

function returnDocument() {
        var file_name = this.document.location.href;
        var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
        return file_name.substring(file_name.lastIndexOf("/")+1, end);
    }

function leftFromSubStringToBeginningOfFullString(fullString, subString) {
	if (fullString.lastIndexOf(subString) == -1) {
		return "";
		}
		else {
		return fullString.substring(0, fullString.lastIndexOf(subString));
		}
	} 

