		var bAutotab = true;
		function GetStateForNPA()
		{		
		if (document.CustomerAdvocacyForm.txtBTNNPA.value.length == 3 && document.CustomerAdvocacyForm.txtBTNLine.value.length == 4 & document.CustomerAdvocacyForm.txtBTNNXX.value.length == 3)
		{
		var strNPA = document.CustomerAdvocacyForm.txtBTNNPA.value;
		var NPAArray = ['201','202','203','206','207','208','209','212','213','214','215','217','219','231','239','240','248','252','253','260','262','267','269','276','281','301','302','304','309','310','315','317','323','325','330','339','347','351','360','361','401','408','409','410','412','413','415','419','425','434','440','443','469','484','503','508','509','512','513','516','517','518','530','540','541','551','559','562','570','571','574','585','586','603','607','608','609','610','614','616','617','618','626','631','646','661','703','704','707','714','715','716','717','718','724','727','732','734','740','757','760','765','774','775','781','802','803','804','805','808','810','812','813','814','815','817','818','828','830','832','843','845','848','856','857','862','863','864','903','908','909','914','917','919','920','928','936','937','940','941','949','951','956','971','972','973','978','979','989'];
		var StateArray = ['NJ','DC','CT','WA','ME','ID','CA','NY','CA','TX','PA','IL','IN','MI','FL','MD','MI','NC','WA','IN','WI','PA','MI','VA','TX','MD','DE','WV','IL','CA','NY','IN','CA','TX','OH','MA','NY','MA','WA','TX','RI','CA','TX','MD','PA','MA','CA','OH','WA','VA','OH','MD','TX','PA','OR','MA','WA','TX','OH','NY','MI','NY','CA','VA','OR','NJ','CA','CA','PA','VA','IN','NY','MI','NH','NY','WI','NJ','PA','OH','MI','MA','IL','CA','NY','NY','CA','VA','NC','CA','CA','WI','NY','PA','NY','PA','FL','NJ','MI','OH','VA','CA','IN','MA','NV','MA','VT','SC','VA','CA','HI','MI','IN','FL','PA','IL','TX','CA','NC','TX','TX','SC','NY','NJ','NJ','MA','NJ','FL','SC','TX','NJ','CA','NY','NY','NC','WI','AZ','TX','OH','TX','FL','CA','CA','TX','OR','TX','NJ','MA','TX','MI'];

		for(i=0; i<149; i++)
		{
			if (NPAArray[i] == strNPA)
			{
				// areacode available, set the state based on that
			//	document.AdvocacyForm.hdstate.value = StateArray[i];
				for (j=0; j<document.CustomerAdvocacyForm.cboState.length; j++)
				{
					if (StateArray[i] == document.CustomerAdvocacyForm.cboState[j].value) 
					{
						document.CustomerAdvocacyForm.cboState.selectedIndex = j;
						document.CustomerAdvocacyForm.cboState.disabled = false;
						break;
					}
				}
				break;
			}
			document.CustomerAdvocacyForm.cboState.selectedIndex = 0;
		}
	}
	else
	{
		document.CustomerAdvocacyForm.cboState.selectedIndex = 0;
	}
}
function isNumeric()
{
	if (navigator.appName.indexOf("Netscape")<0)
	{
		get=event.keyCode;
		
		if((get>45&&get<58)||(get>95&&get<106)||(get==8)||(get==9)) 
		{
			return true;
		}
		else
		{
			event.returnValue=false;
		}
	}
}

