function checkEmail(src)
{
    var error= false;
    var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    if(!regex.test(src))
       error= true;
    return error
}
	
function validate() 
{
    var valid = true, output = '';
    if (document.fcontact.name.value.length == 0) {
    valid = false;
    output +='please fill out the name field.\n';
    } 
    //if (document.fcontact.bizname.value.length == 0) {
    //valid = false;
    //output +='> נא למלא את שדה שם העסק\n';
    //} 
    //if (document.fcontact.phone.value.length == 0) {
    //valid = false;
    //output +='> נא למלא את שדה טלפון\n';
    //}  
    
    if(document.fcontact.email.value.length > 0)
    {
	    if(checkEmail(document.fcontact.email.value))
	    {
		    output +='the email address is invalid.\n'; 
		    valid = false;
	    }
    }
    else
	{
			output +='please fill out the email field.\n'; 
		    valid = false;		
	}

    if (document.fcontact.message.value.length == 0) {
    valid = false;
    output +='please fill out the message field.\n';
    } 



    if (valid)
    {	document.fcontact.submit();
    	
    	/*
        
        document.fcontact.message.value = '';
        document.fcontact.email.value = '';
        document.fcontact.phone.value = '';
        document.fcontact.name.value = '';
        document.fcontact.subject.value = '';
        document.getElementById("thankyou").style.display = ''; 
        */
    }
    else
    {
        alert('' + output);
		return valid;
    }
}

