// === GLOBAL DECLARATIONS ======================================
var NS;
var VER;
var NS6;
var IE;
var pairDelim = "^";
var singleDelim = ":";

//Below array contains the field names to allow "<" and ">" characters.
//"<" ">" will be removed from all other fields.
var arrSplFieldList_ltgt = new Array();
arrSplFieldList_ltgt[0] = "txt_comments";
arrSplFieldList_ltgt[1] = "txt_email_comments";
arrSplFieldList_ltgt[2] = "txt_togacomment";
arrSplFieldList_ltgt[3] = "txt_client_comments";


// === STARTUP CODE =============================================
// check the browser 
VER = parseFloat(navigator.appVersion)
NS6 = false
NS = false;
IE = false;

if (navigator.appName == "Netscape") {
    if (VER >= 5) {
        NS6 = true;
    } else {
        NS = true;
        loadevents();
    }
} else if (navigator.appName == "Microsoft Internet Explorer") {
    IE = true;
}
//==============Netscape Related Code=====================================
function loadevents() {
    //enable Netscape to handle events
    //call this function from the initialization function of a page
    // to enable events in Netscape
    // note: the eventHandler function needs to be defined in Application.js
    if (NS == true) { // then this is netscape
        this.document.captureEvents(Event.MOUSEOVER);
        this.document.captureEvents(Event.MOUSEOUT);
        this.document.captureEvents(Event.FOCUS);
        this.document.captureEvents(Event.BLUR);
        this.document.captureEvents(Event.KEYUP);
        this.document.captureEvents(Event.CLICK);
        this.document.captureEvents(Event.MOUSEDOWN);
        this.document.onMouseOver = eventHandler;
        this.document.onMouseOut = eventHandler;
        this.document.onfocus = eventHandler;
        this.document.onBlur = eventHandler;
        this.document.onkeyup = eventHandler;
        this.document.onmousedown = eventHandler;
    }
}

function eventHandler(e) {
    //capture the events for Netscape and handle them appropriately
    // the functions should be handled at the page level.  

    switch (e.type) {
        case "mouseover":
            pgMouseOver(e.target, e);
            break;
        case "mouseout":
            pgMouseOut(e.target, e);
            break;
        case "focus":
            pgFocus(e.target, e);
            break;
        case "blur":
            pgBlur(e.target, e);
            break;
        case "keyup":
            pgKeyUp(e.target, e);
            break;
        case "click":
            pgClick(e.target, e);
            break;
        case "mousedown":
            pgClick(e.target, e);
            break;
        default:
            clearstatus(e.target, e);
            break;
    }
}

//================================================================

//function loadSelect(control, array, selDefault){
//// takes an array, and populates a Select control with the array.
//// sets the selected index to any index passed.  
//// MWG - 2/2/01 - modified so it sets the value of the option

//// if an invalid default index is passed, set it to 0
//	if (selDefault == null || selDefault > array.length){
//		selDefault = 0
//		}	
//	control.length = 0;
//	// load control	
//	for (var i = 0 ; i < array.length; i++){
//		control.options[i] = new Option(array[i],array[i]);
//	}
//	control.selectedIndex = selDefault
//}


function addOption(control, option, value, selDefault) {
    // add a single option to a select control
    // if an invalid default index is passed, set it to 0
    if (selDefault == null || selDefault > control.length) {
        selDefault = 0
    }
    // load control	
    var newIndex = control.options.length;
    control.options[newIndex] = new Option(option, value);

    control.selectedIndex = selDefault
}



//function MM_openBrWindow(theURL,winName,features) { //v2.0
//  window.open(theURL,winName,features).focus();
//}

////Clears the status bar
//function clearstatus(){
//					window.status = '';
//} 

//function setStatus(text){
//	window.status = text;
//}	

//function disableText(obj){
////force focus away from text boxes if they are disabled
//// this is for netscape.  IE handles this itself
//        if (NS){
//                if (obj.disabled == true  || obj.readonly == true){
//                        obj.blur();                 
//                } 
//        } 
//}


