//	This javascript tags file downloads and external links in Google Analytics.
//	You need to be using the Google Analytics New Tracking Code (ga.js) 
//	for this script to work.
//	To use, place this file on all pages just above the Google Analytics tracking code.
//	All outbound links and links to non-html files should now be automatically tracked.
//
//	This script has been provided by Goodwebpractices.com
//	Thanks to ShoreTel, MerryMan and Colm McBarron
//
//	www.goodwebpractices.com
//	VKI has made changes as indicated below.								

if ( _proxy_jslib_handle(document, 'getElementsByTagName', '', 0, 0)) {
        // Initialize external link handlers
        var hrefs =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)("a");
        for (var l = 0; l < hrefs.length; l++) {
				// try {} catch{} block added by erikvold VKI
			try{
	                //protocol, host, hostname, port, pathname, search, hash
	                if ( _proxy_jslib_handle( _proxy_jslib_handle(hrefs, (l), '', 0, 0), 'protocol', '', 0, 0) == "mailto:") {
	                        startListening( _proxy_jslib_handle(hrefs, (l), '', 0, 0),"click",trackMailto);
	                } else if ( _proxy_jslib_handle( _proxy_jslib_handle(hrefs, (l), '', 0, 0), 'hostname', '', 0, 0) ==  _proxy_jslib_handle( _proxy_jslib_handle(null, 'location', location, 0, 0), 'host', '', 0, 0)) {
	                        var path =  _proxy_jslib_handle( _proxy_jslib_handle(hrefs, (l), '', 0, 0), 'pathname', '', 0, 0) +  _proxy_jslib_handle( _proxy_jslib_handle(hrefs, (l), '', 0, 0), 'search', '', 0, 0);
							var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|\&|\?)/);
	                        if (isDoc) {
	                                startListening( _proxy_jslib_handle(hrefs, (l), '', 0, 0),"click",trackExternalLinks);
	                        }
	                } else {
	                        startListening( _proxy_jslib_handle(hrefs, (l), '', 0, 0),"click",trackExternalLinks);
	                }
			}
			catch(e){
					continue;
			}
        }
}

function startListening (obj,evnt,func) {
        if (obj.addEventListener) {
                obj.addEventListener(evnt,func,false);
        } else if (obj.attachEvent) {
                obj.attachEvent("on" + evnt,func);
        }
}

function trackMailto (evnt) {
        var href = (evnt.srcElement) ?  _proxy_jslib_handle(evnt.srcElement, 'href', '', 0, 0) :  _proxy_jslib_handle(this, 'href', '', 0, 0);
        var mailto = "/mailto/" +  _proxy_jslib_handle(null, 'href', href, 0, 0).substring(7);
        if (typeof(pageTracker) == "object") pageTracker._trackPageview(mailto);
}

function trackExternalLinks (evnt) {
        var e = (evnt.srcElement) ? evnt.srcElement : this;
        while (e.tagName != "A") {
                e = e.parentNode;
        }
        var lnk = ( _proxy_jslib_handle(e, 'pathname', '', 0, 0).charAt(0) == "/") ?  _proxy_jslib_handle(e, 'pathname', '', 0, 0) : "/" +  _proxy_jslib_handle(e, 'pathname', '', 0, 0);
        if ( _proxy_jslib_handle(e, 'search', '', 0, 0) &&  _proxy_jslib_handle(e, 'pathname', '', 0, 0).indexOf( _proxy_jslib_handle(e, 'search', '', 0, 0)) == -1) lnk +=  _proxy_jslib_handle(e, 'search', '', 0, 0);
        if ( _proxy_jslib_handle(e, 'hostname', '', 0, 0) !=  _proxy_jslib_handle( _proxy_jslib_handle(null, 'location', location, 0, 0), 'host', '', 0, 0)) lnk = "/external/" +  _proxy_jslib_handle(e, 'hostname', '', 0, 0) + lnk;
        if (typeof(pageTracker) == "object") pageTracker._trackPageview(lnk); 
} ;
_proxy_jslib_flush_write_buffers() ;