var IE = (document.all) ? true : false;

if (!IE) {
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove=mousePos;
	var netX, netY;
}

function posX() {
	if (IE) {
		tempX=document.body.scrollLeft + event.clientX;
	}
	if (tempX<0) {
		tempX=0;
	}
	return tempX;
}

function posY(e) {
	if (IE) {
		tempY = event.clientY + document.body.scrollTop;
	}
	if (tempY<0) {
		tempY=0;
	}
	return tempY;
}

function mousePos(e) {
	netX=e.pageX;
	netY=e.pageY;
}

function popPokaz(pX, pY, src) {
	if (IE) {

		var pop = document.all.pop;
		pop.style.visibility='visible';
		pop.innerHTML=src;
		if ( posX()+ pX + pop.offsetWidth < document.body.clientWidth)
			pop.style.left = posX() + pX + "px";
		else pop.style.left = document.body.clientWidth - pop.offsetWidth;
			
		if ( posY()+ pY + pop.offsetHeight  < document.body.scrollHeight)
			pop.style.top = posY() + pY + "px";
		else pop.style.top = document.body.scrollHeight - pop.offsetHeight - 24;

	} else {

		var pop = document.getElementById("pop");
		pop.style.visibility='visible';
		pop.innerHTML=src;
		if (netX + pX + pop.offsetWidth < document.width)
			pop.style.left = netX + pX + "px";
		else pop.style.left = document.width - pop.offsetWidth;
			
		if (netY + pY + pop.offsetHeight < document.height)
			pop.style.top = netY + pY + "px";
		else pop.style.top = document.height - pop.offsetHeight;

	}
}

function popPrzesun(pX, pY) {
	if (IE) {
	
		if ( posX()+ pX + document.all.pop.offsetWidth < document.body.clientWidth)
			document.all.pop.style.left = posX() + pX + "px";
		if ( posY()+ pY + document.all.pop.offsetHeight < document.body.scrollHeight)
			document.all.pop.style.top = posY() + pY + "px";

	} else {

		var pop = document.getElementById("pop");
		if (netX + pX + pop.offsetWidth < document.width) 
			pop.style.left = netX + pX + "px";
		if (netY + pY + pop.offsetHeight < document.height)
			pop.style.top = netY + pY + "px";

	}
}

function closeHelp() {
	if (IE) {
		document.all.pop.innerHTML='';
		document.all.pop.style.visibility='hidden';
	} else {
		document.getElementById("pop").style.visibility='hidden';
		document.getElementById("pop").innerHTML='';
	}
}

function showHelp(tresc,szer,odl_x,odl_y) {
	text =	'<table width="' + szer + '" border="0" cellspacing="0" cellpadding="0" style="font-size: 1px;">';
	text += '<tr><td style="height: 17;" colspan="3"><table width="100%" style="height: 17; font-size: 1px;" border="0" cellspacing="0" cellpadding="0"><tr><td width="7"><img src="images/help_popup/left_top_corner.gif"></td><td width="100%" background="images/help_popup/loop_top.gif"></td><td width="18"><img src="images/help_popup/right_top_corner.gif"></td></tr></table></td></tr>';
	text += '<tr><td width="7" background="images/help_popup/loop_left.gif"></td><td style="font-family: Verdana; font-size: 10px;" bgcolor="#B6F7AD">';
	text +=	tresc;
	text += '</td><td width="6" background="images/help_popup/loop_right.gif"></td></tr>';
	text += '<tr><td style="height: 6; width:7"><img src="images/help_popup/left_bottom_corner.gif"></td><td style="height: 6;" width="100%" background="images/help_popup/loop_bottom.gif"></td><td style="height: 6; width:6"><img src="images/help_popup/right_bottom_corner.gif"></td></tr>';
	text += '</table>';
	popPokaz(odl_x, odl_y,text);
}

function moveHelp(pX, pY) {
	popPrzesun(pX, pY);
}

function popSrodekPrzesun() {
	popPrzesun(-90, 15);
}