var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e){
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)){	
		input.value = input.value.slice(0, len);
		
		for (var i=0; i < input.form.length; i++){
			var obj = input.form[i];
			if (obj.getAttribute("tabindex") == (input.getAttribute("tabindex") + 1)){
				obj.focus();
			}
		}
	}

	function containsElement(arr, ele){
		var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
		return found;
	}
	return true;
}/**
	Program			: Common.js
	Description		: Contains common Javascript functions
*/

function cancelBackButton() 
{  
	if (event.keyCode == 8)
	{        
		event.cancelBubble = true;        
		event.returnValue = false;
		return false;    
	} 
}

function stringReplace(originalString, findText, replaceText){
	//URLEncodes string; replaces white spaces with + character	
	
	var pos = 0;
	var len = findText.length;
	pos = originalString.indexOf(findText);

	while (pos != -1) {
		preString = originalString.substring(0,pos);
		postString = originalString.substring(pos + len, originalString.length);
		originalString = preString + replaceText + postString;
		pos = originalString.indexOf(findText);
	}
	return originalString;
}


function ReplaceSingleQuote(originalString)
{
	var newString = "";
	var pos = originalString.indexOf("'");


	if (pos != -1){
		for (var i = 0; i < originalString.length; i++){


			if (originalString.substring(i, i+1) == "'"){
				if (newString == ""){
					newString = "&#39;";
				}else{
					newString = newString + "&#39;";
				}
			}else{
				newString = newString + originalString.substring(i, i+1);
			}
	
		}
	
		return newString;

	}else{
		return originalString;
	}
}


function ReplaceSingleQuoteOld(originalString){

	var newString = "";
	var pos = originalString.indexOf("'");

	if (pos != -1){
		for (var i = 0; i < originalString.length; i++){

			if (originalString.substring(i, i+1) == "'"){
				if (newString == ""){
					newString = "\'";
				}else{
					newString = newString + "\'";
				}
			}else{
				newString = newString + originalString.substring(i, i+1);
			}
	
		}

		return newString;

	}else{
		return originalString;
	}

}

// doError
function doError(anErrorMessage,debugSetting)
{
	if (debugSetting == "alert")
	{
		alert(anErrorMessage);
	}
	else if (debugSetting == "textarea") 
	{
	  	return anErrorMessage;	      	
	}
}

// validNumber
// Returns a valid number including the decimal positions.		
// For example: validNumber(98iu.34) returns 98.34
// validNumber(98iu.34.) returns 98.34
function validNumber(chkValue)
{
	var i;
	var tstValue;
	var returnValue;
	var decimalFound;

	decimalFound = false;
	returnValue = "";

 	numericValues = "0123456789.";
	
	for (var i=0; i < chkValue.length; i++)
	{
		tstValue = chkValue.substring(i, i+1);

   	if (numericValues.indexOf(tstValue) < 0)
		{
		}
		else
		{
			if ((decimalFound == true) && (tstValue == ".")) 
			{
			}
			else
			{
				if (tstValue == ".") 
				{
					decimalFound = true;
				}
				returnValue = returnValue + tstValue;
			}
   	}
  	}

	if (returnValue.length <= 0)
	{
		returnValue = 0;
	}

	return returnValue;
} // validNumber


// wStatus
// look for the id in the sMsg array
// if the id is not in the array and if the id begins with a dollar sign ($)
// then look for the id without the $ sign in the array
// if the id is still not in the array then use the raw id
function wStatus(entryValue)
{  
	var id = entryValue.name;	
	var returnValue;	
	var tid = ""; 	
	if (id == "" || id == undefined)
	{
		returnValue = "";		
	}
	else
	{		
		if (sMsg[id] == "")
		  {		
			if (id.substring(0, 1) == "$")
			  {	
				tid = id.substring(1,id.length);
				if (sMsg[tid] == "")
				   {returnValue = id; }
				else
				   {returnValue = sMsg[tid]; }
			  }
			else
			  {returnValue = id; }
		  }
		else
		  {returnValue = sMsg[id]; }
	}
	if(returnValue==undefined) returnValue = ""; 
	window.status =  returnValue;
		
	return returnValue;
} // wStatus


// ltrim
function ltrim(argvalue)
{
	while (1)
	{
		if (argvalue.substring(0, 1) != " ")
			break;
    	argvalue = argvalue.substring(1, argvalue.length);
  	}

  	return argvalue;
} // ltrim


// rtrim
function rtrim(argvalue)
{
  	while (1)
	{
		if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
			break;
    	argvalue = argvalue.substring(0, argvalue.length - 1);
  	}

  	return argvalue;
} // rtrim


// trim
function trim(argvalue)
{
	if (argvalue != undefined) {
		var tmpstr = ltrim(argvalue);
	 	return rtrim(tmpstr);
	 }
	 else {
		return argvalue;
	 }
} // trim



// customSplit
function customSplit(strvalue, separator, arrayName)
{
	var n = 0;

	if (separator.length != 0)
	{
		while (strvalue.indexOf(separator) != -1)
		{
			eval("arr" + n + " = strvalue.substring(0, strvalue.indexOf(separator));");
			strvalue = strvalue.substring(strvalue.indexOf(separator)+separator.length,
				        strvalue.length+1);
			n++;
		}
		eval("arr" + n + " = strvalue;");
		arraySize = n+1;
	}
	else
	{
		for (var x = 0; x < strvalue.length; x++)
		{
			eval("arr"+n+" = \"" + strvalue.substring(x, x+1) + "\";");
			n++;
		}
		arraySize = n;
	}

	eval(arrayName + " = new makeArray(arraySize);");

	for (var i = 0; i < arraySize; i++)
		eval(arrayName + "[" + i + "] = arr" + i + ";");

	return arraySize;
} //customSplit


