// JavaScript Document

function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
	}
}

function addGaLinkTracking(base)
{
    var makeLinkCallback = function(url) {
	return function(event) {
		var trackUrl = '/' + base + '?' + url;
	    pageTracker._trackPageview(trackUrl);
	};
    };
    // if a link matches this, we don't add onclick (NB, will pick up mailto:s)
    hostRE = new RegExp("^(https?|ftp)://"+window.location.host+"/");
    for (var i=0; i<document.links.length; i++) {
	var a = document.links[i];
	if (a.href && ! a.onclick && ! hostRE.test(a.href)) {
	    // Must use a helper function to get separate closures for a.href
	    a.onclick = makeLinkCallback(a.href);
	}
    }
}

function addGaEmailTracking(base)
{
    var makeLinkCallback = function(url) {
	return function(event) {
		var trackUrl = '/' + base + '?' + url;
//		window.confirm("Tracking this link as: " + trackUrl);
	    pageTracker._trackPageview(trackUrl);
	};
    };
    // if a link matches this, we don't add onclick (NB, will pick up mailto:s)
    hostRE = new RegExp("^(mailto)");
    for (var i=0; i<document.links.length; i++) {
	var a = document.links[i];
	if (a.href && ! a.onclick && hostRE.test(a.href)) {
	    // Must use a helper function to get separate closures for a.href
	    a.onclick = makeLinkCallback(a.href);
	}
    }
}
