/*********************************
// Version 3.6
// last edited 11/2/09 by adr
*********************************/


/*********************************
Global variables
*********************************/
var prefsLoaded = false;
var str_current_layout = 'fixed';
var str_current_fontsize = '100%';
var int_stylerule_count = 0;

/* adr 12/3/07 */

if (str_new_template == null) {
	var str_new_template = 'false';
}


/*********************************
Adapted scripts
*********************************/

/*	
	dynamicCSS.js v1.0 <http://www.bobbyvandersluis.com/articles/dynamicCSS.php>
	Copyright 2005 Bobby van der Sluis
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/
function createStyleRule(selector, declaration) {

	if (!document.getElementsByTagName || !(document.createElement || document.createElementNS)) return;
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_iewin = (is_ie && (agt.indexOf("win") != -1));
	var is_iemac = (is_ie && (agt.indexOf("mac") != -1));
	if (is_iemac) return; // script doesn't work properly in IE/Mac
	var head = document.getElementsByTagName("head")[0]; 
	var style = (typeof document.createElementNS != "undefined") ?  document.createElementNS("http://www.w3.org/1999/xhtml", "style") : document.createElement("style");
	if (!is_iewin) {
		var styleRule = document.createTextNode(selector + " {" + declaration + "}");
		style.appendChild(styleRule); // bugs in IE/Win
	}
	style.setAttribute("type", "text/css");
	style.setAttribute("media", "screen"); 
	head.appendChild(style);
	if (is_iewin && document.styleSheets && document.styleSheets.length > 0) {
		var lastStyle = document.styleSheets[document.styleSheets.length - 1];
		if (typeof lastStyle.addRule == "object") { // bugs in IE/Mac and Safari
			lastStyle.addRule(selector, declaration);
		}
	}
	int_stylerule_count = int_stylerule_count + 1;
}


/*	
	Save layout and font size to cookies
*/
function saveSettings()
{
  createCookie("layout", str_current_layout, 365);
  createCookie("fontsize", str_current_fontsize, 365);
   // credit: adapted from http://arstechnica.com/Templates/ArsTechnica/uiTools.js
}


//Style Sheet Switcher version 1.0 Nov 9th, 2005
//Author: Dynamic Drive: http://www.dynamicdrive.com
//Usage terms: http://www.dynamicdrive.com/notice.htm
function setStylesheet(title) {
	var i, cacheobj
	for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
		if(cacheobj.getAttribute("rel").indexOf("style") != -1 && cacheobj.getAttribute("title")) {
		cacheobj.disabled = true
		if(cacheobj.getAttribute("title") == title)
			cacheobj.disabled = false //enable chosen style sheet
		}
	}
}


/*	
	Save layout and font size to cookies
*/
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
  // credit: http://www.alistapart.com/d/alternate/styleswitcher.js
}


/*	
	Cookie management
*/
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
  // credit: http://www.alistapart.com/d/alternate/styleswitcher.js
}

/* Project 7 */
/* 
  ------------------------------------------------
  PopMenu Magic menu scripts
  Copyright (c) 2004-2006 Project Seven Development
  www.projectseven.com
  Version: 1.0.4
  ------------------------------------------------
*/
var p7PMp,p7PMct;
function P7_setPM(){ //v1.0.4 by PVII-www.projectseven.com
 var i,d='',h="<sty"+"le type=\"text/css\">",tA=navigator.userAgent.toLowerCase();if(window.opera){
 if(tA.indexOf("opera 5")>-1||tA.indexOf("opera 6")>-1){return;}}if(document.getElementById){
 for(i=1;i<20;i++){d+='ul ';h+="\n#p7PMnav "+d+"{position:absolute;left:-9000px;}";}
 document.write(h+"\n<"+"/sty"+"le>");}}P7_setPM();
