var displayMode;

function mouseHover() {
	var f, e = window.event;
	f = (e.type == "mouseover") ? ('_f2') : ('');
	e.srcElement.src = "images/" + e.srcElement.id + f + ".gif";
}

function mouseHoverCSS() {
	var e = window.event, g = e.srcElement.className;
	e.srcElement.className = (e.type == "mouseover") ? (g + "_over") : (g.substr(0, g.length - 5));
}

function validateNumeric() {
	var kc = event.keyCode;
	var txt = event.srcElement;
	var bl = kc < 48 || kc > 57 ? false : true;
	return  bl;
}

function validateAddEditMode() {
	if (displayMode == "Add" || displayMode == "Edit") {
		 return confirm("Are you sure you want to navigate away from this page and lose all entered information?");
	} else {
		return true;
	}
}

function navigatePage(url) {
	if (validateAddEditMode()) {
		location.href = url;
	}
}

function changeCategory() {
	if (!validateAddEditMode()) {
		void(0);
	}
}

function confirmCancel() {
	return confirm("Are you sure you want to cancel editing and lose all the information you entered?");
}

function confirmDelete(name) {
	return confirm("Are you sure you want to delete this " + name + "?");
}

function enlargePicture(img) {
	// save image source in the cookie
	setCookie("picture", img.src);
	// open new window
	var oPictureWindow = window.open("picture.htm", "picture", "left=300, top=100, directories=no, fullscreen=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no");
	// set focus on a new window
	oPictureWindow.focus();
}

function right(e) {
	if (navigator.appName == "Netscape" && (e.which == 3 || e.which == 2))
		return false;
	else if (navigator.appName == "Microsoft Internet Explorer" && (event.button == 2 || event.button == 3)) {
		alert("Sorry, you do not have permission to right click.");
		return false;
	}
	return true;
}


function startHighlight(gvw_name)
{
	var gvw = document.all(gvw_name);
	if (gvw != null)
	{
		// get a reference to the tbody element 
		var tbody = gvw.childNodes[0];
		for (i = 1; i < tbody.childNodes.length; i++)
		{
			var node = tbody.childNodes[i];
			if (node.nodeName == "TR")
			{
				node.onmouseover=function()
				{
					this.className = "over";                
				}
				node.onmouseout=function()
				{
					this.className = this.className.replace("over", "");
				}
			}
		}
	}
}

function getCookie(name) {
    var start = document.cookie.indexOf(name + '=');
    var len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(';',len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + '=' + escape(value) +
        ( (expires) ? ';expires=' + expires.toGMTString() : '') +
        ( (path) ? ';path=' + path : '') + 
        ( (domain) ? ';domain=' + domain : '') +
        ( (secure) ? ';secure' : '');
}



