var LPJT_CONSOLE=false;var LPJT_VERSION="0.1.3";var LPJT_ONREADY_CALLS=new Array();var LPJT_IE_CONSOLE=false;var LPJT_IE_CONSOLE_HIS="";var LPJT_IE_CONSOLE_HTML="";function lpJT(){this.onreadycalls=new Array();var obj=this;if(document.addEventListener){window.addEventListener('load',function(){lpJT.prototype.ready.call(obj);},false);}else{window.attachEvent('onload',function(){lpJT.prototype.ready.call(obj);});}}
lpJT.getCookie=function(cookieName){var cookies=document.cookie.split(";");var cookie;for(var i=0;i<cookies.length;i++){cookie=cookies[i].split("=");try{if(cookie[0].trim()==cookieName)return cookie[1].trim();}catch(e){}}};lpJT.setCookie=function(options){if(!options.name&&!options.value)
return false;var str=options.name+"="+options.value+"";if(options.expires){str+=";expires="+options.expires.toGMTString()+"";}else{str+=";expires=30";}
str+=";path=/";lpJT.log('lpJT: Cookie set:'+str);document.cookie=str;return true;};lpJT.enableConsole=function(){LPJT_CONSOLE=true;try{if(!console)return;}catch(e){LPJT_IE_CONSOLE_HTML='<div id="lpJT_ie_c" style="position: absolute; overflow: scroll; width: 100%; height: 200px; bottom: 0px; left: 0px; background-color: #fff; border-top: 1px solid #c0c0c0; font-family: Arial; font-size: 12px; color: #333;"></div>';lpJT.addReadyListener(lpJT.createIEConsole);}};lpJT.createIEConsole=function(){document.getElementsByTagName('body')[0].innerHTML+=LPJT_IE_CONSOLE_HTML;LPJT_IE_CONSOLE=document.getElementById('lpJT_ie_c');LPJT_IE_CONSOLE.innerHTML=LPJT_IE_CONSOLE_HIS;};lpJT.log=function(msg){if(!LPJT_CONSOLE)return;if(LPJT_IE_CONSOLE_HTML){LPJT_IE_CONSOLE_HIS+=msg+"<br />";var d=document.getElementById('lpJT_ie_c');if(d)d.innerHTML=LPJT_IE_CONSOLE_HIS;}else console.log(msg);};lpJT.addReadyListener=function(func){if(func instanceof Function||func instanceof Array){LPJT_ONREADY_CALLS.push(func);}else lpJT.log('lpJT: trying to add a onReadyListener which isn\'t a function! ONLY FUNCTIONS ACCEPTED!');};lpJT.listener=function(obj,event,handler){if(document.addEventListener){obj.addEventListener(event,handler,false);}else{obj.attachEvent('on'+event,handler);}};lpJT.prototype.ready=function(){lpJT.log('lpJT: DOM ready');for(var i=0;i<LPJT_ONREADY_CALLS.length;i++){if(LPJT_ONREADY_CALLS[i]instanceof Function){LPJT_ONREADY_CALLS[i]();}else if(LPJT_ONREADY_CALLS[i]instanceof Array){LPJT_ONREADY_CALLS[i][0].call(LPJT_ONREADY_CALLS[i][1]);}else lpJT.log('lpJT: onready call: '+LPJT_ONREADY_CALLS[i].toString()+' is not a function');}};function lpJT_switcher(){this.cookieVariable="LP_GA_SWITCHER";this.cookieExpire=new Date(new Date().getTime()+1000*60*60*24*365);}
lpJT_switcher.prototype.isActive=function(){var c=lpJT.getCookie(this.cookieVariable);var a=(c=="1"||c==undefined);lpJT.log('lpJT_switcher: current status: '+a);return a;};lpJT_switcher.prototype.activate=function(){lpJT.log('lpJT_switcher: activated');lpJT.setCookie({name:this.cookieVariable,value:"1",expires:this.cookieExpire});this.onChangeIn();};lpJT_switcher.prototype.deactivate=function(){lpJT.log('lpJT_switcher: deactivated');lpJT.setCookie({name:this.cookieVariable,value:"0",expires:this.cookieExpire});this.onChangeIn();};lpJT_switcher.prototype.toggle=function(){(this.isActive()?this.deactivate():this.activate());this.onChangeIn();};lpJT_switcher.prototype.onChangeIn=function(){lpJT.log('lpJT_switcher: calling lpJT_switcher.onChange method');this.onChange();};lpJT_switcher.prototype.createDefaultButton=function(btn1,btn2){this.onChange=function(){if(this.isActive()){btn1.setAttribute("disabled","disabled");btn2.removeAttribute("disabled");}else{btn2.setAttribute("disabled","disabled");btn1.removeAttribute("disabled");}};var o=this;btn1.onclick=function(){o.activate();};btn2.onclick=function(){o.deactivate();};this.onChange();};lpJT_switcher.prototype.onChange=function(){};lpJT.prototype.switcher=new lpJT_switcher();function lpJT_proof(){this.cookieName="LP_GA_PROOF";this.called=false;this.expireDate=new Date(new Date().getTime()+1000*60*60*24*365);this.enabled=false;}
lpJT_proof.prototype.enable=function(options){lpJT.log('lpJT_proof: is enabled');this.enabled=true;if(options){if(options.onready){lpJT.addReadyListener([this.init,this]);}}};lpJT_proof.prototype.isProofed=function(){var s=(lpJT.getCookie(this.cookieName)=="1");lpJT.log('lpJT_proof: current status '+s);return s;};lpJT_proof.prototype.setProofed=function(){lpJT.log('lpJT_proof: set as proofed');lpJT.setCookie({name:this.cookieName,value:"1",expires:this.expireDate});this.onChecked();};lpJT_proof.prototype.init=function(){lpJT.log('lpJT_proof: initiate');if(!this.enabled)return;if(this.isProofed())
this.onChecked();else
this.onFirstCall();};lpJT_proof.prototype.onFirstCall=function(){lpJT.log('lpJT_proof: calling lpJT_proof.prototype.onFirstCall which is not set yet. Please override this function.');};lpJT_proof.prototype.onChecked=function(){lpJT.log('lpJT_proof: calling lpJT_proof.prototype.onChecked which is not set yet. Please override this function.');};lpJT.prototype.proof=new lpJT_proof();var LPJT_REP={DOWNLOADS:'downloads',LINKS_EXTERN:'links_extern',LINKS_INTERN:'links_intern'};var LPJT_R_INSTANCES=new Array();function lpJT_replace(){this.instanceID=lpJT_replace.createInstance(this);this.options=[[LPJT_REP.DOWNLOADS,{enabled:false,category:'downloads',filter:/\.(pdf|docx?|xlsx?|exe|iso)$/i,filterOn:'href',tag:'a',event:'click',action:null}],[LPJT_REP.LINKS_EXTERN,{enabled:false,catgory:'links_extern',filterOn:'href',tag:'a',event:'click',action:null}],[LPJT_REP.LINKS_INTERN,{enabled:false,category:'links_intern',event:'click',tag:'a',action:null}]];this.getOptions=function(type){for(var i=0;i<this.options.length;i++){if(this.options[i][0]==type){return this.options[i][1];}}};this.hashLast="";this.hashListener=new Array();}
lpJT_replace.createInstance=function(obj){LPJT_R_INSTANCES.push(obj);return LPJT_R_INSTANCES.length-1;};lpJT_replace.HASH_INTERVAL=100;lpJT_replace.prototype.hashInterval=function(){if(this.hashLast!=document.location.hash){lpJT.log('lpJT_replace: Hash changed FIRE EVENT');this.hashLast=document.location.hash;for(var i=0;i<this.hashListener.length;i++){if(this.hashListener[i][1].filter?this.hashLast.match(this.hashListener[i][1].filter):true){this.hashListener[i][1].action(this.hashLast.substr(1));}}}};lpJT_replace.prototype.callAction=function(obj,type){lpJT.log('lpJT_replace: EVENT CALLED: '+type);var f=this.getOptions(type).action;if(f instanceof Function){f(obj);}else if(f instanceof Array){f[0].call(f[1],obj);}else{lpJT.log('lpJT_replace: EVENT CALLED BUT NO LISTENER DEFINED!');}};lpJT_replace.prototype.setConfiguration=function(type,options){type=(type instanceof Array)?type:[[type,options]];var options_found;for(var x=0;x<type.length;x++){options_found=false;try{options=type[x][1];for(var i=0;i<this.options.length;i++){if(this.options[i][0]==type[x][0]){options_found=true;for(var prop in options){this.options[i][1][prop]=options[prop];}}}
if(!options_found){this.options[this.options.length]=[type[x][0],type[x][1]];lpJT.log('lpJT_replace: Custom Filter angelegt:'+type[x][0]);}}catch(e){lpJT.log('lpJT_replace: Exception fired: '+e+' .. known IE Bug can be ignorized');}}};lpJT_replace.prototype.setOnready=function(){lpJT.addReadyListener([this.start,this]);};lpJT_replace.prototype.start=function(){var startTime=new Date().getTime();var obj=this;var ftags=new Array(),otags;for(var o=0;o<this.options.length;o++){if(this.options[o][1].enabled){if(this.options[o][1].tag){otags=this.options[o][1].tag.split("|");for(var ot=0;ot<otags.length;ot++){if(!ftags.contains(otags[ot])){lpJT.log("lpJT_replace:  Add Tag:"+otags[ot]);ftags.push(otags[ot]);}}}
if(this.options[o][1].event=='hashChange'){this.hashListener.push(this.options[o]);}}}
var tags=new Array();var ht;for(var o=0;o<ftags.length;o++){ht=document.getElementsByTagName(ftags[o]);for(var t=0;t<ht.length;t++){tags.push(ht[t]);}}
lpJT.log("lpJT_replace: Tags gefunden: "+tags.length);var options,tag,name,attr,fpos,as;for(var i=0;i<tags.length;i++){tag=tags[i];for(var o=0;o<this.options.length;o++){name=this.options[o][0];options=this.options[o][1];if(options){if(options.enabled&&(options.tag?(fpos=options.tag.split("|").indexOf(tag.tagName.toLowerCase()))!=-1:false)){attr=tag.getAttribute(options.filterOn.split("|")[fpos]);if(attr){if(typeof attr.match=='function'){as=attr;}else{as=attr.toString();}
if(as.match(options.filter)){eval("lpJT.listener(tag, options.event, function(event) { lpJT_replace.prototype.callAction.call(obj, event.srcElement, '"+name+"'); });");}}}}}}
if(this.hashListener.length>0){this.hashLast=document.location.hash;eval('window.setInterval("lpJT_replace.prototype.hashInterval.call(LPJT_R_INSTANCES['+this.instanceID+'])", lpJT_replace.HASH_INTERVAL);');lpJT.log('lpJT_replace: HashListener found and successfull added: '+this.hashListener.length);lpJT.log('lpJT_replace: HashListener Interval is: '+lpJT_replace.HASH_INTERVAL);}
var endTime=new Date().getTime();lpJT.log('lpJT_replace: parsing dom completed, time: '+(endTime-startTime)+'ms');};lpJT.prototype.replace=new lpJT_replace();var lpj=new lpJT();Function.prototype.getName=function(){return this.toString().substring(9,this.toString().indexOf("("));};if(typeof String.prototype.trim!=='function'){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'');};}
Array.prototype.contains=function(s){for(var i=0;i<this.length;i++){if(this[i]==s){return true;}}
return false;};Array.prototype.indexOf=function(s){for(var i=0;i<this.length;i++){if(this[i]==s){return i;}}
return-1;};