function P7_initPM(){ //v1.0 by PVII-www.projectseven.com
 var i,g,tD,tA,tU,pp,lvl,ev,tn=navigator.userAgent.toLowerCase();if(window.opera){
 if(tn.indexOf("opera 5")>-1||tn.indexOf("opera 6")>-1){return;}}else if(!document.getElementById){return;}
 p7PMp=arguments;p7PMct=new Array;tD=document.getElementById('p7PMnav');if(tD){tA=tD.getElementsByTagName('A');
 for(i=0;i<tA.length;i++){tA[i].p7PMcl=p7PMct.length;p7PMct[p7PMct.length]=tA[i];g=tA[i].parentNode.getElementsByTagName("UL");
 tA[i].p7PMsub=(g&&g[0])?g[0]:false;ev=tA[i].getAttribute("onmouseover");if(!ev||ev=='undefined'){tA[i].onmouseover=function(){
 P7_PMtrig(this);};}ev=tA[i].getAttribute("onfocus");if(!ev||ev=='undefined'){tA[i].onfocus=function(){P7_PMtrig(this);};}
 if(tA[i].p7PMsub){pp=tA[i].parentNode;lvl=0;while(pp){if(pp.tagName&&pp.tagName=="UL"){lvl++;}pp=pp.parentNode;}
 tA[i].p7PMlv=lvl;}}tD.onmouseout=P7_PMclose;P7_PMopen();}
}
function P7_PMtrig(a){ //v1.0.4 by PVII-www.projectseven.com
 var b,t;if(document.p7PMt){clearTimeout(document.p7PMt);}document.p7PMa=1;b=(a.p7PMsub)?'P7_PMshow(':'P7_PMtg(';
// t='document.p7PMt=setTimeout("'+b+a.p7PMcl+')",160)';eval (t);
 t='document.p7PMt=setTimeout("'+b+a.p7PMcl+')",0)';eval (t);
}
function P7_PMshow(a,bp){ //v1.0.4 by PVII-www.projectseven.com
 var u,lv,oft,ofr,uw,uh,pp,aw,ah,adj,mR,mT,wW=0,wH,w1,w2,w3,sct,pw,lc,pwv,xx=0,yy=0,wP=true;
 var iem=(navigator.appVersion.indexOf("MSIE 5")>-1)?true:false,dce=document.documentElement,dby=document.body;document.p7PMa=1;
 if(!bp){P7_PMtg(a);}u=p7PMct[a].p7PMsub;if(u.p7pmax&&u.p7pmax==1){return;}u.p7pmax=1;lv=(p7PMp[0]==1&&p7PMct[a].p7PMlv==1)?true:false;
 p7PMct[a].className=p7PMct[a].className.replace("p7PMtrg","p7PMon");oft=parseInt(p7PMp[3]);ofr=parseInt(p7PMp[4]);
 uw=u.offsetWidth;uh=u.offsetHeight;pp=p7PMct[a];aw=pp.offsetWidth;ah=pp.offsetHeight;while(pp){xx+=(pp.offsetLeft)?pp.offsetLeft:0;
 yy+=(pp.offsetTop)?pp.offsetTop:0;if(window.opera||navigator.userAgent.indexOf("Safari")>-1){
 if(p7PMct[a].p7PMlv!=1&&pp.nodeName=="BODY"){yy-=(pp.offsetTop)?pp.offsetTop:0;}}pp=pp.offsetParent;}
 if(iem&&navigator.userAgent.indexOf("Mac")>-1){yy+=parseInt(dby.currentStyle.marginTop);}adj=parseInt((aw*ofr)/100);mR=(lv)?0:aw-adj;
 adj=parseInt((ah*oft)/100);mT=(lv)?0:(ah-adj)*-1;w3=dby.parentNode.scrollLeft;if(!w3){w3=dby.scrollLeft;}w3=(w3)?w3:0;
 if(dce&&dce.clientWidth){wW=dce.clientWidth+w3;}else if(dby){wW=dby.clientWidth+w3;}if(!wW){wW=0;wP=false;}wH=window.innerHeight;
 if(!wH){wH=dce.clientHeight;if(!wH||wH<=0){wH=dby.clientHeight;}}sct=dby.parentNode.scrollTop;if(!sct){sct=dby.scrollTop;if(!sct){
 sct=window.scrollY?window.scrollY:0;}}pw=xx+mR+uw;if(pw>wW&&wP){mR=uw*-1;mR+=10;if(lv){mR=(wW-xx)-uw;}}lc=xx+mR;if(lc<0){mR=xx*-1;}
 // AR 28jan08: deleted u.style.margin for proper submenu alignment
 //pw=yy+uh+ah+mT-sct;pwv=wH-pw;if(pwv<0){mT+=pwv;if(uh>wH){mT=(yy+ah-sct)*-1;}}u.style.marginLeft=mR+'px';u.style.marginTop=mT+'px';
 pw=yy+uh+ah+mT-sct;pwv=wH-pw;if(pwv<0){mT+=pwv;if(uh>wH){mT=(yy+ah-sct)*-1;}};
 if(p7PMp[2]==1){if(!iem){P7_PManim(a,20);}}u.className="p7PMshow";
}
function P7_PMhide(u){ //v1.0.4 by PVII-www.projectseven.com
 var i,tt,ua;u.p7pmax=0;u.className="p7PMhide";ua=u.parentNode.firstChild;ua.className=ua.className.replace("p7PMon","p7PMtrg");
}
function P7_PMtg(a,b){ //v1.0.4 alpha by PVII-www.projectseven.com
 var i,u,tA,tU,pp;tA=p7PMct[a];pp=tA.parentNode;while(pp){if(pp.tagName=="UL"){break;}pp=pp.parentNode;}if(pp){
 tU=pp.getElementsByTagName("UL");for(i=tU.length-1;i>-1;i--){if(b!=1&&tA.p7PMsub==tU[i]){continue;}else{P7_PMhide(tU[i]);}}}
}
function P7_PMclose(evt){ //v1.0.4 by PVII-www.projectseven.com
 var pp,st,tS,m=true;evt=(evt)?evt:((event)?event:null);st=document.p7PMa;if(st!=-1){if(evt){
 tS=(evt.relatedTarget)?evt.relatedTarget:evt.toElement;if(tS){pp=tS.parentNode;while(pp){if(pp&&pp.id&&pp.id=="p7PMnav"){m=false;
 document.p7PMa=1;break;}pp=pp.parentNode;}}if(m){document.p7PMa=-1;if(document.p7PMt){clearTimeout(document.p7PMt);}
// document.p7PMt=setTimeout("P7_PMclr()",360);}}}
 document.p7PMt=setTimeout("P7_PMclr()",0);}}}
}
function P7_PMclr(){ //v1.0.4 by PVII-www.projectseven.com
 var i,tU,tUU;document.p7PMa=-1;tU=document.getElementById('p7PMnav');if(tU){tUU=tU.getElementsByTagName("UL");if(tUU){
 for(i=tUU.length-1;i>-1;i--){P7_PMhide(tUU[i]);}}}
}
function P7_PManim(a,st){ //v1.0.4 by PVII-www.projectseven.com
 var g=p7PMct[a].p7PMsub,sp=30,inc=20;st=(st>=100)?100:st;g.style.fontSize=st+"%";if(st<100){st+=inc;setTimeout("P7_PManim("+a+","+st+")",sp);}
}
function P7_PMmark(){document.p7PMop=arguments;}
function P7_PMopen(){ //v1.0.4 by PVII-www.projectseven.com
 var i,x,tA,op,pp,wH,tA,aU,r1,k=-1,kk=-1,mt=new Array(1,'','');if(document.p7PMop){mt=document.p7PMop;}op=mt[0];if(op<1){return;}
 tA=document.getElementById('p7PMnav').getElementsByTagName("A");wH=window.location.href;r1=/index\.[\S]*/i;for(i=0;i<tA.length;i++){
 if(tA[i].href){aU=tA[i].href.replace(r1,'');if(op>0){if(tA[i].href==wH||aU==wH){k=i;kk=-1;break;}}if(op==2){if(tA[i].firstChild){
 if(tA[i].firstChild.nodeValue==mt[1]){kk=i;}}}if(op==3 && tA[i].href.indexOf(mt[1])>-1){kk=i;}if(op==4){for(x=1;x<mt.length;x+=2){
 if(wH.indexOf(mt[x])>-1){if(tA[i].firstChild&&tA[i].firstChild.data){if(tA[i].firstChild.data==mt[x+1]){kk=i;break;}}}}}}}k=(kk>k)?kk:k;
 if(k>-1){pp=tA[k].parentNode;while(pp){if(pp.nodeName=="LI"){pp.firstChild.className="p7PMmark"+" "+pp.firstChild.className;}
 pp=pp.parentNode;}}if(kk>-1){document.p7PMad=1;}P7_PMadma();P7_PMadmb();
}
function P7_PMadma(){ //v1.0.4 by PVII-www.projectseven.com
 var s,ss,i,j,a,g,b,c,d,t,h,tA,b,tP,r1,r2,tI,bA,aA,tB=new Array(),bC='',x=0,ur=1,mt=document.p7PMad;g=document.getElementById("p7PMnav");
 b=document.getElementById("pmmcrumb");if(g&&b){c=b.getElementsByTagName("A");if(c&&c[0]){tP=c[0].parentNode.childNodes;r1=/<a/i;r2=/\/a>/i;
 tI=c[0].parentNode.innerHTML;j=tI.search(r1);bA=tI.substring(0,j);j=tI.search(r2);aA=tI.substring(j+3);bC+=(bA)?bA:'';s=(aA)?aA:' &gt ';
 if(!c[0].id||c[0].id!="pmmcn"){if(c[0].href!=window.location.href){tB[0]=c[0];x++;ur=2;}}tA=g.getElementsByTagName("A");for(i=0;i<tA.length;i++){
 if(tA[i].className.indexOf("p7PMmark")>-1){tB[x]=tA[i];x++;}}for(i=0;i<tB.length;i++){ss=(i>0)?s:'';a=(i==tB.length-1)?0:1;
 d=(i==0&&c[0].id)?'id="'+c[0].id+'" ':' ';t=tB[i].firstChild.nodeValue;if(a==1||mt==1||x<ur){bC+=ss+'<a '+d+'hr'+'ef="'+tB[i].href+'">'+t+'</a>';
 }else{bC+=ss+t;}}if(mt==1||i<ur){ss=(i>0)?s:'';bC+=ss+document.title;}c[0].parentNode.innerHTML=bC;}}
}
function P7_PMadmb(){ //v1.0.4 by PVII-www.projectseven.com
 var h='',g,i,tA,b,m=false;g=document.getElementById("p7PMnav");b=document.getElementById("pmmnext");if(g&&b){tA=g.getElementsByTagName("A");
 for(i=tA.length-1;i>-1;i--){if(tA[i].className.indexOf("p7PMmark")>-1){m=true;break;}}if(m){if(i<tA.length-1){i++;}else{i=0;}
 while(tA[i].href==window.location.href+"#"||tA[i].href=="javascript:;"){i++;if(i>tA.length-1){
 i=0;break;}}b.href=tA[i].href;b.innerHTML=tA[i].firstChild.nodeValue;}}	
}


