// --------------------------------------------------------------------------------------------------------- SET: Variables (BEGIN)
var activeMenu;
var menuList= new Array(0);
// --------------------------------------------------------------------------------------------------------- SET: Variables (END)
// --------------------------------------------------------------------------------------------------------- SET: Core Styles (BEGIN)
//document.write("<style type=\"text/css\"><!--");
//document.write(".ddholder {position: absolute; margin: 0px; padding: 0px;}");
//document.write(".dd { position: absolute; margin: auto; padding: 0px; z-index: 15; }");
//document.write(".dd table { width:200px; padding: 0px; background-color: #D6D6D6; }");
//document.write(".dd h1 { font-family: Tahoma; font-size: 10px; color: #FFFFFF; padding: 2px; margin-top: 8px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-color: #3c66a5; }");
//document.write(".dd .dd_button { cursor:pointer;}");
//document.write(".dd .cell { padding: 3px; }");
//document.write(".dd .icon { width: 16px; }");
//document.write(".dd .label { font-family: Tahoma; font-size: 10px; font-weight: bold; color: #545454; width:100%;}");
//document.write("</style><![endif]-->");
// --------------------------------------------------------------------------------------------------------- SET: Core Styles (END)
// --------------------------------------------------------------------------------------------------------- SET: Functions (BEGIN)
function getDDButtons() {// --------------------------------------------------------------------------- FUNC: getDDButtons v.1.0
   var my_array = document.getElementsByTagName("*");
   var retvalue = new Array();
   var i;
   var j;
   for (i=0,j=0;i<my_array.length;i++) {
      var c = " " + my_array[i].className + " ";
      if (c.indexOf("dd_button") != -1) retvalue[j++] = my_array[i];
   }
   return retvalue;
}
function cfgDDButtons(coloroff,coloron) {// ----------------------------------------------------------- FUNC: cfgDDButtons v.1.0
	//alert('coloroff: ' + coloroff + ' - coloron: ' + coloron);
	dd_buttons=getDDButtons();
  for (i=0;i<dd_buttons.length;i++) {
		cn=dd_buttons[i].className
		dd_buttons[i].style.backgroundColor = coloroff;
		dd_buttons[i].onBackgroundColor=coloron;
		dd_buttons[i].offBackgroundColor=coloroff;
		dd_buttons[i].buttontype=cn.slice(cn.indexOf(" ")+1,cn.length);
		dd_buttons[i].onmouseover=dd_buttonOn;
		dd_buttons[i].onmouseout=dd_buttonOff;
		dd_buttons[i].onclick=dd_buttonClick;
	}
}
function setDDConfig(){// ----------------------------------------------------------------------------- FUNC: setDDConfig v.1.0
	//alert('RUN: setDDConfig()');
	cfgDDButtons("#D6D6D6","#C2C2C2");
}
function addDDMenus(mlta){// -------------------------------------------------------------------------- FUNC: addDDMenus v.1.0
	//alert('RUN: addDDMenus('+String(mlta)+')');
	//alert('menuList.length: '+menuList.length);
	if(menuList.length==0){startindex=0;}else{startindex=menuList.length;}
	mlta=mlta.split(';');
	for ( var i=0, len=mlta.length; i<len; ++i ){
		//alert('i: '+(startindex+i)+' - VALUE: '+mlta[i]);
		document.getElementById(mlta[i]).style.display='none';
		//alert('SET: style.display='+document.getElementById(mlta[i]).style.display);
		menuList[startindex+i]=mlta[i]
		document.getElementById(mlta[i]).getElementsByTagName('input')[0].value=startindex+i;
		//document.getElementById(mlta[i]).menuID=startindex+i;
  }	
}
function resetDDMenus(showMenu){// ---------------------------------------------------------------------------- FUNC: resetDDMenus v.1.0
	//alert('RUN: resetDDMenus('+String(showMenu).length+')');
	if(String(showMenu)!='')
	{
		var selMenu=document.getElementById(showMenu);
		for ( var i=0, len=menuList.length; i<len; ++i )
		{
			//alert('menuList[i].id == selMenu.id : '+(menuList[i].id==selMenu.id));
			if(String(menuList[i])==String(showMenu))
			{
				document.getElementById(menuList[i]).mmStart = new Date();
				document.getElementById(menuList[i]).mmDHFlag = 'true';
				//document.getElementById(menuList[i]).mmHideMenuTimer = setTimeout("dd_timerHide()", 1000);
				document.getElementById(menuList[i]).style.display='block';
				activeMenu=Number(document.getElementById(menuList[i]).getElementsByTagName('input')[0].value);
			}else{
				//alert('HIDE (Before): Menu\'s: '+menuList[i].id+':'+menuList[i].style.display);
				document.getElementById(menuList[i]).mmDHFlag = 'false';
				document.getElementById(menuList[i]).mmHideMenuTimer = null;
				document.getElementById(menuList[i]).style.display='none';
				//alert('HIDE (After): Menu\'s: '+menuList[i].id+':'+menuList[i].style.display);
			}
			//alert('SET: style.display='+menuList[i].style.display);
		}	
	}
	else
	{
		for ( var i=0, len=menuList.length; i<len; ++i )
		{
//			alert('HIDE (Before): Menu\'s: '+menuList[i].id+':'+menuList[i].style.display);
			document.getElementById(menuList[i]).mmDHFlag = 'false';
			document.getElementById(menuList[i]).mmHideMenuTimer = null;
			document.getElementById(menuList[i]).style.display='none';
			//alert('SET: style.display='+menuList[i].style.display);
//			alert('HIDE (After): Menu\'s: '+menuList[i].id+':'+menuList[i].style.display);
		}	
	}
}
function restoreDDMenus(){// -------------------------------------------------------------------------- FUNC: resetDDMenus v.1.0
	activeMenu=0;
	cfgDDButtons("#D6D6D6","#C2C2C2");
//alert('RUN: restoreDDMenus('+activeMenu+')');
	chk_restoreDDMenus()
}
function chk_restoreDDMenus(){// ---------------------------------------------------------------------- FUNC: chk_restoreDDMenus v.1.0
	//alert('RUN: chk_restoreDDMenus('+activeMenu+')');
}
function dd_startTimeout() {// ------------------------------------------------------------------------ FUNC: dd_startTimeout v.1.0
	//alert('RUN: dd_startTimeout()');
	document.getElementById(menuList[activeMenu]).mmStart = new Date();
	document.getElementById(menuList[activeMenu]).mmDHFlag = 'true';
	document.getElementById(menuList[activeMenu]).mmHideMenuTimer = setTimeout("dd_timerHide()", 1000);
}
function dd_clearTimeout() {// ------------------------------------------------------------------------ FUNC: dd_clearTimeout v.1.0
	//alert('RUN: dd_clearTimeout()');
	if (document.getElementById(menuList[activeMenu]).mmHideMenuTimer) clearTimeout(document.getElementById(menuList[activeMenu]).mmHideMenuTimer);
	document.getElementById(menuList[activeMenu]).mmHideMenuTimer = null;
	document.getElementById(menuList[activeMenu]).mmDHFlag = 'false';
	//dd_mt.setAttribute('mmDHFlag',false);
}
function dd_Show(mid) {// --------------------------------------------------------------------------- FUNC: dd_Show v.1.0
	//alert('RUN: dd_Show('+mid+')');
	resetDDMenus(mid);
	//alert('DONE: dd_Show('+activeMenu+')');
}
function dd_timerHide() {// --------------------------------------------------------------------------- FUNC: dd_timerHide v.1.0
	//alert('RUN: dd_timerHide()');
	//alert('Active Menu: mmDHFlag: ' + document.getElementById(menuList[activeMenu]).mmDHFlag);
	if (document.getElementById(menuList[activeMenu]).mmDHFlag=='false')
	{
		return;
	}
	//alert('ActiveMenu (mmStart): ' + document.getElementById(menuList[activeMenu]).mmStart);
	var elapsed = new Date() - document.getElementById(menuList[activeMenu]).mmStart;
	var timeout = 1000;
	//alert('ActiveMenu ('+elapsed+' < '+timeout+'): ' + (elapsed < timeout));
	if (elapsed < timeout) {
		document.getElementById(menuList[activeMenu]).mmHideMenuTimer = setTimeout("dd_timerHide()", timeout+100-elapsed);
		return;
	}
	resetDDMenus('');	
}
function dd_highlightRow (tr, buttonstate) {// -------------------------------------------------------- FUNC: dd_highlightRow v.1.0
  if (tr) {
		if(buttonstate=="on"){
			//alert('buttonstate: ' + buttonstate + ' - onColor: ' + tr.onBackgroundColor);
			tr.style.backgroundColor = tr.onBackgroundColor;
		}else{
			//alert('buttonstate: ' + buttonstate + ' - offColor: ' + tr.offBackgroundColor);
			tr.style.backgroundColor = tr.offBackgroundColor;
		}
  }
}
function dd_buttonOn () {// --------------------------------------------------------------------------- FUNC: dd_buttonOn v.1.0
	//alert('RUN: dd_buttonOn('+this+')');
	dd_highlightRow(this,"on");
	dd_clearTimeout();
}
function dd_buttonOff () {// -------------------------------------------------------------------------- FUNC: dd_buttonOff v.1.0
	//alert('RUN: dd_buttonOff('+this+')');
	dd_highlightRow(this,"off");
	dd_startTimeout();
}
function dd_buttonClick () {// ------------------------------------------------------------------------ FUNC: dd_buttonClick v.1.0
	switch(this.buttontype){
		case 'ec_content':
				buttontarget=this.id
			break;
		case 'ec_sbpage':
				buttontarget=this.id
			break;
		case 'ec_sbarea':
				buttontarget=this.id
			break;
		case 'ec_mt':
				buttontarget=this.id
			break;
		default :
				buttontarget=this.id
			break;
	}
	window.location = buttontarget
}
// --------------------------------------------------------------------------------------------------------- SET: Functions (END)
