// common

if (typeof ghmxy_hitcollector=='undefined') {
var ghmxy_hitcollector='pro.hit.gemius.pl';
}
var ghmxy_proto;
if(document.location && document.location.protocol) {
ghmxy_proto = 'http'+((document.location.protocol=='https:')?'s':'')+'://';
} else {
ghmxy_proto = 'http://';
}


// (c) by Gemius SA - gemiusHeatMap
// ver. 4.11

var ghmxy_images = new Array();

function ghmxy_checklink(node) {
var imn = null;
if (node.nodeName == "#text") {
if (node.nodeValue && node.nodeValue.replace(/[ \t\r\n]+/g,"").length > 0) {
return node;
}
return null;
}
if (node.nodeName == "IMG") {
return node;
}
if (node.childNodes) {
for (var i = 0 ; i < node.childNodes.length ; i++) {
var hn = ghmxy_checklink(node.childNodes[i]);
if (hn != null) {
if (hn.nodeName == "#text") return hn;
if (imn == null) imn = hn;
}
}
}
return imn;
}

function ghmxy_toutf8(str) {
function Hex(n) {
var hexMap = '0123456789ABCDEF';
return '%'+hexMap.charAt(n>>4)+hexMap.charAt(n&0xF);
}
var c,s,uc,ul;
var dst = '';
for (var i=0 ; i<str.length ; i++) {
c = str.charCodeAt(i);
if ((c>=0xDC00)&&(c<0xE000)) continue;
if ((c>=0xD800)&&(c<0xDC00)) {
i++;
if (i>=str.length) continue;
s = str.charCodeAt(i);
if ((s<0xDC00)||(s>=0xDE00)) continue;
c = ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
}
if (c<=0x20 || c==0x22 || c==0x7C) {
uc = Hex(c);
} else if (c<0x80) {
uc = String.fromCharCode(c);
} else if (c<0x800) {
uc = Hex(0xC0+(c>>6))+Hex(0x80+(c&0x3F));
} else if (c<0x10000) {
uc = Hex(0xE0+(c>>12))+Hex(0x80+(c>>6&0x3F))+Hex(0x80+(c&0x3F));
} else {
uc = Hex(0xF0+(c>>18))+Hex(0x80+(c>>12&0x3F))+Hex(0x80+(c>>6&0x3F))+Hex(0x80+(c&0x3F));
}
dst+=uc; 
}
return dst;
}

function ghmxy_url_escape(str) {
return ghmxy_toutf8(str).replace(/\x2520|\x2509|\x250[aA]|\x250[dD]/g,"")
}

function ghmxy_load() {
if (document.getElementById && document.getElementsByTagName) {
var allImages = document.getElementsByTagName("img");
var allInputs = document.getElementsByTagName("input");
var allForms = document.getElementsByTagName("form");
var i;
if (allImages) {
for (i=0; i<allImages.length; i++) {
if (typeof(allImages[i].src) != "undefined") {
allImages[i].ghmxy_src = allImages[i].src;
}
}
}
if (allInputs) {
for (i=0; i<allInputs.length; i++) {
if (typeof(allInputs[i].value) != "undefined") {
allInputs[i].ghmxy_value = allInputs[i].value;
}
if (typeof(allInputs[i].src) != "undefined") {
allInputs[i].ghmxy_src = allInputs[i].src;
}
}
}
if (allForms) {
for (i=0; i<allForms.length; i++) {
if (typeof(allForms[i].action) != "undefined") {
allForms[i].ghmxy_action = allForms[i].action;
}
}
}
}
}

function ghmxy_gettext(node) {
var rettext="";
if (node.nodeName=="#text") {
return node.nodeValue;
} else if (node.nodeName=="IMG") {
var src="";
var alt="";
if (node.ghmxy_src) {
src = node.ghmxy_src;
} else {
src = node.src;
}
if (node.alt) {
alt = node.alt;
}
return "img:"+ghmxy_url_escape(src)+":"+alt;
} else if (node.childNodes) {
for (var i=0 ; i<node.childNodes.length ; i++) {
if (node.childNodes[i].nodeName!='A') {
rettext+=" "+ghmxy_gettext(node.childNodes[i]);
}
}
}
return rettext;
}

