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;// JavaScript Document

//Check email

function validEmail(email) {
	invalidChars = "/:,;";
	
	if (email == "") {
		return false;
	}
	
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0)>-1) { 
			return false;
		}
	}
	atPos = email.indexOf("@",1);
	if (atPos == -1) {	
		return false;
	}
	
	if (email.indexOf("@",atPos+1)>-1) {
		return false;
	}
	
	periodPos = email.indexOf(".",atPos);
	if (periodPos == -1) {
		return false;
	}
	
	if (periodPos+3 > email.length) {
		return false;
	}
		return true;
}

//Check number
	
function isNum(passedVal) {
		if (passedVal == "") {
			return false;
		}
		for (i=0; i<passedVal.length; i++) {
			if (passedVal.charAt(i) == " ") {
				return true;
			}
			if (passedVal.charAt(i) < "0") { 
				return false;
			}
			if (passedVal.charAt(i) > "9") {
				return false;
			}
		}
	return true;
}


function validate_contact(frm) {
	if (frm.name.value == "") { 
		alert("Please enter your Name");
		frm.name.focus();
		return false;
	}
	if (frm.phone.value == "") { 
		alert("Please enter your Phone Number");
		frm.name.focus();
		return false;
	}
	//Check Email is filled in			
	if (frm.email.value == "") { 
		alert("You must enter your Email Address");
		frm.email.focus();
		return false;		
	}
	//Check email is valid
	if(!validEmail(frm.email.value)) { 
		alert("You must enter a valid E-mail Address");
		frm.email.focus();
		return false;		
	}
	if (frm.position.value == "") { 
		alert("Please enter your Company Role");
		frm.position.focus();
		return false;
	}
	if (frm.address.value == "") { 
		alert("Please enter your company name and address");
		frm.address.focus();
		return false;
	}
	if (frm.comments.value == "") { 
		alert("Please enter your Enquiry");
		frm.comments.focus();
		return false;
	}
	return true;				
}


function generateAuth(frm, key) {
	frm.authKey.value = key;
}