function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
function fixDate(date) {
var base = new Date(0);
var skew = base.getTime();
if (skew > 0)
date.setTime(date.getTime() - skew);
}

function Validator(theForm)
{


  if (theForm.search_source.selectedIndex < 0)
  {
    alert("Please select one of the \"Please specify Search Engine\" options.");
    theForm.search_source.focus();
    return (false);
  }

  if (theForm.search_source.selectedIndex == 0)
  {
    alert("You didn't tell us how you found our site. Please select one of the \"Please specify Search Engine\" options.");
    theForm.search_source.focus();
    return (false);
  }


  if (theForm.client_first_name.value == "")
  {
    alert("Please enter your first name in the  \"First Name\" field.");
    theForm.client_first_name.focus();
    return (false);
  }

  if (theForm.client_first_name.value.length > 15)
  {
    alert("Please enter at most 15 characters in the \"First Name\" field.");
    theForm.client_first_name.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  var checkStr = theForm.client_first_name.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter characters in the \"First Name\" field.");
    theForm.client_first_name.focus();
    return (false);
  }

  if (theForm.client_last_name.value == "")
  {
    alert("Please enter your last name in the \"Last Name\" field.");
    theForm.client_last_name.focus();
    return (false);
  }

  if (theForm.client_last_name.value.length > 15)
  {
    alert("Please enter at most 15 characters in the \"Last Name\" field.");
    theForm.client_last_name.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  var checkStr = theForm.client_last_name.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter characters in the \"Last Name\" field.");
    theForm.client_last_name.focus();
    return (false);
  }

	if (theForm.client_address1.value == "")
  {
    alert("Please enter your address in the  \"Address\" field.");
    theForm.client_address1.focus();
    return (false);
  }
  
	if (theForm.client_address1.value.length < 10)
  {
    alert("Please enter your address in the  \"Address\" field.");
    theForm.client_address1.focus();
    return (false);
  }
  
 if (theForm.client_city.value == "")
  {
    alert("Please enter your City in the  \"City\" field.");
    theForm.client_city.focus();
    return (false);
  }
  
	if (theForm.client_city.value.length < 4)
  {
    alert("Please enter your City in the  \"City\" field.");
    theForm.client_city.focus();
    return (false);
  }
   
   if (theForm.client_zip.value.length < 5)
  {
    alert("Please enter your zip code in the  \"Zip Code\" field.");
    theForm.client_zip.focus();
    return (false);
  }
  
  var checkOK = "0123456789-";
  var checkStr = theForm.client_zip.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"client_zip\" field.");
    theForm.client_zip.focus();
    return (false);
  }
  
    if (theForm.client_email.value.length < 5)
  {
    alert("Please enter your e-mail address in the  \"E-Mail\" field.");
    theForm.client_email.focus();
    return (false);
  }

  
 if (theForm.client_email.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"client_email\" field.");
    theForm.client_email.focus();
    return (false); 
    }

  
  if (theForm.home_phone.value.length < 14)
  {
    alert("Please enter your home phone number in the  \"Home Phone\" field.");
    theForm.home_phone.focus();
    return (false);
  }


  if (theForm.incident_month.selectedIndex < 0)
  {
    alert("Please select one of the \"Please specify Incident Month\" options.");
    theForm.incident_month.focus();
    return (false);
  }

  if (theForm.incident_month.selectedIndex == 0)
  {
    alert("Please tell us the month that incident occured.");
    theForm.incident_month.focus();
    return (false);
  }

  if (theForm.incident_day.selectedIndex < 0)
  {
    alert("Please tell us the DATE that incident occured.");
    theForm.incident_day.focus();
    return (false);
  }

  if (theForm.incident_day.selectedIndex == 0)
  {
    alert("Please tell us the DATE that incident occured.");
    theForm.incident_day.focus();
    return (false);
  }

  if (theForm.incident_year.selectedIndex < 0)
  {
    alert("Please tell us the YEAR that incident occured.");
    theForm.incident_year.focus();
    return (false);
  }

  if (theForm.incident_year.selectedIndex == 0)
  {
    alert("Please tell us the YEAR that incident occured.");
    theForm.incident_year.focus();
    return (false);
  }

  if (theForm.court_date_month.selectedIndex < 0)
  {
    alert("Please tell us the YEAR that incident occured.");
    theForm.court_date_month.focus();
    return (false);
  }

  if (theForm.court_date_month.selectedIndex == 0)
  {
    alert("Please tell us the month of your COURT date.");
    theForm.court_date_month.focus();
    return (false);
  }

  if (theForm.court_date_day.selectedIndex < 0)
  {
    alert("Please tell us the DAY of your court date.");
    theForm.court_date_day.focus();
    return (false);
  }

  if (theForm.court_date_day.selectedIndex == 0)
  {
    alert("Please tell us the DAY of your court date.");
    theForm.court_date_day.focus();
    return (false);
  }

  if (theForm.court_day_year.selectedIndex < 0)
  {
    alert("Please tell us the YEAR of your court date.");
    theForm.court_day_year.focus();
    return (false);
  }

  if (theForm.court_day_year.selectedIndex == 0)
  {
    alert("Please tell us the YEAR of your court date.");
    theForm.court_day_year.focus();
    return (false);
  }

  if (theForm.court_name.value == "")
  {
    alert("Please tell us the COURT name");
    theForm.court_name.focus();
    return (false);
  }

  var checkOK = "0123456789-.";
  var checkStr = theForm.charged_speed.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digits in the \"charged_speed\" field.");
    theForm.charged_speed.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"charged_speed\" field.");
    theForm.charged_speed.focus();
    return (false);
  }

  if (theForm.incident_detail.value == "")
  {
    alert("Please enter a brief description of the incident.");
    theForm.incident_detail.focus();
    return (false);
  }
  return (true);
}
function compareTwo(el1,el2,sPrompt){debugger;var sValue1 = el1.value;var sValue2 = el2.value;if( sValue1 != sValue2) {alert(promptMsg(el1,sPrompt));el1.focus();}}
function validNumeric(value){var checkOK = '0123456789-,';var decPoints = 0;if(value.lastIndexOf('-') != -1) if(value.lastIndexOf('-') != 0) { return false;}for (i = 0;  i < value.length;  i++){ch = value.charAt(i);if(ch == '.') { ++decPoints; continue; }for (j = 0;  j < checkOK.length;  j++){if(ch == checkOK.charAt(j))break;}if (j == checkOK.length)return false;}return (decPoints < 2);}function promptMsg(el,sPrompt) {var sValue1 = el.value;var sMessage = '';pos = sPrompt.indexOf('%V');if(pos != -1) {sMessage = sPrompt.substring(0,pos);sMessage += sValue1;sMessage += sPrompt.substring(pos+2,sPrompt.length);} else {sMessage = sPrompt;}return(sMessage);}
function existingHandlers(elEvent) {sTemp = "";if(elEvent != null) {sTemp = elEvent.toString();iStart = sTemp.indexOf("{") + 1;sTemp = sTemp.substr(iStart,sTemp.length-iStart-2) + ";";}return sTemp;}function IsIn(value,search) {if(search.indexOf(value) != -1) {return 1;} else {return 0;}}
function MaskEdit(mask,prompt,el) {var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-ƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ';var number = "0123456789";var value = '';var pos = 0;var ch = '';if(el.value.length != mask.length) {alert(prompt);return false;}while (pos < mask.length) {value += el.value.charAt(pos);ch = mask.charAt(pos);if (ch == '9') {if(!IsIn(el.value.charAt(pos++),number)) {alert(prompt);el.value = value.substring(0,value.length-1);return false;}} else {if(ch == 'A') {if(!IsIn(el.value.charAt(pos++),alpha)) {alert(prompt);el.value = value.substring(0,value.length-1);return false;}} else {if(ch == '?') {pos++;} else {if(!IsIn(el.value.charAt(pos),mask.charAt(pos))) {alert(prompt);el.value = value.substring(0,value.length-1);return false;}pos++;}}}}for(i=0; i < el.form.elements.length; i++) { if(el.form.elements[i].name == this.name) {el.form.elements[i+1].focus();break; }}return true;}var iNumberoftimes = 0;
function fSubmitOnce(sAdmonishment1,sAdmonishment2) {iNumberoftimes += 1;if (iNumberoftimes > 1) {var sThemessage = sAdmonishment1;if (iNumberoftimes == 3) {sThemessage = sAdmonishment2;}alert(sThemessage);return false;}else{return true;}}
function CreditCardValid(number){var nChecksum = 0;var nProdVal;var nTime = -1;card = strip(number) + '';nLen = card.length;if(nLen < 13) return false;for(count = nLen; count > 0; count--) {nTime = (++nTime % 2);nProdVal = card.charAt(count-1) * (nTime+1);if(nProdVal > 9) nProdVal -= 9;nChecksum += nProdVal;}nChecksum %= 10;return (nChecksum == 0);}
function strip(number) {var sOut = '';mask = '1234567890';for(count = 0; count <= number.length; count++) {if(mask.indexOf(number.substring(count, count+1),0) != -1 ) sOut += number.substring(count,count+1);}return sOut;}
function EmailValid(address){var first, last;if(address.indexOf(" ") != -1) {return false; }if(address.indexOf(".@") != -1) {return false;}if(address.indexOf("@.") != -1) {return false;}if(address.indexOf(".") == address.length-1) {return false;}first = address.indexOf("@");if(first == -1 || first == 0) { return false; }if(first != address.lastIndexOf("@")) { return false; }if(address.lastIndexOf(".") != -1 && (address.length - address.lastIndexOf(".")) < 6) { return true; };return false;}function PhoneValid(mask,prompt,el) {var alpha = "-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ";var number = "0123456789";var value = "";var pos = 0;var ch = "";if(el.value.length != mask.length) {alert(prompt);return false;}while (pos < mask.length) {value += el.value.charAt(pos);ch = mask.charAt(pos);if (ch == '9') {if(!IsIn(el.value.charAt(pos++),number)) {alert(prompt);el.value = value.substring(0,value.length-1);return false;}} else {if(ch == 'A') {if(!IsIn(el.value.charAt(pos++),alpha)) {alert(prompt);el.value = value.substring(0,value.length-1);return false;}break;} else {if(ch == '?') {pos++;break;} else {if(!IsIn(el.value.charAt(pos),mask.charAt(pos))) {alert(prompt);el.value = value.substring(0,value.length-1);return false;}pos++;}}}}return true;}

