function checkportsched(){
	var errors = false;
	var x = getObj('homePortSel');
	var errorTxt = "Sorry, there is a problem trying to submit your request. Please check the problem below and try again:\n";
	if (x.portID.value=="X") {
		errors = true;
		errorTxt += "You did not select a port\n";
	}
	if (errors){
		alert (errorTxt);
		return false;
	}
	else return true;
}

function checknewsletter(){
	var errors = false;
	var x = getObj('newsletter');
	var errorTxt = "Sorry, there is a problem trying to submit your request. Please check the problem below and try again:\n";

	if (!chkEmail(x.email.value) || (x.email.value=="")) {
		errors = true;
		errorTxt += "Please enter a valid email address so we can send you a copy of our newsletter\n";
	}
	if (errors){
		alert (errorTxt);
		return false;
	}
	else return true;
}

function checktracking(){
	var errors = false;
	var x = getObj('turbofreight');
	var errorTxt = "Sorry, there is a problem trying to submit your request. Please check the problem below and try again:\n";
	
	if (x.numbertype.value == "0") { // this is neither
		errors = true;
		errorTxt += "You did not enter your BoL number or your Job Number\n";
	}
	else if ((x.numbertype.value == "1") && (x.bol.value=="")) { // this is bol
		errors = true;
		errorTxt += "You did not enter your BoL number\n";
	}
	else if (x.numbertype.value == "2"){
		if ((x.job0.value == "") || (x.job1.value == "")) { // this is job ref
			errors = true;
			errorTxt += "You have not correctly entered your Job Ref number\nYou must enter it in the following format:\n\t'abc 12345678'";
		}
		else if ((!homevalidChar(x.job0.value)) || (!homevalidNum(x.job1.value))){
			errors = true;
			errorTxt += "You have not entered the Job number correctly. Enter the 3 letters into the first box and the 6 - 8 digit number into the second box. Do not type the full stop.";
		}
	}
	if (errors){
		alert (errorTxt);
		return false;
	}
	else return true;
}

function setType(val){
	var x = getObj('turbofreight');
	x.numbertype.value = val;
}

function homevalidChar(fVal) {
 var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
 var ok = "yes";
 var temp;
 for (var i=0; i<fVal.length; i++) {
   temp = "" + fVal.substring(i, i+1);
   if (valid.indexOf(temp) == "-1") ok = "no";
 }
 if (ok == "no") {
   return false;
 }
 else return true;
}

function homevalidNum(fVal) {
 var valid = "0123456789"
 var ok = "yes";
 var temp;
 for (var i=0; i<fVal.length; i++) {
   temp = "" + fVal.substring(i, i+1);
   if (valid.indexOf(temp) == "-1") ok = "no";
 }
 if (ok == "no") {
   return false;
 }
 else return true;
}