/*2.12.02, MAC 
function areCookiesEnabled() verifies that cookies are enabled
*/
document.cookie = 'tempCookie' + escape('nothing');
function areCookiesEnabled()
{
  if(document.cookie == "") {return false;} 
  else {return true;}
}


/*1.31.02, MAC 
function validates zip code fields, date fields, 
and required fields and creates pop up window with error msg
takes 3 parameters:
oForm the form object
nCount the element to start validating the form at
nLength the element to stop the validating with + 1
to validate all form elements:
pass nCount of 0 & nLength of oForm.elements.length 
*/
function valAllElements(oForm,nCount,nLength)
{
	var lnCount = parseInt(nCount); 
	var lnLength = parseInt(nLength); //last element to validate +1
	var loForm = oForm;
	var lcErrMsg1 = "";//empty fields
	var lcErrMsg2 = "";//incorrect fields
	var lcEmpty_fields = "";
	var lcIncorrect_fields ="";
	var lcTxt1 = "";
	var loStr1 = new String();	
							
	for ( lnCount; lnCount < lnLength; lnCount++)
	{
			lcTxt1 = loForm.elements[lnCount].value;
			loStr1 = loForm.elements[lnCount].name;
			
			if(loStr1.indexOf("_Z")>= 0)
			{
				loStr1 = loStr1.slice(3,-2);
				if( (lcTxt1 == null) || (lcTxt1 == "") ||(lcTxt1 == " ") )
				{
					lcEmpty_fields += "\n   "+ loStr1;
				}else{
				loTempStr1 = parseInt(lcTxt1);
					if( lcTxt1.length != 5 ||isNaN(loTempStr1) || loTempStr1 == 0) 
					{
						lcIncorrect_fields += "\n   "+ lcTxt1 +"  is not a valid entry for "+loStr1;
					}
				}
			}
			if(loStr1.indexOf("_R")>= 0)
			{
				loStr1 = loStr1.slice(3,-2);
				if( (lcTxt1 == null) || (lcTxt1 == "") ||(lcTxt1 == " ") )
				{
					lcEmpty_fields += "\n   "+ loStr1;
				}
			}
			if(loStr1.indexOf("_D")>= 0)
			{
				if( lcTxt1 != ""  )
				{
					
					//prepare substrings
					loStr1 = loStr1.slice(3,-2);//name of control for error msg
					laNumbers = lcTxt1.split("/");
					
					//validate substrings
					if( 
						isNaN(laNumbers[0]) || laNumbers[0] == 0 || laNumbers[0] >12 ||
						isNaN(laNumbers[1]) || laNumbers[1] == 0 || laNumbers[1] >31 ||
						isNaN(laNumbers[2]) || laNumbers[2] == 0 )
					{
						lcIncorrect_fields += "\n   "+ lcTxt1 +" is not a valid entry(NN/NN/NN) for "+loStr1;
					}
				}
			}	
	}
	if(lcEmpty_fields == "" && lcIncorrect_fields == "") 
	{return true;}
	else
	{
			if(lcEmpty_fields != "")
			{
				lcErrMsg1 +="The following required field(s) are empty:"
				+lcEmpty_fields + "\n";
			}
			if(lcIncorrect_fields != "")
			{
				lcErrMsg2 +="The following field(s) have unallowable data:"
				+lcIncorrect_fields + "\n";
			}
			alert(lcErrMsg1 +  lcErrMsg2);
			return false;	
	}
	
}



