function Checkemail(emailstr){
  //var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
  if (filter.test(emailstr)) 
  {
    return true;
  } 
  else
  {
    return false;
  }
}


function ValidateForm(bPrd, bOs, bRegname)
{
  var reVar=true;
  var theForm=document.getElementById('theForm');
  var theLabel=false;
  if(!theForm)
     return retVar;

  theLabel=document.getElementById('idemail');
  if (theForm.email.value=='')
  {
    if(theLabel)
        theLabel.style.color="red";
    reVar=false;
  }
  else if (!Checkemail(theForm.email.value)) 
 {
    alert("Please enter a valid e-mail address.");
    theForm.email.select();
    if(theLabel)
        theLabel.style.color="red";
    reVar=false;
  }
  else
  {
    if(theLabel)
        theLabel.style.color="#333";
  }

 theLabel=document.getElementById('idmessage');
 if (theForm.message.value=='')
 {
    if(theLabel)
        theLabel.style.color="red";
    reVar=false;
 }
 else
 {
    if(theLabel)
        theLabel.style.color="#333";
 }
 
  if(bPrd)
  {
     theLabel=document.getElementById('idproduct');
     if(theForm.product.value=='')
     {
         if(theLabel)
             theLabel.style.color="red";
         reVar=false;
     }
    else
    {
         if(theLabel)
             theLabel.style.color="#333";
    }
  }
  
  if(bOs)
  {
     theLabel=document.getElementById('idos');
     if(theForm.os.value=='')
     {
         if(theLabel)
             theLabel.style.color="red";
         reVar=false;
     }
    else
    {
         if(theLabel)
             theLabel.style.color="#333";
    }
  }

  if(bRegname)
  {
     theLabel=document.getElementById('idregname');
     if(theForm.regname.value=='')
     {
         if(theLabel)
             theLabel.style.color="red";
         reVar=false;
     }
    else
    {
         if(theLabel)
             theLabel.style.color="#333";
    }
  }
  
  if(theForm.randcode)
  {
     theLabel=document.getElementById('idrandcode');
     if(theForm.randcode.value=='')
     {
         if(theLabel)
             theLabel.style.color="red";
         reVar=false;
     }
    else
    {
         if(theLabel)
             theLabel.style.color="#333";
    }
  }

  if(!reVar)
      document.getElementById('iderror').innerHTML="Please complete the required fields.";
  else
      document.getElementById('iderror').innerHTML="&nbsp;";
    
  return reVar;
}

function ValidateTellFriend()
{
    var reVar=true;
    var d=document.getElementById('theForm');
    if(!d)
        return reVar;
    var c=document.getElementById('idemail');
    if(d.email.value=="")
    {
        if(c)
            c.style.color="red";
        reVar=false;
    }
    else if(!Checkemail(d.email.value))
    {
       alert("Please enter valid e-mail address.");
       d.email.select();
       if(c)
          c.style.color="red";
       reVar=false;
  }
  else
  {
       if(c)
          c.style.color="#333";
  }
    
  var c=document.getElementById('idemail2');
  if(d.email2.value=="")
  {
      if(c)
          c.style.color="red";
      reVar=false;
  }
  else if(!Checkemail(d.email2.value))
  {
       alert("Please enter valid e-mail address.");
       d.email2.select();
       if(c)
          c.style.color="red";
       reVar=false;
  }
  else
  {
       if(c)
          c.style.color="#333";
  }

  if(!reVar)
      document.getElementById('iderror').innerHTML="Please complete the required fields.";
  else
      document.getElementById('iderror').innerHTML="&nbsp;";
  return reVar;    
}
