/***********************************************************
	lvtkd.js
	The file contains functions that are used globally
	throughout LVTKD site
***********************************************************/

var backToTopOn = new Image();
var backToTopOff = new Image();
var mainMenuWidth = 110;
var mainMenuHeight = 18;
var isNS6 = document.getElementsByTagName("BODY") && !document.all;
var isIE5 = document.getElementsByTagName("BODY") && document.all;

// These functions take care of mouse rollover to universal
// buttons.  They work only with IE.
function menuMouseOver(src){ 
	src.className = "MainMenuRollOn";
	src.style.cursor = getCursor(); 
	window.status = "";
	return true;
}

function menuMouseOut(src){ 
	src.className = "MainMenu";
	src.style.cursor = 'default';
	window.status = "";
	return true;
} 

// These functions handles text roll overs to main menus when
// a client is using Netscape 4.xx.
function netscape4MenuRollOut(layer) {
	if (!isNS6) {
		layer.bgColor = "#909090";
		layer.document.write("<DIV ALIGN='center'><A CLASS='MainMenu' HREF='javascript:void(0)'>" + layer.name + "</A></DIV>");
		layer.document.close();
		layer.resizeTo(mainMenuWidth, mainMenuHeight);
		window.status = "";
	}
	return true;
}

function netscape4MenuRollOver(layer) {
	if (!isNS6) {
		var functionName = "goto" + layer.name.replace(" ", "")
	
		layer.bgColor = "#ffffff";
		layer.document.write("<DIV ALIGN='center'><A CLASS='MainMenuMouseOver' HREF='javascript:" + functionName + "()'>" + layer.name + "</A></DIV>");
		layer.document.close();
		layer.resizeTo(mainMenuWidth, mainMenuHeight);
		layer.captureEvents(Event.CLICK);
		layer.onclick = eval(functionName);
		window.status = "";
	}
	return true;
}

// Need function for each of menu items.
function gotoHome() {
	window.location.href = "/index.shtml";
}

function gotoAbout() {
	window.location.href = "/about/index.shtml";
}

function gotoTerms() {
	window.location.href = "/term/index.shtml";
}

function gotoPoomse() {
	window.location.href = "/poomse/index.shtml";
}

function gotoColumns() {
	window.location.href = "/columns/";
}

function gotoFAQ() {
	window.location.href = "/faq/index.shtml";
}

function gotoAboutLUTKD() {
	window.location.href = "/lutkd/index.shtml";
}

function gotoContactUs() {
	window.location.href = "/contactus/index.shtml";
}

// Takes care of submenu mouse events
function submenuMouseOver(src) {
	if (isIE5) {
		src.style.cursor = getCursor();
		for (var i=0; i<src.childNodes.length; i++) {
			if (src.childNodes[i].tagName == "A")
				src.childNodes[i].style.color = "#ffff99";
		}
	}
}

function submenuMouseOut(src) {
	if (isIE5) {
		src.style.cursor = "default";
		for (var i=0; i<src.childNodes.length; i++) {
			if (src.childNodes[i].tagName == "A")
				src.childNodes[i].style.color = "#ffffff";
		}
	}
}

function submenuMouseClick(src) {
	if (isIE5) {
		for (var i=0; i<src.childNodes.length; i++) {
			if (src.childNodes[i].tagName == "A")
				self.location.href = src.childNodes[i].href;
		}
	}
}

// Take care of mouse roll overs for back to top button
function backToTopRollOver() {
	document.images["backToTop"].src = backToTopOn.src;
	window.status = "Back to top of the page";
	return true;
}

function backToTopRollOut() {
	document.images["backToTop"].src = backToTopOff.src;
	window.status = "";
	return true;
}

// Image Preloading and menu initialization for Netscape 4.xx
function init() {
	backToTopOn.src = "/image/back_to_top_on.gif";
	backToTopOff.src = "/image/back_to_top_off.gif";
	
	if (!isNS6 && document.layers) {
		for (var i=0; i<document.layers.length; i++) {
			var layer = document.layers[i];
			
			if (layer.name.indexOf("MainMenu") > -1) {
				for (var j=0; j<layer.document.layers.length; j++)
					netscape4MenuRollOut(layer.document.layers[j]);
			}
		}
	}
}

// Display or hide the given section of page.  It works only for IE 5.0 and higher.
function displayElement(elem, show) {
	if (show)
		elem.style.display = "";
	else
		elem.style.display = "none";
}

// Get cursor depending on browser
function getCursor() {
	if (isIE5)
		return "hand";
	else
		return "pointer";
}
