/* GENERAL FUNCTIONS
-----------------------------------------------------*/

function classRows() {
	var myTABLES = document.getElementsByTagName('tbody');	//Only cycle through rows in the table body
	for (var x=0;x<myTABLES.length;x++) {
	   var myTR = myTABLES[x].getElementsByTagName('tr');
	   for (var i=0;i<myTR.length;i++) {
		   if (myTR[i].className == '') {		//Only add a class if there isn't already a class
			   if (i%2) {
				   myTR[i].className = 'even';	//Add even class to even rows
			   } else {
				   myTR[i].className = 'odd';	//Add odd class to odd rows
			   }
		   }
	   }
	}
}

function classAnchors() {
	var externalFiles = new Array('doc', 'pdf', 'jpg');
	var myANCHORS = document.getElementsByTagName('a');
	var baseHREF = document.getElementsByTagName('base')[0].href;
	for (var i=0;i<myANCHORS.length;i++) {
		var k=0;
		for(var k=0;k<externalFiles.length;k++){
			if (myANCHORS[i].getAttribute('href').slice(-3) == externalFiles[k] || (myANCHORS[i].getAttribute('href').slice(0,4) == 'http' && myANCHORS[i].getAttribute('href').slice(0,baseHREF.length) != baseHREF)) {	
				myANCHORS[i].target = '_blank';
			}
		}
	}
}

function Validator(theForm){
  if (theForm.name.value == "") {
    alert("Please enter your name below.");
    theForm.name.focus();
    return false;
  }

  if (theForm.email.value == "") {
    alert("Please enter your e-mail below.");
    theForm.email.focus();
    return false;
  }

  if (theForm.message.value == "") {
    alert("Please enter a message below.");
    theForm.message.focus();
    return false;
  }
  return true;
}

window.onload=function(){
	classAnchors();
	classRows();
}
