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"; 
 } 
}

function init() {
	externalLinks();
}
window.onload = init;

document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
};

function testContactForm(theForm) {
	var reqTextArray = document.getElementsByClassName("reqText");
	var reqTextCount = reqTextArray.length;
	
	document.getElementById("entryErrors").innerHTML = "";
	errorCount = 0;

	//Check Basic Required Fields (Text and Select)
	for (i=0;i<reqTextCount;i++) {
		if (reqTextArray[i].value == "") {
			reqTextArray[i].style.backgroundColor = "#FFCCCC";
			errorCount++;
		} else {
			reqTextArray[i].style.backgroundColor = "#ffffff";
		}
	}
	if ( theForm.cEmail.value == "" && theForm.cPhone.value == "" ) {
		theForm.cEmail.style.backgroundColor = "#FFCC99";
		theForm.cPhone.style.backgroundColor = "#FFCC99";
		errorCount++;
	} else {
		theForm.cEmail.style.backgroundColor = "#ffffff";
		theForm.cPhone.style.backgroundColor = "#ffffff";
	}
	if (errorCount > 0) {
		document.getElementById("entryErrors").innerHTML = "There " + (errorCount>1?"are":"is") + " " + errorCount + " field" + (errorCount>1?"s":"") + " that need" + (errorCount>1?"":"s") + " correcting. Please fill out all fields correctly.";
		return false;
	}
	else {
		return true;
	}

}
