/*********************************************************************************************************
Name: Submit_onclick
Desc: JS Function to call on button submit
Param: 
Form Name
*********************************************************************************************************/
function Submit_onClick() {

    try
    {
        ProcessingMsg(true);
        
	    //Get Error object
        var arrErrors = validateInput(d.forms[0]);

	    //Get Error String
	    var strErrors = InternetExplorer ? displayErrors(d.forms[0], arrErrors, true, 1, "#E45B5B") : displayErrors(d.forms[0], arrErrors, true, 2, "#E45B5B");

	    //Display Errors or Submit
	    if(isEmpty(strErrors))
	    {
		    return true;
	    }
	    else
	    {
            ProcessingMsg(false);
		    //dError.innerHTML = strErrors;
		    //dError.style.display = "block";
		    //errorWindow(strErrors, arrErrors[0].length);
		    //Get value from mod error window
		   if(InternetExplorer)
		   {
		        var rtnValue;
		        rtnValue = modWindow(strErrors, arrErrors[0].length);
		        if (!isEmpty(rtnValue)) { try{d.forms[0].elements[rtnValue].focus();} catch (e) {} }
            }
            else
            {
                alert(strErrors);
            }
		    return false;
	    }
    }
    catch(e)
    {
        return false;
    }
}
/*********************************************************************************************************
Name: displayErrors
Desc: Create error string, highlight fields and update title
Param: 
Input: Array of Elements to  - Form to use, arrErrors - Error object, bHighlightEle - true-Highlight fields false-Don't Hightlight fields
Input: intType - 0-Error window 1-mod window 2-Alert box, strColor - Highlightcolor
Output: Formatted Error String
*********************************************************************************************************/
function displayErrorsFromArray(arrElementsToReset, arrErrors, bHighlightEle, intType, strColor) {
	var strError;
	var strLB;
	
	//Check to see if there are errors
	if(arrErrors[0].length > 0)
	{
		//Set Line Break
		if(intType == 0) { strLB = "<br>"; }
		else if(intType == 2) { strLB = "\n"; }

		//Create Header
		if(intType == 0 || intType == 2) { strError = "The following errors need to be corrected:" + strLB + strLB; }
		//Loop through arr and create error
		for(x=0;x<arrErrors[0].length;x++)
		{
			//Error Element
			if(intType == 0 || intType == 2) { strError += arrErrors[1][x] + strLB; }
			else { strError += "_" + arrErrors[0][x] + "|" + arrErrors[1][x]; }
			//Modify Title
			try {
				arrElementsToReset[arrErrors[0][x]].title = arrErrors[2][x];
				//Highlight element
				if(bHighlightEle) { arrElementsToReset[arrErrors[0][x]].style.backgroundColor = strColor; }
			}
			catch (e) { }
		}
		if(intType == 0 || intType == 2) { strError += strLB; }
	}

	return strError;
}


