// JavaScript Document
<!--
function formHandler(form) {
var windowprops = "height=550,width=525,location=no,"
+ "scrollbars=yes,menubars=no,toolbars=no,resizable=yes";

var URL = form.site.options[form.site.selectedIndex].value;
popup = window.open(URL,"MenuPopup",windowprops);
}

function show_options() {
var value = document.contact_form.contact_via.value;
var HTML = ' <table width="100%" border="0" align="center" cellpadding="1" cellspacing="0"> ';
	if (value=='Email'){
		HTML += ' <tr align="left" valign="top"><td align="right" width="30%" class="BodyText">Email Address:></td><td width="70%"><input name="email" type="text" id="email"></td></tr> ';
	} else if (value=='Mail') {
		HTML += ' <tr align="left" valign="top"><td align="right" width="30%" class="BodyText"><font color="#6699FF">*</font> Mailing Address:</td><td width="70%"><input name="address" type="text" id="address"></td></tr> ';
        HTML += ' <tr align="left" valign="top"><td align="right" class="BodyText"><font color="#6699FF">*</font> City, State, Zip:</td> ';
        HTML += ' <td><input name="city" type="text" id="city" size="15">,&nbsp;<input name="state" type="text" id="state" size="2" maxlength="2">,&nbsp;<input name="zip" type="text" id="zip" size="6" maxlength="5"> ';
        HTML += ' </td></tr> ';
	} else if (value=="Phone") {
		HTML += ' <tr align="left" valign="top"><td width="30%" class="BodyText"><div align="right"><font color="#6699FF">*</font>Phone Number:</div></td><td width="70%" valign="top"><h1><i><input name="phone" type="text" id="phone">&nbsp;(xxx-xxx-xxxx)</i></h1></td></tr>';
		HTML += ' <tr align="left"><td align="right" valign="top" class="BodyText">Best Time to Call:</td><td valign="top"> ';
		HTML += ' <select name="phone_time"><option value="">--SELECT--</option><option value="8:00 AM">8:00 AM</option><option value="9:00 AM">9:00 AM</option><option value="10:00 AM">10:00 AM</option><option value="11:00 AM">11:00 AM</option><option value="12:00 PM">12:00 PM</option> ';
		HTML += ' <option value="1:00 PM">1:00 PM</option><option value="2:00 PM">2:00 PM</option><option value="3:00 PM">3:00 PM</option><option value="4:00 PM">4:00 PM</option> ';
		HTML += ' </select> ';
} else if (value=="Fax") { 
		HTML += ' <tr align="left" valign="top"><td width="30%" class="BodyText"><div align="right"><font color="#6699FF">*</font>Fax Number:</div></td><td width="70%" valign="top"><h1><i><input name="fax" type="text" id="fax">&nbsp;(xxx-xxx-xxxx)</i></h1></td></tr>';
	}
HTML += ' </table> ';
document.getElementById("show_area").innerHTML = HTML;	
}

function validate() {

var error = ""
if (document.getElementById("first").value=="") {
error += "Please provide your first name.\n";
}
if (document.getElementById("last").value=="") {
error += "Please provide your last name.\n";
}

var value = document.contact_form.contact_via.value;

if (value=="Phone") {
var strng = document.contact_form.phone.value;
	if (strng=="") {
	error += "Please provide your phone number.\n";
	} else {
		var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
		if (isNaN(parseInt(stripped))) {
		   error += "The phone number contains illegal characters.";
		}
		if (!(stripped.length == 10)) {
		error += "The phone number is the wrong length. Make sure you included an area code.\n";
		}
	}
} else if (value=="Mail") {
	if (document.getElementById("address").value=="") {
	error += "Please provide your street address.\n";
	}
	if (document.getElementById("city").value=="") {
	error += "Please provide your city.\n";
	}
	if (document.getElementById("state").value=="") {
	error += "Please provide your state.\n";
	}
	if (document.getElementById("zip").value=="") {
	error += "Please provide your zip code.\n";
	}
	var state = document.contact_form.state.value;
	var zip = document.contact_form.zip.value;
	var illegalChars= /0123456789/
       if (state.match(illegalChars)) {
          error += "Please enter a correct state.\n";
       }
	var j;
	for (j = 0; j < zip.length; j++) {   
        // Check that current character is number.
        var c = zip.charAt(j);
        if (((c < "0") || (c > "9"))) {
		error += "Please enter a correct zip code.\n";
		break;
		}
    }

} else if (value=="Email") {
	var email = document.contact_form.email.value;
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(email))) { 
       error += "Please enter a valid email address.\n";
    } else { //test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (email.match(illegalChars)) {
          error += "The email address contains illegal characters.\n";
       }
    }
}

if (document.getElementById("issue").value=="") {
error += "Please select an issue.\n";
}

if (error!="") {
alert(error);
} else {
document.contact_form.submit();
}
}