function BackForm()
{
window.history.back();
}
function ResetForm(){
	window.CustomerAdvocacyForm.reset();
}
function trim(strText) 
{ 
 	while (strText.substring(0,1) == ' ') 
 	    strText = strText.substring(1, strText.length); 	
    	while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
	return strText   
}
function CheckEmailid(lemailStr)
{
	if (lemailStr =='')
    	return '';

	var Mesg = "Please Enter the Valid Email."
	var lemailPat=/^(.+)@(.+)$/
	var lspecialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var lvalidChars="\[^\\s" + lspecialChars + "\]"
	var lfirstChars=lvalidChars
	var lquotedUser="(\"[^\"]*\")"
	var lipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var latom="(" + lfirstChars + lvalidChars + "*" + ")"
	var lword="(" + latom + "|" + lquotedUser + ")"
	var luserPat=new RegExp("^" + lword + "(\\." + lword + ")*$")
	var ldomainPat=new RegExp("^" + latom + "(\\." + latom +")*$")
	var lmatchArray=lemailStr.match(lemailPat)
	
	if (lmatchArray==null) 
	{
		alert (Mesg);
		return false
	}
	
	var luser=lmatchArray[1]
	var ldomain=lmatchArray[2]

	if (luser.match(luserPat)==null) 
	{
		alert (Mesg);
		document.CustomerAdvocacyForm.txtEmail.focus();
		document.CustomerAdvocacyForm.txtEmail.select()
		return false
      }
	  
	var lIPArray=ldomain.match(lipDomainPat)

	if (lIPArray!=null) 
	{
	  	for (var li=1;li<=4;li++) 
	  	{
	    	if (lIPArray[li]>255) 
			{
				alert (Mesg);
				document.CustomerAdvocacyForm.txtEmail.focus();
				document.CustomerAdvocacyForm.txtEmail.select()
				return false
	    	}
    	}
  
	}

	var ldomainArray=ldomain.match(ldomainPat)
	
	if (ldomainArray==null)
	 	{
			alert (Mesg);
			document.CustomerAdvocacyForm.txtEmail.focus();
			document.CustomerAdvocacyForm.txtEmail.select()
			return false
		}
		
	var latomPat=new RegExp(latom,"g")
	var ldomArr=ldomain.match(latomPat)
	var llen=ldomArr.length
	
	if (ldomArr[ldomArr.length-1].length<1 || 
    	ldomArr[ldomArr.length-1].length>255) 
    {
			alert (Mesg);
			document.CustomerAdvocacyForm.txtEmail.focus();
			document.CustomerAdvocacyForm.txtEmail.select()
			return false
	}

	if (((ldomArr[ldomArr.length-1].length>=1) && (ldomArr[ldomArr.length-1].length<=255)) && (llen<2)) 
	{
		alert (Mesg);
		document.CustomerAdvocacyForm.txtEmail.focus();
		document.CustomerAdvocacyForm.txtEmail.select()
    	return  false;
	}
	
	return true

}  // end of function CheckEmailid(lemailStr)
 function ValidateEMail(obj)
  {	

   	var sEmail= new Object;
   	sEmail=trim(obj.value);
	if (sEmail=="")
		{
			alert("You have not entered an email address. \n Please enter it now.") 
				obj.focus(); 
				obj.select();
				return false
		}
			
		if (sEmail.length > 0)
		{
		// Return false if e-mail field does not contain a '@' and '.' .
	
			if (sEmail.indexOf ('@',0) == -1 || sEmail.indexOf ('.',0) == -1)
		  	{
				alert("Your Email Address is in wrong format.")
				obj.focus(); 
				obj.select();
				return false;
			}
			sEmail = trim(sEmail)
			if(CheckEmailid(sEmail))
				return true
			else
				return false
							 
		}	
		return true;	
	}