//function writeString(stemp){
//// write out a string 
// 	document.write(stemp);
//}


//function wrapInTag(tagName,xmlData){
//var retval="";
//	retval =  "<" + tagName + ">\n" + xmlData + "</" + tagName + ">\n";
//	return retval;
//}
// 
//function checkForInvalidChars(invalArray,ctrl){
//	var msg = "";
//	for (var i=0; i< invalArray.length; i++){
//		if (ctrl.value.search(invalArray[i]) >-1){
//			msg = msg +  invalArray[i] + " is an invalid Password character \n";
//		}	
//	}
//	if (msg !=""){
//		return msg ;
//	}else{
//		return true;
//	}
//}

//function validateNumber(control){
//	test = control.value
//	if(isNaN(test)){
//		return false;
//	}else{
//		return true;
//	}		
//}
// 
//function validateNumberAndAlert(control){
//	var val = control.value;
//	
//	if (validateNumber(control) == false){
//		alert("A numeric entry is required for this field");
//		control.focus();
//	}	
//} 


//	// Returns true if character c is an English letter 
//	// (A .. Z, a..z).
//	//
//	// NOTE: Need i18n version to support European characters.
//	// This could be tricky due to different character
//	// sets and orderings for various languages and platforms.
//function isLetter (c){
//	return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
//}

//	// Returns true if character c is a digit 
//	// (0 .. 9).
//function isDigit (c){
//	return ((c >= "0") && (c <= "9"))
//}

//	// Returns true if character c is a letter or digit.
//function isLetterOrDigit (c){
//    return (isLetter(c) || isDigit(c))
//}

//function isInteger(strValue) {
//    var i;

//    // Search through string's characters one by one
//    // until we find a non-numeric character.
//    // When we do, return false; if we don't, return true.

//    for (i = 0; i < strValue.length; i++)
//    {   
//        // Check that current character is number.
//        var c = strValue.charAt(i);

//        if (!isDigit(c)) return false;
//    }

//    // All characters are numbers.
//    return true;
//}

//function isFloat(strValue) {
//    var i;
//    var alreadyDecPoint = false;
//    var alreadyHyphen = false;

//    // Search through string's characters one by one
//    // until we find a non-numeric character.
//    // When we do, return false; if we don't, return true.

//    for (i = 0; i < strValue.length; i++)
//    {   
//        // Check that current character is number.
//        var c = strValue.charAt(i);

//        if (!isDigit(c) && c != "." && c!= "-") return false;
//        
//        if (c == "." && alreadyDecPoint) return false;
//        if (c == ".") alreadyDecPoint=true;
//        
//        if (c == "-" && alreadyHyphen) return false;
//        if (c == "-") alreadyHyphen=true;
//    }

//    // All characters are numbers.
//    return true;
//}
// 
//function checkEmpty(control){
//	test = control.value
//	if(test == "" || test == " "){
//		return false;
//	}else{
//		return true;
//	}		
//}
// 		
//function formatNumber(numToFormat, decPlaces){
//// test this thoroughly - MAL 7/6/01
//		var zeros = ".";
//		var strNum = new String(numToFormat)		
//		if (decPlaces == "" || decPlaces == null){
//			decPlaces = 1;
//		}	
//		//if the number just needs .0's tacked on, handle it as a string
//		
//			if (strNum.indexOf(".") == -1){
//				for (var i = 0; i < decPlaces ; i++){
//					zeros = zeros + "0";
//				}
//				numToFormat = numToFormat + zeros;
//			}else{
//				numToFormat *= Math.pow(10,decPlaces);
//				strNum = new String(numToFormat);
//				var loc = strNum.indexOf(".")
//				var dec = strNum.slice(loc)
//				dec = parseFloat(dec)
//			
//				if (dec > 0.5) {
//					numToFormat = Math.ceil(numToFormat);
//				}else{
//					numToFormat = 	Math.floor(numToFormat);
//				}	
//	        	numToFormat /= Math.pow(10,decPlaces);
//			}	
//			
//		
//	    var tmpStr = new String(numToFormat);
//		return tmpStr;
//}			

