// JavaScript Document
function onDelete( URL, strMsg )	{
	var bConf;
	bConf = confirm(strMsg);
	if (bConf)	window.location.href = URL;
}

function onSubmit( frm )	{
	var f;
	if ( typeof(frm) == "form" )
		f=frm;
	else ( typeof(eval("document."+frm)) == "form" )
		f=eval("document."+frm);
	f.submit();
}

function CheckAll( chk, lbl )	{
	var iLoop,bChecked;
	if(chk.length==undefined) {
		if(chk.checked) {chk.checked=0;bChecked=0;}
		else	{chk.checked=1;bChecked=1;}
	}
	else	{
		for(iLoop=0;iLoop<chk.length;iLoop++)	{
			if ( chk[iLoop].type == "checkbox" )	{
				if(chk[iLoop].checked)	{
					chk[iLoop].checked = 0;
					bChecked=0;
				}
				else	{
					chk[iLoop].checked = 1;
					bChecked=1;
				}
			}
		}
	}
	if(lbl!=null)	ChangeLabel( lbl, bChecked );
	else	ChangeLabel( lbl, bChecked );
}

function ChangeLabel( lbl, byt )	{
	if(document.getElementById(lbl))	{
		lbl = document.getElementById(lbl);
		if(byt) lbl.innerHTML="Uncheck All";
		else lbl.innerHTML="Check All"
	}
}

function ValidatePrintRequests(frm)	{
	var bValidate;
		bValidate = 0;
	var ofrmEl;
		ofrmEl = eval("document."+frm+".elements");
	for(var iLoop=0;iLoop<ofrmEl.length;iLoop++)	{
		if(ofrmEl[iLoop].type=='checkbox')	{
		if(ofrmEl[iLoop].checked)	{
			bValidate = 1;
			break;
			}
		}
	}
	if(bValidate)
		onSubmit(frm);
	else
		alert("Please select a requested user.");
}

function trim(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { 
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { 
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { 
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
   }
   return retValue; 
} 

function replaceChars(entry, replaceThis, replaceWith) {
out = replaceThis; // replace this
add = replaceWith; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
return temp;
//document.subform.text.value = temp;
}

function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

function taCount(visCnt) { 
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;
}


function getLayerValue(id)	{
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

if (ie4) {return document.all[id].innerText;}
if (ns4) {return document.layers[id].innerText;}
if (ns6) {return document.getElementById([id]).innerText;}
}

function setLayerValue(id, value)	{
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

if (ie4) {document.all[id].innerText=value;}
if (ns4) {document.layers[id].innerText=value;}
if (ns6) {document.getElementById([id]).innerText=value;}
}

var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

function hidelayer(lay) {
if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.display = "none";}
}
function showlayer(lay) {
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.display = "block";}
}
