function global_isdefined(o) {
  return (typeof(o)!="undefined");
}

function global_isdefinedid(o) 
{
	var el = document.getElementById(o);
	if(el==null) return false;
	return true;
}

function global_validateInt(n) 
{
    return (!global_isdefined(n) || isNaN(n))?0:n;
}


/********************************** WINDOW SIZE **********************************/
function global_getWindowSize() {
	var myWidth = 0;
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
  	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }
	return [{'width':myWidth,'height':myHeight}];
}

function global_getWindowScroll() {
	var scrOfX = 0;
	var	scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' )
	{
    	//Netscape compliant
    	scrOfY = window.pageYOffset;
    	scrOfX = window.pageXOffset;
  	}
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;
    	scrOfX = document.body.scrollLeft;
	}
	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
	{
    	//IE6 standards compliant mode
    	scrOfY = document.documentElement.scrollTop;
    	scrOfX = document.documentElement.scrollLeft;
  	}
	return [{'scrollX':scrOfX,'scrollY':scrOfY}];
}

function global_getDocumentSize() 
{
    var myWidth = 0;
    var myHeight = 0;
    var body = global_getBodyReference();

	try
	{
    if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
        var rightMargin = parseInt(CSS.get(body,'marginRight'),10) || 0;
        var leftMargin = parseInt(CSS.get(body,'marginLeft'), 10) || 0;
      myWidth = Math.max(body.offsetWidth + leftMargin + rightMargin, document.documentElement.clientWidth);
    }
    else {
      myWidth =  Math.max(body.clientWidth, body.scrollWidth);
    }
    if (isNaN(myWidth) || myWidth==0) {
      myWidth = global_validateInt(self.innerWidth);
    }

    var innerHeight = (global_isdefined(self.innerHeight)&&!isNaN(self.innerHeight))?self.innerHeight:0;
    if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
        var topMargin = parseInt(CSS.get(body,'marginTop'),10) || 0;
        var bottomMargin = parseInt(CSS.get(body,'marginBottom'), 10) || 0;
      return Math.max(body.offsetHeight + topMargin + bottomMargin, document.documentElement.clientHeight, document.documentElement.scrollHeight, screen.zero(self.innerHeight));
    }
    myHeight = Math.max(body.scrollHeight, body.clientHeight, global_validateInt(self.innerHeight));

	return [{'width':myWidth,'height':myHeight}];
	}
	catch(err)
	{
		return [{'width':document.body.offsetWidth,'height':document.body.offsetHeight}];
	}
}


function global_getBodyReference()
{
    if (document.body) {
      return document.body;
    }
    if (document.getElementsByTagName) {
      var bodies = document.getElementsByTagName("BODY");
      if (bodies!=null && bodies.length>0) {
        return bodies[0];
      }
    }
    return null;
}

/********************************** ONLOAD EVENTS **********************************/
function addLoadEvent(func) {
	try
	{
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		}
		else
		{
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
		      func();
			}
		}
	} 
	catch(err) {}
}