//function wrapInTag(tagName,xmlData){
//var retval="";
//	retval =  "<" + tagName + ">\n" + xmlData + "</" + tagName + ">\n";
//	return retval;
//}

//function CanIStripltgt(arrList, fieldName)
//{
//var iCount;
//	for(iCount = 0; iCount < arrList.length; iCount++) {
//		if (arrList[iCount] == fieldName)
//		{	
//			//alert(fieldName);
//			//alert(arrList[iCount]);
//			//Specified Field found in the array. Dont remove < and  >
//			return	false	
//		}			
//	}
//	//Could not find the specified field in the array. remove < and  >
//	return true
//}

//function buildRequestXML(frm){
//var data="";
//var arrCheckBoxes = new Array();   
//	for (var i=0; i < frm.elements.length; i++){
//		var el = frm.elements[i];
//		var el_value = "";
//		var skipElement=false;
//			switch(el.type){
//				case"select-one":
//					if (el.selectedIndex == -1){
//						el_value="";
//					}else{
//						el_value=el.options[el.selectedIndex].value;
//					}	
//					break;
//				case"select-multiple":
//					for(var idx=0;idx<el.options.length;idx++) {
//						//if (el.options[idx].selected) {
//							var val = el.options[idx].value;
//							if(el.name.substring(0,4)=="XML_") {
//								el_value = el_value + "<" + el.name + ">";
//								el_value = el_value + val;
//								el_value = el_value + "</" + el.name + ">";
//							} else {
//								if (CanIStripltgt(arrSplFieldList_ltgt,el.name))							
//								{
//									val = val.replace(new RegExp("<","g"),"");
//									val = val.replace(new RegExp(">","g"),"");
//								}
//								else
//								{
//									val = val.replace(new RegExp("<","g"),"%3C");
//									val = val.replace(new RegExp(">","g"),"%3E");
//								}
//								el_value = el_value + "<" + el.name;
//								el_value = el_value + " value='" + val+"'"
//								el_value = el_value + "/>";
//							}
//						//}
//					}
//					data = data + el_value + '\n';
//					skipElement=true;
//					break; 
//				case "checkbox":
//					if ( el.checked){
//						arrCheckBoxes[arrCheckBoxes.length] = el;
//					}	
//					skipElement=true;
//					break;
//				case  "radio":
//					if(el.checked) {
//						el_value=el.value;
//					} else {
//						skipElement=true;
//					}
//					break
//				case "button":  case "submit": case "reset":
//					skipElement=true;
//					break;
//				case "hidden":
//					if(el.name == "ctrl_XML"){
//						skipElement=true;
//					}else{
//						el_value = el.value;
//					}		
//					break;	
//				default:
//					el_value=el.value;
//					break;
//				}
//				
//				if(!skipElement) {
//					if(el.name.substring(0,4)=="XML_") {
//						data = data + "<" + el.name + ">";
//						data = data + el_value;
//						data = data + "</" + el.name + ">";
//					} else {
//						data = data  + wrapTagAttributes( el.name,el_value);
//					}
//				
//			}	
//	}
//	//process checkboxes separately.  If the checkbox is an array of checkboxes, 
//	// then the values need to be rolled up.
//	if (arrCheckBoxes.length >0){
//		//arrCheckBoxes.sort();
//		var el_name;
//		var el_holdVal;
//		el_value = arrCheckBoxes[0].value;
//		el_name =  arrCheckBoxes[0].name;
//		el_holdVal = el_value;
//		if (arrCheckBoxes.length >=2){
//			for(var x = 1; x < arrCheckBoxes.length; x++){
//				  	el = arrCheckBoxes[x];
//					if ( el_name != el.name){
//						data = data  + wrapTagAttributes( el_name,el_holdVal);
//						el_holdVal = el.value;
//					}else{
//						el_holdVal = el_holdVal + "," + el.value;
//					}	
//					if (x == (arrCheckBoxes.length-1)){
//							data = data  + wrapTagAttributes( el.name,el_holdVal);
//					}
//					el_value = el.value;
//					el_name = el.name;
//			}
//		}else{
//			data = data + wrapTagAttributes(el_name,el_value);
//		}	
//	}
//	data = wrapInTag("data",data);
//	//alert(data)
//	return data;
//}

