// JavaScript Document
function validationReturns()
{
if (frmreturns.OrderNumber.value == "")
  {
    alert("Please enter the order number.");
    frmreturns.OrderNumber.focus();
    return (false);
  }
if (frmreturns.BillingName.value == "")
  {
    alert("Please enter the billing name on the order.");
    frmreturns.BillingName.focus();
    return (false);
  }
if (frmreturns.YourName.value == "")
  {
    alert("Please enter your name.");
    frmreturns.YourName.focus();
    return (false);
  }
if (frmreturns.Email.value == "")
  {
    alert("Please enter the email address for correspondence regarding return.");
    frmreturns.Email.focus();
    return (false);
  }
if (! IsValidEmail(document.frmreturns.Email.value))
  {
	alert("Invalid email.  Please re-enter email address.");
	document.frmreturns.Email.focus();
	return (false);
  }
if (frmreturns.Phone.value == "")
  {
    alert("Please enter phone number.");
    frmreturns.Phone.focus();
    return (false);
  }
if (document.frmreturns.reason.options[document.frmreturns.reason.selectedIndex].value == "")
  {
    alert("Please select the reason.");
    frmreturns.reason.focus();
    return (false);
  }
if (frmreturns.Comments.value == "")
  {
    alert("Please enter comments.");
    frmreturns.Comments.focus();
    return (false);
  }
if (frmreturns.Deadline.value == "")
  {
    alert("Please choose a deadline date from the calendar or input N/A if not applicable.");
    frmreturns.Deadline.focus();
    return (false);
  }
if (frmreturns.ShipAddress.value == "")
  {
    alert("Please enter either the shipping address or N/A if not applicable.");
    frmreturns.ShipAddress.focus();
    return (false);
  }

return (true);
}

function IsValidEmail(emailstr) {
       if(emailstr.length == 0)
         return true;
        var whitespace = " \t\n\r";

                for (i = 0; i < emailstr.length; i++)
                {   
                        // Check that current character isn't whitespace.
                        var c = emailstr.charAt(i);
                                if (whitespace.indexOf(c)>=0)
                                return false;
                }
                
                // now, check for something that *remotely* looks like an email address
                var atIndex = emailstr.indexOf("@")
        if (atIndex <= 0)
                return false;
               
 var username = emailstr.substring(0,atIndex-1);
                var domain = emailstr.substring(atIndex + 1, emailstr.length);

                if (!(domain.indexOf(".") > 0 && domain.lastIndexOf(".") < domain.length - 1))
                        return false;
        
        return true;
}





















