function testVATNumber () {
  var myVATNumber = document.getElementById('vatnumber').value;
if (myVATNumber=="") {
  return true;
}
  if (checkVATNumber (myVATNumber)) {
    document.getElementById('vatnumber').value = checkVATNumber (myVATNumber)
    //alert ("VAT number has a valid format"); 
  return true;
  }  
  else alert ("Sorry, your VAT number is invalid. If you do not know your VAT number, please leave the box blank and click Next.");
document.getElementById('vatnumber').value = "";
return (false)
}

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					
 }

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 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(TheNumber.charAt(i) + " is not a number.")
			valid = 0
			return valid
		} // End if statement
	} // End for loop
	return valid
}

function SubmitBrokerage (theForm) 
{
var formOK = true;
//MM_validateForm('','','R','','','R','','','RisEmail')


	if(theForm.billing_email.value == "")
	{
		alert("Please enter your billing email address.");
return (false);
	}
	else if(theForm.billing_email.value != theForm.billing_email2.value)
	{
		alert("Your billing email addresses do not match.");
return (false);
	}
	else if(theForm.billing_first_name.value == "")
	{
		alert("Please enter the first name of the billing.");
return (false);
	}
	else if(theForm.billing_last_name.value == "")
	{
		alert("Please enter the last name of the billing.");
return (false);
	}
	else if(theForm.billing_address.value == "")
	{
		alert("Please enter the address of the billing.");
return (false);
	}
	else if(theForm.billing_town.value == "")
	{
		alert("Please enter the town or city of the billing.");
return (false);
	}
	else if(theForm.billing_postcode.value == "")
	{
		alert("Please enter the postcode of the billing.\n\nIf you do not have a postcode, please enter 0.");
return (false);
	}
	else if(theForm.vat_country.value == "")
	{
		alert("Please select the country of the billing address.");
return (false);
	}
var check=echeck(theForm.billing_email.value);
if (check== false)
	{
	return (false);
	}		
var check=CheckPhoneNumber(theForm.billing_telephone.value);
if (check== false)
	{
	return (false);
	}			
var check=CheckPhoneNumber(theForm.billing_fax.value);
if (check== false)
	{
	return (false);
	}			

}
function SubmitForm(theForm)
{
var formOK = true;
//MM_validateForm('','','R','','','R','','','RisEmail')


if (itemChosen <1) {
alert("Please choose your subscription term.")
return (false);
}



	if (theForm.renewal.value=="yes" && theForm.subs_no.value != "") {
var check=CheckNumber(theForm.subs_no.value);
if (check== false)
	{
	return (false);
	}		
	var starto=theForm.start.value*1
	var endo=theForm.end.value*1
	if (theForm.subs_no.value < starto || theForm.subs_no.value > endo)
	{
		alert("Sorry, your subscriber number is not valid. Please check it and try again. \n\nPlease enter the last set of numbers only\neg: for MY/340/23098, just enter 23098.");
return (false);
	}

}


	if(theForm.recipient_email.value == "")
	{
		alert("Please enter your subscriber email address.");
return (false);
	}
	else if(theForm.recipient_email.value != theForm.recipient_email2.value)
	{
		alert("Your subscriber email addresses do not match.");
return (false);
	}
	else if(theForm.recipient_first_name.value == "")
	{
		alert("Please enter the first name of the subscriber.");
return (false);
	}
	else if(theForm.recipient_last_name.value == "")
	{
		alert("Please enter the last name of the subscriber.");
return (false);
	}
	else if(theForm.recipient_address.value == "")
	{
		alert("Please enter the address of the subscriber.");
return (false);
	}
	else if(theForm.recipient_town.value == "")
	{
		alert("Please enter the town or city of the subscriber.");
return (false);
	}
	else if(theForm.recipient_postcode.value == "")
	{
		alert("Please enter the postcode of the subscriber, without this we cannot guarantee deilvery.\n\nIf you do not have a postcode, please enter 0.");
return (false);
	}
	else if(theForm.recipient_country.value == "")
	{
		alert("Please select the country of the subscriber address.");
return (false);
	}
var check=echeck(theForm.recipient_email.value);
if (check== false)
	{
	return (false);
	}		
var check=CheckPhoneNumber(theForm.recipient_telephone.value);
if (check== false)
	{
	return (false);
	}		
var check=CheckPhoneNumber(theForm.recipient_fax.value);
if (check== false)
	{
	return (false);
	}		


	if(theForm.billing_email.value == "")
	{
		alert("Please enter your billing email address.");
return (false);
	}
	else if(theForm.billing_email.value != theForm.billing_email2.value)
	{
		alert("Your billing email addresses do not match.");
return (false);
	}
	else if(theForm.billing_first_name.value == "")
	{
		alert("Please enter the first name of the billing.");
return (false);
	}
	else if(theForm.billing_last_name.value == "")
	{
		alert("Please enter the last name of the billing.");
return (false);
	}
	else if(theForm.billing_address.value == "")
	{
		alert("Please enter the address of the billing.");
return (false);
	}
	else if(theForm.billing_town.value == "")
	{
		alert("Please enter the town or city of the billing.");
return (false);
	}
	else if(theForm.billing_postcode.value == "")
	{
		alert("Please enter the postcode of the billing.\n\nIf you do not have a postcode, please enter 0.");
return (false);
	}
	else if(theForm.billing_country.value == "")
	{
		alert("Please select the country of the billing address.");
return (false);
	}
var check=echeck(theForm.billing_email.value);
if (check== false)
	{
	return (false);
	}		
var check=CheckPhoneNumber(theForm.billing_telephone.value);
if (check== false)
	{
	return (false);
	}			
var check=CheckPhoneNumber(theForm.billing_fax.value);
if (check== false)
	{
	return (false);
	}			
}

