function IsDigit(character){
	// return true is valid, false otherwise
	if (character >='0' && character<='9' ) 
		return true;
	else
		return false;		
}


function form_onsubmit(theform) {
	if(theform.WebReferID.value!=""){
		validstring=theform.WebReferID.value
		for (i=0; i<validstring.length; i++){
			//check if the character is valid
			if(IsDigit(validstring.charAt(i))==false){
				alert("Your referer id is invalid.");
				theform.WebReferID.value=""
				theform.WebReferID.focus();
				return false;
				}
			} 
	}
	
	if(theform.ContactFirstName.value==""){
		alert("Contact's first name required");
		theform.ContactFirstName.focus();
		return false;
		}
	if(theform.ContactLastName.value==""){
		alert("Contact's last name required");
		theform.ContactLastName.focus();
		return false;
		}

	if(!validateNumberEntry(theform.ContactFaxNumber)){
		return false
	}
	if(theform.ContactEmailAddress.value==""){
		alert("Contact's Email address required");
		theform.ContactEmailAddress.focus();
		return false;
		}
	else{
		address=theform.ContactEmailAddress.value
		if(address.length<5 || address.indexOf('@')<0 || address.indexOf('.')<0 ){
			alert("Contact's Email format is incorrect.");
			theform.ContactEmailAddress.focus();
			return false;
			}
	}		
	if(theform.WebURL.value==""){
		alert("The web URL is not specified.");
		theform.WebURL.focus();
		return false;
		}
	else{		
		url=theform.WebURL.value
		if(url.indexOf('@')>=0){
			alert("The web URL should not have @.");
			theform.WebURL.focus();
			return false;
			}
		else if(url.indexOf('.')<0){
			alert("The web URL should be formatted this way:  www.yoursite.com.");
			theform.WebURL.focus();
			return false;
			}
		}
		
	
		
	
	return true;		
}

