// -- Revision 1.0 -->
// -- Copyright (c) 2007-2009 e-dynamics GmbH  All rights reserved. -->
// -- $DateTime: 2009/06/19 18:10:00 $ -->
function Heatmap(){
    // configure
	this.collectData = true; // tracking on/off
	this.randomtracking = 1;  // 1 = every user
	this.dom = 'lufthansa.e-heat.de';
	this.accountID = 'eh303031_6161';
	this.maxHeight = 5000; // maximum height
	this.interval = 1000; // time between clicks in milliseconds
	this.startPoint = document.getElementById('ch-wrp');
	
	// initialize tracking
	this.debug = false; // debugging on (no requests will be send)
	if(this.collectData === true){this.go();}
}
Heatmap.prototype.loadEvent=function(){var that=this;document.body.attachEvent?document.body.attachEvent('onmousedown',function(event){that.getClick(event)}):document.body.addEventListener('mousedown',function(event){that.getClick(event)},false)};
Heatmap.prototype.getClick=function(e){e=e||window.event;if((e.which&&e.which==3)||(e.button&&e.button==2)){return}var actual_time=new Date();if(actual_time.getTime()-this.timeDiff<this.interval){return}this.timeDiff=actual_time.getTime();this.setPos();this.setWidth();if(this.IE){this.x=event.clientX+document.body.scrollLeft-this.offX;this.y=event.clientY+document.body.scrollTop-this.offY}else{this.x=e.pageX-this.offX;this.y=e.pageY-this.offY}if(this.y>this.maxHeight){return}this.request()};
Heatmap.prototype.request=function(){var url='http'+(window.location.protocol.indexOf('https:')==0?'s':'')+'://'+this.dom+'/'+this.accountID+'/img.gif?';url+='x='+this.x+'&y='+this.y+'&t='+(this.timeDiff-this.time)+'&w='+this.ww+'&p='+encodeURIComponent(this.pagename);for(var seg in this.segment){url+='&'+seg+'='+encodeURIComponent(this.segment[seg])}if(this.debug){alert(decodeURIComponent(url))}else{this.sendRequest(url)}};
Heatmap.prototype.sendRequest=function(url){if(document.images){this.images[this.index]=new Image();this.images[this.index].src=url;this.index++}else{document.write('<img alt="" border="0" name="heatimage" width="1" height="1" src="'+url+'">')}};
Heatmap.prototype.go=function(){var z=Math.random()*this.randomtracking;if(z>1){return}this.segment=[];this.images=[];this.index=0;this.timeDiff=new Date();this.time=this.timeDiff=this.timeDiff.getTime();this.IE=(navigator.appName=='Microsoft Internet Explorer')?true:false;if(!this.startPoint){this.startPoint=document.getElementsByTagName('body')[0].childNodes[1]}if(!this.pagename){this.pagename=window.location.pathname}this.loadEvent()};
Heatmap.prototype.defSegment=function(p_name,p_value){if(this.segment){this.segment[p_name]=p_value}};
Heatmap.prototype.setPos=function(){this.offX=this.offY=0;var obj=this.startPoint;if(obj.offsetParent){do{this.offX+=obj.offsetLeft;this.offY+=obj.offsetTop}while(obj=obj.offsetParent)}else if(obj.x){this.offX+=obj.x;this.offY+=obj.y}};
Heatmap.prototype.setWidth=function(){this.ww=this.IE?document.body.clientWidth:window.innerWidth};
function ed_write_cookie(s_coo){var d_now=new Date();var d_exp=new Date(d_now.getTime()+36806400000);var expiry="; expires="+d_exp.toGMTString();document.cookie='e_coo='+escape(s_coo)+expiry+'; path=/'+(((typeof(gFpcDom)!='undefined')&&(gFpcDom!=''))?('; domain='+gFpcDom):(''))}
function ed_is_new(){var s_coo='';var d_now=new Date();d_now=Math.round(d_now.getTime()/1000000);if(dcsGetCookie('e_coo')){s_coo=dcsGetCookie('e_coo');/^(\d*?),/i.exec(s_coo);var i_time=parseInt(RegExp.$1,10);/^\d*?,([rf])/i.exec(s_coo);var s_nor=RegExp.$1;if(i_time+2<d_now){ed_write_cookie(s_coo.replace(/^\d*?,[rf]/i,d_now.toString()+',r'));return'returning'}else{ed_write_cookie(s_coo.replace(/^\d*?,/i,d_now.toString()+','));return(s_nor=='f')?'new':'returning'}}else{ed_write_cookie(d_now.toString()+',f');return'new'}}
function ed_build_page(pagename){try{e_h=new Heatmap();e_h.pagename=pagename;e_h.defSegment('h_nvr',ed_is_new());if(gImages[0]){e_h.defSegment('h_wtstring',gImages[0].src.substring(gImages[0].src.indexOf('dcs.gif?')+8))}}catch(e){}}
function ed_track(){
    try {
        var cases = DCSext.ShownPage.replace(/http:\/\/.*?\//,'/');
        /(nodeid=[^\&]*)/i.exec(cases);
        var r_node = RegExp.$1;
        /(l=[^\&]*)/i.exec(cases);
        var r_l =  RegExp.$1; 
        /(cid=[^\&]*)/i.exec(cases);
        var r_cid =  RegExp.$1;
        cases = cases.slice(0,cases.indexOf('?')+1)+r_node+'&'+r_l+'&'+r_cid;     
        
        switch (cases){
            case '/online/portal/lh/de/homepage?nodeid=1649106&l=de&cid=18002': // DE (DE)
            case '/online/portal/lh/us/homepage?nodeid=1678690&l=en&cid=1000390': // US (EN)
            case '/online/portal/lh/it/homepage?nodeid=1680030&l=it&cid=1000273': // IT (IT)
            case '/online/portal/lh/uk/homepage?nodeid=1679381&l=en&cid=1000243': // UK (EN)
            case '/online/portal/lh/fr/homepage?nodeid=1681382&l=fr&cid=1000241': // FR (FR)
            case '/online/portal/lh/es/homepage?nodeid=1680697&l=es&cid=1000233': // ES (ES)
            case '/online/portal/lh/jp/homepage?nodeid=1665490&l=ja&cid=1000276': // JP (JA)
            case '/online/portal/lh/in/homepage?nodeid=1662862&l=en&cid=1000267': // IN (EN)
            case '/online/portal/lh/ru/homepage?nodeid=1672090&l=ru&cid=1000348': // RU (RU)
            case '/online/portal/lh/at/homepage?nodeid=1648585&l=de&cid=18001': // AT (DE)
                if(window.location.search && window.location.search.indexOf('action=CheckInAction')!=-1){
                    ed_build_page('/checkin'+cases);                 
                }else{
                    ed_build_page(cases);
                }
                break;  
            case '/online/portal/lh/de/specials?nodeid=1649181&l=de&cid=18002': // DE Specials 
            case '/online/portal/lh/de/info_and_services/flightinfo/arrivals_departures?nodeid=1649230&l=de&cid=18002': // DE Ankunft
                ed_build_page(cases);
                break;
        }        
    } catch(e) {
        // alert(e.message);
    }    
}
var now = new Date();
if(now.getTime() < 1267225200000){ed_track();}


