// JavaScript Document


function checkRegistration(theForm) {
	
if(theForm.firstname.value == "") {
		alert("Please enter your first name.");
		theForm.firstname.focus();
	return false;
}
if(theForm.surname.value == "") {
		alert("Please enter your surname.");
		theForm.surname.focus();
	return false;
}
	var x = theForm.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(x) !=true){
		alert("Please enter a valid email address.");
		theForm.email.focus();
	return false;
}
if(theForm.telephone.value == "") {
		alert("Please enter your telephone number.");
		theForm.telephone.focus();
	return false;
}
if(theForm.namenum.value == "") {
		alert("Please enter your house name/number.");
		theForm.namenum.focus();
	return false;
}
if(theForm.street.value == "") {
		alert("Please enter your street name.");
		theForm.street.focus();
	return false;
}
if(theForm.city.value == "") {
		alert("Please enter your town/city.");
		theForm.city.focus();
	return false;
}
if(theForm.county.value == "") {
		alert("Please enter your county.");
		theForm.county.focus();
	return false;
}
if(theForm.zip.value == "") {
		alert("Please enter your postcode/zip.");
		theForm.zip.focus();
	return false;
}
if(theForm.password.value == "") {
		alert("Please enter a password.");
		theForm.password.focus();
	return false;
}
if(theForm.password.value == "") {
		alert("Please enter a password.");
		theForm.password.focus();
	return false;
}

if(theForm.passwordconfirm.value == "") {
		alert("Please confirm your chosen password.");
		theForm.passwordconfirm.focus();
	return false;
}
	
}

//////////////////////////////////////////////////////////////////////

function valbutton(theForm) {

method = -1;
for (i=theForm.selectpayment.length-1; i > -1; i--) {
if (theForm.selectpayment[i].checked) {
method = i; i = -1;
}
}
if (method == -1) {
alert("Please select a payment method.");
return false;
}

if(theForm.selectpayment[method].value=="creditcard") {
	theForm.setAttribute('action','https://domaingod.com/domaingoddev/checkout/billing-details/');
}else{
	theForm.setAttribute('action','http://www.paypal.com');
}
return true;
}


//////////////////////////////////////////////////////////////////////

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Copyright 1999 Idocs, Inc. http://www.idocs.com
Distribute this script freely but keep this notice in place */

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}
