Kunstnere = {	
	_div: "kunstner_galleri",
	_last_user : "",
	timeout_show : "",
	timeout_hide: "",
			
	mark: function(bruger){
		document.onmousemove = Kunstnere.followMouse;
		var funk = function(){
			document.getElementById(Kunstnere._div).style.display = "block";
			document.getElementById(Kunstnere._div).innerHTML = "Henter malerier...";
			YAHOO.util.Connect.asyncGetRequest("ajax/kunstnere/galleri_udsnit.php?bruger="+bruger,Kunstnere._div,'');	
			Kunstnere._last_user = bruger;
		document.onmousemove = Kunstnere.followMouse;
		}
		if(bruger != this._last_user){
			document.getElementById(Kunstnere._div).style.display = "none";
			this.timeout_show = window.setTimeout(funk,500);
		}
		else{		
			window.clearTimeout(this.timeout_hide);
			document.getElementById(this._div).style.display = "block";
		}
	},
	
	unmark: function(){
		window.clearTimeout(this.timeout_show);
		funk = function(){
			document.onmousemove = "";
			document.getElementById(Kunstnere._div).style.display = "none";	
		}
		this.timeout_hide = window.setTimeout(funk,100);
	},
	
	followMouse: function(event){
		var x = MouseInfo.mouseX(event);
		var y = MouseInfo.mouseY(event);
		
		var left = 12;
		var top = 17;	
		var width = parseInt(document.getElementById(Kunstnere._div).style.width);
		var height = parseInt(document.getElementById(Kunstnere._div).style.height);
		if((x+width+20) > WindowInfo.getWidth())
			left = (width*-1)-5;
		if((y+height+20) > WindowInfo.getHeight())
			top = height*-1;

		left += x;
		top += y;	
			
		document.getElementById(Kunstnere._div).style.top = top+"px";
		document.getElementById(Kunstnere._div).style.left = left+"px";
	}
}      

WindowInfo = {
	
	getWidth : function(){
		var res = "";
		if (window.innerWidth)
	    	res = window.innerWidth;
	    else if(document.body) 
	    	res = document.body.clientWidth;
	    else if(document.documentElement && document.documentElement.clientWidth) 
			red = document.documentElement.clientWidth;
		return res;
	},
	
	getHeight : function(){ // height of the window
		var res = "";
		if (window.innerHeight)
	    	res = window.innerHeight;
	    else if (document.body)
	    	res = document.body.clientHeight;
		else if (document.documentElement && document.documentElement.clientHeight)
	    	res = document.documentElement.clientHeight;
		return res;
	}
}

MouseInfo = {
	
	mouseX: function(evt){
		if (!evt) 
			evt = window.event; 
		if (evt.pageX) 
			return evt.pageX; 
		else if (evt.clientX)
			return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); 
		else 
			return 0;
	},
	
	mouseY: function(evt){
		if(!evt)
			evt = window.event; 
		if (evt.pageY) 
			return evt.pageY; 
		else if(evt.clientY)
			return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
		else 
			return 0;
	}                    
}