//Check email format
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			return false;
		}
		if (str.indexOf(at,(lat+1))!=-1){
		return false;
		}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return false;
		}
		
		if (str.indexOf(dot,(lat+2))==-1){
			return false;
		}
		if (str.indexOf(" ")!=-1){
			return false;
		}
	}


	function validateForm(form){
		var theMessage = "Please complete the following before submission:\n";
		var noErrors = theMessage;
		var s=s_gi(s_account);

		if(""===form.first.value){
			theMessage = theMessage + "First Name\n";
			s.sendFormEvent("e",s.pageName,form.name,"First Name: Empty");
		}
		if(""===form.last.value){
			theMessage = theMessage + "Last Name\n";
			s.sendFormEvent("e",s.pageName,form.name,"Last Name: Empty");
		}
		if(""===form.email.value){
			theMessage = theMessage + "Email\n";
			s.sendFormEvent("e",s.pageName,form.name,"Email: Empty");
			
		} else if (echeck(form.email.value)===false){
			form.email.value="";
			theMessage = theMessage + "Valid Email Address\n";
			s.sendFormEvent("e",s.pageName,form.name,"Email: Invalid");
		}
		if(""===form.company.value){
			theMessage = theMessage + "Company\n";
			s.sendFormEvent("e",s.pageName,form.name,"Company Name: Empty");
		}
		if(""===form.state.value){
			theMessage = theMessage + "State/Province";
			s.sendFormEvent("e",s.pageName,form.name,"State/Province: Empty");
		}
		
		if (theMessage === noErrors) {
		
			// Create cookie for Omniture state
			var cookie_date = new Date(); 
			cookie_date.setDate(cookie_date.getDate()+1);
			
			var state = form.state.value;
			$.cookie('where'+form.name, state, {expires: 1});
			
			if (form.optin.value !== undefined) {
				var optin = form.optin.checked;
				optin = (optin)?"opt in":"opt out";
				$.cookie('optin'+form.name, optin, {expires: 1});
			}
			s.sendFormEvent("s",s.pageName,form.name);

			return true;
		
		} else {
			alert(theMessage);
			return false;
		}
	}	

/*	
	
	
//validate Form
	function validateForm(form1){
			
		var theMessage = "Please fill all fields before submission.\n";
		var noErrors = theMessage;
		var s=s_gi(s_account);
			
		if(""==document.forms.form1.first.value){
			theMessage = theMessage + "First Name\n";
			s.sendFormEvent("e",s.pageName,"s_contact_sales","First Name: Empty");
		}
		if(""==document.forms.form1.last.value){
			theMessage = theMessage + "Last Name\n";
			s.sendFormEvent("e",s.pageName,"s_contact_sales","Last Name: Empty");
		}
		if(""==document.forms.form1.email.value){
			theMessage = theMessage + "Email\n";
			s.sendFormEvent("e",s.pageName,"s_contact_sales","Email: Empty");
			
		} else if (echeck(document.forms.form1.email.value)==false){
			document.forms.form1.email.value="";
			theMessage = theMessage + "Valid Email Address\n";
			s.sendFormEvent("e",s.pageName,"s_contact_sales","Email: Invalid");
		}
		if(""==document.forms.form1.company.value){
			theMessage = theMessage + "Company\n";
			s.sendFormEvent("e",s.pageName,"s_contact_sales","Company Name: Empty");
		}
		if(""==document.forms.form1.state.value){
			theMessage = theMessage + "State/Province";
			s.sendFormEvent("e",s.pageName,"s_contact_sales","State/Province: Empty");
		}
		
		if (theMessage == noErrors) {
		
			// Create cookie for Omniture state
			var cookie_date = new Date(); 
			cookie_date.setDate(cookie_date.getDate()+1);
			
			var state = document.forms.form1.state.value;
			var optin = document.forms.form1.optin.checked;
			
			optin = (optin)?'opt in':'opt out';

			document.cookie = "whereContactMe=" + state; + ": expires=" + cookie_date;
			document.cookie = "optinContactMe=" + optin; + ": expires=" + cookie_date;

			cookie.state = state;
			cookie.optin = optin;
			s.sendFormEvent("s",s.pageName,"s_contact_sales");

			_hbSet('c4', document.forms.form1.email.value + ':' + document.URL);
			_hbSend();

			return true;
		
		} else {
				
			var required = document.getElementById('required');
			//required.innerHTML = theMessage;
			alert(theMessage);
			return false;
		}
	}
	
*/


//Remove Google Styles
  
  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }
	