/*********************************************************************************************************
Name: validateArrayOfInputs
Desc: Validate Input values
Param:
Input: Array Of Input objects
Output: Array with errors
*********************************************************************************************************/
function validateArrayOfInputs(arrElementsToValidate) {
	//Declare values
	var strFormat;
	var intCnt = 0;
	var strValReq;
	var strValErrMsg;
	var strEleValue;
	var arrErrors = new Array();
	//Error Number
	arrErrors[0] = new Array();
	//Error Desc
	arrErrors[1] = new Array();
	//Error Format
	arrErrors[2] = new Array();

	//Clear Errors
	clearArrErrors(arrElementsToValidate);

	//Loop through form and valid
	for(x=0;x<arrElementsToValidate.length;x++)
	{
		//Get ReqVal
		strValReq = "false";
		try 
		{ 
			strValReq = arrElementsToValidate[x].attributes['valrequired'].value.toLowerCase(); 
		}
		catch(e)
		{
		}

		//Get Element Value
		//If Textbox
		if(arrElementsToValidate[x].type == "text") { strEleValue = arrElementsToValidate[x].value; }
		//If Select
		else if(arrElementsToValidate[x].type == "select-one") { strEleValue = arrElementsToValidate[x].options[objForm.elements[x].selectedIndex].value; }
		//If TextArea
		else if(arrElementsToValidate[x].type == "textarea") { strEleValue = arrElementsToValidate[x].value; }
		//If Password
		else if(arrElementsToValidate[x].type == "password") { strEleValue = arrElementsToValidate[x].value; }
		//If Checkbox
		else if(arrElementsToValidate[x].type == "checkbox") { strEleValue = arrElementsToValidate[x].checked; }

		//Check to see if element is required
		if(strValReq == "true" && isEmpty(strEleValue))
		{
			//Field Required
			arrErrors[0][intCnt] = x;
			
			if (arrElementsToValidate[x].attributes['valerrormsg'].value != "" && arrElementsToValidate[x].attributes['valerrormsg'].value != null)
				arrErrors[1][intCnt] = arrElementsToValidate[x].attributes['valerrormsg'].value;
			else
				arrErrors[1][intCnt] = "Please enter a " + arrElementsToValidate[x].attributes['valerrorname'].value;

			arrErrors[2][intCnt] = "Value Needed";
			intCnt++;
		}
		else
		{
			if(!isEmpty(arrElementsToValidate[x].value) && (arrElementsToValidate[x].type == "text" || objForm.elements[x].type == "password"))
			{
				//Check input values
				strFormat = checkInputField(arrElementsToValidate[x]);
				if(!isEmpty(strFormat))
				{
					try { strValErrMsg = arrElementsToValidate[x].attributes['valerrorname'].value; }
					catch(e) { }
					//Not a valid input
					arrErrors[0][intCnt] = x;
					arrErrors[1][intCnt] = "You entered an invalid " + strValErrMsg + ".";
					arrErrors[2][intCnt] = "Field format: " + strFormat;
					intCnt++;
				}
			}
		}
	}
	return arrErrors;
}