/*********************************
Custom scripts
*********************************/


/*
Browser neutral object 
*/
function crossObject(str_element) {
    var obj_element = (document.getElementById) ? document.getElementById(str_element) : document.all(str_element);
    return obj_element;
}

/*
Change font size and save state
*/
function set_fontsize(str_fontsize) {
	// set size
   	obj_container = crossObject('container');
   	obj_container.style.fontSize = str_fontsize;
	// save for cookie
   	str_current_fontsize = str_fontsize;
	// reset underlining of 'A's in toolbar
	if (crossObject('sizexsmall') != undefined) {
		crossObject('sizexsmall').style.textDecoration = "none";
		crossObject('sizesmall').style.textDecoration = "none"; 
		crossObject('sizemedium').style.textDecoration = "none";
		crossObject('sizelarge').style.textDecoration = "none";
		crossObject('sizexlarge').style.textDecoration = "none";
		crossObject('smaller').style.textDecoration = "none";
		crossObject('larger').style.textDecoration = "none";
			if (str_fontsize == '80%') {
			crossObject('sizexsmall').style.textDecoration = "underline";
		}
		else if (str_fontsize == '90%') {
			crossObject('sizesmall').style.textDecoration = "underline";
		}
		else if (str_fontsize == '100%') {
			crossObject('sizemedium').style.textDecoration = "underline";
		}
		else if (str_fontsize == '110%') {
			crossObject('sizelarge').style.textDecoration = "underline";
		}
		else if (str_fontsize == '120%') {
			crossObject('sizexlarge').style.textDecoration = "underline";
		}
	}
   	return false;
}
function set_fontsize1(str_action) {
	if (str_action == 'decrease') {
		str_fontsize = str_current_fontsize.replace(/%$/,"");
		if (isNaN(str_fontsize)) {
			str_fontsize = '100';
		}
		str_fontsize = str_fontsize/1.1+'%';
 	} else if (str_action == 'increase') {
		str_fontsize = str_current_fontsize.replace(/%$/,"");
		if (isNaN(str_fontsize)) {
			str_fontsize = '100';
		}
		str_fontsize = str_fontsize*1.1+'%';
	}
 	set_fontsize(str_fontsize);
}
/*
Set style and save style to cookie
*/
function set_layout(str_layout) {
	if (str_layout == 'fixed') {
	//	setStylesheet('screen-fixed');
		setStylesheet('screen-fixed');
        obj_fixed = crossObject('fixed');
        //obj_fixed.style.display = 'inline';
        obj_fixed.style.display = 'list-item';
		
        obj_fluid = crossObject('fluid');
        obj_fluid.style.display = 'none';
	}
    else {
	//	setStylesheet('screen-fluid');
	
		setStylesheet('screen-fluid');
        obj_fixed = crossObject('fixed');
        obj_fixed.style.display = 'none';
		
        obj_fluid = crossObject('fluid');
    //    obj_fluid.style.display = 'inline';		
        obj_fluid.style.display = 'list-item';		
	}
    str_current_layout = str_layout;
	return false;
}


