function set(target)
 {
 document.forms[0].dispatch.value=target;

 }
 
 

function validate()
 {
var pay= document.forms[0].amount.value;
var _exp = new RegExp(/\d\.\d/);
  var _test=_exp.test(pay);

var advr= document.forms[0].advr.value;
option1 = -1;
for (i=0; i < document.forms[0].address.length; i++) {
if (document.forms[0].address[i].checked) {
option1 = i;
}
}
if(!_test){
alert("Please enter payment in this manner : 150.20");
return false;
}
if ((advr =="Y") && (option1 == -1)) {
alert("You must verify your address!");
return false;
}
else{
return true;}
 }


//Enter-listener
if (document.layers)
  document.captureEvents(Event.KEYDOWN);
  document.onkeydown =
    function (evt) {
      var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;
      if (keyCode == 13)   //13 = the code for pressing ENTER
      {
document.forms[0].dispatch.value= 'srchEnter';
document.forms[0].submit();
return false;
      }
    }

//for vehicles
function validatevehicle()
 {
var stdate= document.forms[0].strdate.value;
var endate= document.forms[0].enddate.value;
var advr= document.forms[0].advr.value;
var x="Please enter dates of your vehicle insurance ";
var insurance= document.forms[0].insur.value;

var pay= document.forms[0].amount.value;
var _exp = new RegExp(/\d\.\d/);
  var _test=_exp.test(pay);

option1 = -1;
for (i=0; i < document.forms[0].address.length; i++) {
if (document.forms[0].address[i].checked) {
option1 = i;
if( option1 >0){
alert("We are unable to process your payment at this time.  Please call the Auditor's office at (843) 355-9321 ext. 543  to update your address.");
}
}
}
if(!_test){
alert("Please enter payment in this manner : 150.20");
return false;
}
if(insurance.length<1){
alert("Please enter the name of the insurance provider");
return false;
}
if ((stdate.length<1) || (endate.length<1)){
alert(x);
return false;
}
if ((advr =="Y") && (option1 == -1)) {
alert("You must verify your address!");
return false;
}
else{
return true;}
 }

function echeck() {

var pwd= document.forms[0].pwd.value;

var pwdcnf = document.forms[0].pwdcnf.value;

if(pwd.length>9){
alert("Password cannot be more than 9 characters");
return false;
}

if(pwdcnf.length>9){
alert("Password confirmation cannot be more than 9 characters");
return false;
}

var str= document.forms[0].email.value;

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 return true
	}




