/*
============================================================
Capturing The Mouse Position in IE4-6 & NS4-6
(C) 2000 www.CodeLifter.com
Free for all users, but leave in this  header
//
*/


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

//	priradime dokumentu aby si pamatal poziciu mysi v globalnej premennej tempX a tempY
addEvent(window, "load", function() {
	addEvent(document, 'mousemove', getMouseXY);
})

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  	if (IE) { // grab the x-y pos.s if browser is IE
    	tempX = event.clientX + document.body.scrollLeft
    	tempY = event.clientY + document.documentElement.scrollTop
  	} else {  // grab the x-y pos.s if browser is NS
    	tempX = e.pageX
    	tempY = e.pageY
  	}  

  	// catch possible negative values in NS4
  	if (tempX < 0){tempX = 0}
  	if (tempY < 0){tempY = 0}  

  	return true;
}

/*			FCIE NEVSEOBECNE....KONKRETNE PRE REINBERG.NET				*/
/*	@param src 	..	src obrazku
	#param prefix	..	napr. 'cw_' patri do id divu floatingPreview
*/

var tmp = new Image()		//	na usetrenie pamati je globalna

function showPreview(src, prefix) {
	
	//	nemame zdroj obrazku 
	if (!src)	return false;
	
	var div = gebi(prefix + 'floatingPreview');
	var img = gebi(prefix + 'previewImg');

	if (!div || !img)	return false;
	
//	ak sme v IE6, tak to treba potiahnut hore, lebo to mam relativne pozicovane content, a od toho sa to rata potom :-(
	//	nastavim poziciu	
	var lmove = tmove = 0;
//	alert(parseInt(navigator.appVersion))
//	alert(navigator.appVersion)
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6.0") != -1) {
		lmove = 180;
		tmove = 160;
	}
	div.style.left = (parseInt(tempX) + 20 - lmove) + 'px';
	div.style.top = (parseInt(tempY) - 20 - tmove) + 'px';
//	alert(div.style.top)
	//	a obrazok
//	img.src = "http://jokesy.gamepub.sk/rules/pics/loading.gif";	div.className = 'visible';
//	img.src = null;

	//	iba ak to este nie je 'zacacheovane'
	if (tmp.src != src) {
		tmp.onload = function() { 
			img.src = src;
			img.style.visibility = "visible"		
		}
		tmp.src = src;
	} else {
		img.src = src;
		img.style.visibility = "visible"	
	}
	
	
	//	zobrazim box
	div.className = 'visible';
	
}

function hidePreview(prefix) {

	var div = gebi(prefix + 'floatingPreview');
	if (!div)	return false;
	
	//	dam do riti aj obrazok	..	mozno docasne
	var img = gebi(prefix + 'previewImg');
//	img.src=null;		//	toto nejde, v src necha posledny obrazok nacitany..treba ho schovat docasne
	img.style.visibility = "hidden"
	
	div.className = 'invisible';
}

