//wtpdf.js// 06Feb2007 by Darren Semotiuk// with plenty of reusable code in case anything similar (not necessarily PDF files, not necessarily this exact WT function, etc.) is ever needed again.// 15Feb2007 -- modified so it returns only the *relative* path (i.e. "http://agapps16.agric.gov.ab.ca/$dept/dbfile.nsf/view/dockey/file.pdf?OpenElement&parm1=value1#anchorX" returns "$dept/dbfile.nsf/view/dockey/file.pdf")// 18Jul2007 -- no longer a "Page", now a "Javascript Script Library" to prevent IBM WebSEAL's annoying problem with inserting the SCRIPT tag doc.cookie=... into HTML pages >:(function getAnchorLabel(o){return !o?"":o.textContent?o.textContent:o.innerText?o.innerText:o.innerHTML?o.innerHTML:"";};function getAnchorPathMinusParms(o,bFullPath){	if(!o || !o.href)return "";	var rv=o.href;	if(!bFullPath && o.hostname!="")rv=rv.substring(o.href.indexOf(o.hostname)+o.hostname.length+1); //default is relative path only	rv=rv.replace(/\'/g,"\\\'");	return !o.search?rv:rv.substring(0,rv.indexOf(o.search));};function getAnchorFullPathMinusParms(o){	return getAnchorPathMinusParms(o,true);};function getExtension(strFilename,bForceLowerCase){	if(!strFilename)return "";	var intLoc=strFilename.replace(/\\/g,"/").lastIndexOf("/");	strFilename=intLoc!=-1?strFilename.substring(intLoc+1):strFilename;	intLoc=strFilename.indexOf(".");	var rv=intLoc!=-1?strFilename.substring(intLoc+1):"";	return !bForceLowerCase?rv:rv.toLowerCase();};function addClickEvent(strExtension,bCaseSensitive,intAction){	if(!strExtension)strExtension="pdf";	if(!intAction)intAction=1;	if(!bCaseSensitive)strExtension=strExtension.toLowerCase();	var dl=document.links;	var o;	var strFormula="";	var strFullPathMinusParms="";	for(var i=0;i<dl.length;i++)	{		o=dl[i];		if(getExtension(o.pathname,!bCaseSensitive)==strExtension)		{			switch(intAction)			{			case 1:				strFormula=!self.dcsMultiTrack?"":("function(){dcsMultiTrack('DCS.dcsuri', '" + getAnchorPathMinusParms(o) + "', 'WT.ti', '" + getAnchorLabel(o).replace(/\'/g,"\\\'") + "');};");				break;			default:				strFormula="";				break;			};			if(strFormula)eval("o.onclick=" + strFormula);		};	};};function initPDFs(){addClickEvent("pdf",false,1);};setTimeout("initPDFs()",50);
