function initNav(){
    if ( document.getElementById ){
		if (document.getElementById('subnav')){
			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);
				if (unescape(currenthref)==unescape(currentloc) || unescape(currenthref)+"/"==unescape(currentloc)){
					subnavas[a].className="current";  
					break;
				}
			}
		}
	}
	if (document.getElementById("printable")) initPrintable();
}

function initPrintable(){
	var p = 	document.getElementById("printable");
	addAnEvent(p,'click',popPrint);
}

function popPrint(){
	var sProperties = "scrollbars=1,status=0,menubar=1,location=0,toolbar=1, resizable";
        
	oPrintWindow = window.open (this.href,"printWindow",sProperties);
	oPrintWindow.focus ();
	return false;	
}

window.onload=initNav;

function popwi(page){
	    var sProperties = "";
    
		sProperties += "scrollbars=1,";
		sProperties += "width=400,";
		sProperties += "height=530,";
		sProperties += "status=0,";
		sProperties += "menubar=0,";
		sProperties += "location=0,";
		sProperties += "toolbar=0,";
		sProperties += "screenX=0,";
		sProperties += "screenY=0,";
		sProperties += "left=0,";
		sProperties += "top=0, resizable";
        
		oFormWindow = window.open (page,"formWindow",sProperties);
		oFormWindow.focus ();
        
}

function addAnEvent( target, eventName, functionName){
        eval('target.on'+eventName+'=functionName');
}

// PopUp window for email notice, passes variable for email address
function MyMail(sName)
{	sURL = "../inc/email_notice.htm?eMail=" + sName
	var selectWindow = window.open(sURL,"mywindow","left=200, top=150, width=400, height=315, resizable=no, scrollbars=no, menubar=no");
}

function manageLinks(event) {
	//alert(event.target.href);
	if ( !event )
    	{
        	event = window.event;
    	}
	var link = event.target ? event.target : event.srcElement;
	var url = link.href;
	//alert(url.indexOf("cwclaw.com"));
	if (url.indexOf("mailto:") == -1 || url.indexOf("cwclaw.com") == -1 ){

		return true;
	}else {
		sURL = "../inc/email_notice.htm?eMail=" + url.substr(7)
		var selectWindow = window.open(sURL,"mywindow","left=200, top=150, width=400, height=315, resizable=no, scrollbars=no, menubar=no");
		return false;
	}
	
}

document.onclick=manageLinks;