// getValue 
function getValue(entryValue)
{
	var returnValue = "";
	var i = 0;

	if (entryValue.type == "text")
	{
		// text box
		returnValue = entryValue.value;
	}
	else if(entryValue.type == "password")
	{
		// Password box
		returnValue = entryValue.value;
	}
	else if (entryValue.type == "textarea")
	{
		// text area
		returnValue = entryValue.value;
	}
	else if (entryValue.type == "select-one")
	{
		// single select
		returnValue = entryValue.value;
	}
	else if (entryValue.type == "select-multiple")
	{
		// multiple select
		for (i=0; i < entryValue.options.length; i++)
		{
			if (entryValue.options[i].selected == true)
			{
				if (returnValue == "")
				{
					returnValue = entryValue.options[i].value;
		 		}
				else
				{
					returnValue += "|" + entryValue.options[i].value;
				}
			}
		}
	}
	else if (entryValue.type == "radio")
	{
		// radio buttons
		for (i=0; i < entryValue.length; i++)
		{
			alert("in loop")
			if (entryValue[i].checked)
			{
			    alert(entryValue[i].value)
				returnValue = entryValue[i].value;
				break;
			}
		}
	}
	else if (entryValue.type == "checkbox")
	{
		// check box
		if (entryValue.checked)
		{
			returnValue = entryValue.value;
		}
	}
	
	return returnValue;
} // getValue


// isLeapYear
function isLeapYear(entryYear)
{
	if (((entryYear % 4 == 0) && (entryYear % 100 != 0)) || (entryYear % 400 == 0))
	{
		return true;
	}
	else
	{
  		return false;
	}
} // isLeapYear

// formatYear
function formatYear(entryYear) {
	var returnValue=0;
	var yr = getValue(entryYear);
	var today = new Date(dtServerDate);
	var todayYear = today.getFullYear(); 
  	//Changed from getYear() to getFullYear() by Satya on 07/08/2002 for compatability with Netscape
	var sYr = new Date(yr,0,1);
	var yr = sYr.getYear();
	if (yr < 1000)
	{
		
		yr+=2000
		if (yr > todayYear)
		{
			yr -=2000;
			yr +=1900;
		}
	} 
	if (yr > todayYear)
	{
		returnValue = todayYear;
	}
	else
	{
		returnValue = yr;
	}

	return returnValue;
} // formatYear


// format_Year
function format_Year(entryYear)
{		
	var returnValue = "";
	var yr = getValue(entryYear);
	if(isNaN(yr) || containsSpace(yr) ) yr = "";
	if(yr!="") {
		var today = new Date(dtServerDate);
		var todayYear = today.getFullYear();
		var sYr = new Date(yr,0,1);
		var yr = sYr.getYear();

		if (yr < 1000)
		{
			yr+=2000
			if (yr > todayYear)
			{
				yr -=2000;
				yr +=1900;
			}
		} 
		if (yr > todayYear)
			returnValue = todayYear;
		else		
			returnValue = yr;
	}
	if(isNaN(returnValue)) returnValue = "";
	return returnValue;
} // format_Year

// upperCase
function upperCase(entryValue)
{
	var returnValue = entryValue.toUpperCase();
	return returnValue;
} // upperCase

//  lowerCase
function lowerCase(entryValue)
{
	var returnValue = entryValue.toLowerCase();
	return returnValue;
} // lowercase


// properCase
function properCase(entryValue)
{
	var strArray;
	var returnValue="";
    
	strArray = lowerCase(trim(entryValue)).split(" ");	
	for (var x = 0; x < strArray.length; x++)
	{
		strArray[x] =  strArray[x].replace(strArray[x].charAt(0),
			            strArray[x].charAt(0).toUpperCase());				
		returnValue += strArray[x] + " ";
	}

	return trim(returnValue);
} // properCase

// numericOnly
function numericOnly(e)
{
	var myChar;
	
	if (document.all)
	{
		e = window.event;
		myChar = String.fromCharCode(e.keyCode);
	}
	else if (document.layers)
	{
		var myChar = String.fromCharCode(e.which); 
	}
	
   numericValues = "0123456789";

   if (numericValues.indexOf(myChar) < 0)
	{
		if (document.layers) { return false; }
		else if (document.all) { e.returnValue = false; }
	}
} // numericOnly

// numericPNOnly  Added By Swami
//Used to check the unsigned integers....need to be used in conjunction with numericonly
function numericPNOnly(e,txtField)
{
	var myChar;
	
	if (document.all)
	{
		e = window.event;
		myChar = String.fromCharCode(e.keyCode);
	}
	else if (document.layers)
	{
		var myChar = String.fromCharCode(e.which); 
	}
	
	if(isNaN(trim(txtField.value))&&txtField.value.length>1)
	{
		txtField.value=txtField.value.substring(0,txtField.value.length-1);
	}
	
} // numericPNOnly


//unsignednumericOnly Only
function unsignednumericOnly(e)
{
	var myChar;
	
	if (document.all)
	{
		e = window.event;
		myChar = String.fromCharCode(e.keyCode);
	}
	else if (document.layers)
	{
		var myChar = String.fromCharCode(e.which); 
	}
	
   numericValues = "-0123456789";

   if (numericValues.indexOf(myChar) < 0)
	{
		if (document.layers) { return false; }
		else if (document.all) { e.returnValue = false; }
	}
} // unsignednumericOnly


