function switchCountyDD(state) {
	hideDD();
	if(document.getElementById('county'+state)) document.getElementById('county'+state).style.display = 'block';
}

function hideDD() {
	document.getElementById('countyIN').style.display = 'none';
	document.getElementById('countyMI').style.display = 'none';
	if(document.getElementById('countyWI')) document.getElementById('countyWI').style.display = 'none';
}

function getArgs() {	var args = new Object();	var query = location.search.substring(1);	var pairs = query.split("&");	for(var i = 0; i < pairs.length; i++) {	var pos = pairs[i].indexOf('=');	if (pos == -1) continue;	var argname = pairs[i].substring(0,pos);	var value = pairs[i].substring(pos+1);	args[argname] = unescape(value);	}	return args;}

function showCountyDD() {
	var args = getArgs();	if (args.state) {
		state = args.state;		switchCountyDD(state);
	}
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function FValidateControl(control, prompt) {
	if (control.value=="") {
		alert("The " + prompt +" field is a required field, and it must be filled in before your form can be sent to our server.");
		control.focus();
		return false;
	}
	return true;
}
  
function becomeAgentValidation(form) {
	if (!FValidateControl(form.agency,'Agency Name')) return false;
	if (!FValidateControl(form.fname,'Contact First Name')) return false;
	if (!FValidateControl(form.lname,'Contact Last Name')) return false;
	if (!FValidateControl(form.phone,'Phone Number')) return false;
	if (!FValidateControl(form.email,'Email Address')) return false;
	if (!FValidateControl(form.state,'State')) return false;
	if ( 
		(!FValidateControl(form.countyIN,'County')) &&
		(!FValidateControl(form.countyMI,'County')) &&
		(!FValidateControl(form.countyWI,'County'))
	) return false;
	
	return true;
}

function showLoc(i,address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        //alert(address + " not found");
      } else {

        var marker = new GMarker(point);
        map.addOverlay(marker);
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(locs[i]);
		});
        marker.openInfoWindowHtml(locs[i]);
      }
    }
  );
}

//addLoadEvent(showCountyDD);