function validateField(lField, nop)
{    
 var i;
  lField = trim(lField)
  lField =  new String(lField)
  
  
 	if ((lField.length == 0) || (parseInt(lField.length) !=  parseInt(nop))  )
    {
		return false
    }
    else
    {
		for(i=0; i < lField.length; i++)
		{
			
			//alert((parseInt(lField.charAt(i)))	)
			if ( (parseInt(lField.charAt(i))) >=  0 && (parseInt(lField.charAt(i))) <= 9)
			{
				//alert((parseInt(lField.charAt(i)))	)
			}	
			else
				return false	
		} 
			
    }
    
     return true
    
}	
function chkMaxLength(obj, l)
{
	var k = event.keyCode;
	if(k != 37 && k!=38 && k!=39 && k!=40 && k!=13 && k!=8 && k!=46)
	{
		if(obj.value.length >= l)
		return false;
	}
	return true;
}
	function validatePhone()
{
	
	if (validateField(document.CustomerAdvocacyForm.txtBTNNPA.value,3)) 
		{
			if (validateField(document.CustomerAdvocacyForm.txtBTNNXX.value,3)) 
			{
					if (validateField(document.CustomerAdvocacyForm.txtBTNLine.value, 4))
					{
						return true			
					}	
					else
					{
						document.CustomerAdvocacyForm.txtBTNLine.focus();
						alert("Please Enter the Last four digits Correctly.");
						return false
					}
			}
			else
			{
				document.CustomerAdvocacyForm.txtBTNNXX.focus();
				alert("Please Enter the Correct Phone No..");
				return false
			}	
		}	
		else
		{
			alert("Please Enter the Correct Area Code.");
			document.CustomerAdvocacyForm.txtBTNNPA.focus();
			return false
		}
	
		
}
function ValidateContactDetails()
{
		if((trim(document.CustomerAdvocacyForm.txtComments.value)) == "" )
		{
				alert("Please enter your question.");
				document.CustomerAdvocacyForm.txtComments.focus();
				return false;
		}
		if((trim(document.CustomerAdvocacyForm.txtFname.value)) == "" )
		{
			alert("Please enter your First Name.");
			document.CustomerAdvocacyForm.txtFname.focus();
			return	false;			
		}
		
		if((trim(document.CustomerAdvocacyForm.txtLname.value)) == "" )
		{
			alert("Please enter your Last Name.");
			document.CustomerAdvocacyForm.txtLname.focus();
			return false;
		}

		
		if(!(validatePhone()))
		{
			return false;
		}
		if((trim(document.CustomerAdvocacyForm.txtEmail.value)) == "" )
		{
				alert("Please enter your Email.");
				document.CustomerAdvocacyForm.txtEmail.focus();
				return false;
		}
		if((trim(document.CustomerAdvocacyForm.txtRetypeEmail.value)) == "" )
		{
				alert("Please retype your Email.");
				document.CustomerAdvocacyForm.txtRetypeEmail.focus();
				return false;
		}
		if(ValidateEMail(document.CustomerAdvocacyForm.txtEmail) == false)
		{
			document.CustomerAdvocacyForm.txtEmail.focus();
			return false;
		}

		if(ValidateEMail(document.CustomerAdvocacyForm.txtEmail) == true)
		{
			if(document.CustomerAdvocacyForm.txtEmail.value != document.CustomerAdvocacyForm.txtRetypeEmail.value)
			{
				alert("Please retype your email address.  The email addresses are not the same.  They must match.");
				document.CustomerAdvocacyForm.txtEmail.focus();
				return false;
			}
		}
		
		var contPhone = (document.CustomerAdvocacyForm.txtBTNNPA.value + document.CustomerAdvocacyForm.txtBTNNXX.value + document.CustomerAdvocacyForm.txtBTNLine.value);
		
		if( ((contPhone.length>0) && (isNaN(contPhone))) || ((contPhone.length>0) && (!isNaN(contPhone)) && (contPhone.length<10)))
		{	
			alert('Enter valid Contact Number');
			return false;
		}
		else if((contPhone.charAt(0)=='0') || (contPhone.charAt(0)=='1'))
		{
			alert('Please check your entry for Contact Phone Number.It cannot begin with 0 or 1');
			return false;
		}
		var strNPa = document.CustomerAdvocacyForm.txtBTNNPA.value;
		
		if ((strNPa.length ==  3 )&& (strNPa.charAt(0) == strNPa.charAt(1)) && (strNPa.charAt(0) == strNPa.charAt(2)))
		{
			document.CustomerAdvocacyForm.txtBTNNPA.focus();
			alert('Enter valid area code');
			return false;
		}
		if(validatePhone() && document.CustomerAdvocacyForm.cboState.selectedIndex == 0)
		{	
			
			alert('Please select the state');
			return false;
		}
		var comments = trim(document.CustomerAdvocacyForm.txtComments.value);
		if(comments.length >= 700)
		{
			alert('Your Question cannot be more than 700 characters');
			return false;
		}
		if(!chkMaxLength(document.CustomerAdvocacyForm.txtComments,700))
			return false;
	return true;

}	
function onSubmit()
{

	if (!ValidateContactDetails())
		return false;
	else	
		document.CustomerAdvocacyForm.submit();
		
	

}
function AutoTab( hItem, maxLength, linkItem )
{
	
	
	isNumeric();
	if (navigator.appVersion.indexOf('Mac') != -1)
	{
		return;
	}
	else
	{
		var vKeyCode,oItem;
		oItem = eval(linkItem);
	
		vKeyCode = window.event.keyCode
		if(vKeyCode==9 && window.event.shiftKey){ return; }
		switch(window.event.keyCode)
		{
			case 37 : return;
			case 39 : return;
			case 16 : return;
			case 46 : return;
		}
		if (window.event.keyCode != 9 )
		{
			if( typeof(oItem) == "object" )
			{
					
					if(bAutotab && (String(oItem.value).length ==0) && (String(hItem.value).length == maxLength) && (window.event.keyCode != 8))
					{
						oItem.focus();
					}
			}
		}
	}
	bAutotab = true;
}

function stopAutoTab()
{
	bAutotab = false;
}