// charOnly
function charOnly(e)
{
	var myChar;

	if (document.all)
	{
		e = window.event;
		myChar = String.fromCharCode(e.keyCode);
	}
	else if (document.layers)
	{
		var myChar = String.fromCharCode(e.which); 
	}
	
   charValues = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz";

   if (charValues.indexOf(myChar) < 0)
	{
		if (document.layers) { return false; }
		else if (document.all) { e.returnValue = false; }
	}
} // charOnly


// formatSSN
function formatSSN(entryValue)
{
  var returnValue;
  var tstValue;
	
	if (trim(entryValue).length > 0) 
	{	 
		tstValue = padNumericRight(entryValue, 9);
		returnValue = tstValue.substring(0,3) + "-" + tstValue.substring(3,5) + "-" +
		 	           tstValue.substring(5,9);
	}
	else 
	{
	 	returnValue = "";
	}
		
	return returnValue;
} // formatSSN


// stripAllEditing
function stripAllEditing(entryValue)
{
	var i;
	var tstValue;
	var returnValue;
	returnValue = "";

 	numericValues = "0123456789";
	
	for (var i=0; i < entryValue.length; i++)
	{
   	tstValue = entryValue.substring(i, i+1);

   	if (numericValues.indexOf(tstValue) < 0)
		{
		}
		else
		{
    		returnValue = returnValue + tstValue;
   	}
	}

	if (returnValue.length <= 0)
	{
		returnValue = "";
	}

	return returnValue;
} // stripAllEditing


//currencyOnly
function currencyOnly(e)
{
	var myChar;
	
	if (document.all)
	{
		e = window.event;
		myChar = String.fromCharCode(e.keyCode);
	}
	else if (document.layers)
	{
		var myChar = String.fromCharCode(e.which); 
	}
	
	numericValues = "0123456789.-";

   if (numericValues.indexOf(myChar) < 0)
	{
		if (document.layers) {return false;}
		else if (document.all) {e.returnValue = false;}
	}
} // currencyOnly


// formatZipCode
function formatZipCode(entryValue)
{
	var returnValue="";

	if (trim(entryValue).length > 0) 
	{	
		returnValue = entryValue.substring(0,5); 
		if (trim(entryValue.substring(5,9)).length > 0)
		{
			if (trim(entryValue.substring(5,9)).length < 4)
			{
				entryValue += "0000";				 	 
			}
		 	returnValue += "-" + trim(entryValue.substring(5,9));
		}
	}
	else 
	{
		returnValue = "";
	}
		
	return returnValue;
} // formatZipCode


// format_ZipCode
function format_ZipCode(entryValue)
{   	var returnValue="";
	if(isNaN(entryValue)) entryValue="";

	if (trim(entryValue).length > 0) 
	{	
		returnValue = entryValue.substring(0,5); 
		if (trim(entryValue.substring(5,9)).length > 0)
		{
			if (trim(entryValue.substring(5,9)).length < 4)
			{
				entryValue += "0000";				 	 
			}
		 	returnValue += "-" + trim(entryValue.substring(5,9));
		}
	}
	else 
	{
		returnValue = "";
	}		
	return returnValue;
} 
// format_ZipCode


// padNumericRight
function padNumericRight(entryValue, toLength)
{
	var returnValue=entryValue;
	var i;

	returnValue = (returnValue.length == 0) ? 0 : returnValue;
	for (var i=1; i < toLength; i++)
	{
   	returnValue += "0";
	}
   
	return returnValue.substring(0,toLength);	
} // padNumericRight


// formatHour12
function formatHour12(entryValue)
{
	var returnValue = entryValue;
	returnValue = (returnValue > 12) ? 12 : returnValue;

	return returnValue;
} // formatHour12


// formatMinutes
function formatMinutes(entryValue)
{
	var returnValue = entryValue;
	returnValue = (returnValue > 59) ? 0 : returnValue;
	returnValue = (returnValue < 10) ? ("0" + returnValue).substring(0,2) : returnValue.substring(0,2);
	returnValue = (returnValue == 0) ? "00" : returnValue; 

	return returnValue;
} // formatMinutes


// Month
// to use:
// var month = new Month();
// alert(month[3]); //you should see March
function Month()
{
	this.length = 13;
	this[0] = "";
	this[1] = "January";
	this[2] = "February";
	this[3] = "March";
	this[4] = "April";
	this[5] = "May";
	this[6] = "June";
	this[7] = "July";
	this[8] = "August";
	this[9] = "September";
	this[10] = "October";
	this[11] = "November";
	this[12] = "December";
} // Month

// Day
// to use:
// var day = new Day();
// alert(day[3]); //you should see Wednesday
function Day()
{
	this.length = 7;
	this[0] = "Sunday";
	this[1] = "Monday";
	this[2] = "Tuesday";
	this[3] = "Wednesday";
	this[4] = "Thursday";
	this[5] = "Friday";
	this[6] = "Saturday";
} // Day
	
// yesterdayDate
function yesterdayDate(entryValue)
{
	var today = new Date(dtServerDate);
	var nday = new Date(dtServerDate);
	var temp = today.getDate() - 1;
	nday.setDate(temp);
	return nday;
} // yesterdayDate
	

// tomorrowDate
function tomorrowDate(entryValue) {
	var today = new Date(dtServerDate);
	var nday = new Date(dtServerDate);
	var temp = today.getDate() + 1;
	nday.setDate(temp);
	return nday;
} // tomorrowDate



