// dhtml basic functions

var isCSS, isW3C, isIE4, isIE6CSS, isIE5MAC, isNN4, isNN6, isOP7, MAC;

function checkIBrowser() {
	isCSS = (document.body && document.body.style)? true : false;
	isW3C = (isCSS && document.getElementById)? true : false;
	isIE4 = (isCSS && document.all)? true : false;
	isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0)? true : false;
	isNN4 = (document.layers)? true : false;
	isNN6 = (document.getElementById && !document.all)? true : false;
	isOP7 = (document.insertAdjacentHTML)? true : false;
	MAC = (navigator.appVersion.indexOf( 'Mac' ) != -1);
	isIE5MAC = (document.all && document.getElementById && MAC);
	
	return;
}

// Set the background color of an object
function setBGColor(obj, color) {
	var theObj = getObject(obj);
	if (theObj) {
		if (isNN4) {
			theObj.bgColor = color;
		} else if (isCSS) {
			theObj.backgroundColor = color;
		}
	}
}

// Convert object name string or object reference
// into a valid style (or NN4 layer) reference
function getObject(obj) {
	var theObj = getRawObject(obj);
	if (theObj && isCSS) {
		theObj = theObj.style;
	}
	return theObj;
}

// Convert object name string or object reference
// into a valid element object reference
function getRawObject(obj) {
	var theObj;
	if (typeof obj == "string") {
		if (isW3C) {
			theObj = document.getElementById(obj);
		} else if (isIE4) {
			theObj = document.all(obj);
		} else if (isNN4) {
			theObj = seekLayer(document, obj);
		}
	} else {
		// pass through object reference
		theObj = obj;
	}
	return theObj;
}

// Set the visibility of an object to visible - true or hidden - false
function showHideObject(obj, sw) {
    var theObj = getObject(obj);
    if (theObj) {
    	if (sw)
        	theObj.visibility = "visible";
        else
        	theObj.visibility = "hidden";
    }
}

