function ad(thead) {
	var w=window.open("http://www.reefertrends.com/ads.php?ad=" + thead,"sponsor","");
	w.focus();
}

function checkregister(f) {
	if(!f.firstname.value) {
		alert("Please enter your first name.");
		return false;
	}
	if(!f.lastname.value) {
		alert("Please enter your last name.");
		return false;
	}
	if(!f.company.value) {
		alert("Please enter your company name.");
		return false;
	}
	if(!f.tel1.value) {
		alert("Please enter your telephone number.");
		return false;
	}
	if(!f.email.value) {
		alert("Please enter your email address.");
		return false;
	}
	var str = f.email.value;
	if ((str.indexOf(".") > 2) && (str.indexOf("@") > 0)) {
		return true;
	} else {
		alert("Please enter a valid email address.");
	}
	return false;
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

window.onload = externalLinks;

function bbc() {
	var f = document.getElementById("searchform");
	if(validsearch(f)) {
		var url = "http://newssearch.bbc.co.uk/cgi-bin/search/results.pl?scope=newsukfs&tab=news&q=";
		var w = window.open(url + f.searchtxt.value,"bbc_news","");
		w.focus();
	} else {
		alert("Please enter a term to search for.");
	}
}

function google(f) {
	var f = document.getElementById("searchform");
	if(validsearch(f)) {
		var url = "http://news.google.com/news?hl=en&ned=us&btnG=Search+News&q=";
		var w = window.open(url + f.searchtxt.value,"bbc_news","");
		w.focus();
	} else {
		alert("Please enter a term to search for.");
	}
}

function reefer() {
	var f = document.getElementById("searchform");
	if(validsearch(f)) {
		f.submit();
	} else {
		alert("Please enter a term to search for.");
	}
}

function validsearch(f) {
	if(!f.searchtxt.value) return false;
	return true;
}

function search() {
	var f = document.getElementById("searchform");
	if(validsearch(f)) return true;
	alert("Please enter a term to search for.");
	return false;
}

function report(theid) {
	var w = window.open("/viewreport.php?rowid=" + theid,"report","");
	w.focus();
}

function shipoptions(f) {
	var theship = f.rowid.value;
	var thepage = f.detailpage.value;
	if(thepage=='0') thepage = "";
	var thelocation = "http://www.reefertrends.com/shipdetails/" + theship + "/" + thepage;
	document.location.href = thelocation;
}

function statistics(f) {
	var w = window.open("http://www.reefertrends.com/viewstatistics.php?stat=" + f.statistic.value,"stats","location=0, status=0, width=1000, height=500, scrolling=1, scrolling=yes, scrollbars=1, scrollbars=yes");
	w.focus();
}