// optionMonths
// return a option string of month values
// to use:
// <select>
//		<script type="text/javascript">
//			document.write(optionMonths());
//		</script>
// </select>
// optional: monthToSelect valid values 0-12
// to use:
// <select>
//		<script type="text/javascript">
//			document.write(optionMonths(10)); //selects October
//		</script>
// </select>
function optionMonths(monthToSelect)
{
	var returnValue = "";	
	var month = new Month();	
	for ( var i=0; i <= month.length-1; i++) 
	{
		var x = (i == 0) ? "''" : String(i);
		if (x.length == 1 )
		  { x = 0 + x ; }		  		    		  
		if (monthToSelect == i)
		{
			returnValue += "<OPTION selected value=" + x + ">" + month[i] + "</OPTION>";
		}
		else
		{
			returnValue += "<OPTION value=" + x  + ">" + month[i] + "</OPTION>";
		}
	}

	return returnValue;
} // optionMonths	


// USStates	
// to use:
// var usstates = new USStates();
// alert(usstates.state["AR"]);
// you should see Arkansas
function USStates()
{
	this.abbr = new Array("AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL",
		                       "GA","HI","ID","IL","IN","IA","KS","KY","LA","ME",
		                       "MD","MA","MI","MN","MS","MO","MT","NE","NV","NH",
		                       "NJ","NM","NY","NC","ND","OH","OK","OR","PA","PR",
		                       "RI","SC","SD","TN","TX","UT","VT","VA","VI","WA",
		                       "WV","WI","WY");

	this.state = new Array("Alabama","Alaska","Arizona","Arkansas","California",
						 "Colorado","Connecticut","Delaware","District of Columbia","Florida",
						 "Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky",
						 "Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota",
						 "Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire",
						 "New Jersey","New Mexico","New York","North Carolina","North Dakota",
						 "Ohio","Oklahoma","Oregon","Pennsylvania","Puerto Rico","Rhode Island",
						 "South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont",
						 "Virginia","Virgin Islands","Washington","West Virginia","Wisconsin",
						 "Wyoming");
} // USStates	


// optionStates
// return a option string of U.S. State values
// to use:
// <select>
//		<script type="text/javascript">
//			document.write(optionStates());
//    </script>
// </select>
//		optional: stateToSelect valid values: any state abbreviation
//		to use:
// <select>
//		<script type="text/javascript">
//			document.write(optionStates("AR")); //selects Arkansas
//		</script>
// </select>
//	optional: stateToOmit valid values: any state abbreviation
//	to use:
//	<select>
//		<script type="text/javascript">
//			document.write(optionStates("","AR"));   //omits Arkansas from the list
//		</script>
// </select>
// to use:
// <select>
//		<script type="text/javascript">
//			document.write(optionStates("MO","AR")); //selects Missouri, omits Arkansas from the list
//		</script>
// </select>
function optionStates(stateToSelect,stateToOmit)
{
	var returnValue = "";
	var usstates = new USStates();
	for (var i=0; i <= usstates.abbr.length-1; i++)
	{
		if ( (stateToOmit == usstates.abbr[i]) && (i > 0) ) {i+=1;}
		{
			var x = (i == 0) ? "" : usstates.abbr[i];
			if (stateToSelect == usstates.abbr[i])
			{
				returnValue += "<OPTION selected value=" + x + ">" + usstates.state[i] + "</OPTION>";
			}
			else
			{
				returnValue += "<OPTION value=" + x  + ">" + usstates.state[i] + "</OPTION>";
			}
		}
	}

	return returnValue;
} // optionStates	


// optionYesNo
function optionYesNo(optionToSelect)
{
	var returnValue="";
	returnValue += "<OPTION value=''></OPTION>";
	returnValue += (optionToSelect == "Y") ?
		            "<OPTION value=Y selected>Yes</OPTION>" : 
						"<OPTION value=Y>Yes</OPTION>";
	returnValue += (optionToSelect == "N") ? 
						"<OPTION value=N selected>No</OPTION>" : 
						"<OPTION value=N>No</OPTION>";

	return returnValue;
} // optionYesNo


// setTabIndex
function setTabIndex(documentForm)
{
	var blnSetFocus = false;
	var elem = documentForm.elements;
	var j=0;
	for (var i=0; i<elem.length; i++)
	{
		if (elem[i].name.length > 0)
		{
			j = elem[i].tabIndex;
		 	if (j >= 0) 
			{
				if (j > 0)
				{

				}
				else 
				{ 
					elem[i].tabIndex = i + 1;
					if (elem[i].type != "hidden") 
					{
						if (blnSetFocus == false)   // set focus on first input capable field 
						{
							elem[i].focus(); 
							blnSetFocus = true;
						}
					}
				}
			}
		}
	}

	return;
} // setTabIndex


function writeSMsg(documentForm)
{
	var elem = documentForm.elements;
	var returnValue = "";
	for (var i = 0; i < elem.length; i++)
	{
 		if (elem[i].name.length > 0)  
		{
			if (elem[i].type != "hidden") 
			{  
				returnValue += 'sMsg["' + elem[i].name + '"] = " ";';				
			}
		}
	}
	document.write(returnValue);

	return;
} // writeSMsg



///////////////////////////////////////////////////////////////////////////
/////////////////////      To add in Common          //////////////////////
///////////////////////////////////////////////////////////////////////////

