//startsWith function
String.prototype.startsWith = function(str) {return (this.match("^" + str) ==str) }
//endsWith function
String.prototype.endsWith = function(str) {return (this.match(str + "$") ==str) }

//Menu
function LoadMenu() {
	if (document.getElementById("nav") != undefined)
	{
		if (document.all && document.getElementById) {
			navRoot = document.getElementById("nav");
			for (i=0; i<navRoot.childNodes.length; i++)
			{ 
				node = navRoot.childNodes[i];
			   if (node.nodeName=="li" || node.nodeName=="LI")
				{
					node.onmouseover=function() {this.className+=" over";};
					node.onmouseout=function() {this.className=this.className.replace(" over", "");};
				}
			}
		}
	}
}

//footer
function LoadFooter() {
	if (document.getElementById("footer") != undefined)
	{
		document.getElementById("footer").style.bottom = "10px";
//		if (document.documentElement.clientHeight < document.body.offsetHeight)
//		{ 
//		   document.getElementById("footer").style.position = "";
//		} else
//		{ 
//			document.getElementById("footer").style.position = "absolute";
//		} 
	}
}

//ChangeBtnText
function ChangeBtnText(cntrl,tag)
{
    var msg;
	var DefaultText;
    if (tag=='S')
    {
        msg = 'Searching...';
    }
    else if (tag=='G')
    {
        msg = 'Getting...';
    }
    else if (tag=='E')
    {
        msg = 'Exporting...';
    }
    else if (tag=='L')
    {
        msg = 'Loading...';
    }
    else if (tag=='P')
    {
        msg = 'Processing...';
    }
    else
    {
        msg = tag;
    }
	DefaultText = cntrl.value;
	cntrl.value = msg;
	setTimeout("ResetBtnText('" + cntrl.id + "','" + DefaultText + "')",5000);
}
function ResetBtnText(cntrlid,text)
{
	document.getElementById(cntrlid).value = text;
}

//Open newWindow
function openWindow(url)
{
	window.open(url,'Mywin', 'status=yes,toolbar=no,menubar=no,resizable=yes,resize=yes,scrollbars=yes, height=600,width=700',false);
	window.focus();
}

//CheckAll chkbox
function CheckAll(gridID,chkbox)
{
	for (var i=0;i<document.Form1.elements.length;i++)
	{
		var e = document.Form1.elements[i];
		
		if ((e.name != 'checkall') && (e.type=='checkbox') && (e.id.toUpperCase().startsWith(gridID.toUpperCase())) )
		{
			e.checked = chkbox.checked;
			HighlightRow(e);
		}	
	}
}

//HighlightRow
var oldclass;
function HighlightRow(chk)	
{	
	if (chk.checked==true)
	{
		oldclass = chk.parentNode.parentNode.className;
		chk.parentNode.parentNode.className='dgSelect';
	}
	else
	{
		chk.parentNode.parentNode.className=oldclass;
	}
}

//ClearMsg
function ClearMsg()
{
	if(document.getElementById('lblMsg') != undefined || document.getElementById('lblmsg') != undefined)
	{
		setInterval("ClearLabel()",60000);	
	}
}
function ClearLabel()
{
	if(document.getElementById('lblMsg') != undefined)
	{
		document.getElementById('lblMsg').innerHTML = "";
	}
	if(document.getElementById('lblmsg') != undefined)
	{
		document.getElementById('lblmsg').innerHTML = "";
	}
}

//Window Functions
window.document.body.defaultStatus=document.title;
window.onload = function() {LoadMenu(); ClearMsg();};