function SubmitFormProducts(theForm)
{
var formOK = true;
//MM_validateForm('','','R','','','R','','','RisEmail')

	if(theForm.recipient_email.value == "")
	{
		alert("Please enter the recipient\'s email address.");
return (false);
	}
	else if(theForm.recipient_email.value != theForm.recipient_email2.value)
	{
		alert("Your email addresses do not match.");
return (false);
	}
	else if(theForm.recipient_first_name.value == "")
	{
		alert("Please enter the first name of the recipient.");
return (false);
	}
	else if(theForm.recipient_last_name.value == "")
	{
		alert("Please enter the last name of the recipient.");
return (false);
	}
	else if(theForm.recipient_address.value == "")
	{
		alert("Please enter the address of the recipient.");
return (false);
	}
	else if(theForm.recipient_town.value == "")
	{
		alert("Please enter the town or city of the recipient.");
return (false);
	}
	else if(theForm.recipient_postcode.value == "")
	{
		alert("Please enter the postcode of the recipient, without this we cannot guarantee deilvery.\n\nIf you do not have a postcode, please enter 0.");
return (false);
	}
	else if(theForm.recipient_country.value == "")
	{
		alert("Please select the country of the delivery address.");
return (false);
	}
var check=echeck(theForm.recipient_email.value);
if (check== false)
	{
	return (false);
	}		
var check=CheckPhoneNumber(theForm.recipient_telephone.value);
if (check== false)
	{
	return (false);
	}		
var check=CheckPhoneNumber(theForm.recipient_fax.value);
if (check== false)
	{
	return (false);
	}		


	if(theForm.billing_email.value == "")
	{
		alert("Please enter your billing email address.");
return (false);
	}
	else if(theForm.billing_email.value != theForm.billing_email2.value)
	{
		alert("Your billing email addresses do not match.");
return (false);
	}
	else if(theForm.billing_first_name.value == "")
	{
		alert("Please enter the first name of the billing.");
return (false);
	}
	else if(theForm.billing_last_name.value == "")
	{
		alert("Please enter the last name of the billing.");
return (false);
	}
	else if(theForm.billing_address.value == "")
	{
		alert("Please enter the address of the billing.");
return (false);
	}
	else if(theForm.billing_town.value == "")
	{
		alert("Please enter the town or city of the billing.");
return (false);
	}
	else if(theForm.billing_postcode.value == "")
	{
		alert("Please enter the postcode of the billing.");
return (false);
	}
	else if(theForm.billing_country.value == "")
	{
		alert("Please select the country of the billing address.");
return (false);
	}
var check=echeck(theForm.billing_email.value);
if (check== false)
	{
	return (false);
	}		
var check=CheckPhoneNumber(theForm.billing_telephone.value);
if (check== false)
	{
	return (false);
	}			
var check=CheckPhoneNumber(theForm.billing_fax.value);
if (check== false)
	{
	return (false);
	}			

}