//function wrapTagAttributes(name,value){
//		var data;
//		value = value.replace( /'/g,"%27");
//		//%22 changed to %27%27. KPS 08/23/2002. Change done to be consistent with code in 
//		//togaHelper module replaceChrsForStringSave function.
//		value = value.replace(/\"/g, '%27%27');		
//		value = value.replace(new RegExp("&","g"),"%26");
//		if (CanIStripltgt(arrSplFieldList_ltgt,name))							
//		{
//			value = value.replace(new RegExp("<","g"),"");
//			value = value.replace(new RegExp(">","g"),"");
//		}
//		else
//		{
//			value = value.replace(new RegExp("<","g"),"%3C");
//			value = value.replace(new RegExp(">","g"),"%3E");
//		}
//		data =  "<" + name;
//		data = data + " value='" + value+"'"
//		data = data + "/>";
//		data = data + '\n';
////		alert(data);	
//	return data;
//}

//=======================================================================

//function ctrlItems() {

//	document.write('<input type="hidden" name="ctrl_CallerID" id="ctrl_CallerID" value="" />');
//	document.write('<input type="hidden" name="ctrl_Command" id="ctrl_Command" value="" />');
//	document.write('<input type="hidden" name="ctrl_ApplicationID" id="ctrl_ApplicationID" value="" />');
//	document.write('<input type="hidden" name="ctrl_GUID" id="ctrl_GUID" value="" />');
//	document.write('<input type="hidden" name="stt_Stack" id="stt_Stack" value="" />');
//	//document.write('<input type="hidden" name="ctrl_XML" id="ctrl_XML" value="" />');
//	writeApplicationControls();
//	
//}

//function writeApplicationControls(){
////function to be overridden by application if needed
//}

//function goHome() {
//	window.location=appRoot+"/";
//}

//function showReport(rptName) {
//    ses = new JS_State();
//	strXML = "<data>";
//	strXML += "<ctrl_CallerID value='menu' />";
//	strXML += "<ctrl_Command value='" + rptName.toLowerCase() + "' />";
//	strXML += "<ctrl_ApplicationID value='" + appName + "' />";
//	strXML += "<ctrl_GUID value='" + ses.GUID + "' />";
//	strXML += "</data>";
//	strURL = "controller.asp?ctrl_XML=" + strXML
//	window.open(strURL,rptName,"status,resizable,height=400,width=600");
//	
//}
// 
var hWindow;

//function doSubmit(objForm,objDataForm,command) {
//	// set control object values
//	objDataForm.ctrl_CallerID.value = objForm.name;
//	objDataForm.ctrl_Command.value = command;
//	objDataForm.ctrl_ApplicationID.value = appName;
//	objForm.ctrl_XML.value =  buildRequestXML(objDataForm);
//	
////	alert(objForm.ctrl_XML.value)
//	window.status = "Please Wait . . .";	
//	hWindow = window.open("pagepending.html",command,"status,titlebar=no,toolbar=no,menubar=no,left=" + screen.width / 3 + ",top=" + screen.height / 3 + ",resizable,height=150,width=204");
//	hWindow.focus();
//	objForm.action=  "Controller.asp";
//	objForm.submit();
//}

// function writeGuid(objForm){
// 	var ses = new JS_State()
//	//alert(ses.GUID)
//	objForm.ctrl_GUID.value = ses.GUID
//	objForm.stt_Stack.value = ses.Stack
//}

