// ==========================================================================================================
// COMBOBOX                                                                                          COMBOBOX
// ==========================================================================================================

/*
jsTrace.send( '->true ' + ddmenuitem );
<script type="text/javascript" src="../../../common/js/jsTrace.js"></script>
<script type="text/javascript" src="../../../common/js/dom-drag.js"></script>
*/

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
var ddBtn	= 0;

var btnUpStyle	= "cbController";
var btnDownStyle	= "cbControllerDown";

// open hidden layer
function mopen(btnID, id, _btnUpStyle, btnDownStyle)
{
	btnUpStyle = _btnUpStyle;
	btnDownStyle = btnDownStyle;
	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddBtn) ddBtn.className = btnUpStyle;
	ddBtn = document.getElementById(btnID);
	ddBtn.className = btnDownStyle;

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	ddBtn.className = btnUpStyle;
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}


// ==========================================================================================================
// MEMBERS                                                                                            MEMBERS
// ==========================================================================================================

var timerID = null;
var NN4 = document.layers ? true : false;
var IE4 = document.all ? true : false;
var FF = document.getElementById ? true : false;

var isVisible = 0;

// ==========================================================================================================
// FUNCTIONS                                                                                        FUNCTIONS
// ==========================================================================================================

function closeMenu( id, _controlId, _controlClass )
{
	_id=id;
	
	if( isVisible==1 )
	{
		hide(_id, _controlId, _controlClass);
		isVisible=0;
	}
}

// ==========================================================================================================

function openclose(id, _controlId, _controlClass)
{
	isVisible=isVisible;
	hide(id, _controlId, _controlClass)
	isVisible=0; 
	clearTimeout(timerID);
	
	if (isVisible==0)
	{
		display(id, _controlId, _controlClass)
		isVisible=1;
	}
}

// ==========================================================================================================

function display(id, _controlId, _controlClass) {
	setControlClass(_controlId, _controlClass);

	if (FF) {
		document.getElementById(id).style.visibility = "visible";
	}
	else if (NN4) {
		document.layers[id].visibility = "show";
	}
	else if (IE4) {
		document.all[id].style.visibility = "visible";
	}
	else {
		document.getElementById(id).style.visibility = "visible";
	}
}

// ==========================================================================================================

function hide(id, _controlId, _controlClass) {
	setControlClass(_controlId, _controlClass);

	if (FF) {
		document.getElementById(id).style.visibility = "hidden";
	}
	else if (NN4) {
		document.layers[id].visibility = "hide";
	}
	else if (IE4) {
		document.all[id].style.visibility = "hidden";
	}
	else {
		document.getElementById(id).style.visibility = "hidden";
	}
}

// ==========================================================================================================

function setControlClass(_id, _class) {
	if (FF) {
		document.getElementById(_id).className = _class;
	}
	else if (NN4) {
		document.layers[_id].className = _class;
	}
	else if (IE4) {
		document.all[_id].className = _class;
	}
	else {
		document.getElementById(_id).className = _class;
	}
}
// ==========================================================================================================
