// JavaScript Document
function formValidate(theForm) {
      var why = "";
	  for (i=0, n=theForm.title.length; i<n; i++) {
        if (theForm.title[i].checked) {
            var checkvalue = theForm.title[i].value;
            break;
        } 
    	}
	  why += checktitle(checkvalue);	
	  why += checkname(theForm.name.value);
	  why += checklastname(theForm.lastname.value);
	  why += checkDOB();
	  why += checkphone(theForm.phone.value);

      if (why != "") {
         alert(why);
         return false;
      }

	document.checkout.submit()
	return true;
}

function checktitle(checkvalue) {
	  var error = "";
   	  if (!(checkvalue)) {
        error = "Please check a title box.\n";
      }
	return error;    
}

function checkname (strng) {
	  var error = "";
	  if (strng == "") {
        error = "Please insert your name.\n";
	  }
	return error; 
}

function checklastname (strng) {
	  var error = "";
	  if (strng == "") {
        error = "Please insert your surname.\n";
	  }
	return error; 
}

function checkDOB () {
	  var error = "";
	  if ( (document.orderform.dob.value == "") || (document.orderform.dob2.value == "") || (document.orderform.dob3.value == "") ) {
        error = "Please check date of birth.\n";
	  }
	return error; 
}



function checkEmail(strng) {
   	  var error = "";
//	  if (strng == "") {
      if (strng.indexOf(".") < 2){ // && (strng.indexOf("@") !> 0){
   		error = "Please insert valid email address.\n";
	  }
	return error;
}

function checkphone (strng) {
	  var error = "";
	  if (strng == "") {
		error = "You didn't enter a phone number.\n";
	  }
		var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
      if (isNaN(parseInt(stripped))) {
		error = "Please insert a phone number.\n";
	  } 
	return error;
}

function checkPost (strng) {
	  var error = "";
	  if (strng == "") {
        error = "Please insert your postcode.\n";
	  }
	return error; 
}

function checkAddress (strng) {
	  var error = "";
	  if (strng == "") {
        error = "Please insert your Address.\n";
	  }
	return error; 
}

function checkCity (strng) {
	  var error = "";
	  if (strng == "") {
        error = "Please insert your city.\n";
	  }
	return error; 
}

function checkCounty (strng) {
	  var error = "";
	  if (strng == "") {
        error = "Please insert your county or state.\n";
	  }
	return error; 
}

function marital(choice) {
	  var error = "";
      if (choice == 0) {
        error = "Please insert your marital status.\n";
      }    
	return error;
}


function mySubmit() {
    setTimeout('document.checkout.reset()',2000);
    return false;
}