function initSubnav(){
	var subnav = document.getElementById('subnav');
	var subnavas = subnav.getElementsByTagName('a');
	for (var a=0; a<subnavas.length; a++){
		var currenthref=String(subnavas[a].href);
		var currentloc=String(document.location);
		currentloc = currentloc.split("#");
		currentloc = currentloc[0];
		if (unescape(currenthref)==unescape(currentloc)){
			subnavas[a].className="current"
		}
	}
}

function initLinks(){
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();
	var a = document.getElementsByTagName("a");	
	this.check = function(obj){
		var href = obj.href.toLowerCase();
		return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false;				
	};
	this.set = function(obj){
		obj.target = "_blank";
		obj.className += " external";
		obj.title += "This link will open in a new window.";
	};
	this.checkpdf = function(obj){
		var href = obj.href.toLowerCase();
		return (href.indexOf("pdf")!=-1) ? true : false;				
	};
	this.setpdf = function(obj){
		obj.target = "_blank";
		obj.className += " pdf";
		obj.title += "This PDF will open in a new window.";
	};
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
		if(checkpdf(a[i])) setpdf(a[i]);
	};
};

function siteEmail(user){
	var hostname = "piedmonthighboosters.org";
	document.write("<a href=" + "mail" + "to:" + user + "@" + hostname + ">" + user + "@" + hostname + "</a>")
}

function addAnEvent(target, eventName, functionName){
	eval('target.on'+eventName+'=functionName');
}

function initPage(){
	if (document.getElementById){
		if (document.getElementById("subnav")) initSubnav();
		initLinks();
	}
}

window.onload=initPage;