function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
	return cursor;
}

function getWindowHeight(){
	myHeight = 0;
	if (typeof(window.innerWidth) == 'number') {
		//Non-IE
		myHeight = window.innerHeight;
	}
	else 
		if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myHeight = document.documentElement.clientHeight;
		}
		else 
			if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
				//IE 4 compatible
				myHeight = document.body.clientHeight;
			}
	return myHeight;
}

function getWindowWidth(){
	myHeight = 0;
	if (typeof(window.innerWidth) == 'number') {
		//Non-IE
		myWidth = window.myWidth;
	}
	else 
		if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
		}
		else 
			if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
				//IE 4 compatible
				myWidth = document.body.clientWidth;
			}
	return myWidth;
}


function getScrollY(){
	scrOfY = 0;
	if (typeof(window.pageYOffset) == 'number') {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	}
	else 
		if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
		}
		else 
			if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
				//IE6 standards compliant mode
				scrOfY = document.documentElement.scrollTop;
			}
	return scrOfY;
}

function getScrollX(){
	scrOfX = 0;
	if (typeof(window.pageXOffset) == 'number') {
		//Netscape compliant
		scrOfX = window.pageXOffset;
	}
	else 
		if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
			//DOM compliant
			scrOfX = document.body.scrollLeft ;
		}
		else 
			if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
				//IE6 standards compliant mode
				scrOfX = document.documentElement.scrollLeft ;
			}
	return scrOfX;
}


function showAjaxDiv(newDivName,e,url,xplus,yplus,width,height)
{
	if (!xplus) xplus = 10;
	if (!yplus) yplus = 100;
	if (!width) width = 300;
	if (!height) height = 200;
	
	posX = getPosition(e).x + xplus;
	if (posX < 0) {
		posX = 0
	};
	if (posX + width - getScrollX() > getWindowWidth()) {
		posX = getWindowWidth() - width - 10;
	};
	
	posY = getPosition(e).y + (yplus);
	if (posY < 0) {
		posY = 0
	};
	if (posY + height - getScrollY() > getWindowHeight()) {
		posY = getPosition(e).y - height
	};
	
	if (document.getElementById(newDivName) == null){
		var newdiv = document.createElement('div');
		newdiv.id  = newDivName;
		newdiv.style.position = 'absolute';
		document.body.appendChild(newdiv);
		newdiv.style.left = posX;
		newdiv.style.top = posY; 
		newdiv.style.display='';
		newdiv.style.zIndex = 1000;
		easyAjax(url,newDivName);
	}else{
		newdiv = document.getElementById(newDivName)
		newdiv.style.left = posX;
		newdiv.style.top = posY;
		newdiv.style.display='';
		if (url != '')	easyAjax(url,newDivName);
	}
}

function removeElement(divNum) {
	if (document.getElementById(divNum) != null)
	{
		//opacity(divNum, 10, 0, 100);
		document.getElementById(divNum).style.display='none'
	}
}