//function strToArrays(str){	
////Takes a string separated by two delimiters create two sequential arrays.  
////The arrays are "Rolled up" using the value of the first array.
////The second array will be a string containing all of the values related to the first array, separated
//// by a delimiter.   
//// it returns a single array containg the two sequential arrays. 
//	var item;
//	var arrPairs;
//	var arrItem1 = new Array();
//	var arrItem2 = new Array();
//	var counter1 =0 ;
//	var counter2 =0 ;
//	var arrReturn = new Array();
//	
//	//split the string into an array of pairs
//	arrPairs = str.split(pairDelim);
//	
//	
//	for(item  in arrPairs){
//	var arrHold = arrPairs[item].split(singleDelim);
//	//split each pair, and test the first item.  If it is the same as the last item, append the second
//	// item to the second array using a delimeter.  Otherwise, start a new item for both arrays
//		if (counter1 > 0){
//		 	if(arrItem1[counter1-1] == arrHold[0]){
//				arrItem2[counter1 -1] = arrItem2[counter1 -1] + singleDelim + arrHold[1];
//			}else{
//				arrItem1[counter1]=arrHold[0];
//				arrItem2[counter1]=arrHold[1];
//				counter1 = counter1 + 1;
//			}
//		 }else{
//		 		arrItem1[counter1]=arrHold[0];
//				arrItem2[counter1]=arrHold[1];
//				counter1 = counter1 + 1;
//			}		
//	}
//	
//	arrReturn[0] =arrItem1;
//	arrReturn[1] = arrItem2;
//	return arrReturn;
//				
//}	


//function strToArrayNoRollup(str){
////Takes a string separated by two delimiters, and returns two syncronized arrays.
////THis is a one for one split, there is no rollup.
//// it returns a single array containg the two sequential arrays. 
//	var item;
//	var arrPairs;
//	var arrItem1 = new Array();
//	var arrItem2 = new Array();
//	var arrReturn = new Array();
//	
//	//split the string into an array of pairs
//	arrPairs = str.split(pairDelim);

//	for(item  in arrPairs){
//	//split each pair and move the values to the same position in both return arrays
//		var arrHold = arrPairs[item].split(singleDelim);
//		arrItem1[item]=arrHold[0];
//		arrItem2[item]=arrHold[1];
//	}
//	arrReturn[0] =arrItem1;
//	arrReturn[1] = arrItem2;
//	return arrReturn;

//}			

//function strToArray2Level(str){	
////This function takes a string with two delimiters, and rolls the contents up into two sequential arrays.
//// it returns a single array containg the two sequential arrays.  
//	var item;
//	var arrPairs;
//	var arrItem1 = new Array();
//	var arrItem2 = new Array();
//	var counter1 =0 ;
//	var counter2 =0 ;
//	var arrReturn = new Array();
//	
//	//split the string into an array of pairs
//	arrPairs = str.split(pairDelim);

//	for(item  in arrPairs){
//	var arrHold = arrPairs[item].split(singleDelim);
//	var item2
//	//split each pair and test to see if the first item is the same as the previous item1
//	// if it is, test the second item to see if it is the same as the second item2
//	// if this is true, skip the item, we already have it, otherwise append it to the item2 array with a delimiter.
//		if (counter1 > 0){
//		 	if(arrItem1[counter1-1] == arrHold[0]){
//			
//				if (item2 != arrHold[1]){
//					arrItem2[counter1 -1] = arrItem2[counter1 -1] + singleDelim + arrHold[1];
//				}
//				item2 = arrHold[1]	
//			}else{
//				arrItem1[counter1]=arrHold[0];
//				arrItem2[counter1]=arrHold[1];
//				item2 = arrHold[1]
//				counter1 = counter1 + 1;
//			}
//		 }else{
//		 		arrItem1[counter1]=arrHold[0];
//				arrItem2[counter1]=arrHold[1];
//				item2 = arrHold[1]
//				counter1 = counter1 + 1;
//			}		
//	}
//	arrReturn[0] =arrItem1;
//	arrReturn[1] = arrItem2;
//	return arrReturn;
//	
//}	

