<!--
<!--***FormValidation***-->

<!--

function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("City", "County", "State", "First_Name", "Last_Name", "Email", "Phone");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("City", "County", "State", "First Name", "Last Name", "Email", "Phone");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

function JumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+this.location.pathname+"?state="+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function JumpMenu2(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+this.location.pathname+"?state="+selObj.form.State.options[selObj.form.State.selectedIndex].value+"&county="+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function Querystring()
{
// get the query string, ignore the ? at the front.
	var querystring=location.search.substring(1,location.search.length);

// parse out name/value pairs separated via &
	var args = querystring.split('&');

// split out each name = value pair
	for (var i=0;i<args.length;i++)
	{
		var pair = args[i].split('=');

		// Fix broken unescaping
		temp = unescape(pair[0]).split('+');
		name = temp.join(' ');

		temp = unescape(pair[1]).split('+');
		value = temp.join(' ');

		this[name]=value;
	}

	this.get=Querystring_get;
}


function Querystring_get(strKey,strDefault)
{
	var value=this[strKey];
	if (value==null)
	{
		value=strDefault;
	}

	return value;
}

function SetSelectValue (obj, val) {
	var i=0;
	for (i=0;i<obj.options.length;i++) {
		if (obj.options[i].value == val) {
			obj.selectedIndex = i;
			break;
		}
	}
}

function DisableElements()
{
	var objForm = document.forms.FightYourCaseQuiz;

	objForm.DateArrested.readOnly = true;
	objForm.First_Name.readOnly = true;
	objForm.Last_Name.readOnly = true;
	objForm.Email.readOnly = true;
	objForm.Phone.readOnly = true;
	objForm.Comments.readOnly = true;

	objForm.Submit.disabled = true;
	objForm.Reset.disabled = true;


}

function EnableElements()
{
	var objForm = document.forms.FightYourCaseQuiz;
	for (i=0;i<objForm.elements.length;i++) {
		objForm.elements[i].disabled = false;
	}
}



function isEmailAddr(email) {
	var result = false;
	var theStr = new String(email);
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1)) {
		result = true;
		}
	}
	return result;
}
function isAlpha(obj) {
	var result = false;
	var inThere = obj.match(/\D/);
	if (inThere) {
		result = true;
	}
	return result;
}
function isAlphaNum(obj) {
	var result = false;
	var inThere = obj.match(/\w/);
	if (inThere) {
		result = true;
	}
	return result;
}
function isNotAlphaNum(obj) {
	var result = false;
	var inThere = obj.match(/[^\w\s]/);
	if (inThere) {
		result = true;
	}
	return result;
}

function isNum(obj) {
	var result = false;
	var inThere = obj.match(/\d/);
	if (inThere) {
		result = true;
	}
	return result;
}

function hasWhiteSpace(obj) {
	var result = false;
	var inThere = obj.match(/\s/);
	if (inThere) {
		result = true;
	}
	return result;
}

function isChecked(obj) {
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked) {
			return "yes";
		}
	}
	return "no";
}

// Functions that validates the forms

function fvalid(FightYourCaseQuiz) {
	
	
	// State
	if (document.FightYourCaseQuiz.State.value == "") {
		alert("The \"State\" field cannot be left blank.");
		document.FightYourCaseQuiz.State.focus();
		return false;
	}
	
	if (document.FightYourCaseQuiz.County.value == "") {
		alert("The \"County\" field cannot be left blank.");
		document.FightYourCaseQuiz.County.focus();
		return false;
	}
	if (document.FightYourCaseQuiz.City.value == "") {
		alert("The \"City\" field cannot be left blank.");
		document.FightYourCaseQuiz.City.focus();
		return false;
	}
	if (document.FightYourCaseQuiz.First_Name.value != "") 
		{
		if (isNum(document.FightYourCaseQuiz.First_Name.value)) {
			alert("Numbers are not allowed in the \"First Name\" field.");
			document.FightYourCaseQuiz.First_Name.focus();
			return false;
		} 
		else if (isNotAlphaNum(document.FightYourCaseQuiz.First_Name.value)) 
		{
			alert("Special characters are not allowed in the \"First Name\" field.");
			document.FightYourCaseQuiz.First_Name.focus();
			return false;
		}
		} 
		else 
		{
		alert("The \"First Name\" field cannot be left blank.");
		document.FightYourCaseQuiz.First_Name.focus();
		return false;
		}
	
	if (document.FightYourCaseQuiz.Last_Name.value != "") {
		if (isNum(document.FightYourCaseQuiz.Last_Name.value)) {
			alert("Numbers are not allowed in the \"Last Name\" field.");
			document.FightYourCaseQuiz.Last_Name.focus();
			return false;
		} else if (isNotAlphaNum(document.FightYourCaseQuiz.Last_Name.value)) {
			alert("Special characters are not allowed in the \"Last Name\" field.");
			document.FightYourCaseQuiz.Last_Name.focus();
			return false;
		}
	} else {
		alert("The \"Last Name\" field cannot be left blank.");
		document.FightYourCaseQuiz.Last_Name.focus();
		return false;
	}
	
	// EmailAddr
	if (document.FightYourCaseQuiz.Email.value != "") {
		if (!isEmailAddr(document.FightYourCaseQuiz.Email.value)) {
			alert("Please enter a complete Email address in the form: yourname@yourdomain.com");
			document.FightYourCaseQuiz.Email.focus();
			return false;
		} else if (hasWhiteSpace(document.FightYourCaseQuiz.Email.value)) {
			alert("Your Email address cannot contain blank spaces.");
			document.FightYourCaseQuiz.Email.focus();
			return false;
		}
	} else {
		alert("The \"Email Address\" field cannot be left blank.");
		document.FightYourCaseQuiz.Email.focus();
		return false;
	}
	
	// Phone
	if (document.FightYourCaseQuiz.Phone.value != "") {
		if (isAlpha(document.FightYourCaseQuiz.Phone.value)) {
			alert("Only numbers are allowed in a Phone Number.");
			document.FightYourCaseQuiz.Phone.focus();
			return false;
		} else if (document.FightYourCaseQuiz.Phone.value.length < 10) {
			alert("This \"Phone Number\" field must have 10 characters.");
			document.FightYourCaseQuiz.Phone.focus();
			return false;
		}
	} else {
		alert("The \"Phone Number\" field cannot be left blank.");
		document.FightYourCaseQuiz.Phone.focus();
		return false;
	}	
		if (document.FightYourCaseQuiz.Comments.value != "") {
			if (document.FightYourCaseQuiz.Comments.value.indexOf("http") != -1)
		 	{
			alert("Please do not enter http in Description of DUI / DWI Legal Problem field");
			document.FightYourCaseQuiz.Comments.focus();
			return false;
			} 
	} else {
		alert("The \"Description of DUI / DWI Legal Problem\" field cannot be left blank.");
		document.FightYourCaseQuiz.Comments.focus();
		return false;
	}
	createCookie('stateName','WA','7')
}

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);
		input.form[(getIndex(input)+1) % input.form.length].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;
}

function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
			else i++;
		return index;
	}
return true;
}

function setCounty() {
	if (document.FightYourCaseQuiz.County.value == "") {
		alert('Please select a County.');
		document.FightYourCaseQuiz.County.focus();
		return true;
	}
}

function createCookie(name,value1,days) {
var value = value1;
value = "";
value = ""+document.FightYourCaseQuiz.County.options[document.FightYourCaseQuiz.County.selectedIndex].value+"-"+document.FightYourCaseQuiz.State.options[document.FightYourCaseQuiz.State.selectedIndex].value;
	
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();

	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	
	//alert(value);
}

-->