function ghmxy_checksum(itext,pos) {
var cs=0;
var b64map=".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
for (var n = pos; n < itext.length; n++) {
cs = ((cs * 13) + itext.charCodeAt(n))&0xFFF;
}
return b64map.charAt((cs>>6)&0x3F)+b64map.charAt(cs&0x3F);
}


function ghmxy_escape(str,limit,csflag) {
function Hex(n) {
var hexMap = "0123456789ABCDEF";
return hexMap.charAt(n>>4)+hexMap.charAt(n&0xF);
}
var c,s,uc,ul;
var dst = "";
for (var i=0 ; i<str.length ; i++) {
c = str.charCodeAt(i);
if ((c>=0xDC00)&&(c<0xE000)) continue;
if ((c>=0xD800)&&(c<0xDC00)) {
i++;
if (i>=str.length) continue;
s = str.charCodeAt(i);
if ((s<0xDC00)||(s>=0xE000)) continue;
c = ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
}
if (c<0x80) {
uc = escape(String.fromCharCode(c)).replace(/\+/g,"%2B").replace(/\//g,"%2F");
if (c<=0x20) {
ul=3;
} else {
ul=1;
}
} else if (c<0x800) {
uc = "%u"+Hex(c>>8)+Hex(c&0xFF);
ul = 2;
} else if (c<0x10000) {
uc = "%u"+Hex(c>>8)+Hex(c&0xFF);
ul = 3;
} else {
uc = "%U"+Hex((c>>24)&0xFF)+Hex((c>>16)&0xFF)+Hex((c>>8)&0xFF)+Hex(c&0xFF);
ul = 4;
}
limit -= ul;
if (limit<0) {
if (csflag) {
return dst+"|"+ghmxy_checksum(str,i);
} else {
return dst;
}
}
dst+=uc; 
}
if (csflag) {
return dst+"|";
} else {
return dst;
}
}

function ghmxy_send(mhref,area,ltext,lid) {
var href=ghmxy_url_escape(new String(document.location.href));
mhref=ghmxy_url_escape(mhref);
ltext=ltext.replace(/[ \t\r\n]+/g," ").replace(/^ /,"").replace(/ $/,"").replace(/\x22|\||\x2520/g,"_");
area=area.replace(/;|&|\//g,"_");
lid=lid.replace(/;|&|\/|\|/g,"_");
var ghmxy_url = ghmxy_proto+ghmxy_hitcollector+"/_"+(new Date()).getTime()+"/redot.gif?l=1&id="+ghmxy_identifier+"&sarg="+ghmxy_escape(ltext,190,1)+"|"+ghmxy_escape(area,50,0)+"&ref=http%3A%2F%2F0.0.0.0%2F"+ghmxy_escape(mhref,230,1)+"|"+ghmxy_escape(lid,50,0)+"&href="+ghmxy_escape(href,299,0);
var ghmxy_image = new Image();
ghmxy_image.src = ghmxy_url;
ghmxy_images[ghmxy_images.length] = ghmxy_image;
var start = (new Date()).getTime();
while (start+200>(new Date()).getTime());
}

function ghmxy_hm_click(ev) {
var p=0;
var np=0;
var ln=0;
var ocln=0;
var fform=0;
var imgclick=0;
var mhref="",ocmhref="",path="",ltext="",ocltext="",lid="";
if (document.getElementById) {
if (!window.event) { 
p=ev.target;
} else {
p=window.event.srcElement;
}
try {
if (p.nodeName == "A") {
var cp = ghmxy_checklink(p);
if (cp != null && cp.nodeName == "IMG") p = cp;
}
if (p.nodeName=="INPUT" || p.nodeName=="BUTTON") {
if (p.type=="submit") {
var value="";
if (p.ghmxy_value) {
value = p.ghmxy_value;
} else {
value = p.value;
}
ltext="formsubmit:"+value;
fform=1;
}
if (p.type=="image") {
var src="";
if (p.ghmxy_src) {
src = p.ghmxy_src;
} else {
src = p.src;
}
ltext="formimage:"+ghmxy_url_escape(src);
fform=1;
}
} else if (p.nodeName=="IMG") {
imgclick=1;
}
while (p) {
if (!ocln && p.attributes && p.attributes.getNamedItem) {
ocnode = p.attributes.getNamedItem("onclick");
if (ocnode && ocnode.nodeValue) {
ocln=p;
ocmhref="hmc="+ocnode.nodeValue;
ocltext=p.nodeName+" "+ghmxy_gettext(p);
}
}
if (!ln) {
if (p.nodeName=="AREA" && typeof(p.href)=="string" && p.href!="") {
ln=p;
mhref="hma="+p.href;
ltext = p.shape+" "+p.coords;
}
if (p.nodeName=="A" && typeof(p.href)=="string" && p.href!="") {
ln=p;
if (imgclick) {
mhref="hmi="+p.href;
} else {
mhref="hml="+p.href;

}
if (typeof(p.className)=="string" && p.className!="") {
ltext=p.className+" "+ghmxy_gettext(p);
} else {
ltext=ghmxy_gettext(p);
}
}
if (fform && p.nodeName=="FORM") {
if (typeof(p.ghmxy_action)=="string" && p.ghmxy_action!="") {
ln=p;
mhref="hmf="+p.ghmxy_action;
} else if (p.attributes && p.attributes.getNamedItem) {
osnode = p.attributes.getNamedItem("onsubmit");
if (osnode && osnode.nodeValue) {
ln=p;
mhref="hms="+p.attributes.getNamedItem("onsubmit").nodeValue;
}
}
}
}
if (typeof(p.id)=="string" && (ln || ocln)) {
if (p.id.substr(0,7)=="LinkID:") {
lid=p.id.replace(/\x2520/g,"_").substr(7,50);
}
if (p.id.substr(0,9)=="LinkArea:") {
pel=p.id.replace(/\x2520/g,"_").substr(9,10);
if (path) {
path=pel+"|"+path;
} else {
path=pel; 
} 
}
}
np = 0;
if (typeof(p.parentNode)=="object") {
var pp = p.parentNode;
if (pp && pp.childNodes) {
for (var ch=0 ; ch<pp.childNodes.length ; ch++) {
if (pp.childNodes[ch] == p) {
np=pp;
}
}
}
}
p=np;
}
if (ln) {
ghmxy_send(mhref,path,ltext,lid);
} else if (ocln) {
ghmxy_send(ocmhref,path,ocltext,lid);
}
} catch (_ev) {
}
}
}

// (c) by Gemius SA - gemiusHeatMapXY
// ver. 2.3

if (typeof(ghmxy_type)=='undefined' || (ghmxy_type!='percent' && ghmxy_type!='absolute')) {
var ghmxy_type='x';
} else {
ghmxy_type = ghmxy_type.substr(0,1);
}
if (typeof(ghmxy_align)=='undefined' || (ghmxy_align!='left' && ghmxy_align!='center' && ghmxy_align!='right')) {
var ghmxy_align='x';
} else {
ghmxy_align = ghmxy_align.substr(0,1);
}

var ghmxy_heat_map_image = new Image();
var ghmxy_values = '';
var ghmxy_sarg = '';

function ghmxy_save() {
if (ghmxy_values != '') {
var ghmxy_clickvalues = ghmxy_values;
ghmxy_values=''; // clear ghmxy_values as fast as possible (race condition !!!)
var href = new String(document.location.href);
var ghmxy_link = ghmxy_proto+ghmxy_hitcollector+'/_'+(new Date()).getTime()+'/redot.gif?l=2&id='+ghmxy_identifier+'&arg=1&sarg='+ghmxy_sarg+'&href='+escape(href.substring(0,299))+'&ref=http%3A%2F%2F0.0.0.0%2Fxy%3D'+ghmxy_clickvalues;
ghmxy_heat_map_image.src = ghmxy_link;
}
}

function ghmxy_heat_map_add_event(ob,evname,fn) {
if (ob.attachEvent) {
ob.attachEvent("on"+evname,fn);
} else if(ob.addEventListener) {
ob.addEventListener(evname,fn, false);
}
}

function ghmxy_get_correct_data (n_win, n_docel, n_body) {
var n_result = n_win ? n_win : 0;
if (n_docel && (!n_result || (n_result > n_docel))) {
n_result = n_docel;
}
return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function ghmxy_width() {
return ghmxy_get_correct_data (window.innerWidth ? window.innerWidth : 0, document.documentElement ? document.documentElement.clientWidth : 0, document.body ? document.body.clientWidth : 0);
}

function ghmxy_height() {
return ghmxy_get_correct_data (window.innerHeight ? window.innerHeight : 0, document.documentElement ? document.documentElement.clientHeight : 0, document.body ? document.body.clientHeight : 0);
}

function ghmxy_posx() {
return ghmxy_get_correct_data (window.pageXOffset ? window.pageXOffset : 0, document.documentElement ? document.documentElement.scrollLeft : 0, document.body ? document.body.scrollLeft : 0);
}

function ghmxy_posy() {
return ghmxy_get_correct_data (window.pageYOffset ? window.pageYOffset : 0, document.documentElement ? document.documentElement.scrollTop : 0, document.body ? document.body.scrollTop : 0);
}

function ghmxy_heat_map_refresh_window_params() {
var wparam = 'r'+screen.width+','+screen.height+'|s'+ghmxy_width()+','+ghmxy_height()+'|a'+ghmxy_align.substr(0,1)+'|t'+ghmxy_type.substr(0,1)+'|m'+ghmxy_posx()+','+ghmxy_posy()+'|p';
if (document.body && typeof(document.body.scrollWidth)!='undefined' && typeof(document.body.scrollHeight)!='undefined') {
wparam += document.body.scrollWidth+','+document.body.scrollHeight;
}
return wparam;
}

function ghmxy_xy_click(ev) {
if (ghmxy_values=='') {
ghmxy_sarg = ghmxy_heat_map_refresh_window_params();
ghmxy_values = ev.clientX+':'+ev.clientY;
} else {
ghmxy_values += '|'+ev.clientX+':'+ev.clientY;
if (ghmxy_values.length > 250) {
ghmxy_save();
}
}
}

function ghmxy_flash(id,xx,yy) {
var ghmxy_obj = document.getElementById(id);
if (ghmxy_obj) {
var x=0;
var y=0;
if (ghmxy_obj.offsetParent) {
do {
x += ghmxy_obj.offsetLeft;
y += ghmxy_obj.offsetTop;
ghmxy_obj = ghmxy_obj.offsetParent;
} while (ghmxy_obj);
} else {
if (ghmxy_obj.x) {
x = ghmxy_obj.x;
}
if (ghmxy_obj.y) {
y = ghmxy_obj.y;
}
}
x+=xx;
y+=yy;
if(ghmxy_values==''){
ghmxy_sarg = ghmxy_heat_map_refresh_window_params();
ghmxy_values = x+':'+y;
} else {
ghmxy_values += '|'+x+':'+y;
if (ghmxy_values.length > 250) {;
ghmxy_save();
}
}
}
}


/* opoznia wysylanie requestu do gemiusa dla obrazkow o nazwach w tablicy names  */
function request_ghmxy_hm_click_delay(ev,names){
	event_ev=ev;
	var event_element;
	var delay=false;
	var time=500;
	
//przechwytuje obiekt zdarzenia	
	if (!window.event) { 
		event_element=ev.target;
	} else {
		event_element=window.event.srcElement;
	}
//sprawdzam czy obiekt jest obrazkiem oraz czy przekazano tablice nazw obrazkow 	
	if(event_element.src!=null&&names!=null){
       if(names.length>0){
		//sprawdzam obiekt generujacy zdarzenia  znajduje sie w tablicy wejsciowej 
         for(i=0; i<names.length;i++){
			 if(event_element.src.indexOf(names[i])!=-1){
				      delay=true;
				 }
			 }
              if(delay==true){
		           setTimeout("ghmxy_hm_click(event_ev)",time);
			   }else{ghmxy_hm_click(ev);}
	       }else{ghmxy_hm_click(ev);}
	   }else{ghmxy_hm_click(ev);}
}


// common

function ghmxy_click(ev) {
	names=["slide_arrow_right.png","slide_arrow_left.png"];
    request_ghmxy_hm_click_delay(ev,names);
	ghmxy_xy_click(ev);
}

function ghmxy_add_event(ob,evname,fn) {
if (ob.attachEvent) {
ob.attachEvent("on"+evname,fn);
} else if(ob.addEventListener) {
ob.addEventListener(evname,fn, false);
}
}

// common:
ghmxy_add_event(document,"click",ghmxy_click);
// heat map:
ghmxy_add_event(window,"load",ghmxy_load);
// xy map:
ghmxy_add_event(window,"unload",ghmxy_save);
ghmxy_add_event(window,"scroll",ghmxy_save);
ghmxy_add_event(window,"resize",ghmxy_save);