//browser detection
var ie = (document.all)? 1 : 0 ;
var ns = (document.getElementById)? 1 : 0 ;
var ns4 = (document.layers)? 1 : 0 ;
var ns6 = document.getElementById && !document.all;


function DetectBrowser(){ //Detectarea browserului folosit
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new DetectBrowser();




//f_sm
var f_sm = 0;
var f_sm2 = 0;

//set a property to a layer
function setLay(name, prop, val){
  	if(!ns4) {
   		if(ns6) obj = eval('document.getElementById("'+name+'").style');
		   else obj = eval('document.all("'+name+'").style');
		obj[prop] = val + 'px';
	}
}


var tout = null;
var tout2 = null;


function createSubmenu(nr){ //BLUE SUBMENUS
	menW = 130;
	//create submenu items
	var var_submenu_items = '';
	for(i=1;i<=submenu[nr][0];i++){
		clasa = 'submenuItem';
		
		//hasSubmenu
		hasSubmenu = '';
		linkul = '<span id="link_'+nr+'_'+i+'" class="'+clasa+'" '+hasSubmenu+'>&nbsp;&nbsp;&nbsp;'+ submenu[nr][i][0] +'</span>';
		// tdOver('+nr+','+i+'); tdOut('+nr+','+i+'); 
		if(submenu[nr][i][0] == '') var_submenu_items += '';//'<tr><td colspan="3" bgcolor="#eeeeee"><img src="'+LAYOUTS+'images/spacer.gif" width="'+menW+'" height="1" border="0"></td></tr>';
		else if(submenu[nr][i][2] == 1) 
			 var_submenu_items += '            <tr>              <td width="100%" align="left" valign="middle"><table id="tab_'+nr+'_'+i+'" onMouseOver="showSubmenu(\'show\', '+nr+''+i+');" onMouseOut="showSubmenu(\'hide\','+nr+''+i+');" class="clickable" '+hasSubmenu+' onClick=document.location="'+submenu[nr][i][1]+'" height="20" width="'+(menW)+'"  border="0" cellspacing="0" cellpadding="0" bgcolor="#012D6C">   <tr>  <td align="left" valign="middle" width="'+(menW)+'"><table width="'+menW+'" border="0" cellpadding="0" cellspacing="0" id="td_'+nr+'_'+i+'" bgcolor="#012D6C"><tr><td>&nbsp;&nbsp;'+linkul+'</td></tr></table></td>  </tr>  </table></td>           </tr>';
		else var_submenu_items += '            <tr>              <td width="100%" align="left" valign="middle"><table id="tab_'+nr+'_'+i+'" onMouseOver="tdOver('+nr+','+i+')" onMouseOut="tdOut('+nr+','+i+')" class="clickable" '+hasSubmenu+' onClick=document.location="'+submenu[nr][i][1]+'" height="20" width="'+(menW)+'"  border="0" cellspacing="0" cellpadding="0" bgcolor="#012D6C">   <tr>  <td align="left" valign="middle" width="'+(menW)+'"><table width="'+menW+'" border="0" cellpadding="0" cellspacing="0" id="td_'+nr+'_'+i+'" bgcolor="#012D6C"><tr><td align="left" height="20">&nbsp;&nbsp;'+linkul+'</td></tr></table></td>  </tr>  </table></td>           </tr>';
	}
	
	
	//overLayer  menu/submenu
	if(nr < nrSubmenus+1) overLay = 'onMouseOver="showMenu(\'show\','+nr+');" onMouseOut="showMenu(\'hide\','+nr+');"';
		 else overLay = ' onMouseOver="showSubmenu(\'show\','+nr+')" onMouseOut="showSubmenu(\'hide\','+nr+')" ';

	//create submenu layer  
	var_submenu = '<div class="lay" id="submenu'+nr+'" '+overLay+'><table width="'+(menW+5)+'" border="0" cellpadding="0" cellspacing="0" bgcolor="#012D6C"><tr><td bgcolor="#012D6C"><table width="'+(menW)+'" border="0" cellpadding="0" cellspacing="0">     '+ var_submenu_items +'    </table></td></tr></table></div></div>';

	//print menu layer
	document.write(var_submenu);
}



function initMenus(){
	for(nr=1; nr<=nrSubmenus; nr++) createSubmenu(nr);
}



function showMenu(visibility,nr) { 
if(nr<=nrSubmenus){
  for(i=1;i<=nrSubmenus;i++) if(i!=nr) {
	  MM_showHideLayers('submenu'+i,'','hide');	
  }
  clearTimeout(tout);
  clearTimeout(tout2);
  
  //get table position
  if(ns6){
	posLeft = document.getElementById('xy').offsetLeft;  
	posTop = document.getElementById('xy').offsetTop;
  } else { 
	posLeft = xy.offsetLeft;  
	posTop = xy.offsetTop; 
  }
  
  ww=0; hh=0;
  ww = widths[nr];
  hh = heights[nr];

  //place layers
  setLay('submenu'+nr,'left',posLeft + ww);
  setLay('submenu'+nr,'top',posTop + hh);
  
  //alert((posTop + hh) + ' ' + (posLeft + ww));
  
  //show layers
  if (visibility=='show') MM_showHideLayers('submenu'+nr,'','show');
  else if (visibility=='hide') {
  	if(f_sm == 0) {
		tout = setTimeout('MM_showHideLayers("submenu'+nr+'","","hide")',400);
		tout2 = setTimeout('MM_swapImgRestore()',400);
	}
  }
}
}



function showSubmenu(visibility, nr) { 
//alert(nr);
if( (nr == 13) ){

  if((nr >= 100) && (window.tout3)) clearTimeout(tout3);
  clearTimeout(tout2);
  
  //get table position
  if(ns6){
	posLeft = document.getElementById('xy').offsetLeft;  
	posTop = document.getElementById('xy').offsetTop;
  } else { 
	posLeft = xy.offsetLeft;  
	posTop = xy.offsetTop; 
  }
  
  //place layers
  setLay('submenu'+nr,'left',posLeft + widths[nr]);
  setLay('submenu'+nr,'top',posTop + heights[nr]);
  
  //show layers
  if (visibility=='show') {
	f_sm = nr;
	MM_showHideLayers('submenu'+nr,'','show');
	nr2=nr;
	while(nr2>=10){
		showMenu('show', parseInt(nr2/10));
		nr2 = parseInt(nr2/10);
		}
	}
  else if (visibility=='hide') {
	//alert(nr);
  	if(nr >= 100) {
		tout3 = setTimeout('MM_showHideLayers("submenu'+nr+'","","hide")',200);
		nr2 = nr;
		while(nr2>=10){
			showSubmenu('hide', parseInt(nr2/10))
			nr2 = parseInt(nr2/10);
			}	
		}
  	else tout2 = setTimeout('MM_showHideLayers("submenu'+nr+'","","hide")',300);
	f_sm = 0;
	showMenu('hide', parseInt(nr/10));
  }
}
}

//mouseOver Table Cell
function tdOver(nr,i){
	tab = fieldOb('tab_'+nr+'_'+i);
	tab.bgColor = "#FFFFFF"; 
	cell = fieldOb('td_'+nr+'_'+i);
	cell.bgColor = "#FFFFFF"; 
	linkul = fieldOb('link_'+nr+'_'+i);
	linkul.className = "submenuItemOver";
	//img = fieldOb('img_'+nr+'_'+i);
	//img.src = LAYOUTS + "images/arrow_22.gif";
}

//mouseOut Table Cell
function tdOut(nr,i){
	tab = fieldOb('tab_'+nr+'_'+i);
	tab.bgColor = "#012D6C"; 
	cell = fieldOb('td_'+nr+'_'+i);
	cell.bgColor = "#012D6C";  
	linkul = fieldOb('link_'+nr+'_'+i);
	linkul.className = "submenuItem";
	//img = fieldOb('img_'+nr+'_'+i);
	//img.src = LAYOUTS + "images/arrow_26.gif";
}


//initializate menus
initMenus();