// LocalOffices	
// to use:
// var localOffices = new LocalOffices();
// alert(localOffices.localOffice["10221"]);
// you should see Arkadelphia
function LocalOffices()
{
	this.abbr = new Array("", "00290", "00010", "00300", "00020", "00030", "00210", "00040",
								 "00050", "00060", "00070", "00080", "00090", "00100", "00110",
								 "00160", "00120", "00130", "00200", "00220", "00140", "00150",
								 "00270", "00230", "00240", "00170", "00250", "00180", "00260",
								 "00190", "00280", "00320","00135","00165","00175","00305",
								 "00405","00409");
	                      

	this.localOffice = new Array( " ", "Arkadelphia", "Batesville", "Benton", "Blytheville", 
	                              "Camden","Conway","El Dorado","Fayetteville", "Forrest City",
	                              "Fort Smith", "Harrison", "Helena", "Hope", "Hot Spring",
	                              "Jacksonville", "Jonesboro", "Little Rock", "Magnolia",
	                              "Malvern", "Mena", "Monticello", "Mountain Home", "Newport",
	                              "Paragould", "Pine Bluff", "Rogers", "Russellville", "Searcy",
	                              "Texarkana", "Walnut Ridge", "West Memphis", "Little Rock NMU",
	                              "Jacksonville NMU","Pine Bluff NMU","Benton NMU","Interstate NMU",
	                              "Interstate Unit");
} // LocalOffices

// optionLocalOffices
// return a option string of LocalOffices values
// to use:
// <select>
//		<script type="text/javascript">
//			document.write(optionLocalOffices());
//    </script>
// </select>
//		optional: localOfficeToSelect valid values: any localOffice abbreviation.
// To use:
// <select>
//		<script type="text/javascript">
//			document.write(optionLocalOffices("10320")); //selects 'West Memphis'
//		</script>
// </select>
function optionLocalOffices(localOfficeToSelect)
{
	var returnValue = "";
	var localOffices = new LocalOffices();
	for (var i=0; i <= localOffices.abbr.length-1; i++)
	{
		var x = (i == 0) ? "" : localOffices.abbr[i];
		if (localOfficeToSelect == localOffices.abbr[i])
		{
			returnValue += "<OPTION selected value=" + x + 
			               ">" + localOffices.localOffice[i] + "</OPTION>";
		}
		else
		{
			returnValue += "<OPTION value=" + x  + ">" + localOffices.localOffice[i] + "</OPTION>";
		}
	}	
	return returnValue;
} // optionLocalOffices	


// Gender
// to use:
// var gender = new Gender();
// alert(Gender[1]); you should see Male
function Gender()
{
	this.length = 3;
	this[0] = "";
	this[1] = "Male";
	this[2] = "Female";
} // Gender

function optionGender(GenderToSelect)
{
	var returnValue = "";
	var gender = new Gender();
	for ( var i=0; i <= gender.length-1; i++) 
	{
		var x = (i == 0) ? "" : i;
		if (GenderToSelect == i)
		{
			returnValue += "<OPTION selected value=" + x +
				           ">" + gender[i] + "</OPTION>";
		}
		else
		{
			returnValue += "<OPTION value=" + x  + ">" +
				           gender[i] + "</OPTION>";
		}
	}

	return returnValue;
} // optionGender

// Ethnicity
// to use:
// var ethnicity = new Ethnicity();
// alert(ethnicity[3]); you should see Hispanic
function Ethnicity()
{
	this.length = 7;
	this[0] = "";
	this[1] = "White-Non Hispanic";
	this[2] = "Black-Non Hispanic";
	this[3] = "Hispanic";
	this[4] = "American Indian or American Native";
	this[5] = "Asian or Pacific Islander";
	this[6] = "Other";
} // Ethnicity

// Ethnicity
// to use:
// var ethnicity = new Ethnicity();
// alert(ethnicity[2]); you should see 'Service occupations'
function optionEthnicity(ethnicityToSelect)
{
	var returnValue = "";
	var ethnicity = new Ethnicity();
	for ( var i=0; i <= ethnicity.length-1; i++) 
	{
		var x = (i == 0) ? "" : i;
		if (ethnicityToSelect == i)
		{
			returnValue += "<OPTION selected value=" + x +
				           ">" + ethnicity[i] + "</OPTION>";
		}
		else
		{
			returnValue += "<OPTION value=" + x  + ">" +
				           ethnicity[i] + "</OPTION>";
		}
	}

	return returnValue;
} // optionEthnicity


/****************************** Functions added by Satya Kolli *********************/
//To validate numeric fields
function numbersOnly(entryValue) {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   for (i = 0; i < entryValue.length && blnResult == true; i++) {
      strChar = entryValue.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) {
         blnResult = false;
      }
   }
   return blnResult;
} // end of numbersOnly


/********************************  Function added by Sreenivas Mandava *************/

//This function sets title to the window 
function setTitle(strTitle) {
	parent.window.document.title = strTitle;
}  // end of setTitle

//-------------- validating SSN
function validateSSN(ssnItem, ssn, REQUIRED)
{
   if(!(REQUIRED == false))
   {
	if (!numbersOnly(ssn)) 
		{writeToErrorArray("text", ssnItem.name, "Invalid SSN. Enter numbers only.");}
	else if (ssn.length != 9) 
		{writeToErrorArray("text", ssnItem.name, "Invalid SSN. SSN should be nine numerics.");}		
   }	
  else
   { 
     if (!(ssn.length == 0 ||(ssn.length == 9 && numbersOnly(ssn)))) 
		 {writeToErrorArray("text", ssnItem.name, "Invalid SSN.Please enter a valid 9 digit SSN.")};				 			
   }   
}		    
//end of validateSSN

// Function to take the control to the next field
function nextField(thisItem, len, nextItem) {
	if (thisItem.value.length == len) {
		nextItem.focus();
    }				
} 

