
var rotationInterval = null;

function resizeLines() {
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	var nav = document.getElementById("nav"); 
	var logo = document.getElementById("logo"); 
	var main = document.getElementById("main"); 
	var main2 = document.getElementById("main2"); 
	var hdrimg = document.getElementById("headerimg"); 
	var v = document.getElementById("lineV");  
	
	//alert ("NAV H:" +  nav.offsetHeight + ", L:" + nav.offsetLeft  + ", T:" + nav.offsetTop  + ", W:" + nav.offsetWidth + " *** LOGO H:" +  logo.offsetHeight + ", L:" + logo.offsetLeft  + ", T:" + logo.offsetTop  + ", W:" + logo.offsetWidth + " *** MAIN H:" +  main.offsetHeight + ", L:" + main.offsetLeft  + ", T:" + main.offsetTop  + ", W:" + main.offsetWidth + " *** HIMG H:" +  hdrimg.offsetHeight + ", L:" + hdrimg.offsetLeft  + ", T:" + hdrimg.offsetTop  + ", W:" + hdrimg.offsetWidth);
	if (main != null) {
		var mainNum = main.offsetTop + main.offsetHeight;
	}
	if (main2 != null) {
		var main2Num = main2.offsetTop + main2.offsetHeight;
		if (main != null) {
			if (mainNum2 > mainNum) {
				mainNum = main2Num;
			}	
		} else {
			mainNum = main2Num;
		}
	}
	
	var minimum = getMinLineHeight();
	var navNum = nav.offsetTop + nav.offsetHeight - 10;
	if (mainNum > navNum) {
		if (mainNum > minimum) {
			v.style.height =  mainNum;
		} else {
			v.style.height = minimum;
		}
	} else {
		if (navNum > minimum) {
			v.style.height =  navNum;
		} else {
			v.style.height = minimum;
		}
	}

}
function getMinLineHeight() {
	   var container = document.createElement('div'); // This element is needed as appender, but it doesn't need to be appended to something
	   var tester = document.createElement('div') ;
	   tester.setAttribute('className', 'lineMinHeight');
	   container.appendChild(tester); // only by appending an element gets the proper style.display property
	   return tester.style.height;
}

function centerIndex() {
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	var nav = document.getElementById("nav"); 
	var logo = document.getElementById("logo"); 
	var main = document.getElementById("main"); 
	var hdrimg = document.getElementById("headerimg"); 
	var v = document.getElementById("lineV"); 
	var h = document.getElementById("lineH"); 
	
	
	var y = (winH - (main.offsetTop + main.offsetHeight)) / 2;
 
	v.style.top =  y;
	h.style.top = y;
	nav.style.top = y;
	logo.style.top =  y;
	main.style.top =  y;
	hdrimg.style.top =  y;
}

function flipImageOut(currObj, onImgSrc, offImgSrc) {
	if (rotationInterval == null) {
		currObj.src = offImgSrc;
	} else {
		currObj.src = onImgSrc;		
	}
}
function flipImageOver(currObj, onImgSrc, offImgSrc) {
	if (rotationInterval != null) {
		currObj.src = offImgSrc;
	}
}
function startImageRotate() {
	rotationInterval = setInterval('doRotate()',4000);
}
function stopImageRotate() {
	clearInterval(rotationInterval);
	rotationInterval = null;
}
function flipImageRotate(currImg, onImgSrc, offImgSrc) {
	if (rotationInterval == null) {
		startImageRotate();
		currImg.src = onImgSrc;
	} else {
		stopImageRotate();
		currImg.src = offImgSrc;
	}
}
function doRotate() {
	//alert("Starting doRotate()");
	var imgDivArr = new Array();
	var imgDivPrefix = "imgrotate-";
	var imgIdx = 0;
	var currIdx = 0;
	var imgDiv = document.getElementById(imgDivPrefix+imgIdx);
	while (imgDiv != null) {
		if(imgDiv.className === "show") {
			currIdx = imgIdx;
		}
		imgDivArr[imgIdx++] = imgDiv;
		imgDiv = document.getElementById(imgDivPrefix+imgIdx);
	}
	var len = imgDivArr.length;
	var ranNum = Math.floor((Math.random() * (new Date()).getTime()) % len);
	if (ranNum == currIdx) {
		if ((ranNum + 1) < len) {
			ranNum++;
		} else if ((ranNum - 1) >= 0){
			ranNum--;
		}
	}
	
	//alert("Found " + len + " DIVs and the random number is " + ranNum);
	
	for (var i = 0; i < len; i++) {
		if (i == ranNum) {
			imgDivArr[i].className = "show";
		} else {
			imgDivArr[i].className = "hide";
		}
	}
}

function doVnAjaxResponse() {
        if (request.readyState == 4) {
                if (request.status == 200) {
                        //alert("calling response function: " + respFunction);
                        eval (respFunction);
                } else if (request.status == 404) {
                        //alert("An error occured during AJAX transaction: URL does not exist");
                } else {
                        //alert("An error occured during AJAX transaction: status code is " + request.status);
                }
        }
}

function getVnAjaxRequest() {
        var vnAjaxReq = false;
        try {
                vnAjaxReq = new XMLHttpRequest();
        } catch (trymicrosoft) {
                try {
                        vnAjaxReq = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (othermicrosoft) {
                        try {
                                vnAjaxReq = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch (failed) {
                                vnAjaxReq = false;
                        }
                }
        }
        if (!vnAjaxReq) {
                alert("Error initializing some critical JavaScript components!");
                return false;
        }
               
        return vnAjaxReq;
}
function iefix() {
	/*Use Object Detection to detect IE6*/
	var  m = document.uniqueID /*IE*/
	&& document.compatMode  /*>=IE6*/
	&& !window.XMLHttpRequest /*<=IE6*/
	&& document.execCommand ;
	
	try{
		if(!!m){
			m("BackgroundImageCache", false, true); /* = IE6 only */ 
		}
		
	}catch(oh){};
}
function jq_navi() {
	// set opacity to nill on page load
	$("ul#navlist span").css("opacity","0");
	$("div#HomeImage span").css("opacity","0");
	$("div#HomePlayPauseImage span").css("opacity","0");
		
	$("#headerimg td:not(.m_sel) div#HomeImage a").hover(function () {
		// animate opacity to full
		$(this).stop().animate({
			opacity: 0.25
		}, "fast");
	}, function () { // on mouse out
		// animate opacity to nill
		$(this).stop().animate({
			opacity: 1
		}, "fast");
	});

	$("#headerimg td:not(.m_sel) div#HomePlayPauseImage a").hover(function () {
		// animate opacity to full
		$(this).stop().animate({
			opacity: 0.25
		}, "fast");
	}, function () { // on mouse out
		// animate opacity to nill
		$(this).stop().animate({
			opacity: 1
		}, "fast");
	});
		
	$("ul#navlist li:not(.m_sel) a").hover(function () {
		// animate opacity to full
		$(this).stop().animate({
			opacity: 0.25
		}, "fast");
	}, function () { // on mouse out
		// animate opacity to nill
		$(this).stop().animate({
			opacity: 1
		}, "fast");
	});
}


