//Display DIV
function toggleview() {
  var contactType = document.getElementById('ContactType').value;  
  selTab(contactType);
}
function toggleview2() {
  var contactType = document.getElementById('Satisfied').value;  
  selTab2(contactType);
}
function toggleview3() {
  var contactType = document.getElementById('Brand').value;  
  selTab2(contactType);
}
var actLayer;
var actLayer2;
var actLayer3;
function selTab(actTab){
  	if (actLayer){  	    	  
  	  tmp=document.getElementById(actLayer+"_Layer");
  	  tmp.className="infLayer";
  	} 	
  	if (actLayer2){  	    	  
  	  tmp=document.getElementById(actLayer2+"_Layer");
  	  tmp.className="infLayer";
  	} 	
  	tmp=document.getElementById(actTab+"_Layer");
  	tmp.className="actinfLayer";
  	actLayer=actTab;
  }
  

function selTab2(actTab){
  	if (actLayer2){  	    	  
  	  tmp=document.getElementById(actLayer2+"_Layer");
  	  tmp.className="infLayer";
  	} 	
  	tmp=document.getElementById(actTab+"_Layer");
  	tmp.className="actinfLayer";  	
  	actLayer2=actTab;
  	
 
  }  

function selTab3(actTab){
  	if (actLayer3){  	    	  
  	  tmp=document.getElementById(actLayer3+"_Layer");
  	  tmp.className="infLayer";
  	} 	
  	tmp=document.getElementById(actTab+"_Layer");
  	tmp.className="actinfLayer";  	
  	actLayer3=actTab;
  	
 
  }  
 //End Display DIV
 
//Validate fields
function validate_email(field,alerttxt){

    with (field){
    apos=value.indexOf("@");
    dotpos=value.lastIndexOf(".");
    if (apos<1||dotpos-apos<2)
      {alert(alerttxt);return false;}
    else {return true;}
    }
}

function validate_form(thisform){

    with (thisform){
      if (ContactType.value==''){
      alert('Please enter your Inquiry Category.');
      ContactType.focus();
      return false;
    }   
    
    if (FirstName.value==''){
      alert('Please enter your first name.');
      FirstName.focus();
      return false;
    }
    if (LastName.value==''){
      alert('Please enter your last name.');
      LastName.focus();
      return false;
    }
  
    if (Address.value==''){
      alert('Please enter your address.');
      Address.focus();
      return false;
    }
      if (City.value==''){
      alert('Please enter your city.');
      City.focus();
      return false;
    }
        if (State.value==''){
      alert('Please enter your state.');
      State.focus();
      return false;
    }
        if (Zip.value==''){
      alert('Please enter your zip.');
      Zip.focus();
      return false;
    }
      if (captcha_code.value==''){
      alert('Please enter Captcha.');
      captcha_code.focus();
      return false;
    }
   
    if (validate_email(Email,"Not a valid e-mail address!")==false){
      Email.focus();
      return false;
    }
    if (Telephone.value==''){
      alert('Please enter your telephone.');
      Telephone.focus();
      return false;
    }
    
    if (Satisfied.value=='' && ContactType.value=='feedback'){
      alert('Were you satisfied with the product?');
      Satisfied.focus();
      return false;
    }
    if (NumberBottle.value=='' && ContactType.value=='feedback' && Satisfied.value=="no"){
      alert('Please enter # of bottles purchased');
      NumberBottle.focus();
      return false;
    }
     if (BottleCode.value=='' && ContactType.value=='feedback' && Satisfied.value=="no"){
      alert('Please enter Bottle code');
      BottleCode.focus();
      return false;
    }
     if (StoreName.value=='' && ContactType.value=='feedback' && Satisfied.value=="no"){
      alert('Please enter store name');
      StoreName.focus();
      return false;
    }
     if (CityPurchased.value=='' && ContactType.value=='feedback' && Satisfied.value=="no"){
      alert('Please enter city purchased');
      CityPurchased.focus();
      return false;
    }
     if (StatePurchased.value=='' && ContactType.value=='feedback' && Satisfied.value=="no"){
      alert('Please enter state purchased');
      StatePurchased.focus();
      return false;
    }
     if (BottleSize.value=='' && ContactType.value=='feedback' && Satisfied.value=="no"){
      alert('Please enter bottle size');
      BottleSize.focus();
      return false;
    }
    
    
    }
  return true;  
}//End Validate fields

function valcheck(){    
    if (validate_form(document.forms.contactfrm)){
      document.forms.contactfrm.submit();
    }
}
  