function selectMatch(id, ctrl) {
    //select the option in a select box that matches the id passed in
    if (ctrl.type == 'select-one') {
        for (var i = 0; i < ctrl.options.length; i++) {
            if (parseInt(ctrl.options[i].value, 10) == parseInt(id, 10))
                ctrl.options[i].selected = true;
        }
    }

}

//function selectMatchStr(id,ctrl){
////select the option in a select box that matches the id passed in

//	if (ctrl.type == 'select-one'){
//		for(var i = 0 ; i < ctrl.options.length ; i++){
//			if ((ctrl.options[i].value) == (id))
//				ctrl.options[i].selected = true;
//		}		
//	}

//}


function clearFields() {
    var els = document.forms[0].elements;
    var el;

    for (el = 0; el < els.length; el++) {
        switch (els[el].type) {
            case "text": case "password": case "textarea":
                els[el].value = "";
                break;
            case "select-one":
                els[el].options.selectedIndex = 0;
                break;
            case "select-multiple":
                els[el].options.length = 0;
                break;
        }
    }
}

//// Month and Date field validation 
//function isMMDD(ctrl) { 
//var inputStr = ctrl.value;

//// convert hyphen delimiters to slashes 
//	while (inputStr.indexOf("-") != -1) { 
//		inputStr = replaceString(inputStr,"-","/") ;
//		
//	} 

//	var delim1 = inputStr.indexOf("/") 
//	var delim2 = inputStr.lastIndexOf("/") 

//	 if (delim1 != -1) { 
//		 if (delim1 != delim2) { 
//			 // there are more than one delimiters;
//			 	alert("The month and day entry is not in an acceptable format.\n\nYou can enter dates in the following formats: mm/dd, or mm-dd.");
//				ctrl.focus();
//				ctrl.select();
//				return false;
//		 }

//		 // there are delimiters; extract component values 
//		 if(!isInteger(inputStr.substring(0,delim1)))
//			{
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		 if(!isInteger(inputStr.substring(delim1 + 1,inputStr.length)))
//			{
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		
//		 var mm = parseInt(inputStr.substring(0,delim1),10);
//		 var dd = parseInt(inputStr.substring(delim1 + 1,inputStr.length),10);
//	 } else { 
//	 	// there are no delimiters; extract component values 
//		 if(!isInteger(inputStr.substring(0,2)))
//			{
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		 if(!isInteger(inputStr.substring(2,4)))
//			{
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}

//		var mm = parseInt(inputStr.substring(0,2));
//		var dd = parseInt(inputStr.substring(3,4));
//	 } 
//	 
//	 if (isNaN(mm) || isNaN(dd)) {
//	  // there is a non-numeric character in one of the component values 
//	 	alert("The month and day entry is not in an acceptable format.\n\nYou can enter dates in the following formats: mm/dd, or mm-dd.");
//		ctrl.focus();
//		ctrl.select();
//		return false;
//	} if (mm < 1 || mm > 12) { 
//	// month value is not 1 thru 12 
//		alert("Months must be entered between the range of 01 (January) and 12 (December).");
//		ctrl.focus();
//		ctrl.select();
//		return false;
//	} 

//	if(mm == 2){
//		if (dd < 1 || dd > 29) { 
//			// date value is not 1 thru 29 for February
//			alert("Days must be entered between the range of 01 and a maximum of 29 for the month of February.");
//			ctrl.focus();
//			ctrl.select();
//			return false;
//		} 
//	}		

//	if (dd < 1 || dd > 31) { 
//		// date value is not 1 thru 31 
//		alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
//		ctrl.focus();
//		ctrl.select();
//		return false;
//	} 

//	if(checkMonthLength(mm,dd) ==false){
//		return false;
//	}

//	ctrl.value =mm + "/" + dd  
//	return 	true; 
//} 

//// date field validation 
//function isDate(ctrl) { 
//var inputStr = ctrl.value;

