function show(id) { document.getElementById(id).style.display = ''; }
function hide(id) { document.getElementById(id).style.display = 'none'; }
function fload(page) { document.getElementById('frame_child').src = page; }
function sh(id) 
{ 
if (document.getElementById(id).style.display == '') {document.getElementById(id).style.display = 'none';}
else {document.getElementById(id).style.display = '';}
}

/* -- form helper / e form -- */
function verify_e_news_form(theform)
{
	var error="NONE";
	// clear bad input tags
	document.getElementById('email_tag').className="";
	document.getElementById('fname_tag').className="";
	document.getElementById('lname_tag').className="";

	document.getElementById('address1_tag').className="";
	document.getElementById('city_tag').className="";
	document.getElementById('state_tag').className="";
	document.getElementById('zip_tag').className="";
	document.getElementById('country_tag').className="";
	document.getElementById('phone_tag').className="";
	
	// check email
	error=chckEmail(theform.eform_email.value, theform.eform_email.value);
	if (error != "NONE") { alert(error); theform.eform_email.focus(); theform.eform_email.select(); document.getElementById('email_tag').className="red";}
	else
	{
	// check name
	error=chckName(theform.eform_first_name.value);
	if(error != "NONE") { alert(error); theform.eform_first_name.focus(); theform.eform_first_name.select(); document.getElementById('fname_tag').className="red";}
	else
	{
	error=chckName(theform.eform_last_name.value);
	if(error != "NONE") { alert(error); theform.eform_last_name.focus(); theform.eform_last_name.select(); document.getElementById('lname_tag').className="red";}
	else
	{
	// check address1
	if(theform.eform_address1.value == "") { alert('Please enter your address.'); theform.eform_address1.focus(); theform.eform_address1.select(); document.getElementById('address1_tag').className="red";}
	else
	{	
	// check city
	if(theform.eform_city.value == "") { alert('Please enter your city.'); theform.eform_city.focus(); theform.eform_city.select(); document.getElementById('city_tag').className="red";}
	else
	{	
	// check state
	if(theform.eform_state.value == "") { alert('Please enter your state.'); theform.eform_state.focus(); theform.eform_state.select(); document.getElementById('state_tag').className="red";}
	else
	{	
	// check zip
	if(theform.eform_zip.value == "") { alert('Please enter your zip code.'); theform.eform_zip.focus(); theform.eform_zip.select(); document.getElementById('zip_tag').className="red";}
	else
	{	
	// check country
	if(theform.eform_country.value == "") { alert('Please enter your country.'); theform.eform_country.focus(); theform.eform_country.select(); document.getElementById('country_tag').className="red";}
	else
	{	
	// check phone
	error=chckPhone(theform.eform_phone.value);
	if(error != "NONE") { alert(error); theform.eform_phone.focus(); theform.eform_phone.select(); document.getElementById('phone_tag').className="red";}
	else
	{
	
		// send if no error
		theform.submit();
	}}}}}}}}}
}

/* -- subroutines -- */ 
function chckName(str)
{
	if (str.length < 2) { return "The name must contain atleast 2 characters."; }
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if ( illegalChars.test(str.replace(/[\(\)\.\-\ ]/g, '')) ) { return "Name must contain only characters or numbers."; }
	return "NONE";
}
function chckEmail(str1,str2)
{
	// check if match
	if ( str1 != str2) { return "Email mismatch."; }

	var filter=/^.+@.+\..{2,3}$/
	if (! filter.test(str1) ) return "The email address is invalid.";
	return "NONE";
}
function chckPhone(str)
{
	var stripped = str.replace(/[\(\)\.\-\ ]/g, '');
	//strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) { return "The phone number contains illegal characters. Format rquired: xxx-xxx-xxxx."; }
	if (!(stripped.length == 10)) { return "The phone number is the wrong length. Format rquired: xxx-xxx-xxxx."; }
	return "NONE";
}