/*********************************************************************************************************
Name: validateInput
Desc: Validate Input values
Param:
Input: objForm - Form to validate
Output: Array with errors
*********************************************************************************************************/
function validateInput(objForm) {
	//Declare values
	var strFormat;
	var intCnt = 0;
	var strValReq;
	var strValErrMsg;
	var strEleValue;
	var arrErrors = new Array();
	//Error Number
	arrErrors[0] = new Array();
	//Error Desc
	arrErrors[1] = new Array();
	//Error Format
	arrErrors[2] = new Array();

	//Clear Errors
	clearErrors(objForm);

	//Loop through form and valid
	for(x=3;x<objForm.length;x++)
	{
		//Get ReqVal
		strValReq = "false";
		try 
		{ 
			strValReq = objForm.elements[x].attributes['valrequired'].value.toLowerCase(); 
		}
		catch(e)
		{
		}

		//Get Element Value
		//If Textbox
		if(objForm.elements[x].type == "text") { strEleValue = objForm.elements[x].value; }
		//If Select
		else if(objForm.elements[x].type == "select-one") { strEleValue = objForm.elements[x].options[objForm.elements[x].selectedIndex].value; }
		//If TextArea
		else if(objForm.elements[x].type == "textarea") { strEleValue = objForm.elements[x].value; }
		//If Password
		else if(objForm.elements[x].type == "password") { strEleValue = objForm.elements[x].value; }
		//If Checkbox
		else if(objForm.elements[x].type == "checkbox") { strEleValue = objForm.elements[x].checked; }

		//Check to see if element is required
		if(strValReq == "true" && isEmpty(strEleValue))
		{
			//Field Required
			arrErrors[0][intCnt] = x;
			
			if (objForm.elements[x].attributes['valerrormsg'].value != "" && objForm.elements[x].attributes['valerrormsg'].value != null)
				arrErrors[1][intCnt] = objForm.elements[x].attributes['valerrormsg'].value;
			else
				arrErrors[1][intCnt] = "Please enter a " + objForm.elements[x].attributes['valerrorname'].value;

			arrErrors[2][intCnt] = "Value Needed";
			intCnt++;
		}
		else
		{
			if(!isEmpty(objForm.elements[x].value) && (objForm.elements[x].type == "text" || objForm.elements[x].type == "password"))
			{
				//Check input values
				strFormat = checkInputField(objForm.elements[x]);
				if(!isEmpty(strFormat))
				{
					try { strValErrMsg = objForm.elements[x].attributes['valerrormsg'].value; }
					catch(e) { }
					//Not a valid input
					arrErrors[0][intCnt] = x;
					arrErrors[1][intCnt] = "You entered an invalid " + strValErrMsg + ".";
					arrErrors[2][intCnt] = "Field format: " + strFormat;
					intCnt++;
				}
			}
		}
	}
	return arrErrors;
}
/*********************************************************************************************************
Name: isEmpty
Desc: Check to see if value has a value
Param:
Input: objEleVal - Item to check
Output: true - value is empty, false - value is not empty
*********************************************************************************************************/
function isEmpty(objEleVal) {
	if(objEleVal == "" || objEleVal == " " || objEleVal == null) { return true; }
	else { return false; }
}
/*********************************************************************************************************
Name: clearErrors
Desc: Clear Errors and highlight colors
Param:
Input: objForm - Form to clear
Output: None
*********************************************************************************************************/
function clearErrors(objForm) {
	//Loop through form and clear
	for(x=3;x<objForm.length;x++)
	{
		objForm.elements[x].style.backgroundColor="#FFFFFF";
		objForm.elements[x].title = "";
	}
}
/*********************************************************************************************************
Name: clearErrors
Desc: Clear Errors and highlight colors
Param:
Input: objForm - Form to clear
Output: None
*********************************************************************************************************/
function clearArrErrors(arrElements) {
	//Loop through Arr and clear
	for(x=0;x<arrElements.length;x++)
	{
		arrElements[x].style.backgroundColor="#FFFFFF";
		arrElements[x].title = "";
	}
}
/*********************************************************************************************************
Name: checkInputField
Desc: Check input value for formatting errors
Param: 
Input: objEle - Element object to check
Output: formatstring error, empty no errors
*********************************************************************************************************/
function checkInputField(objEle) {
	var strValType;
	var strValFormat;
	var strReturnFormat = "";

	var htRegExp = new Array();
	htRegExp["decimal"] = /^[-+]?\d*\.?\d(\.\d{1,3})*$/;
	htRegExp["money"] = /^[-+]?\d*\.?\d(\.\d{1,2})*$/;
	htRegExp["price"] = /^[-+]?\d*\.?\d(\.\d{1,4})*$/;
	htRegExp["phonenoarea"] = /^\d{3}-\d{4}$/;
//	htRegExp["phone"] = /^\d{3}-\d{3}-\d{4}$/;
	htRegExp["phone"] = /^\d{3}-\d{3}-\d{4}$/;
	htRegExp["areacode"] = /^\d{3}$/;
	htRegExp["numberonly"] = /^\d*$/;
	htRegExp["textonly"] = /^[A-Za-z(\s)?]*$/;
	htRegExp["textnumberonly"] = /^[A-Za-z0-9(\s)?]*$/;
	htRegExp["date"] = /((^(10|12|0?[13578])([/])(3[01]|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(11|0?[469])([/])(30|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(2[0-8]|1[0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(29)([/])([2468][048]00)$)|(^(0?2)([/])(29)([/])([3579][26]00)$)|(^(0?2)([/])(29)([/])([1][89][0][48])$)|(^(0?2)([/])(29)([/])([2-9][0-9][0][48])$)|(^(0?2)([/])(29)([/])([1][89][2468][048])$)|(^(0?2)([/])(29)([/])([2-9][0-9][2468][048])$)|(^(0?2)([/])(29)([/])([1][89][13579][26])$)|(^(0?2)([/])(29)([/])([2-9][0-9][13579][26])$))/;
	htRegExp["ssn"] = /^\d{3}-\d{2}-\d{4}$/;
	htRegExp["zip"] = /^\d{5}$/;
	htRegExp["zip4"] = /^\d{4}$/;
	htRegExp["year"] = /^\d{4}$/;
	htRegExp["aba_number"] = /^\d{9}$/;
	htRegExp["msa_number"] = /^\d{4}$/;
	htRegExp["county_code"] = /^\d{3}$/;
	htRegExp["census_tract"] = /^\d{4}.\d{2}$/;
	htRegExp["email"] = /^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
	htRegExp["datetime"] = 	/^\d{2}\/\d{2}\/\d{4}\ \d{1,2}\:\d{2}\ (AM)|(PM)$/;
	htRegExp["password"] = 	/^\d{2}\/\d{2}\/\d{4}\ \d{1,2}\:\d{2}\ (AM)|(PM)$/;
	htRegExp["boolean"] = 	/^\d{2}\/\d{2}\/\d{4}\ \d{1,2}\:\d{2}\ (AM)|(PM)$/;
	htRegExp["time"] = 	/^\d{2}\/\d{2}\/\d{4}\ \d{1,2}\:\d{2}\ (AM)|(PM)$/;

	//Set Format Values
	var htFormat = new Array();
	htFormat["decimal"] = "999.999";
	htFormat["money"] = "9.99";
	htFormat["phonenoarea"] = "999-9999";
//	htRegExp["phone"] = "999-999-9999";
	htFormat["phone"] = "999-999-9999";
	htFormat["areacode"] = "999";
	htFormat["numberonly"] = "Numbers Only";
	htFormat["textonly"] = "Letters only";
	htFormat["textnumberonly"] = "Letters or Numbers only";
	htFormat["date"] = "m/d/yyyy";
	htFormat["ssn"] = "999-99-9999";
	htFormat["zip"] = "99999";
	htFormat["zip4"] = "9999";
	htFormat["year"] = "1999";
	htFormat["aba_number"] = "999999999";
	htFormat["msa_number"] = "9999";
	htFormat["county_code"] = "999";
	htFormat["census_tract"] = "9999.99";
	htFormat["email"] = "abc@xyz.com";
	htFormat["datetime"] = "mm/dd/yyyy hh:mm AM or PM";
	htFormat["password"] = "Password must contain 1 lower case letter, 1 upper case letter, 1 number and between 6 and 10 characters";
	htFormat["boolean"] = "Field must be checked";
	htFormat["time"] = "HH:MM";
	
	//Get valtype
	try { strValType = objEle.valtype.toLowerCase() }
	catch(e) { return ""; }

	//Check formatting
	//RegExp Manual
	if(strValType == "regexp")
	{
		try { if(objEle.value.match(eval("/" + objEle.valregexp + "/")) == null) { strReturnFormat = objEle.valreformat; } }
		catch(e) { return ""; }
	}
	//Date Check
	else if(strValType == "date") { if(!isValDate(objEle.value)) { strReturnFormat = "MM/DD/YYYY"; } }
	//Furture Date Check
	else if(strValType == "datenofurture") { if(isFutureDate(objEle.value)) { strReturnFormat = "MM/DD/YYYY - Today and Prior Dates"; } }
	//Money Check
	else if(strValType == "money") { if(!isMoney(objEle.value)) { strReturnFormat = "9.99"; } }
	//Password Check
	else if(strValType == "password") { if(!isPassword(objEle.value)) { strReturnFormat = "Password must contain 1 lower case letter, 1 upper case letter, 1 number and between 6 and 10 characters"; } }
	//Checkbox Check
	else if(strValType == "checkbox") { if(!isChecked(objEle)) { strReturnFormat = "Field must be checked"; } }
	//Time Check
	else if(strValType == "time") { if(!isTime(objEle.value)) { strReturnFormat = "HH:MM"; } }
	//Money Range Check
	else if(strValType == "moneyrange")
	{
		try
		{
			if(!isMoney(objEle.value)) { strReturnFormat = "9.99"; }
			else { if(!isMoneyRange(objEle.value, objEle.valrange1, objEle.valrange2)) { strReturnFormat = "Between " + objEle.valrange1 + " and " + objEle.valrange2; } }
		}
		catch(e) { return ""; }
	}
	//Everything Else
	else { if(objEle.value.match(htRegExp[strValType]) == null) { strReturnFormat = htFormat[strValType]; } }

	//Return Format
	if(isEmpty(strReturnFormat)) { return ""; }
	else
	{
		//Get manual format
		try { strValFormat = objEle.valreformat; }
		catch(e) { }
		if(isEmpty(strValFormat)) { return strReturnFormat; }
		else { return strValFormat; }
	}
}
/*********************************************************************************************************
Name: y2k
Desc: Y2k Convert
Param:
Input: number - Year
Output: y2k year
*********************************************************************************************************/
function y2k(number) {
	return (number < 1000) ? number + 1900 : number;
}
/*********************************************************************************************************
Name: isValDate
Desc: Check to see if date is valid
Param:
Input: ckDate - Date to check
Output: true - valid date, false - invalid date
*********************************************************************************************************/
function isValDate(ckDate) {
	var sDay;
	var sMonth;
	var sYear;
    var today = new Date();
	var test;
	if(ckDate == "") { return false; }
	smonth = ckDate.substr(0, ckDate.indexOf("/"));
	sday = ckDate.substring(ckDate.indexOf("/")+1, ckDate.lastIndexOf("/"));
	syear = ckDate.substring(ckDate.lastIndexOf("/")+1, ckDate.length);
	test = new Date(smonth + "/" +  sday + "/" + syear);
    if((y2k(test.getYear()) == syear) && (smonth == test.getMonth()+1) && (sday == test.getDate())) { return true; }
    else { return false; }
}
/*********************************************************************************************************
Name: isFutureDate
Desc: Check to see if date is in the future. Tomorrow and later
Param:
Input: strDate - Date to check
Output: true - date is in the furture, false - date is not in the furture
*********************************************************************************************************/
function isFutureDate(strDate) {
	//Check for valid date
	if(!isValDate(strDate)) { return false; }
	else
	{
		//Check for Future Date
		return true;
	}
}
/*********************************************************************************************************
Name: isTime
Desc: Checks to see if time
Param:
Input: strTime - Time to check
Output: true - time, false - not time
*********************************************************************************************************/
function isTime(strTime) {
	if(strTime.length != 5) { return false; }
	if(strTime.substr(2, 1) != ":") { return false; }

	var strH = strTime.substr(0, 2);
	if(isNaN(strH)) { return false; }
	if(strH < 1 || strH > 24)  { return false; }

	var strM = strTime.substr(3, 2);
	if(isNaN(strM)) { return false; }
	if(strM < 0 || strM > 60)  { return false; }
	return true;
}
/*********************************************************************************************************
Name: isMoney
Desc: Check to see if value is a money value 9.99, 9, 9.9
Param:
Input: strValue - Value to check
Output: true - is a money value, false - invalid money value
*********************************************************************************************************/
function isMoney(strValue) {
	if(isNaN(strValue)) { return false; }
	else { if(strValue.indexOf(".") > -1) { if(strValue.substr(strValue.indexOf(".")+1).length < 1 || strValue.substr(strValue.indexOf(".")+1).length > 2) { return false; } } }
		
	return true;
}
/*********************************************************************************************************
Name: isChecked
Desc: Check to see if field is checked
Param:
Input: objElement - Obj to check
Output: true - is checked, false - is not checked
*********************************************************************************************************/
function isChecked(objElement) {
	if(objElement.checked) { return true; }
	else { return false; }
}
/*********************************************************************************************************
Name: isPassword
Desc: Check to see if value is a valid password. Password must contain 1 lower case letter, 1 upper case letter, 1 number and between 6 and 10 characters
Param:
Input: strValue - Value to check
Output: true - is a password value, false - invalid password value
*********************************************************************************************************/
function isPassword(strValue) {
	if(strValue.length > 5 && strValue.length < 11)
	{
		var a = 0;
		var b = 0;
		var c = 0;

		var Pattern=/[a-z]/;
		if (Pattern.test(strValue) == true)
		{
			a = 1;
		}
		var PatternA=/[A-Z]/;
		if (PatternA.test(strValue) == true)
		{
			b = 1;
		}
		var PatternB=/[0-9]/;
		if (PatternB.test(strValue) == true)
		{
			c = 1;
		}

		var Scope=/[^1]/;
		if (Scope.test(a) || Scope.test(b) || Scope.test(c)) 
		{	
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return false;
	}
}
/*********************************************************************************************************
Name: isMoneyRange
Desc: Check to see if value is between two numbers
Param:
Input: strValue - Value to check, strStartRange, strEndRange
Output: true - is a money value, false - invalid money value
*********************************************************************************************************/
function isMoneyRange(strValue, strStartRange, strEndRange) {
		if((strValue >= parseFloat(strStartRange)) && (strValue <= parseFloat(strEndRange))) { return true; }
		else { return false; }
}
/*********************************************************************************************************
Name: displayErrors
Desc: Create error string, highlight fields and update title
Param: 
Input: objForm - Form to use, arrErrors - Error object, bHighlightEle - true-Highlight fields false-Don't Hightlight fields
Input: intType - 0-Error window 1-mod window 2-Alert box, strColor - Highlightcolor
Output: Formatted Error String
*********************************************************************************************************/
function displayErrors(objForm, arrErrors, bHighlightEle, intType, strColor) {
	var strError = '';
	var strLB;
	
	//Check to see if there are errors
	if(arrErrors[0].length > 0)
	{
		//Set Line Break
		if(intType == 0) { strLB = "<br>"; }
		else if(intType == 2) { strLB = "\n"; }

		//Create Header
		if(intType == 0 || intType == 2) { strError = "The following errors need to be corrected:" + strLB + strLB; }
		//Loop through arr and create error
		for(x=0;x<arrErrors[0].length;x++)
		{
			//Error Element
			if(intType == 0 || intType == 2) { strError += arrErrors[1][x] + strLB; }
			else { strError += "_" + arrErrors[0][x] + "|" + arrErrors[1][x]; }
			//Modify Title
			try {
				objForm.elements[arrErrors[0][x]].title = arrErrors[2][x];
				//Highlight element
				if(bHighlightEle) { objForm.elements[arrErrors[0][x]].style.backgroundColor = strColor; }
			}
			catch (e) { }
		}
		if(intType == 0 || intType == 2) { strError += strLB; }
	}

	return strError;
}
/*********************************************************************************************************
Name: errorWindow
Desc: Open an Error window
Param:
Input: strerror - Error String, numError - Number of Errors
Output: 
*********************************************************************************************************/
function errorWindow(strerror, numerror){
	var url = "../errorwindow.html?serror=" + escape(strerror) + "&num=" +escape(numerror);
	errorWin = window.open(url, "newWin",'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=320,height=325');
	errorWin.focus();	
}
/*********************************************************************************************************
Name: NewPWindow
Desc: Open an pop window
Param:
Input: strUrl - URL to Open, intWidth - window width, intHeight - window height
Output: 
*********************************************************************************************************/
function NewPWindow(strUrl, intWidth, intHeight){
	newPWindow = window.open(strUrl, "newPWin",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + intWidth + ',height=' + intHeight);
	newPWindow.focus();	
}
/*********************************************************************************************************
Name: STORE_UNCHECKED_CHECKBOX_IDS
Desc: Stores the ids of unchecked text boxes in __unChkBoxes
Param:
Input: objForm - Form
Output: 
*********************************************************************************************************/
function STORE_UNCHECKED_CHECKBOX_IDS(objForm)
{
        val = '';
        inp = document.all.tags( 'input' );
        for ( i = 0; i < inp.length; i++ )
        {
                if ( inp[ i ].type == 'checkbox' && !inp[ i ].checked )
                {
                        if ( val != '' )
                        {
                                val += ',';
                        }
                        val += inp[ i ].name;
                }
        }
        objForm.__unChkBoxes.value = val;
}
/*********************************************************************************************************
Name: checkSSN
Desc: Add - to SSN
Param:
Input: objEle - ssn
Output: 
*********************************************************************************************************/
function checkSSN(objEle){
	var tmpSSN = "";

	if(objEle.length == 9)
	{
		for(cnt = 0; cnt < objEle.length; cnt++)
		{
			if(cnt == 3 || cnt == 5)
			{
				tmpSSN += "-";
				tmpSSN += objEle.charAt(cnt)
			}
			else
			{
				tmpSSN += objEle.charAt(cnt)
			}
		}
	}
	else
	{
		tmpSSN = objEle;
	}
	return tmpSSN;
}
/*********************************************************************************************************
Name: OpenWindow
Desc: Open an window
Param:
Input: strUrl - URL, strName - Window Name, strWidth - Width, strHeight - Height X - X Coor, Y - Y Coor
Output: 
*********************************************************************************************************/
function OpenWindow(strUrl, strName, strWidth, strHeight, X, Y){
	newWindow = window.open(strUrl, strName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+strWidth+',height='+strHeight+', screenX='+X+', screenY='+Y+', top='+Y+',left='+X+'');
	newWindow.focus();	
}
/*********************************************************************************************************
Name: OpenWindowMenu
Desc: Open an window
Param:
Input: strUrl - URL, strName - Window Name, strWidth - Width, strHeight - Height X - X Coor, Y - Y Coor
Output: 
*********************************************************************************************************/
function OpenWindowMenu(strUrl, strName, strWidth, strHeight, X, Y){
	newWindow = window.open(strUrl, strName,'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistory=no,width='+strWidth+',height='+strHeight+', screenX='+X+', screenY='+Y+', top='+Y+',left='+X+'');
	newWindow.focus();	
}
/*********************************************************************************************************
Name: openCalendar
Desc: Calendar Popup Window
Param:
Input: Date, Form Name, Field Name
Output: 
*********************************************************************************************************/
function openCalendar(strSelDate, strFormName, strFieldName) {
	if(!isValDate(strSelDate))
	{
		var dtToday = new Date();
		strSelDate = (dtToday.getMonth()+1) + "/" + dtToday.getDate() + "/" + dtToday.getYear();
	}
	OpenWindow("calpopup.aspx?FormName=" + strFormName + "&FieldName=" + strFieldName + "&SelectedDate=" + strSelDate, "Calendar", "160", "155", intX+200, intY+100);
}
/*********************************************************************************************************
Desc: Get XY of Mouse
*********************************************************************************************************/
var intX;
var intY;

function mtrack(e) {
    var ev = InternetExplorer ? window.event : e;

	if (InternetExplorer)
	{
		intX = ev.clientX;//+document.body.scrollLeft;
		intY = ev.clientY;//+document.body.scrollTop;
	}
	else
	{
		intX = ev.pageX;//+window.pageXOffset;
		intY = ev.pageY;//+window.pageYOffset;
	}
	//window.status = "X="+intX+",Y="+intY+"";
}

document.onmousemove=mtrack;

/*********************************************************************************************************
Name: showTitle
Desc: Show Title
Param:
Input: element - Element to use
Output: 
*********************************************************************************************************/
function showTitle(element) {
	element.title = element.value;
}
/*********************************************************************************************************
Name: modWindow
Desc: Open an Error window
Param:
Input: strerror - Error String, numError - Number of Errors
Output: 
*********************************************************************************************************/
function modWindow(strerror, numerror){
	var rtnValue;
	var url = "../errorwindow.html?serror=" + escape(strerror) + "&num=" +escape(numerror);

	rtnValue = window.showModalDialog(url, '', 'dialogHeight: 325px; dialogWidth: 320px; edge: sunken; center: Yes; help: No; resizable: No; status: No; scroll: Yes;' );

	return rtnValue;

}
/*********************************************************************************************************
Name: modWindow - modPopWin
Desc: Open a Mod Window
Param:
Input: strUrl - URL to call, intWidth - Width of Window, intHeight - Height of Window
Output: 
*********************************************************************************************************/
function modPopWin(strUrl, intWidth, intHeight){
	var rtnValue;
	rtnValue = window.showModalDialog(strUrl, '', 'dialogHeight: '+intHeight+'px; dialogWidth: '+intWidth+'px; edge: sunken; center: Yes; help: No; resizable: No; status: No; scroll: Yes;' );

	return rtnValue;

}