// (c) 2007 by Gemius SA - gemiusHeatMap
// ver. 2.0

var ghm_maxtimeout = 200;
var ghm_image = new Image();
var ghm_url = "";

function ghm_add_event(ob,evname,fn) {
	if (ob.attachEvent) {
		ob.attachEvent("on"+evname,fn);
	} else if(ob.addEventListener) {
		ob.addEventListener(evname,fn, false);
	}
}

function ghm_unload() {
	if (ghm_url!="") {
		if (typeof(ghm_image.fileSize) == "undefined") {
			ghm_image.fileSize=-1;
		}
		ghm_image.src = ghm_url;
		var start = (new Date()).getTime();
		while (ghm_image.fileSize==-1 && start+ghm_maxtimeout>(new Date()).getTime()) ;
	}
}

function ghm_getparams(ln,sarg,ltext) {
	if (ln.nodeName=='FORM') {
		var mhref = new String(ln.action);
	} else {
		var mhref = new String(ln.href);
	}
	var href=new String(document.location.href);
	if (ltext=='') {
		for (i=0 ; i<ln.childNodes.length ; i++) {
			if (ln.childNodes[i].nodeName=='#text') {
				ltext += ln.childNodes[i].nodeValue;
			}
		}
	}
	ghm_url = document.location.protocol+"//"+ghm_hitcollector+"/_"+(new Date()).getTime()+"/redot.gif?id="+ghm_identifier+"&sarg="+sarg+"&ref=http://0.0.0.0/link="+escape(mhref.replace(/\|/g,"_").substr(0,200)+"|"+ltext.replace(/\|/g,"_").substr(0,50))+"&href="+escape(href.substr(0,299));
}

function ghm_click(ev) {
	var p=0;
	var ln=0;
	var path='',ltext='';
	if (typeof(Error)!='undefined' && document.getElementById) {
		if (!window.event) { 
			p=ev.target;
		} else {
			p=window.event.srcElement;
		}
		fform=0;
		if (p.nodeName=="INPUT") {
			if (p.type=="submit") {
				ltext='formsubmit:'+p.value
				fform=1;
			}
			if (p.type=="image") {
				ltext='formimage:'+p.src
				fform=1;
			}
		}
		eval(" try { while (p) { if ((((p.nodeName=='A' || p.nodeName=='AREA') && p.href) || (fform && p.nodeName=='FORM' && p.action)) && !ln) { ln=p; } if (p.nodeName=='IMG' && fform==0) { if (p.alt) { ltext='imgalt:'+p.alt; } else if (p.src) {ltext='imgsrc:'+p.src } } if (p.id && ln) { if (p.id.substr(0,9)=='LinkArea:') { pel=p.id.substr(9,10); if (path) { path=pel+'|'+path; } else { path=pel; } } } p=p.parentNode; } if (ln) ghm_getparams(ln,path,ltext); } catch (ev) {}");
	}
}

ghm_add_event(document,"click",ghm_click);
ghm_add_event(window,"unload",ghm_unload);

