function CheckDomainLookup(theForm)
{
	if((theForm.domain.value == "") || (theForm.domain.value == "Enter name here"))
	{
		alert("Please enter a valid domain name to search for.");
		theForm.domain.focus();
return (false);
	}
var check=domainLookup(theForm.domain.value);
if (check== false)
	{
	return (false);
	}		
}

function domainLookup(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
 alert("\'"+TheNumber.charAt(i) + "\' is not valid. Legal characters are 0-9, a-z and -. \n\nPlease do not enter the www. bit or the extension (eg, .co.uk, .com).")
			valid = 0
			return valid
		} // End if statement
	} // End for loop
	return valid
}


function CheckDomain(theForm)
{
	if(theForm.os0.value == "")
	{
		alert("Please enter a valid domain name for this hosting package.");
		theForm.os0.focus();
return (false);
	}
var check=domain(theForm.os0.value);
if (check== false)
	{
	return (false);
	}		
}


function domain(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789.-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
 alert(TheNumber.charAt(i) + " is not valid in a domain name. Legal characters are 0-9, a-z, . and -")
			valid = 0
			return valid
		} // End if statement
	} // End for loop
	return valid
}



function CheckAmount(theForm)
{
var formOK = true;
	if((theForm.item_name.value == "") || (theForm.item_name.value == "Enter invoice number(s)"))
	{
		alert("Please enter a valid invoice number.");
return (false);
	}
	if(theForm.amount.value == "")
	{
		alert("Please enter an amount to pay.");
return (false);
	}
var check=CheckNumber(theForm.amount.value);
if (check== false)
	{
	return (false);
	}		
}

function CheckNumber(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789."
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
 alert("Please enter a valid amount (eg: 249.99).")
			valid = 0
			return valid
		} // End if statement
	} // End for loop
	return valid
}
function SubmitSupportForm(theForm)
{
//To require javascript checks, you should have hidden field name=jsChecks value=No in HTML form and
//check $_POST['jsChecks'="Yes" in form processing PHP and uncomment line below...

theForm.jsChecks.value="Yes";

//now check for required fields and move cursor there in form if missing

if(theForm.name.value == "")
	{
		alert("Please enter your name.");
		theForm.name.focus();
return (false);
	}
	else if ((theForm.email.value == "") && (theForm.telephone.value == ""))
	{
		alert("You must enter at least an email address or\ntelephone number so that we may contact you.");
		theForm.email.focus();
return (false);
	}
	else if(theForm.message.value == "")
	{
		alert("Please enter your message.");
		theForm.message.focus();
return (false);
	}
	else if(theForm.security_code.value == "")
	{
		alert("Please enter the security code in the graphic.");
		theForm.security_code.focus();
return (false);
	}
//check email address
	if(theForm.email.value != "") {

var check=echeck(theForm.email.value);
if (check== false)
	{
	return (false);
	}		

}
//check phone number if exists
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
		
}


function SubmitForm(theForm)
{
//To require javascript checks, you should have hidden field name=jsChecks value=No in HTML form and
//check $_POST['jsChecks'="Yes" in form processing PHP and uncomment line below...

theForm.jsChecks.value="Yes";

//now check for required fields and move cursor there in form if missing

if(theForm.name.value == "")
	{
		alert("Please enter your name.");
		theForm.name.focus();
return (false);
	}
	else if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
	else if(theForm.telephone.value == "")
	{
		alert("Please enter your telephone number.");
		theForm.telephone.focus();
return (false);
	}
	else if(theForm.message.value == "")
	{
		alert("Please enter your message.");
		theForm.message.focus();
return (false);
	}
	else if(theForm.security_code.value == "")
	{
		alert("Please enter the security code in the graphic.");
		theForm.security_code.focus();
return (false);
	}
//check email address
var check=echeck(theForm.email.value);
if (check== false)
	{
	return (false);
	}		
//check phone number if exists
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
		
}


function CheckPhoneNumber(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789()-+ "
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
 alert(TheNumber.charAt(i) + " is not valid in a phone number.")
			valid = 0
			return valid
} // End if statement
	} // End for loop
	return valid
}

function echeck(str) 
{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("E-mail not in correct format.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("E-mail not in correct format.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("E-mail not in correct format.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("E-mail not in correct format.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("E-mail not in correct format.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("E-mail not in correct format.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("E-mail not in correct format.")
		    return false
		 }

 		 return true					
 }


