BITracer=function(intTimeout,blnPmkInError,strPathCounter){this.pmkForm=false;this.intTimeout=intTimeout;this.link=null;this.curTimeout=null;if((strPathCounter!='')&&(strPathCounter!=null)&&(strPathCounter!='undefined')){this.pathCounter=strPathCounter;}else{this.pathCounter='http://adimg.alice.it/tracks/bi/images/kpi.gif';};this.debugBI=this.getUrlParameter("debugBI");this.pathGo="http://go.alice.it";this.blnPmkInError=blnPmkInError;this.formLink=location.host;}
BITracer.prototype={callBIGif:function(objLink,blnGo,thePmk,theClkc,strFascia,newStrPathCounter,fncGoPage){try{this.pmkForm=false;if(this.curTimeout!=null){clearTimeout(this.curTimeout);}
this.objLink=objLink;this.link=objLink.href;var strUrlCounter="";if(((strFascia!=null)&&(strFascia!='undefined'))&&((thePmk!='')&&(thePmk!=null)&&(thePmk!='undefined'))){thePmk=thePmk+strFascia;}
if((fncGoPage!=null)&&(fncGoPage!='undefined')){this.fncGoPage=fncGoPage;}else{this.fncGoPage=null;}if(blnGo==false){var strPathCounter=this.pathCounter;if((newStrPathCounter!='')&&(newStrPathCounter!=null)&&(newStrPathCounter!='undefined')){strPathCounter=newStrPathCounter;}strUrlCounter=strPathCounter+'?pmk='+thePmk+'&rand='+Math.floor(1000000*Math.random())+'&link='+this.link;if(this.debugBI=="true"){alert(strUrlCounter);}var objRequest=this;
var returnsTimeout=function(){return objRequest.timeoutBI(thePmk);};var returns=function(){return objRequest.callBackBI();};var imgBi = document.createElement("IMG");imgBi.id="imgBi";imgBi.onload=returns;imgBi.src=strUrlCounter;document.body.appendChild(imgBi);this.curTimeout=setTimeout(returnsTimeout,this.intTimeout);}else if(blnGo==true){
strUrlCounter=this.pathGo+'/';if((theClkc!='')&&(theClkc!=null)&&(theClkc!='undefined')){strUrlCounter=strUrlCounter+theClkc;}strUrlCounter=strUrlCounter+'/';var strLink=this.link;if((thePmk!='')&&(thePmk!=null)&&(thePmk!='undefined')){var strPmk="pmk="+thePmk;if(this.link.indexOf("?")!=-1){strPmk="&"+strPmk;}else{strPmk="?"+strPmk;};strLink=this.link+strPmk;}strUrlCounter=strUrlCounter+strLink;if(this.debugBI=="true"){alert(strUrlCounter);}this.goUrl(strUrlCounter);}}catch(e){return true;}return false;},
callBackBI:function(){try{if(this.curTimeout!=null){clearTimeout(this.curTimeout);}if(this.fncGoPage!=null){this.fncGoPage();return false;};this.goUrl(this.link);}catch(e){if(this.fncGoPage!=null){this.fncGoPage();return false;};this.goUrl(this.link);}},timeoutBI:function(thePmk){try{if(this.curTimeout!=null){clearTimeout(this.curTimeout);}if(this.blnPmkInError){strPmk="pmk="+thePmk;if(this.link.indexOf("?")!=-1){strPmk="&"+strPmk;}else{strPmk="?"+strPmk;}if(this.fncGoPage!=null){this.fncGoPage();return false;};if(this.objLink.href.indexOf("#")==0){this.goUrl(this.link+strPmk);}else{top.document.location.href=this.objLink.href;}}
else{if(this.fncGoPage!=null){this.fncGoPage();return false;};this.goUrl(this.link);}}catch(e){if(this.fncGoPage!=null){this.fncGoPage();return false;};this.goUrl(this.link);}},getUrlParameter:function(param){var val="";var qs=window.location.search;var start=qs.indexOf(param);if(start!=-1){start+=param.length+1;var end=qs.indexOf("&",start);if(end==-1){end=qs.length}val=qs.substring(start,end);}return val;},
setDomainFormUrl:function(domainFormUrl){this.formLink=domainFormUrl;},
goUrl:function(urlLink){objRequest=false;page_request=false;if(this.objLink.target!=""){if(this.objLink.target.toLowerCase()=="_blank"){document.getElementById('frmBILinkRedirect').target="_blank";document.getElementById('frmBILinkRedirect').action=urlLink;document.getElementById('frmBILinkRedirect').submit();return false;};if(this.objLink.target.toLowerCase()=="_top"){document.getElementById('frmBILinkRedirect').target="_top";document.getElementById('frmBILinkRedirect').action=urlLink;document.getElementById('frmBILinkRedirect').submit();return false;};if(this.objLink.target.toLowerCase()=="_parent"){document.getElementById('frmBILinkRedirect').target="_parent";document.getElementById('frmBILinkRedirect').action=urlLink;document.getElementById('frmBILinkRedirect').submit();return false;}};document.getElementById('frmBILinkRedirect').target="";document.getElementById('frmBILinkRedirect').action=urlLink;document.getElementById('frmBILinkRedirect').submit();},
goUrlForm:function(urlLink){objRequest=false;page_request=false;if(this.objLink.target!=""){if(this.objLink.target.toLowerCase()=="_blank"){document.getElementById('frmBILinkRedirect').target="_blank";document.getElementById('frmBILinkRedirect').action=urlLink;document.getElementById('frmBILinkRedirect').submit();return false;};if(this.objLink.target.toLowerCase()=="_top"){document.getElementById('frmBILinkRedirect').target="_top";document.getElementById('frmBILinkRedirect').action=urlLink;document.getElementById('frmBILinkRedirect').submit();return false;};if(this.objLink.target.toLowerCase()=="_parent"){document.getElementById('frmBILinkRedirect').target="_parent";document.getElementById('frmBILinkRedirect').action=urlLink;document.getElementById('frmBILinkRedirect').submit();return false;}};document.getElementById('frmBILinkRedirect').target="";document.getElementById('frmBILinkRedirect').action=urlLink;document.getElementById('frmBILinkRedirect').submit();},
goUrlLink:function(urlLink){objRequest=false;page_request=false;if(this.objLink.target!=""){if(this.objLink.target.toLowerCase()=="_blank"){window.open(urlLink);return false;};if(this.objLink.target.toLowerCase()=="_top"){top.document.location.href=urlLink;return false;};if(this.objLink.target.toLowerCase()=="_parent"){parent.document.location.href=urlLink;return false;}};document.location.href=urlLink;},
callBIForm:function(objLinkForm,blnGoForm,thePmkForm,theClkcForm,strFasciaForm,newStrPathCounterForm,fncGoPageForm){if (!this.pmkForm){objLinkForm.href=objLinkForm.action;return objBI.callBIGif(objLinkForm,blnGoForm,thePmkForm,theClkcForm,strFasciaForm,newStrPathCounterForm,function(){this.pmkForm=true;fncGoPageForm();});this.pmkForm=true;}else{return true;}}
}