eee=[];
isMacIE=(navigator.appVersion.match(/mac/gi)!=null && navigator.appName.match(/microsoft/gi)!=null && navigator.appVersion.match(/safari/gi)==null);
isMacNS=(navigator.appVersion.match(/mac/gi)!=null && navigator.appName.match(/microsoft/gi)==null && navigator.appVersion.match(/safari/gi)==null);

function writeMacCheck(){
if (isMacNS){
document.writeln('<span style="color:black;"><br><br><b>Macintosh Netscape/Firefox users:</b> to successfully upload your photo, you will need to manually type "<b>file://</b>" in front of the file name after browsing for it.  <nobr>e.g.: "file:///Users/myusername/Pictures/mypicture.jpg"</nobr></span>');
} else if (isMacIE) {
document.writeln('<span style="color:black;"><br><br><b>Macintosh Internet Explorer users:</b> Sorry, but file upload will not work with Internet Explorer.  Please use a different browser for your submission. If you don\'t have another browser installed, you can click to download the latest version of <b><a href="http://browser.netscape.com/ns8/download/default.jsp" target="_blank">Netscape for Mac</a></b> here. OR Click to download the latest version of <b><a href="http://www.mozilla.org/products/firefox/" target="_blank">Firefox for Mac</a> </b>here.</span>');
}}

function validateEmail(email){
var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
etest=(!reg1.test(email) && reg2.test(email))?true:false;
return etest;
}

function checkStuff(me) {
for (cc=0; cc<eee.length; cc++){
try{
elle=me.elements[eee[cc][0]];
if (((elle.type=="text" || elle.type=="textarea" || elle.type=="file") && elle.value=='') || (elle.type=="select-one" && elle.selectedIndex==0)){
alert(eee[cc][1]); elle.focus(); return false;
}}catch(e){}}
if (doEmailCheck){
if (!validateEmail(me.elements["E-Mail"].value)){ alert("Please enter a valid E-Mail address."); me.elements["E-Mail"].focus(); return false; }
}
try{ if (location.href.indexOf('generic_mail_attach.cgi')!=-1){
if (!(/(.gif|.jpg|.jpe|.jpeg)/.test(me.file.value))){ alert("Please send your photo in jpg or gif format only."); me.file.focus(); return false; }
} }catch(y){}
try{ if (isMacNS && me.file.value.match(/file\:/gi)==null){
alert("Mac Netscape/Firefox users, please type \"file://\" in front of the file name."); me.file.focus(); return false;
}}catch(y){}
ccs=customCheckStuff();
if (ccs){
try{ gid('workit').style.visibility='visible'; }catch(wit){}
try{ me.elements["submit"].disabled=true; }catch(wit){}
}
return ccs;
}
doEmailCheck=false;
function customCheckStuff(){ return true; } //TO BE OVERRIDDEN IN THE TEMPLATE

function selectStateProvince(_state,noQuebec){ //does not include Quebec
var states=["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming" ];
var provinces=["Alberta", "British Columbia", "Manitoba", "New Brunswick", "Newfoundland", "Nova Scotia", "Northwest Territories", "Ontario", "Prince Edward Island", "Saskatchewan", "Yukon Territory"];
if (noQuebec==null){ provinces[provinces.length]="Quebec"; }
document.writeln('<optgroup label="United States">');
for (i=0; i<states.length; i++){ document.write('<option value="'+states[i]+'"'); if (states[i]==_state){ document.write(' selected'); } document.writeln('>'+states[i]+'</option>'); }
document.writeln('</optgroup><optgroup label="Canada">');
for (i=0; i<provinces.length; i++){ document.write('<option value="'+provinces[i]+'"'); if (provinces[i]==_state){ document.write(' selected'); } document.writeln('>'+provinces[i]+'</option>'); }
document.writeln('</optgroup>');
}

messageLimit=0;
function n(wut){
if (messageLimit>0){
try{ gid('CHARACTERCOUNT').innerHTML=messageLimit-wut.value.length; }catch(mes){}
if (wut.value.length>=messageLimit){ alert('We ask that you please limit your submission to '+messageLimit+' characters. \n Thank you.');
wut.value=wut.value.substring(0,messageLimit-1);
}}}
// onKeyUp="n(this)"

function parseFileErrors(formname){
bob=document.forms[formname];
if (isMacIE){ bob.submit.disabled=true; }
if (bob.parseError.value.indexOf('Attachment file is too large')!=-1){
document.getElementById('errorMessage').innerHTML='<br>Error: file too large.  Limit is '+bob.maxattach.value+'k<br><br>';
} else if (bob.parseError.value.indexOf('file are required')!=-1){
document.getElementById('errorMessage').innerHTML='<br>Error: Click the "Browse..." button on the form below to locate your file.<br><br>';
}}