// JavaScript Document

function validateEmail(tempEmail)
{

   var valid = true;
   len = tempEmail.length;

   if(len==0){
        valid = false;
   }


   spaces = tempEmail.indexOf(' ');
        // check for spaces
        if(spaces != -1)
                valid = false;

   ampers = tempEmail.indexOf('&');
        // check for ampersands
        if(ampers != -1)
                valid = false;

   at = tempEmail.indexOf('@');
        // check there is a at sign
        if(at == -1)
                valid = false;

   atmore = tempEmail.indexOf('@',(at+1));
        // check for more at signs
        if(atmore != -1)
                valid = false;

   dot = tempEmail.indexOf('.',at);
        // check for a dot after the at sign
        if(dot== -1)
                valid = false;

   if((at == 0)||(at== len))
   {
        // check where the at sign is
        valid = false;
   }

   return valid;
}

function checkContact(f)
{
    var formok = true;
    var errmsg = "The following entries are required:\n\n";
	
    if (f.email.value == "")
    {
        formok = false;
        errmsg += "- Email Address\n";
    }
    else if (!validateEmail(f.email.value))
    {
        formok = false;
        errmsg += "- A Valid Email Address\n";
    }

    if (!formok)
    {
        errmsg += "\nPlease try again.";
        alert(errmsg);
    }

    return formok;
}