function getClientSize()
{
	if (typeof(window.innerWidth) == 'number')
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight )) 
	{
    w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	} 
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) 
	{
    w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	return { width:w, height:h }
}

function getAbsLeft(o) {
    oLeft = o.offsetLeft
    while(o.offsetParent!=null) {
        oParent = o.offsetParent
        oLeft += oParent.offsetLeft
        o = oParent
    }
    return oLeft
}

function getAbsTop(o) {
    oTop = o.offsetTop
    while(o.offsetParent!=null) {
        oParent = o.offsetParent
        oTop += oParent.offsetTop
        o = oParent
    }
    return oTop
}

function getCursorPos(e)
{
   var posx = 0;
   var posy = 0;
   if (!e) var e = window.event;
   if (e.pageX || e.pageY)    {
      posx = e.pageX;
      posy = e.pageY;
   }
   else if (e.clientX || e.clientY)    {
      posx = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) -
         document.documentElement.clientLeft;
      posy = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) -
         document.documentElement.clientTop;
   }
   return { x:posx, y:posy };
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function getMouseButton(event)
{
	if (event.which == null)
		/* IE case */
    return (event.button < 2) ? "LEFT" : ((event.button == 4) ? "MIDDLE" : "RIGHT");
  else
		/* All others */
    return (event.which < 2) ? "LEFT" : ((event.which == 2) ? "MIDDLE" : "RIGHT");
}

function openWindow(url, name, w, h) {
	var wnd = window.open(url, name, "left=" + Math.round((screen.availWidth - w) / 2) + ",top=" + Math.round((screen.availHeight-h)/2) + ",width=" + w + ",height=" + h + ",scrollbars=yes");
	wnd.focus(); 
  return wnd;
}

function setZoomRect(e, l, t, w, h) {
	if (navigator.appName != "Microsoft Internet Explorer" || navigator.appVersion.indexOf("6.") < 0) {
		w -= 2;
		h -= 2;
	}
	e.style.left = l + "px";
	e.style.top = t + "px";
	e.style.width = Math.max(w, 0) + "px";	
	e.style.height = Math.max(h, 0) + "px";	
}

function getZoomRect(e) {
	var w = parseInt(e.style.width);
	var h = parseInt(e.style.height);
	if ((navigator.appName != "Microsoft Internet Explorer" || navigator.appVersion.indexOf("6.") < 0) && w > 0 && h > 0)
	{
		w += 2;
		h += 2;
	}
	return { left:parseInt(e.style.left), top:parseInt(e.style.top), width:w, height:h }
}
