var mozilla=document.getElementById && !document.all
var ie=document.all;

window.getElementClientHeight =function (objectToSelect) {
	return objectToSelect.offsetHeight;
}

window.classExists=function (obj, name) {
    var re = new RegExp("\\b" + name + "\\b");
    if (obj && obj.className && re.exec(obj.className)) return true;
    
    return false;
}

Array.prototype.in_array = function(p_val) {
    for(var i = 0, l = this.length; i < l; i++) {
        if(this[i] == p_val) {
            return true;
        }
    }
    return false;
}



window.getDocumentClientHeight=function (objectToSelect) {
	if (!objectToSelect) objectToSelect = document;
    return objectToSelect.compatMode == 'CSS1Compat' /*&& !window.opera*/ ? objectToSelect.documentElement.clientHeight : objectToSelect.body.clientHeight;
}

window.getElementClientWidth=function (objectToSelect) {
	return objectToSelect.offsetWidth;
}

window.getDocumentClientWidth=function (objectToSelect) {
	if (!objectToSelect) objectToSelect = document;
    return objectToSelect.compatMode == 'CSS1Compat' /*&& !window.opera*/ ? objectToSelect.documentElement.clientWidth : objectToSelect.body.clientWidth;
}

window.getElementScrollTop = function (objectToSelect) {
	return objectToSelect.scrollTop;
}

window.getDocumentScrollTop= function (objectToSelect) {
	if (!objectToSelect) objectToSelect = document;
    return objectToSelect.compatMode == 'CSS1Compat' /*&& !window.opera*/ ? objectToSelect.documentElement.scrollTop : objectToSelect.body.scrollTop;
}

window.setDivSizes = function () {
	document.getElementById("GBscrollDiv").style.height=(getDocumentClientHeight()-getElementClientHeight(document.getElementById("topControlPanelDiv")))+"px";
}

getClientWidth = function (d) {
	if (!d) d = document;
	return d.body.clientWidth;
}

window.getClientHeight = function (d) {
	if (!d) d = document;
	return d.body.clientHeight;
}

gwindow.etScrollTop  = function (d) {
	if (!d) d = document;
	return d.documentElement.scrollTop;
}

window.getScrollLeft = function (d) {
	if (!d) d = document;
	return d.documentElement.scrollLeft;
}

window.getScrollHeight = function (d) {
	if (!d) d = document;
	return d.body.scrollHeight;
}

window.getOffsetHeight = function (d) {
	if (!d) d = document;
	return d.documentElement.scrollHeight;
}

window.getOffsetWidth = function (d) {
	if (!d) d = document;
	return d.documentElement.scrollWidth;
}

if (ie) {
    document.attachEvent("onload", setDivSizes);
    document.attachEvent("onresize", setDivSizes);
}
if (mozilla) {
	window.addEventListener("onresize", setDivSizes, true);
	window.addEventListener("onload", setDivSizes, true);
}

window.findPos = function (obj) {
	var curleft = curtop = 0;
	
	if (obj && obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}

	return [curleft,curtop];
}

window.addOnloadListener = function (funcName) {
    var mozilla=document.getElementById && !document.all
    var ie=document.all;
    if (ie) {
        window.attachEvent("onload", funcName);
    }
    if (mozilla) {
        window.addEventListener("load", funcName, true);
    }
} 