// Function to take the control to the next field when the petition prefix is entered.
function nextField1(thisItem, nextItem) {
	var ItemValue
	ItemValue = thisItem.value
	if(ItemValue.charAt(0) == "t" || ItemValue.charAt(0) == "T" ) //if it is TAA petition
	{
		if (thisItem.value.length == 3) {
			nextItem.focus();
		}				
	}
	else if(ItemValue.charAt(0) == "n" || ItemValue.charAt(0) == "N" ) // If it is Nafta petition
	{
		if (thisItem.value.length == 5) {
			nextItem.focus();
		}				
	}
} //end of nextField1



// formatDay
function formatDay(entryMonth, entryDay, entryYear)
{
	var returnValue="";
	var mth = entryMonth;
	var day = entryDay;
	var yr = entryYear;
    
	// jan,mar,may,jul,aug,oct,dec
	if ((mth == 1) || (mth == 3) || (mth == 5) || (mth == 7) || (mth == 8) || (mth == 10) || (mth == 12))	
	{
	
		if (day > 31)
		{			
			returnValue = 31;
		}
		else 
		{
			returnValue = day;
		}	
	}
	// feb
	else if (mth == 2)
	{
		if (isLeapYear(yr))
		{
			if (day > 29)
			{
				returnValue = 29;
			}
			else
			{
				returnValue = day;
			}
		}
		else
		{
			if (day > 28)
			{
				returnValue = 28;
			}
			else
			{
				returnValue = day;
			}
		}	
	}
	// apr,jun,sep,nov
	else if ((mth == 4) || (mth == 6) || (mth == 9) || (mth == 11))
	{
		if (day > 30)
		{
			returnValue = 30;
		}
		else
		{
			returnValue = day;
		}
	}
	else if (mth == 0)
	{
		returnValue = day;
	}

	return returnValue;
} // formatDay


// padNumericLeft
function padNumericLeft(entryValue, toLength)
{
	var returnValue=entryValue;
	var i;
   
	returnValue = (returnValue.length == 0) ? 0 : returnValue;
	if (returnValue=="")
	{
		returnValue="0"
	}
	for (var i=returnValue.length; i < toLength; i++)
	{
   	returnValue = "0" + returnValue ;
	}
	return returnValue;	
} // padNumericLeft


//to find the date difference
function ConvertYear(ynumber) 
{ EnterYearAlone = ynumber;
  if (trim(ynumber).length > 0) 
  {
        if(ynumber.length == 1)  
        {ynumber = "0" + ynumber }
		if(ynumber.length == 2) 
		 { 
		   var today = new Date(dtServerDate);
 		   var todayYear = String(today.getFullYear()); 	
		   var YearLimit = Number(todayYear.substring(0,2) + 20) ;
		   var EnterYearAlone = Number(todayYear.substring(0,2) + ynumber ) ;
		   if(EnterYearAlone > YearLimit)
		    {
		      EnterYearAlone = Number(todayYear.substring(0,2) + ynumber) - 100 ;
		    }
		   else
		    {
		      EnterYearAlone = Number(todayYear.substring(0,2) + ynumber);
		    }      
		 }
   }
   else
   { EnterYearAlone = "" ; }		 
   return EnterYearAlone;
}

//if the full date is known
function daysElapsed(date1,date2) {
    var difference =
        Date.UTC(date1.getYear(),date1.getMonth(),date1.getDate(),0,0,0)
      - Date.UTC(date2.getYear(),date2.getMonth(),date2.getDate(),0,0,0);
    return difference/1000/60/60/24;
}

//if the fields are entered separatly
function DateDiff(year1,month1,day1,year2,month2,day2)
{      
    var difference = Date.UTC(year1,month1,day1,0,0,0)
      - Date.UTC(year2,month2,day2,0,0,0) ;
    return difference/1000/60/60/24;    
}

//if the fields are entered separatly and full date is given
function vDateDiff(date1,year2,month2,day2) 
{
var date2 = new Date(dtServerDate)
var targetDate = new Date(date1) 
date2.setFullYear(year2,month2-1,day2);
var timeAfterTarget = Math.floor(( date2.getTime()
        - targetDate.getTime() ) / 86400000);
return timeAfterTarget;    
}

//if the fields are entered separatly..to check if date entered is greater than current date
function CurDateDiff(year1,month1,day1)
{
var today = new Date(dtServerDate);
var difference = Date.UTC(year1,month1-1,day1,0,0,0)
      - Date.UTC(today.getYear(),today.getMonth(),today.getDate(),0,0,0);
    return difference/1000/60/60/24;
}  

//to get the week difference
function Weeks(year1,month1,day1,year2,month2,day2)
{      
    var difference = Date.UTC(year1,month1-1,day1,0,0,0)
      - Date.UTC(year2,month2-1,day2,0,0,0) ;
    return difference/1000/60/60/24/7;    
}

