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"; 
		}
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "appendix") {
			anchor.target = "_blank"; 
		}
	} 
} 
window.onload = externalLinks;

function checkContactForm() {
	var errors = '';
	var validname     = /^([a-zA-Z\-'])+ *([a-zA-Z\- '])*$/;
	var validemail    = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var oMyForm = document.contactform;
	
	if(!validname.test(oMyForm.name.value))
		errors += 'Type your name\n';
	if(!validemail.test(oMyForm.email.value))
		errors += 'Provide a valid email address\n';
	if(oMyForm.subject.value == '')
		errors += 'Provide a message subject\n';
	if(oMyForm.message.value == '')
		errors += 'Type a message\n';
	if (errors){alert('Errors on the Form\n---------------------------------------------------\n'+errors);}
	else{oMyForm.submit();}
}

function checkJoinForm() {
	var errors = '';
	var validemail    = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var validname     = /^([a-zA-Z\-'])+ *([a-zA-Z\- '])*$/;
	var validurl      = /^http:\/\/[a-zA-Z0-9\.\- \/]{8,}$/;
	var validphone    = /^[\d ]{10,}$/;
	var oMyForm = document.joinform;
	
	if(!validname.test(oMyForm.name.value))
		errors += 'Type your name\n';
	if(!validurl.test(oMyForm.url.value) && oMyForm.url.value != '')
		errors += 'Type a valid web address including http:// or completely empty the website text box\n';
	if(!validemail.test(oMyForm.email.value))
		errors += 'Provide a valid email address\n';
	if(!validphone.test(oMyForm.tel.value))
		errors += 'Provide a valid telephone number\n';
	if (errors){alert('Errors on the Form\n---------------------------------------------------\n'+errors);}
	else{oMyForm.submit();}
}