isNS4 = (document.layers) ? 1 : 0;
isIE4 = (document.all) ? 1 : 0;
isW3C = (document.getElementById && !document.all) ? 1 : 0;

function FIND(item) {
	var agt = navigator.userAgent.toLowerCase();
	window.mmIsOpera = agt.indexOf("opera") != -1;
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function getCalculatedProperty(objName, property) {

    // ***** W3C Compatible DOM (NN6, Mozilla 16, etc.) *****

    if (isW3C) {
        docObj = document.getElementById(objName);
		
        if (property == "visibility") {
	    cssp = docObj.style.visibility;
	    return (cssp == "") ? "inherit" : cssp;
	}

	if (property == "clip") {
	    cssp = docObj.style.clip;

	    if (cssp == "") {
		cssStr = "rect(0px "; 
		cssStr += getCalculatedProperty(objName, "width") + " ";
		cssStr += getCalculatedProperty(objName, "height") + " ";
		cssStr += "0px)";
		return cssStr;
	    }
	    return cssp;
	}

	if (property == "zIndex") {
	    cssp = docObj.style.zIndex;
	    return (cssp == "") ? "inherit" : cssp;
	}

	cssp = document.defaultView.getComputedStyle(docObj, "").getPropertyValue(property);

	return (cssp == "") ? "unknown" : cssp;
    }

    // ***** Netscape Navigator 4+ DOM *****

    if (isNS4) {
	docObj = document.layers[objName];

	if (property == "visibility") {
	    cssp = docObj.visibility;
	    return (cssp == "hide") ? "hidden" : (cssp == "show") ? "visible" : "inherit";
	}

	if (property == "clip") {
	    cssStr = "rect(" + docObj.clip.top + "px ";
	    cssStr += docObj.clip.right + "px ";
	    cssStr += docObj.clip.bottom + "px ";
	    cssStr += docObj.clip.left + "px)";
	    return cssStr;
	}


	if ((property == "width") || (property == "height")) {
	    return eval("docObj.clip." + property) + "px";
	}

	if (property == "top") property = "pageY";
	if (property == "left") property = "pageX";

	cssp = eval("docObj." + property);

	if (property != "zIndex") cssp += "px";

	return cssp;
    }

    // ***** Internet Explorer 4+ DOM *****

    if (isIE4) {
	if (property == "width") return eval(objName + ".offsetWidth") + "px";

	if (property == "height") return eval(objName + ".offsetHeight") + "px";

	if (property == "clip") {
	    cssp = eval(objName + ".style.clip");

	    if (cssp == "") {
		cssStr = "rect(0px ";
		cssStr += getCalculatedProperty(objName, "width") + " ";
		cssStr += getCalculatedProperty(objName, "height") + " ";
		cssStr += "0px)";
		return cssStr;
	    }
	    return cssp;
	}

	if (property == "top") return eval(objName + ".offsetTop") + 'px';

	if (property == "left") return eval(objName + ".offsetLeft") + 'px';

        // Else, use 'currentStyle' to find the rest

	return eval(objName + ".currentStyle." + property);
    }
}

function PlaceFooterDiv(SourceDiv, MoveDiv) {

	var TopPos=parseInt(getCalculatedProperty(SourceDiv, "top")) ;
	var DivHeight=parseInt(getCalculatedProperty(SourceDiv, "height")) ;
	var _id='' ;
	
	// now put the div in the right place
	var PlaceAt=TopPos+DivHeight+20 ;

//	alert('The top is at row '+TopPos+', the height is '+DivHeight+' so with a 20px buffer the top of '+MoveDiv+' is '+PlaceAt)

	_id=FIND(MoveDiv) ;
	if(document.all && _id != false){
		_id.style.top = PlaceAt;
		_id.style.visibility="visible";
	}else if(document.layers && _id != false){
		_id.top = PlaceAt;
		_id.visibility="visible";
	}else if(document.getElementById && _id != false){
		_id.style.top = PlaceAt;
		_id.style.visibility="visible";
	}

//	alert('Placing '+MoveDiv+' at position '+PlaceAt) ;
}

function start(WhatDiv) { 
	if (WhatDiv == '') return ;
	str = "Browser: ";
	str += (isIE4) ? "Internet Explorer 4+" : (isNS4) ? "Netscape Navigator 4+" : (isW3C) ? "W3C Compliant" : "unknown";
	str += "\n"+WhatDiv+".height = " + getCalculatedProperty(WhatDiv, "height") + "\n";
	str += WhatDiv+".width = " + getCalculatedProperty(WhatDiv, "width")+ "\n";
	str += WhatDiv+".top = " + getCalculatedProperty(WhatDiv, "top")+ "\n";
	str += WhatDiv+".left = " + getCalculatedProperty(WhatDiv, "left")+ "\n";
	str += WhatDiv+".right = " + getCalculatedProperty(WhatDiv, "right")+ "\n";
	str += WhatDiv+".clip = " + getCalculatedProperty(WhatDiv, "clip")+ "\n";
	str += WhatDiv+".visibility = " + getCalculatedProperty(WhatDiv, "visibility") + "\n";
	str += WhatDiv+".zIndex = " + getCalculatedProperty(WhatDiv, "zIndex");

	alert(str);
}

function hideObject(_o, _a) {
	var _i=FIND(_o) ;

	if (document.layers) {
		_i.visibility = _a;
	} else {
		_i.style.visibility = _a;
	}
	return(true);
}

function removeObjectFromSight(_o, _a) {
	var _i=FIND(_o) ;

	if (document.layers) {
		_i.display = _a;
	} else {
		_i.style.display = _a;
	}
	return(true);
}

function MakeDropdownOption(OptionValue, OptionName, CurrentOption) {
	SelectedOption='' ;
	if (OptionValue == CurrentOption) {
		SelectedOption=' SELECTED' ;
	}
	document.write('<OPTION VALUE="' + OptionValue + '"' + SelectedOption + '>' + OptionName + "</OPTION>") ;
}


function selSELECT(_i, which) {
	/*
	Inspired by a script by Joe Crawford http://www.artlung.com/
	*/
	//document.forms[0].mySelectBox.selectedIndex = which;
	var _o=FIND(_i) ;

	var _v=-1 ;
	for (var i=0; i<_o.length ; i++)
	{
		if (_o[i].value == which)
		{
			_v=i ;
			break ;
		}
	}
	if ( _v != -1)
	{
//		alert('Setting the default index position to '+_v) ;
//		_o.selectedIndex=_v ;
		_o[_v].selected=true ;
	}
}
