
function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p.className = "active";

	if( c["at_position"] == 'y' )
	{
		var top  = p.offsetHeight + 5;
  		var left = -10;
	}
	else
	{
		var top  = -c.offsetHeight - 2;
		var left = -10;
	}

  for (; p; p = p.offsetParent)
  {
    if (p.style.position != 'absolute')
    {
      left += p.offsetLeft;
      top  += p.offsetTop;
    }
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
  
  // TOM
  document.getElementById(parent+'_div').style.backgroundImage = 'url(img/m0_on_bg.gif)';
  
//	var s = document.getElementsByTagName('select');
//	for( var i=0; i<s.length; i++ ) s[i].style.zIndex = 1;

  // /TOM

 //IVAN
	if (BrowserDetect.browser == "Safari")
	{
		//eliminar flash		
		document.getElementById('flashcontent').style.visibility="hidden";
	}
 //IVAN	
}

// ----- Hide Aux -----

function at_hide_aux(parent, child)
{
  // document.getElementById(parent).className = "parent";
  document.getElementById(child ).style.visibility = "hidden";
  
  // TOM
  document.getElementById(parent+'_div').style.backgroundImage = 'none';
  // /TOM
  
   //IVAN
	if (BrowserDetect.browser == "Safari")
	{
		//eliminar flash		
		document.getElementById('flashcontent').style.visibility="visible";
	}
 //IVAN	
}

// ----- Show -----

function at_show_p(  )
{
  c = document.getElementById(this["at_child" ]);
  at_show_aux(this.id, c.id);
  clearTimeout(c["at_timeout"]);
}

function at_show_c(  )
{
  p = document.getElementById(this["at_parent"]);
  at_show_aux(p.id, this.id);
  clearTimeout(this["at_timeout"]);
}

// ----- Hide -----

function at_hide_p()
{
  c = document.getElementById(this["at_child" ]);
  c["at_timeout"] = setTimeout("at_hide_aux('"+this.id+"', '"+c.id+"')", 50);
}

function at_hide_c()
{
  p = document.getElementById(this["at_parent"]);
  this["at_timeout"] = setTimeout("at_hide_aux('"+p.id+"', '"+this.id+"')", 50);
}

// ----- Attach -----

function at_attach(parent, child, position)
{
  p = document.getElementById(parent);
  c = document.getElementById(child);

  p["at_child"]    = c.id;
  c["at_parent"]   = p.id;
  c["at_position"] = position;

  //p.onmouseover = at_show_p;
  //p.onmouseout  = at_hide_p;
  c.onmouseover = at_show_c;
  c.onmouseout  = at_hide_c;
}

// ----- DropDown Menu ---------------------------------------------------------

// ----- Build Aux -----

function dhtmlmenu_build_aux(parent, child, position)
{
	// document.getElementById(parent).className = "parent";
	
	document.write('<div class="vert_menu" id="'+parent+'_child">');
	
	for( i = 0; i < child.length; i ++ )
	{
		has_css = ( child[i]['css'] != '' );
		has_hrf = ( child[i]['hrf'] != '' );
		
		if( has_css )
			document.write('<div class="'+ child[i]['css'] +'">');
		
		if( has_hrf )
			document.write('<a id="'+parent+'_'+i+'" href="'+child[i]['hrf']+'">' );
		
		document.write( child[i]['txt'] );
		
		if( has_hrf )
			document.write('</a>');
		
		if( has_css )
			document.write('</div>');
	}
	
	//document.write('<iframe style="display: none; left: 0px; position: absolute; top: 0px; z-index: 10;" src="javascript:false;" frameborder="0" scrolling="no" width="300" height="300"></iframe>');
	
	document.write('</div>');
	
	at_attach(parent, parent+"_child", position);
	
	c.style.position   = "absolute";
	c.style.top        = '0px';
	c.style.left       = '0px';
}

// ----- Build -----

function dhtmlmenu_build( menu, menu_position )
{
	for( var i in menu )
	{
		dhtmlmenu_build_aux( i, menu[i], menu_position );
	}
}
