// JavaScript Document


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;
	for (i=0;i<objForm.elements.length;i++) {
		if (objForm.elements[i].type != "hidden") {
			objForm.elements[i].disabled = true;
		}
	}
	objForm.State.disabled = false;
	objForm.County.disabled = false;
	objForm.City.disabled = false;
}

function EnableElements()
{
	var objForm = document.forms.FightYourCaseQuiz;
	for (i=0;i<objForm.elements.length;i++) {
		objForm.elements[i].disabled = false;
	}
}

//-->