function SubmitBrokerageForm(theForm)
{
var formOK = true;
//MM_validateForm('','','R','','','R','','','RisEmail')
	if(theForm.vat_country.value == "")
	{
		alert("Please select the country for billing.");
return (false);
	}
}



function SubmitIndexForm(theForm)
{
var formOK = true;
//MM_validateForm('','','R','','','R','','','RisEmail')
	if(theForm.region.value == "")
	{
		alert("Please select the area to which you want the magazine sent.");
return (false);
	}
}

function CheckAmount(theForm)
{
var formOK = true;
	if(theForm.ref.value == "")
	{
		alert("Please enter a reference code.");
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 Duplicate(theForm)
{
	theForm.billing_first_name.value == theForm.recipient_first_name.value	
}


<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var billing_first_name = "";
var billing_last_name = "";
var billing_email = "";
var billing_email2 = "";
var billing_company = "";
var billing_address = "";
var billing_town = "";
var billing_county = "";
var billing_telephone = "";
var billing_fax = "";
var billing_country = "";
var billing_countryIndex = 0;
var billing_postcode = "";

function InitSaveVariables(form) {
recipient_first_name = form.recipient_first_name.value;
recipient_last_name = form.recipient_last_name.value;
recipient_email = form.recipient_email.value;
recipient_email2 = form.recipient_email2.value;
recipient_address = form.recipient_address.value;
recipient_company= form.recipient_company.value;
recipient_town = form.recipient_town.value;
recipient_postcode = form.recipient_postcode.value;
recipient_county = form.recipient_county.value;
recipient_countryIndex = form.recipient_country.selectedIndex;
recipient_country = form.recipient_country[recipient_countryIndex].value;
}

function ShipToBillPerson(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.billing_first_name.value = form.recipient_first_name.value;
form.billing_last_name.value = form.recipient_last_name.value;
form.billing_email.value = form.recipient_email.value;
form.billing_email2.value = form.recipient_email2.value;
form.billing_company.value = form.recipient_company.value;
form.billing_address.value = form.recipient_address.value;
form.billing_town.value = form.recipient_town.value;
form.billing_postcode.value = form.recipient_postcode.value;
form.billing_county.value = form.recipient_county.value;
form.billing_telephone.value = form.recipient_telephone.value;
form.billing_fax.value = form.recipient_fax.value;
form.billing_country.value = form.recipient_country.value;
//form.billing_country.selectedIndex = form.recipient_country.selectedIndex;
}
else {
form.billing_first_name.value = billing_first_name;
form.billing_last_name.value = billing_last_name;
form.billing_email.value = billing_email;
form.billing_email2.value = billing_email2;
form.billing_company.value = billing_company;
form.billing_address.value = billing_address;
form.billing_town.value = billing_town;
form.billing_postcode.value = billing_postcode;       
form.billing_county.value = billing_county;       
form.billing_telephone.value = billing_telephone;       
form.billing_fax.value = billing_fax;       
form.billing_country.value = billing_country;
   }
}


function ShipToBillPersonProducts(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.billing_first_name.value = form.recipient_first_name.value;
form.billing_last_name.value = form.recipient_last_name.value;
form.billing_company.value = form.recipient_company.value;
form.billing_email.value = form.recipient_email.value;
form.billing_email2.value = form.recipient_email2.value;
form.billing_address.value = form.recipient_address.value;
form.billing_town.value = form.recipient_town.value;
form.billing_postcode.value = form.recipient_postcode.value;
form.billing_county.value = form.recipient_county.value;
form.billing_telephone.value = form.recipient_telephone.value;
form.billing_fax.value = form.recipient_fax.value;
form.billing_country.selectedIndex = form.recipient_country.selectedIndex;
}
else {
form.billing_first_name.value = billing_first_name;
form.billing_last_name.value = billing_last_name;
form.billing_company.value = billing_company.value;
form.billing_email.value = billing_email;
form.billing_email2.value = billing_email2;
form.billing_address.value = billing_address;
form.billing_town.value = billing_town;
form.billing_postcode.value = billing_postcode;       
form.billing_county.value = billing_county;       
form.billing_telephone.value = billing_telephone;       
form.billing_fax.value = billing_fax;       
form.billing_country.selectedIndex = billing_countryIndex;
   }
}


//  End -->

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