/*
Set style and change print/screen icon in toolbar if changing between print and screen
Does not save style to cookie
*/

function change_style(str_style, bol_save_state) {
	if (str_style == 'print') {
		setStylesheet('for-print');
	
        obj_screen = crossObject('screenstyle');
        obj_screen.style.display = 'inline';
	    //obj_screen.style.display = 'list-item';

        obj_print = crossObject('printerstyle');
        obj_print.style.display = 'none';

	}
	else {
		// fall back on save style
		setStylesheet('screen-'+str_current_layout);
	
        obj_screen = crossObject('screenstyle');
        obj_screen.style.display = 'none';
		
        obj_print = crossObject('printerstyle');
        obj_print.style.display = 'inline';
        //obj_print.style.display = 'list-item';
	}
	return false;
}


/*
Initial function called onload.  Read cookies, set display state (fixed/fluid, and font size) based on result.
Round corners and add menu for left hand navigation
*/
function setUserOptions(){
//	alert("setting options");
	// Read cookies, set display state (fixed/fluid, and font size) based on result.
	if(!prefsLoaded){
		cookie = readCookie("layout");
		str_current_layout = cookie ? cookie : 'fixed';
		var str_override_fixed_style = typeof bol_override_fixed_style;
		if (str_override_fixed_style == 'undefined') {
			//setStylesheet('screen-'+str_current_layout+'-TEST');
			// adr 12/6
			change_style('screenst');
			set_layout('fixed');
		} else {
			if (bol_override_fixed_style == true) {
				//setStylesheet('screen-fluid');
				setStylesheet('screen-fluid');
				set_layout('fluid');
			} else {
			//setStylesheet('screen-'+str_current_layout);
			setStylesheet('screen-fixed');
			set_layout('fixed');
			}
			change_style('screenst');
		}
		cookie = readCookie("fontsize");
		str_current_fontsize = cookie ? cookie : '100%';
		set_fontsize(str_current_fontsize);
		prefsLoaded = true;
	}
	// Round corners and add menu for left hand navigation
//	if (str_new_template != true) {
	if (str_new_template == false) {
		Nifty("div#header","transparent");
		Nifty("div#pageheader","transparent");
		Nifty("div#pagenav","transparent");
		Nifty("div#sidenav","transparent");
		Nifty("div.sidenav_currentarea","transparent");
		P7_initPM(1,0,0,-20,10);
	} else if (str_new_template == true) {
		Nifty("div#pageDescription","transparent");
		Nifty("div#itproPageDescription","transparent");
		Nifty("div#libraryPageDescription","transparent");
		Nifty("div.hot","transparent");
		Nifty("div#pagenav","transparent");
		Nifty("div.sidenav_currentarea","transparent"); 
		Nifty("div.infoBox","transparent");
		Nifty("*.roundcorners","transparent");
		P7_initPM(1,0,0,-20,10);
	
		//createStyleRule("#container", "visibility:visible;");	
	} else if (str_new_template == "frontpage") {
	
			Nifty("div#topTabs a","transparent bottom");
			Nifty("div#pageDescription","transparent");
			Nifty("div#itproPageDescription","transparent");
			Nifty("div#libraryPageDescription","transparent");
			Nifty("div.hot","transparent");
			Nifty("div#location_find","transparent");
			Nifty("div.infoBox","transparent");
			Nifty("*.roundcorners","transparent");
			P7_initPM(1,0,0,-20,10);

	} else if (str_new_template == "iteach") {
			P7_initPM(1,0,0,-20,10);
	} else {
		
		Nifty("div#header","transparent");
		Nifty("div#pageheader","transparent");
		Nifty("div#pagenav","transparent");
		Nifty("div#sidenav","transparent");
		Nifty("div.sidenav_currentarea","transparent");
		P7_initPM(1,0,0,-20,10);
	}
	
	//prepareLinksIn('current_menu');
	compactMenu('current_menu',true,oPl);
	//compactMenu('other_menu',true,oPl); 
	compactMenu('other_menu',true,oPl);
		
	if (typeof str_highlight_page != 'undefined') {
		selfLink('current_menu','thisPage',true, str_highlight_page);
	} else {
		if ((str_new_template != "frontpage") && (str_new_template != 'iteach')) {
			selfLink('current_menu','thisPage',true);
		}
	}
	// Set container back to visible
	//createStyleRule("#container", "visibility:visible;");
	// credit: adapted from http://arstechnica.com/Templates/ArsTechnica/uiTools.js

}


