// Code from JavaScript Guide ed5.
var browser = 
{
    version: parseInt(navigator.appVersion),
    isNetscape: navigator.appName.indexOf("Netscape") != -1, 
    isMicrosoft: navigator.appName.indexOf("Microsoft") != -1
};


// Event processing code from JavaScript & DHTML Cookbook ed2.
function addEvent(elem, evtType, func, capture)
{
   capture = (capture) ? capture : false;
   if (elem.addEventListener)
   {
      elem.addEventListener(evtType, func, capture);
   }
   else if (elem.attachEvent)
   {
      elem.attachEvent("on" + evtType, func);
   }
   else
   {
      // for IE/Mac, NN4, and older
      elem["on" + evtType] = func;
   }
}

function removeEvent(elem, evtType, func, capture)
{
   capture = (capture) ? capture : false;
   if (elem.removeEventListener)
   {
      elem.removeEventListener(evtType, func, capture);
   }
   else if (elem.attachEvent)
   {
      elem.detachEvent("on" + evtType, func);
   }
   else
   {
      // for IE/Mac, NN4, and older
      elem["on" + evtType] = null;
   }
}

function addOnLoadEvent(func)
{
    if (window.addEventListener || window.attachEvent)
    {
        addEvent(window, "load", func, false);
    }
    else
    {
        var oldQueue = (window.onload) ? window.onload : function() {};
        window.onload = function()
        {
            oldQueue();
            func();
        }
    }
}

// Return the available content width space in browser window
function getInsideWindowWidth ()
{
	if (window.innerWidth)
	{
		return window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		return document.documentElement.clientWidth;
	}
	else if (document.body && document.body.clientWidth)
	{
		return document.body.clientWidth;
	}
	return null;
}

// Return the available content height space in browser window
function getInsideWindowHeight ()
{
	if (window.innerHeight)
	{
		return window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		return document.documentElement.clientHeight;
	}
	else if (document.body && document.body.clientHeight)
	{
		return document.body.clientHeight;
	}
	return null;
}

// calculates the total position (offset) for an element - can accept string id or element object.
// return the position as an array with [x,y].
function getAbsPos (elem)
{
	if (typeof elem == "string") elem = document.getElementById(elem);
	
	var posx = 0;
	var posy = 0;
	if (elem.offsetParent)
	{
		posx = elem.offsetLeft;
		posy = elem.offsetTop;
		while (elem = elem.offsetParent)
		{
			posx += elem.offsetLeft;
			posy += elem.offsetTop;
		}
	}
	return [posx, posy];
}

// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
