﻿var defaultColor="#D7E5F2",errorColor="Yellow";function sf(){document.inquiry.firstname.focus()}function validateFormOnSubmit(a){var b="";b+=validateEmail(a.email);b+=validateEmpty(a.firstname);if(a.phone.value.length>0)b+=validatePhone(a.phone);else a.phone.style.background=defaultColor;if(b!=""){alert("Some fields need correction:\n"+b);return false}else setCookie("username",a.firstname.value,365);return true}function validateEmpty(a){var b="";if(a.value.length==0){a.style.background=errorColor;b="The required field has not been filled in.\n"}else a.style.background=defaultColor;return b}function trim(a){return a.replace(/^\s+|\s+$/,"")}function validateEmail(a){var b="",e=trim(a.value),d=/^[^@]+@[^@.]+\.[^@]*\w\w$/,c=/[\(\)\<\>\,\;\:\\\"\[\]]/;if(a.value==""){a.style.background=errorColor;b="You didn't enter an email address.\n"}else if(!d.test(e)){a.style.background=errorColor;b="Please enter a valid email address.\n"}else if(a.value.match(c)){a.style.background=errorColor;b="The email address contains invalid characters.\n"}else a.style.background=defaultColor;return b}function validatePhone(a){var b="",c=a.value.replace(/[\(\)\.\-\ ]/g,"");if(a.value==""){b="You didn't enter a phone number.\n";a.style.background=errorColor}else if(isNaN(parseInt(c))){b="The phone number contains illegal characters.\n";a.style.background=errorColor}else if(!(c.length==10)){b="The phone number is the wrong length. Make sure you included an area code.\n";a.style.background=errorColor}else a.style.background=defaultColor;return b}function resetFields(a){if(confirm("Are you sure you want to reset form?")){a.email.style.background=defaultColor;a.firstname.style.background=defaultColor;a.phone.style.background=defaultColor;a.reset()}}function getCookie(a){if(document.cookie.length>0){c_start=document.cookie.indexOf(a+"=");if(c_start!=-1){c_start=c_start+a.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end))}}return ""}function setCookie(c,d,b){var a=new Date;a.setDate(a.getDate()+b);document.cookie=c+"="+escape(d)+(b==null?"":";expires="+a.toGMTString())}