

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_required(field,alerttxt)
{
  with (field)
  {
    if (value==null||value=="")
      {alert(alerttxt);return false;}
    else {return true}
  }
}

function validate_key(field,alerttxt)
{
  with (field)
  {
    alen=value.length;

    if (alen<10||alen>10)
       {alert(alerttxt);return false;}
     else {return true;}
  }
}

function validate_serial(field,alerttxt)
{
  with (field)
  {
   	alen=value.length;
    if (alen == 19){
       apos1=value.indexOf("-");
       apos2=value.lastIndexOf("-");

       if (apos1!=4||apos2<14)
            {alert(alerttxt);return false;}
      else {return true;}
    }
    else{
      alert(alerttxt);return false;
    }
  }
}

function validate_state(field,alerttxt)
{
  with (field)
  {
   	alen=value.length;
	if (alen != 2){
	   alert(alerttxt);return false;
	}
	else{
		 return true;
	}
  }
}

function validate_altemail(field,alerttxt)
{
with (field)
{
  if (value==null||value==""){
  	 return true;	 
  }
  else {
  	   if (validate_email(field,alerttxt)==false)
	 	{return false;} 
	 else
	 	 {return true;}
  
  }
}
}


function set_acount(thisform)
{
  thisform.recipient.value = "register@gjcsoftware.com"; 
  thisform.product.value = "EZ Viewer v3"; 
  thisform.subject.value = "Online Registration"; 
}

function validate_form(thisform)
{
  with (thisform)
  {
    if (validate_required(First,"First name must be filled out!")==false)
       {First.focus();return false;}

    if (validate_required(Last,"Last name must be filled out!")==false)
       {Last.focus();return false;}

    if (validate_required(Address,"Address must be filled out!")==false)
       {Address.focus();return false;}

    if (validate_required(City,"City must be filled out!")==false)
       {City.focus();return false;}

    if (validate_state(State,"Please select a state!")==false)
       {State.focus();return false;}

    if (validate_required(ZipCode,"Zip Code must be filled out!")==false)
       {ZipCode.focus();return false;}


    if (validate_required(email,"Email must be filled out!")==false)
       {email.focus();return false;}

    if (validate_email(email,"Not a valid e-mail address!")==false)
       {email.focus();return false;}

    if (validate_altemail(altemail,"ALt e-mail is not valid!")==false)
       {altemail.focus();return false;}

    if (validate_required(key,"Key must be filled out!")==false)
       {key.focus();return false;}
  
    if (validate_key(key,"Not a EZ Viewer 3 Key!")==false)
       {key.focus();return false;}
	
    if (validate_required(serial,"Serial must be filled out!")==false)
       {serial.focus();return false;}	

    if (validate_serial(serial,"Not a EZ Viewer 3 Serial!")==false)
       {serial.focus();return false;}
  }
}


function validate_botbeat(field,alerttxt)
{
    if (field.value == "4")
	   {return true;}
     else 
	   {
	   alert(alerttxt);
	   return false;
	   }
 
}

function validate_support(thisform)
{
  with (thisform)
  {
    if (validate_required(Name,"Name must be filled out!")==false)
       {Name.focus();return false;}

    if (validate_required(email,"Email must be filled out!")==false)
       {email.focus();return false;}

    if (validate_email(email,"Not a valid e-mail address!")==false)
       {email.focus();return false;}
	   
	if (validate_required(botbeat,"You must answer the secuirty question.")==false)
       {botbeat.focus();return false;}
	   
	if (validate_botbeat(botbeat,"You must answer the secuirty question correctly.\n Hint 4!")==false)
       {botbeat.focus();return false;}
	   
	   
	if (validate_required(Question,"You did not fill in any details.")==false)
       {Question.focus();return false;}   
	   
	
	}
}