var menuClassName = "";
function menu_Hover(item) {
  menuClassName = item.className;
  item.className += " ga-topnavhover"; 
}
function menu_Unhover(item) {
  item.className = menuClassName
}
/* String Functions */
function trim(value) {
	return value.replace(/^\s+|\s+$/g, "");
}
function findObj(id) {
  return document.getElementById(id);
}
function checkEnter(event, clientFunction) {
	if (event.keyCode == 13)
		clientFunction.apply(this);
	else
		return;
}
function isDigit(event) {
	if (!event) var event = window.event
	if (event.keyCode) code = event.keyCode;
	else if (event.which) code = event.which;
	
	if (((code < 48)||(code > 57 ))) 
		if (code != 46 && code != 37 && code != 39 && code != 8 && code != 9) 
			return false;
}
function setValue(id, value) {
	var ctrl = findObj(id);
	if (ctrl) {
		switch (ctrl.type) {
			case "select-multiple":
				setSelectMultipleValue(id, value);
				break;
			case "radio":
				setRadioValue(id, value);
				break;
			case "checkbox":
				setCheckBoxValue(id, value);
				break;
			case "password":
				break;
			default:
				ctrl.value = value.replace(/<br>/g, "\r\n");
				break;
		}
	}
	else {
		ctrl = findObj(id + "1");
		if (ctrl && ctrl.type == "radio") 
			setRadioValue(id, value);
		else if (ctrl && ctrl.type == "checkbox") 
			setCheckBoxValue(id, value);
	}
}
function setSelectMultipleValue(id, value) {
	var value_array = value.split("|");
	var ctrl = findObj(id);
	for (var i = 0; i < ctrl.length; i++) {
		for (var j = 0; j < value_array.length; j++) {
			if (ctrl.options[i].value == value_array[j])
				ctrl.options[i].selected = true;
		}
	}		
}
function getRadioValue(id) {
	var ctrl = document.forms[0].elements[id];
	
	if(!ctrl) return "";
	var ctrlLength = ctrl.length;
	if (ctrlLength == undefined)
		if (ctrl.checked) return ctrl.value; else return "";
	for (var i = 0; i < ctrlLength; i++) {
		if(ctrl[i].checked) 
			return ctrl[i].value;
	}
	return "";
}
function setRadioValue(id, value) {
	var index = 1;
	var ctrl = findObj(id + index);
	while (ctrl) {
		if (ctrl.value == value) {
			ctrl.checked = true;
			break;
		}
		index++;
		ctrl = findObj(id + index);
	}
}
function setCheckBoxValue(id, value) {
	var ctrl = findObj(id);
	if (ctrl) { 
		ctrl.checked = (value != ""); 
	}
	else {
		var index = 1;
		var value_array = value.split("|");
		var ctrl = findObj(id + index);
		while (ctrl) {
			for (var j = 0; j < value_array.length; j++) {
				if (ctrl.value == value_array[j]) {
					ctrl.checked = true;
					break;
				}
			}
			index++;
			ctrl = findObj(id + index);
		}
	}
}
function setFocus(controlID) {
	if (findObj(controlID).type != "hidden") {
		window.setTimeout("findObj('" + controlID + "').focus()", 1); 
	}
}
function validateLogin() {
	IsValid = true;
	if (IsValid)
		IsValid = RequiredField("LoginUserID", "Please enter User ID.");
	if (IsValid)
		IsValid = RequiredField("LoginPassword", "Please enter Password.");
	if (IsValid) {
		document.formLogin.action = "login_action.php";
		document.formLogin.submit();
	}
}
function logout() {
	document.location = "logout_action.php";
}
function autoEllipseText(id, text) {
	span = findObj("inSpan");
	width = findObj(id).offsetWidth - 10;
	span.innerHTML = text;
	if (span.offsetWidth > width) {
		var i = 1;
		span.innerHTML = "";
		while (span.offsetWidth < (width) && i < text.length) {
			span.innerHTML = text.substr(0, i) + "...";
			i++;
		}
		findObj(id).innerHTML = span.innerHTML;
	}
	else {
		findObj(id).innerHTML = text;
	}
	span.innerHTML = "";
} 
function queryString(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
		for (i = 0; i < gy.length; i++) {
			ft = gy[i].split("=");
			if (ft[0] == ji) {
				return ft[1];
		}
	}
}
function getPageSize() {
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
		
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
		
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	
	return [pageWidth,pageHeight];
}