/**
 * @author Marcin Wrzyciel
 * 
 * Klasa wyświetla okienko podpowiedzi w miejscu pozycji kursora. 
 */
function Hint(){
	this.showed = false;
	this.show = show;
	this.hide = hide;
	this.setText = setText;	
	this._init = _init; 
	
	this._init();
	
	function setText(text){
		this._hdiv.innerHTML = text;
	}	
			
	function show(e){
		 coords = __getMouseCoords(e)
		 this._hdiv.style.top = coords[1] + 15 +'px'
		 this._hdiv.style.left = coords[0] + 15 + 'px'
		 this._hdiv.style.display = 'block'
	}
	
	function hide() { 
		this._hdiv.style.display = 'none'
		}
	
	
	function _init(){
		this._hdiv = document.createElement("div")
		this._hdiv.style.display = 'none'
		this._hdiv.style.position = "absolute"
		document.body.appendChild(this._hdiv)	
	}
	
	/**
	 * funkcja pobierająca aktualną pozycję myszki wraz z poprawkami na tak, aby 
	 * dobrze działała na wszystkich przeglądarkach
	 */
	function __getMouseCoords(e){
		if(!e) {
	    	if(window.event) e = window.event;
	    	else return false;
	  	}
	  	if(typeof( e.pageX )=='number') {
	    	var xcoord = e.pageX;
	    	var ycoord = e.pageY;
	  	} else {
	    	if(typeof( e.clientX ) == 'number') {
	      		var xcoord = e.clientX;
	      		var ycoord = e.clientY;
	      		if (!((window.navigator.userAgent.indexOf( 'Opera' ) + 1) || (window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1) || window.navigator.vendor == 'KDE' )) {
		        	if(document.body && ( document.body.scrollLeft || document.body.scrollTop)) {
		          		xcoord += document.body.scrollLeft;
		          		ycoord += document.body.scrollTop;
		        	} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
			        	xcoord += document.documentElement.scrollLeft;
		          		ycoord += document.documentElement.scrollTop;
		        	}
	      		}
	    	} else return false;
	  	}
		return [xcoord, ycoord];
	}
}

