// Function opens link in new window
//
function openInNewWindow(address) {
var newWindow = window.open(address, 'newWindow');
newWindow.focus();
return false;
}

// Function checks for mandatory fields in form
//
function frmChecker() {
	var frm; frm=document.normalForm; 
	if (frm.name.value == "") { 
		alert("Please enter your name."); 
		frm.name.focus(); return false; 	
	}
	if (frm.email.value == "") { 
		alert("Please enter your e-mail address."); 
		frm.email.focus(); return false; 	
	}
	if (frm.message.value == "") { 
		alert("Please enter a message."); 
		frm.message.focus(); return false; 
	}
	for (i=0, n=frm.subject.length; i<n; i++) {
		if(frm.subject[i].checked) {
			var checkvalue = "true";
			break;
		}
	}
	if (checkvalue != "true") { 
		alert("Please select a reason for contacting us."); 
		return false; 
	}
	return true 
} 

// Function runs on window load, going through link tags looking for rel="external".
// These links receive onclick events that cause the link to open in a new window.
//
function initLinker()
{
	
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName("a");

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "external")){
			anchor.onclick = function () {openInNewWindow(this.getAttribute("href")); return false;}
		}
	}
}
function initForm() {
	if(pageForm = document.getElementById('normalForm')) {
		pageForm.onsubmit = function() { return frmChecker(); }
	}
}
//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}


addLoadEvent(initLinker);	// run initLinker onLoad
addLoadEvent(initForm);	// run initForm onLoad