//// convert hyphen delimiters to slashes 
//	while (inputStr.indexOf("-") != -1) { 
//		inputStr = replaceString(inputStr,"-","/") ;
//		
//	} 

//	var delim1 = inputStr.indexOf("/") 
//	var delim2 = inputStr.lastIndexOf("/") 
//	if (delim1 != -1 && delim1 == delim2) {
//		 // there is only one delimiter in the string 
//		 alert("The date entry is not in an acceptable format.\n\nYou can enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy. (If the month or date data is not available, enter \'01\' in the appropriate location.)") 
//		 ctrl.focus();
//		 ctrl.select();
//		 return false; 
//	 } 
//	 
//	 if (delim1 != -1) { 
//		 // there are delimiters; extract component values 
//		 if(!isInteger(inputStr.substring(0,delim1)))
//			{
//			alert('Please enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.')
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		 if(!isInteger(inputStr.substring(delim1 + 1,delim2)))
//			{
//			alert('Please enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.')
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		 if(!isInteger(inputStr.substring(delim2 + 1, inputStr.length)))
//			{
//			alert('Please enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.')
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		 var mm = parseInt(inputStr.substring(0,delim1),10);
//		 var dd = parseInt(inputStr.substring(delim1 + 1,delim2),10);
//		 var yyyy = parseInt(inputStr.substring(delim2 + 1, inputStr.length),10);
//	 } else { 
//	 	// there are no delimiters; extract component values 
//		 if(!isInteger(inputStr.substring(0,2)))
//			{
//			alert('Please enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.')
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		 if(!isInteger(inputStr.substring(2,4)))
//			{
//			alert('Please enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.')
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		 if(!isInteger(inputStr.substring(4, inputStr.length)))
//			{
//			alert('Please enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.')
//			ctrl.focus();
//			ctrl.select();
//			return false;
//			}
//		var mm = parseInt(inputStr.substring(0,2),10);
//		var dd = parseInt(inputStr.substring(2,4),10);
//		var yyyy = parseInt(inputStr.substring(4,inputStr.length),10);
//	 } 
//	 if (isNaN(mm) || isNaN(dd) || isNaN(yyyy)) {
//	  // there is a non-numeric character in one of the component values 
//	 	alert("The date entry is not in an acceptable format.\n\nYou can enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.");
//		ctrl.focus();
//		ctrl.select();
//		return false;
//	} if (mm < 1 || mm > 12) { 
//	// month value is not 1 thru 12 
//		alert("Months must be entered between the range of 01 (January) and 12 (December).");
//		ctrl.focus();
//		ctrl.select();
//		return false;
//	} 
//	if (dd < 1 || dd > 31) { 
//		// date value is not 1 thru 31 
//		alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
//		ctrl.focus();
//		ctrl.select();
//		return false;
//	} 
//	// validate year, allowing for checks between year ranges // passed as parameters from other validation functions 
//	if (yyyy < 100) { 
//	// entered value is two digits, which we allow for 1930-2029 
//		if (yyyy >= 30) { 
//			yyyy += 1900;
//		} else { 
//			yyyy += 2000;
//		} 
//	} 
//	
//	if(checkMonthLength(mm,dd) ==false){
//		return false;
//	}
//	if (checkLeapMonth(mm,dd,yyyy) == false){
//		return false;
//	}		
//	ctrl.value =mm + "/" + dd + "/" + yyyy 
//	return 	true; 
//} 
//// check the entered month for too high a value 
//function checkMonthLength(mm,dd) { 
//	var months = new Array("","January","February","March","April","May","June","July","August","September","October","November","December");
// 	if ((mm == 4 || mm == 6 || mm == 9 || mm == 11) && dd > 30) {
//		alert(months[mm] + " has only 30 days."); 
//		return false;
//	 } else if (dd > 31) { 
//	 	alert(months[mm] + " has only 31 days."); 
//		return false;
//	 } 
//	 return true; 
//} // check the entered February date for too high a value 
//function checkLeapMonth(mm,dd,yyyy) { 
//	if(mm != 2){
//		return true;
//	}else if (yyyy % 4 > 0 && dd > 28 ) { 
//		alert("February of " + yyyy + " has only 28 days."); 
//		return false;
//	} else if (dd > 29 ) {
//		 alert("February of " + yyyy + " has only 29 days.");
//		  return false;
//	} return true; 
//} 

