// JavaScript Document
function bidValidation(frmbid)
{

if (frmbid.fullname.value == "")
  {
    alert("Please enter your name.");
    frmbid.fullname.focus();
    return (false);
  }

if (frmbid.phone.value == "")
  {
    alert("Please enter your daytime telephone #.");
    frmbid.phone.focus();
    return (false);
  }
if (frmbid.email.value == "")
  {
    alert("Please enter your e-mail address.");
    frmbid.email.focus();
    return (false);
  }
if (! IsValidEmail(document.frmbid.email.value))
	{
	alert("Invalid E-mail.  Please re-enter e-mail address.");
	document.frmbid.email.focus();
	return (false);
	}
if (frmbid.auctionitem.value == "")
  {
    alert("Please choose an auction item.");
    frmbid.auctionitem.focus();
    return (false);
  }
else if (frmbid.bid.value == "")
	{
		alert("Please enter a bid amount.");
		frmbid.bid.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;
}