// Counties	
// to use:
// var counties = new Counties();
// alert(counties.county["AR"]);
// you should see Arkansas
function Counties()
{
	this.abbr = new Array("001","003","005","007","009","011","013","015","017","019",
	                      "021","023","025","027","029","031","033","035","037","039","041",
	                      "043","045","047","049","051","053","055","057","059","061","063",
	                      "065","067","069","071","073","075","077","079","081","083","085",
	                      "087","089","091","093","095","097","099","101","103","105","107",
	                      "109","111","113","115","117","119","121","123","125","127","129",
	                      "131","133","135","137","139","141","143","145","147","149","151");
	                      

	this.county = new Array("Arkansas","Ashley","Baxter","Benton","Boone","Bradley",
	                        "Calhoun","Carroll","Chicot","Clark","Clay","Cleburne","Cleveland",
	                        "Columbia","Conway","Craighead","Crawford","Crittenden","Cross",
	                        "Dallas","Desha","Drew","Faulkner","Franklin","Fulton","Garland",
	                        "Grant","Greene","Hempstead","Hot Spring","Howard","Independence",
	                        "Izard","Jackson","Jefferson","Johnson","Lafayette","Lawrence",
	                        "Lee","Lincoln","Little River","Logan","Lonoke","Madison","Marion",
	                        "Miller","Mississippi","Monroe","Montgomery","Nevada","Newton",
	                        "Ouachita","Perry","Phillips","Pike","Poinsett","Polk","Pope",
	                        "Prairie","Pulaski","Randolph","St. Francis","Saline","Scott",
	                        "Searcy","Sebastian","Sevier", "Sharp","Stone","Union","Van Buren",
	                        "Washington","White","Woodruff","Yell","Out Of State");	                        
} // Counties


// optionCounties
// return a option string of County values
// to use:
// <select>
//		<script type="text/javascript">
//			document.write(optionCounties());
//    </script>
// </select>
//		optional: countyToSelect valid values: any county abbreviation.
// To use:
// <select>
//		<script type="text/javascript">
//			document.write(optionCounties("003")); //selects Ashley
//		</script>
// </select>
function optionCounties(countyToSelect)
{
	var returnValue = "";
	var counties = new Counties();
	for (var i=0; i <= counties.abbr.length-1; i++)
	{
		var x = (i == 0) ? "" : counties.abbr[i];
		if (countyToSelect == counties.abbr[i])
		{
			returnValue += "<OPTION selected value=" + x + ">" + counties.county[i] + "</OPTION>";
		}
		else
		{
			returnValue += "<OPTION value=" + x  + ">" + counties.county[i] + "</OPTION>";
		}
	}
	return returnValue;
} // optionCounties


// This function returns current Year
function getCurrYear() {
	var today = new Date(dtServerDate);
	var todayYear = today.getFullYear();
	return todayYear;
}


// This function returns current Quarter
function getCurrQuarter() {
	var today = new Date(dtServerDate);
	var todayMonth = today.getMonth();
	var todayQtr;
	if(todayMonth==1 || todayMonth==2 || todayMonth==3)
		todayQtr = 1;
	if(todayMonth==4 || todayMonth==5 || todayMonth==6)
		todayQtr = 2;
	if(todayMonth==7 || todayMonth==8 || todayMonth==9)
		todayQtr = 3;
	if(todayMonth==10 || todayMonth==11 || todayMonth==12)
		todayQtr = 4;
	return todayQtr;
}


// This function checks spaces in the value (val)
function containsSpace(val) {
	var boolB = false;
	var intLen = val.length;	
	for(var i=0;i<intLen;i++) {		
		if(val.charAt(i)==" ") {
			boolB=true;
			break;
		}
	}
	return boolB;
}


// This function gets value of text box
// If the entered value is space or text, returns ""
function getNumberVal(controlName) {
	var returnVal="";	
	if( isNaN(controlName.value) || containsSpace(controlName.value) ) {
		returnVal =  "";
		controlName.value="";
	}
	else if(controlName.value=="")
		returnVal =  "";
	else
		returnVal = controlName.value;	
	return returnVal;
}


// checkDate
function checkDate(controlName1, controlName2, controlName3, errMsg, isRequired) {
	var controlVal1 = controlName1.value;
	var controlVal2 = controlName2.value;
	var controlVal3 = controlName3.value;
	dteClaimFiledDate = getDateValue(controlVal1, controlVal2, controlVal3);		
	if(isRequired==true) {
		validateDate(controlName1, dteClaimFiledDate, errMsg);
	}
	else {
		if(controlVal1!="" || controlVal2!="" || controlVal3!="")
			validateDate(controlName1, dteClaimFiledDate, errMsg);
	}
	
} // checkDate




//optionTitle
function optionTitle(optionToSelect) {
  var returnValue="";
	returnValue += "<option value=&nbsp;>[Select]</option>";
	returnValue += (optionToSelect == "MR") ? 
							"<option value=MR selected=true>Mr</option>" : 
							"<option value=MR>Mr</option>";
	returnValue += (optionToSelect == "MRS") ? 
							"<option value=MRS selected=true>Mrs</option>" : 
							"<option value=MRS>Mrs</option>";
	returnValue += (optionToSelect == "MISS") ? 
							"<option value=MISS selected=true>Miss</option>" : 
							"<option value=MISS>Miss</option>";
	return returnValue;
} //optionTitle


//optionSuffix
function optionSuffix(optionToSelect) {
  var returnValue="";
	returnValue += "<option value=&nbsp;>[Select]</option>";
	returnValue += (optionToSelect == "JR") ? 
							"<option value=JR selected=true>Junior</option>" : 
							"<option value=JR>Junior</option>";
	returnValue += (optionToSelect == "SR") ? 
							"<option value=SR selected=true>Senior</option>" : 
							"<option value=SR>Senior</option>";
	returnValue += (optionToSelect == "I") ? 
							"<option value=I selected=true>I</option>" : 
							"<option value=I>I</option>";
	returnValue += (optionToSelect == "II") ? 
							"<option value=II selected=true>II</option>" : 
							"<option value=II>II</option>";
	returnValue += (optionToSelect == "III") ? 
							"<option value=III selected=true>III</option>" : 
							"<option value=III>III</option>";
	return returnValue;
} //optionSuffix


