if (typeof ff != "object") ff = new Object();

ff.userAgent = navigator.userAgent.toLowerCase();
ff.bSafari = (ff.userAgent.indexOf("safari") > -1);
ff.bOpera = (ff.userAgent.indexOf("opera") > -1);

ff.getH = function(elmLayer) {
	if (window.getComputedStyle) {
		var style=getComputedStyle(elmLayer, null);
		return parseInt(style.getPropertyValue('height'));
	}
	else if (elmLayer.style.pixelHeight)
		return elmLayer.style.pixelHeight;
	else if(elmLayer.offsetHeight)
		return elmLayer.offsetHeight;
}

ff.getW = function(elmLayer) {
	if (window.getComputedStyle) {
		var style=getComputedStyle(elmLayer, null);
		return parseInt(style.getPropertyValue('width'));
	}
	else if (elmLayer.style.pixelWidth)
		return elmLayer.style.pixelWidth;
	else if(elmLayer.offsetWidth)
		return elmLayer.offsetWidth;
}

ff.getDocumentHeight = function() {
	return (!ff.bSafari) ? document.documentElement.scrollHeight : document.body.offsetHeight;
}

ff.getDocumentWidth = function() {
	return (!ff.bSafari) ? document.documentElement.scrollWidth : document.body.offsetWidth;
}

ff.getClientHeight = function() {
	if (window.innerHeight)
		return window.innerHeight;
	else
		return document.documentElement.clientHeight;
}

ff.getClientWidth = function() {
	if (window.innerWidth)
		return window.innerWidth;
	else
		return (!ff.bSafari) ? document.documentElement.clientWidth : document.body.clientWidth;
}

ff.getElementsByClassName = function(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

ff.getDocumentScroll = function() {
	if (typeof window.pageXOffset != "undefined")
		return {x:window.pageXOffset, y:window.pageYOffset}
	else if (typeof window.scrollX != "undefined")
		return {x:window.scrollX, y:window.scrollY};
	else if (document.all) {
		if (document.compatMode && document.compatMode == "CSS1Compat")
			return {x:document.body.parentNode.scrollLeft, y:document.body.parentNode.scrollTop};
		else
			return {x:document.body.scrollLeft, y:document.body.scrollTop};
	}
	return {x:0, y:0};
}

ff.getScrollTop = function() {
	return ff.getDocumentScroll().y;
}

ff.getScrollLeft = function() {
	return ff.getDocumentScroll().x;
}

ff.centerElement = function(elmLayer) {
	elmLayer.style.visibility = "hidden";
	elmLayer.style.top = (ff.getClientHeight() / 2) + ff.getScrollTop() - (ff.getH(elmLayer) / 2) + "px";
	elmLayer.style.left = (ff.getClientWidth() / 2) + ff.getScrollLeft() - (ff.getW(elmLayer) / 2) + "px";
	elmLayer.style.visibility = "visible";
}

ff.createElement = function(strTagName, strId, objParent) {
	var objElement = document.createElement(strTagName);
	if (strId)
		objElement.id = strId;
	if (objParent)
		objParent.appendChild(objElement);
	return objElement;
}

ff.showOverLay = function(oClickFunction) {
	var oOverLay = document.getElementById("overlay");
	if (oOverLay == null) {
		oOverLay = ff.createElement("div","overlay",document.forms[0]);
		if (oClickFunction) {
			oOverLay.onclick = oClickFunction;
		}
	}
	ff.resizeOverLay();
	oOverLay.style.display = "block";
}

ff.hideOverLay = function() {
	document.getElementById("overlay").style.display = "none";
	document.forms[0].removeChild(document.getElementById("overlay"));
}

ff.resizeOverLay = function() {
	var oOverLay = document.getElementById("overlay");
	if (oOverLay == null || oOverLay.style.display == "none")
		return;
	oOverLay.style.height = ff.getDocumentHeight() + "px";
}

ff.popUp = function(strURL,w,h,blnCentered,strOptions){
	var name="popup"+parseInt(Math.random()*100)
	if(strOptions) strOptions+=","
	else var strOptions=""
	if(blnCentered){
		var x = (screen.width - w) / 2
		x = (x<0) ? 0 : x
		var y = (screen.height - h) / 2
		y = (y<0) ? 0 : y
		strOptions+="left=" + x + ",top=" + y+ ","
	}
	if(w) strOptions+="width="+w + ","
	if(h) strOptions+="height="+h + ","
	if(strOptions.substr(strOptions.length-1)==",") strOptions = strOptions.substr(0,strOptions.length-1)
	var win=window.open(strURL,name,strOptions);
	if(strURL.indexOf("http://")==-1 || strURL.indexOf(document.location.hostname)>-1) win.focus();
	return win
}



