/* 
tools.js    v.1.0

The latest version is available at
http://www.molooga.de

Created 08.06.2006 by H.Matthias (Web: http://www.molooga.de )
Last modified: 08.06.2006

JavaScript collection of useful, cross browser capable routines
Currently provides methods to
- detect windows size
- detect mouse position

*/

var docEl = (typeof document.compatMode!="undefined" && document.compatMode!="BackCompat")?"documentElement":"body";
var mouseX=0, mouseY=0;

function mousePos(e) {
	mouseX=e?e.pageX:window.event.x;
	mouseY=e?e.pageY:window.event.y;

	// for ie add scroll position
	if(document.all&&!document.captureEvents) {
	    mouseX+=document[docEl].scrollLeft;
	    mouseY+=document[docEl].scrollTop;
    }
    
	if (document.layers) routeEvent(e); // for NS4
}

if(document.layers) document.captureEvents(Event.MOUSEMOVE); //NS4
document.onmousemove = mousePos;

function getMouseX(){
	return mouseX;
}	

function getMouseY(){
	return mouseY;
}

function getWindowWidth(win){
    if(win == undefined) win = window;
    if(win.innerWidth) return win.innerWidth;
    else{
        if(win.document.documentElement && win.document.documentElement.clientWidth) 
        	return win.document.documentElement.clientWidth;
		return win.document.body.offsetWidth;
    }
}

function getWindowHeight(win){
    if(win==undefined) win=window;
    if(win.innerHeight) return win.innerHeight;
    else{
        if(win.document.documentElement && win.document.documentElement.clientHeight) 
	       return win.document.documentElement.clientHeight;
        return win.document.body.offsetHeight;
    }
}