//get the week ending date - saturday
function SaturdayDate(imonth,iday,iyear)
{  
    var isatday = new Date();	    
	isatday.setFullYear(iyear,imonth-1,iday) ;	
	var daydiff = 6 - isatday.getDay();
	var temp = isatday.getDate() + daydiff;	
	isatday.setDate(temp);	
	return isatday;
}           


//check if the date entered is a saturday
function isSaturDay(imonth,iday,iyear)
{ 
	var date1 = new Date();
   var date2 = new Date();
  date1.setFullYear(iyear,imonth-1,iday);
  date2 =  SaturdayDate(imonth,iday,iyear);  
  if(parseInt(daysElapsed(date2,date1)) != 0)
   {return false ; }
  else
   {return true ; }       
}           

//get the week begin date - sunday
function SundayDate(imonth,iday,iyear)
{  
    var isunday = new Date();	    
	isunday.setFullYear(iyear,imonth-1,iday) ;	
	var daydiff = 0 - isunday.getDay();
	var temp = isunday.getDate() + daydiff;	
	isunday.setDate(temp);	
	return isunday;
}           
//get the current week begin date - sunday
function CurSundayDt()
{  
    var isunday = new Date();	    	
	isunday.setFullYear(isunday.getYear(),isunday.getMonth(),isunday.getDate()) ;	
	var daydiff = 0 - isunday.getDay();
	var temp = isunday.getDate() + daydiff;	
	isunday.setDate(temp);	
	return isunday;
}      

//check if the date entered is a sunday
function isSunDay(imonth,iday,iyear)
{ 
	var date1 = new Date();
   var date2 = new Date();
  date1.setFullYear(iyear,imonth-1,iday);
  date2 =  SundayDate(imonth,iday,iyear);  
  if(parseInt(daysElapsed(date2,date1)) != 0)
   {return false ; }
  else
   {return true ; }       
}           


//To subtract days from today's date 
function SubDays(days)
{  
	var date1 = new Date();
    //date1.setFullYear(iyear,imonth-1,iday);
    return new Date(date1.getTime() - days*24*60*60*1000);
}


//Resizes the frames and loads the contents. 
//AUthor: Srinivasarao Pappala.
function Resizeframes(frame1size, frame1URL, frame2size, frame2URL, frame3size, frame3URL, frame4size, frame4URL)
{
	//Pass the URL to load it in the frame. For maintaining the samepage, pass "" empty string.
	parent.document.body.rows= frame1size + ',' + frame2size + ',' + frame3size + ',' + frame4size
	//alert(parent.frames.item(0).document.location.href)
	if(frame1URL != "")
	{
		parent.frames.item(0).document.location.href = frame1URL
	}
	if(frame2URL != "")
	{
		parent.frames.item(1).document.location.href = frame2URL
	}
	if(frame3URL != "")
	{
		parent.frames.item(2).document.location.href = frame3URL
	}
	if(frame4URL != "")
	{
		parent.frames.item(3).document.location.href = frame4URL
	}

}

//Function added by Satya on 08/09/2002
//Resets form
function resetForm(objForm) {
	for (i=0; i < objForm.length; i++) {
		var objItem = objForm[i];
		if (objItem.tabIndex > 0) {
			switch(objItem.type) {
				case "text":
					objItem.value = "";
					break;
				case "select-one":
					objItem.options.selectedIndex = 0;
					break;
				case "select-multiple":
					for (j=0; j < objItem.length; j++) {
						if (objItem.options[j].selected) {
							objItem.options[j].selected = false;
						}
					}				
					break;
				case "radio":
					objItem.checked = false;
					break;
				case "checkbox":
					objItem.checked = false;
					break;
			}
		}
	}
} //end of resetForm
//Pad Numeric Left
function fnPadLeft(entryValue, toLength){
	if(entryValue==""){
		return '';
	}else{
		return padNumericLeft(entryValue, toLength);
	}
}
//Pad Numeric Right
function fnPadRight(entryValue, toLength){
	if(entryValue==""){
		return '';
	}else{
		return padNumericRight(entryValue, toLength);
	}
}
//Format future Year
function formatFYear(entryYear)
{
  if(entryYear!=""){
	var returnValue=0;
	var yr = entryYear;
	var sYr = new Date(yr,0,1);
	var yr = sYr.getYear();
	if (yr < 1000)
	{	
		if(yr>30){
			yr +=1900;
		}else{
			yr+=2000
		}	
		returnValue = yr;
	}else{
		returnValue = yr;
	}
  }else{
		returnValue="";
  }	
	return returnValue;
} // formatFYear


//Function Name		: nextElement
//Description			: Takes focus to next given element. 
//							  Works also when shift+tab is used	
//Arguments				: current object, next object to which focus to be taken,
//							 length to be checked, event		
function nextElement(thisObj, nextObj, len, e) {
	var kCode, arrKCodes, exists;

	if (navigator.appName == "Microsoft Internet Explorer") {
		kCode = e.keyCode;
		arrKCodes = [0,8,9,16,17,18,37,38,39,40,46];
	}
	else if (navigator.appName == "Netscape") {
		kCode = e.which;
		arrKCodes = [0,8,9];
	}
	
	if (thisObj.value.length >= len) {
		exists = false;
		for (var i = 0; i < arrKCodes.length; i ++) {
			if (arrKCodes[i] == kCode) {
				exists = true;
				break;
			}
		} 
		if (!exists) {					
			thisObj.value = thisObj.value.slice(0, len);
			nextObj.focus();
		}
	}				
}//nextElement
