
// confirmation box
function confirmBox(txt, url) {
	if (confirm(txt)) {
		window.location.href=url;
	} 
}

// cycle display (none/block)
function cycleDisplay(name) {
	if (name.length > 0) {
		document.getElementById(name).style.display = (document.getElementById(name).style.display == "block" ) ? "none" : "block";
	}
}

// hide display
function hideDisplay(name) {
	if (name.length > 0) {
		document.getElementById(name).style.display = "none";
	}
}

// check valid email address
function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
		return true;
	} else {
		return false;
	}
}			

// spawn window
function spawnWindow(wurl, wname, width, height,tmpvalue,tmpdate) {
	if (tmpvalue != null)
		thewindow = window.open(wurl+'?lsec='+tmpvalue+'&ldate='+tmpdate,wname,'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizeable=no');
	else
		thewindow = window.open(wurl,wname,'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizeable=no');			
	thewindow.focus();
}  

// spawn window (no frame)
function spawnWindowNoFrame(wurl, wname, width, height) {
	thewindow = window.open(wurl,wname,'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no');
	thewindow.focus();
}

// table ruler
function tableruler(ruledclass,lightclass,darkclass)
{
	if (document.getElementById && document.createTextNode)
	{
		var tables=document.getElementsByTagName('table');
		for (var i=0;i<tables.length;i++)
		{
			if(tables[i].className=='ruler')
			{
				var trs=tables[i].getElementsByTagName('tr');
				var currentrow = 1;
				for(var j=0;j<trs.length;j++)
				{
					if(trs[j].parentNode.nodeName=='TBODY')
					{
						trs[j].onmouseover=function(){this.className=ruledclass;return false}
						if (currentrow % 2 == 0) {
							trs[j].onmouseout=function(){this.className=lightclass;return false}
						} else {
							trs[j].onmouseout=function(){this.className=darkclass;return false}
						}
						currentrow = currentrow + 1;						
					}
				}
			}
		}
	}
}

// Toggles an elements visibility between hidden and visible
function toggleVis(currElem) {
	dom = eval('document.all.' + currElem + '.style');
	state = dom.visibility;
	if (state == "visible" || state == "show") {
		dom.visibility = "hidden";
	} else {
		dom.visibility = "visible";
	}
}

// form submitted only once function
counter = 0;
function monitor() {
	counter++;
	if(counter > 1) { return false; }
	return true;
}

// delcare global variable to keep track of opened slide down window
var current_edsubpanel = '';

