//faq toggle
function toggle(obj) {
	var el = document.getElementById(obj);
	var ar = document.getElementById(obj+'ar');
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
		ar.innerHTML='<img src="images/arw_right.gif" style="width:5px;height:9px;" alt="" title="" />';
	}
	else {
		el.style.display = 'block';
		ar.innerHTML='<img src="images/arw_down.gif" style="width:9px;height:5px;" alt="" title="" />';
	}

}



// function: clear form field
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = "";
  el.setAttribute('maxLength','9');
}

  // ** validation **
function checkform ( form )
{
  if (form.first_name.value == "") {
    alert( "Please enter your first name." );
    form.first_name.focus();
    return false ;
  }
  if (form.last_name.value == "") {
    alert( "Please enter your last name." );
    form.last_name.focus();
    return false ;
  }
    if (form.email_address.value == "") {
    alert( "Please enter your email address." );
    form.email_address.focus();
    return false ;
  }
  if (echeck(form.email_address.value)==false){ 
   form.email_address.value=""  
   form.email_address.focus(); 
   return false 
  }
   if (form.addr1.value == "") {
    alert( "Please enter your street address." );
    form.addr1.focus();
    return false ;
  }
  if (form.city.value == "") {
    alert( "Please enter the city in which you live." );
    form.city.focus();
    return false ;
  }
  if (form.state.value == "") {
    alert( "Please enter your state or province." );
    form.state.focus();
    return false ;
  }
  if (form.zip_code.value == "") {
    alert( "Please enter your postal code." );
    form.zip_code.focus();
    return false ;
  }
  if (form.purch_date.value == "") {
    alert( "Please enter the purchase date." );
    form.purch_date.focus();
    return false ;
  }
return true ;
}

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){
     alert("Email address is not formated correctly.");
     return false;
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Email address is not formated correctly.");
     return false;
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Email address is not formated correctly.");
      return false;
  }
   if (str.indexOf(at,(lat+1))!=-1){
      alert("Email address is not formated correctly.");
      return false;
   }
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      alert("Email address is not formated correctly.");
      return false;
   }
   if (str.indexOf(dot,(lat+2))==-1){
      alert("Email address is not formated correctly.");
      return false;
   }
  
   if (str.indexOf(" ")!=-1){
      alert("Please enter your email address.");
      return false;
   }
    return true;     
 }




  // ** validation **
function checkformu ( form )
{
  if (form.e.value == "") {
    alert( "Please enter your email address." );
    form.e.focus();
    return false ;
  }
return true ;
}

