// Class Anchor
window.anchor = function(a){
  
    this.adId = null;
    this.anchor = a;
    this.url = null;
    //this.redirector_url = "http://68.194.209.11:7755/adlink/adrun/redirector/showad";
    this.redirector_url = "http://adlet.druplet.com:80/redirector/showad";
    
    if ( this.anchor.getAttribute("pubid") )
    {
      this.adId = a.getAttribute("pubid");
      this.url = this.redirector_url + "?pubid=" + a.getAttribute("pubid") + "&finalDestination="+ escape(a.getAttribute("href"));
      //a.setAttribute("href", this.url);
      if ( a.addEventListener ){ // All but IE
         a.addEventListener("click",function gothere(e)
                                  {
                                      if ( e.srcElement )
                                      {
                                          var obj = window.adlinks[e.srcElement];
                                        	if(e.stopPropagation)
                                        	  e.stopPropagation();
                                        	if(e.preventDefault)
                                        	  e.preventDefault();
                                        	e.cancelBubble = true;
                                        	e.cancel = true;
                                        	e.returnValue = false;
                                          window.location = obj.url;
                                      }
                                      return false;
                                  },false);
      }
      else{
         a.attachEvent("onclick",function gothere(e)
                                  {
                                      if ( e.srcElement )
                                      {
                                          var obj = window.adlinks[e.srcElement];
                                        	if(e.stopPropagation)
                                        	  e.stopPropagation();
                                        	if(e.preventDefault)
                                        	  e.preventDefault();
                                        	e.cancelBubble = true;
                                        	e.cancel = true;
                                        	e.returnValue = false;
                                          window.location = obj.url;
                                      }
                                      return false;
                                  }
                      );
      }
    }
          
}
    
// Locate all anchors
var anchors=document.getElementsByTagName("A");

// Create new anchor objects based on native HTML anchors
window.adlinks = new Object();

if ( anchors.length != 0 )
{
	var n=anchors.length;
	for ( var i=0; i < n; i++)
	{
	   window.adlinks[anchors[i]] = new window.anchor(anchors[i]);
	}
}
