var intSubmitCount=0;
var strcINVALID_NUMBER_CHARACTERS="[^0-9]";

function trim(strVar) {
	while(strVar.charAt(0)==" ") {
		strVar=strVar.substring(1,strVar.length);
	}
	while(strVar.charAt(strVar.length-1)==" ") {
		strVar=strVar.substring(0,strVar.length-1);
	}
	return strVar;
}
function validateForm()
    {
		var strcINVALID_EMAIL_CHARACTERS="[^A-Za-z0-9._@\x2D]"
		var strcINVALID_POSTCODE_CHARACTERS="[^A-Za-z0-9 ]" // \x20 equates to char(32) in hex
		var strcINVALID_PHONE_CHARACTERS="[^0-9 \x28\x29]"
        var strcFLAGS="gim"

        if (trim(document.getElementById("Name").value) == "")
        {
			alert("The Name cannot be blank.");
			document.getElementById("Name").focus();
			return(false);
		}

        if (trim(document.getElementById("Phone").value) == "")
        {
			alert("Please enter a valid Telephone number");
			document.getElementById("Phone").focus();
			return(false);
		} else
        {
			strValue=new String(document.getElementById("Phone").value)
			if(strValue.search(new RegExp(strcINVALID_PHONE_CHARACTERS))!=-1)
            {
				alert("The Telephone number must only contain the following: Numbers (0..9), Brackets (), Spaces ( )")
				return(false)
			}
		}

        if (trim(document.getElementById("Email").value) == "")
        {
			alert("Please enter an email address");
			document.getElementById("Email").focus();
			return(false);
		}
        else
        {
			strValue=new String(document.getElementById("Email").value)
			if(strValue.search(new RegExp(strcINVALID_EMAIL_CHARACTERS))!=-1)
            {
				alert("The Email address must only contain only the following: Letters (A..Z), Numbers (0..9), Apostrophe ('), Full stop (.), AT (@), Underscore (_) and Dash (-). Spaces are not allowed.")
				return(false)
			}
			if (strValue.indexOf("@") == -1)
            {
				alert("The Email address must contain the @ character to be valid.")
				return(false)
			}
			if (strValue.indexOf("@") != strValue.lastIndexOf("@"))
            {
				alert("The Email address must contain only one @ character to be valid.")
				return(false)
			}
		}


        if(!document.getElementById("signage").checked && !document.getElementById("design").checked && !document.getElementById("web").checked && !document.getElementById("tbd12").checked)
        {
            alert("Please select at least one 'I would like information on the following services option'.");
			document.getElementById("signage").focus();
			return(false);
        }

        if (intSubmitCount == 0)
        {
			intSubmitCount++;
			return(true);
		}
        else
        {
        	if(intSubmitCount > 0)
            {
        		alert("This form has already been submitted & we are currently processing your request.");
        		return(false);
        	}
		}
    }


