/* ============================================================================
Function for adding surfAid tracking functions to all PDF links.

This function should be linked in all v16 UK IT Manager pages via the following
include file:
  ./itsolutions/ssi/head_itsolutions.shtml

Sample usage:
  <a href="sample_asset.pdf" rel="pdf">sample text</a>
============================================================================ */

function rel_download()
{
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++)
  {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "download-cw" || anchor.getAttribute("rel") == "download-nw"))
	{
      if(anchor.addEventListener)
	  { // non-IE code
	    anchor.addEventListener("click",function (e) {sa_onclick(this.href);},true);
		anchor.addEventListener("keypress",function (e) {sa_onclick(this.href);},true);
	  }
	  else if(anchor.attachEvent)
	  { // IE code
		anchor.onclick = function(){sa_onclick(this.href);};
		anchor.onkeypress = function(){sa_onclick(this.href);};
	  }
	  if(anchor.getAttribute("rel") == "download-nw") anchor.target="_blank";
	}
  }
}

if(window.addEventListener)
{ // non-IE code
  window.addEventListener("load",rel_download,true);
}
else if(window.attachEvent)
{ // IE code
  window.attachEvent("onload",rel_download);
}