////replace instances of one string with another
//function replaceString(mainStr,searchStr,replaceStr) { 
//	var front = getFront(mainStr,searchStr); 
//	var end = getEnd(mainStr,searchStr); 
//	if (front != null && end != null) { 
//		return front + replaceStr + end ;
//	} 
//	return null;
//} 

//// extract front part of string prior to searchString 
//function getFront(mainStr,searchStr){
//	foundOffset = mainStr.indexOf(searchStr);
//	if (foundOffset == -1) { 
//		return null;
//	}
// return mainStr.substring(0,foundOffset);
// } 
// // extract back end of string after searchString 
//function getEnd(mainStr,searchStr) { 
// 	foundOffset = mainStr.indexOf(searchStr);
//	if (foundOffset == -1) {
//		return null;
//	} 
//	return mainStr.substring(foundOffset+searchStr.length,mainStr.length);
// } 
// 

function pgBlur(ctrl) {
    if (ctrl.disabled) {
        ctrl.blur();
    }
}


//function valFieldLen(ctrl, maxLen, fieldName){
//	if (ctrl.value.length > maxLen){
//		alert(fieldName + " can be no more than " + maxLen + " characters long.");
//		ctrl.value = ctrl.value.slice(0,maxLen);
//	}

//}

function pgMouseOver(ctrl) { }
function pgMouseOut(ctrl) { }
function pgFocus(ctrl) { }
function pgKeyUp(ctrl) { }
function clearstatus(ctrl) { }
function pgClick(ctrl) { }


/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/

//function LTrim(str)
///*
//   PURPOSE: Remove leading blanks from our string.
//   IN: str - the string we want to LTrim
//*/

//{
//   var whitespace = new String(" \t\n\r");

//   var s = new String(str);

//   if (whitespace.indexOf(s.charAt(0)) != -1) {
//      // We have a string with leading blank(s)

//      var j=0, i = s.length;

//	// Iterate from the far left of string until we
//    // don't have any more whitespace...
//      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
//         j++;

//      // Get the substring from the first non-whitespace
//      // character to the end of the string...
//      s = s.substring(j, i);
//   }
//   return s;
//}

///*
//==================================================================
//RTrim(string) : Returns a copy of a string without trailing spaces.
//==================================================================
//*/

//function RTrim(str)
///*
//   PURPOSE: Remove trailing blanks from our string.
//   IN: str - the string we want to RTrim
//*/
//{
//   // We don't want to strip JUST spaces, but also tabs,
//   // line feeds, etc.  Add anything else you want to
//   // "trim" here in Whitespace
//   var whitespace = new String(" \t\n\r");

//   var s = new String(str);

//   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
//    // We have a string with trailing blank(s)

//      var i = s.length - 1;    // Get length of string

//    // Iterate from the far right of string until we
//	// don't have any more whitespace...
//      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
//         i--;

//      // Get the substring from the front of the string to
//      // where the last non-whitespace character is...
//      s = s.substring(0, i+1);
//   }

//   return s;
//}

///*
//=============================================================
//Trim(string) : Returns a copy of a string without leading or trailing spaces
//=============================================================
//*/

//function Trim(str)
///*
//   PURPOSE: Remove trailing and leading blanks from our string.
//   IN: str - the string we want to Trim
//   
//   RETVAL: A Trimmed string!
//*/
//{
//   return RTrim(LTrim(str));
//}

//06/14/2006.Vijaya
function selectOptionMatch(option, ctrl) {
    //select the option in a select box that matches the option number passed in
    if (ctrl.type == 'select-one') {
        if (ctrl.options.length > option) {
            ctrl.options[option].selected = true;
        }
    }
}