/* 
Handle error conditions.  Most Javascript on the page is used for formatting.  
One special case is the createStyleRule function, used to hide some jumpy content.  The problem is, however, if any
function throws an error, the page will stay invisible.  
Solution: Check to see if the page has been set to visible (int_stylerule_count < 2).  If not, turn it back on.
Errors will still be logged by the browser.
*/
function citesErrorHandler() {
	if (int_stylerule_count < 2) {
		createStyleRule("#container", "visibility:visible;");
		createStyleRule("#screen", "visibility:visible;");
	}
}



/*********************************
Window event handling
*********************************/

if (str_new_template != 'iteach') {
	if (navigator.userAgent.indexOf("Safari") == -1) {
		createStyleRule("#container", "visibility:hidden;");
		createStyleRule("#screen", "visibility:hidden;");
	}
	window.onload = setUserOptions;
	window.onunload = saveSettings;
	window.onerror = citesErrorHandler;
	createStyleRule("#container", "visibility:visible;");	
	createStyleRule("#screen", "visibility:visible;");	

}


/***********************************************
Link Tracker (for javascript events)
http://www.astoundingstories.com/lt/
************************************************/
// change the following to the place where you put the linktrack script.
var linktrack="/js/linktrack.php";


// make error proof
function lt_clicker(e) {
  try {
    lt_do_clicker(e);
  } catch (err) {
     //alert("error "+err);
     return true;
  }
  return true;
}
function lt_do_clicker(e) {
  // Restrict tracking to a handful of functions
  if ((!e.target.id.match(/\w+er\b/))&&(!e.target.id.match(/\w+style\b/))&&(!e.target.id.match('fixed'))&&(!e.target.id.match('fluid'))) return true;
  // this grabs the link and redirects it to the php site.
  var lt_target = null;
  if (e != null) { 
     lt_target = e.target;
  } else {
     lt_target = window.event.srcElement;
  }
  // move on to our next site

  if (lt_target==null) return true; // can't track a link that doesn't exist
  if (lt_target.nodeName.toUpperCase() != 'A') return true; // don't want to track anything but links.
  if (lt_target.href==null) return true; // if we aren't going anywhere don't track
  var lt_href=lt_target.href;
  var lt_atext="";
  if (lt_target.innerText!=null) {
     lt_atext=lt_target.innerText;
  } else if (lt_target.innerHTML!=null) {
     lt_atext=lt_target.innerHTML;
  } else if (lt_target.text!=null) {
     lt_atext=lt_target.text;
  } else {
    return true; // can't track a link with no description
  }
  if(lt_href==null||lt_atext==null) return true; // once more with feeling.
  if(typeof(lt_href) != 'string') return true;  // not sure what else it could be, except an image.
  // see if the link is off the page
  var lt_host = document.location.hostname.toLowerCase();
  if (lt_host==null||lt_host=="") lt_host="hey hey";

  lt_atext = escape(lt_atext);
  // we have a link. We have to mess with it.
  // it seems the best way to do this is to create a new image, but you can use an iframe
  
  // create the ref to the new image
     var lt_newurl=linktrack+"?ATEXT="+lt_atext;

  try{ // put it in a try/next to avoid http errors
    var lt_newimg = new Image();
    lt_newimg.src = lt_newurl;
  }catch(err){ 
    return true; 
  }
  return true; // let link do his job 
}

// direct code that is executed immediately
    document.onclick=lt_clicker; // this directs links to our code 
// end of link tracking
