
function setOpacity( obj, opacity )
{
 opacity = (opacity>=100)? 99.999 : opacity;
  
 // IE/Win
 obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
 obj.style.KHTMLOpacity = opacity/100;
  
 // Older Mozilla and Firefox
 obj.style.MozOpacity = opacity/100;
  
 // Safari 1.2, newer Firefox and Mozilla, CSS3
 obj.style.opacity = opacity/100;
}

function FadeIn( id, opacity, pas)
{
 obj = document.getElementById(id);
 if (opacity <= 100)
 		{
     setOpacity(obj, opacity);
     opacity += pas;
     window.setTimeout("FadeIn('"+id+"',"+opacity+","+pas+")", 50);
    }
}

function ZoomUP( id, pas, x, y, w, h, x2, y2, w2, h2 ) 
{
 obj = document.getElementById( id );

 if( pas )
 	{
 	 x += Math.floor( Math.abs( x2 - x ) / pas );
 	 y -= Math.floor( Math.abs( y2 - y ) / pas );

 	 w += Math.floor( Math.abs( w2 - w ) / pas );
 	 h += Math.floor( Math.abs( h2 - h ) / pas );
 	}
 else
 	{
 	 x = x2; y = y2; w = w2; h = h2;
 	}
  
 obj.style.left   = x + 'px';  
 obj.style.top    = y + 'px';
 obj.style.width  = w + 'px';
 obj.style.height = h + 'px';
 
 if( pas-- )
 	window.setTimeout("ZoomUP('"+id+"',"+pas+","+x+","+y+","+w+","+h+","+x2+","+y2+","+w2+","+h2+")", 10 );
}

function ZoomDOWN( id, pas, x, y, w, h, x2, y2, w2, h2 ) 
{
 obj = document.getElementById( id );

 if( pas )
 	{
 	 x += Math.floor( Math.abs( x2 - x ) / pas );
 	 y += Math.floor( Math.abs( y2 - y ) / pas );

 	 w += Math.floor( Math.abs( w2 - w ) / pas );
 	 h += Math.floor( Math.abs( h2 - h ) / pas );
 	}
 else
 	{
 	 x = x2; y = y2; w = w2; h = h2;
 	}
  
 obj.style.left   = x + 'px';  
 obj.style.top    = y + 'px';
 obj.style.width  = w + 'px';
 obj.style.height = h + 'px';
 
 if( pas-- )
 	window.setTimeout("ZoomDOWN('"+id+"',"+pas+","+x+","+y+","+w+","+h+","+x2+","+y2+","+w2+","+h2+")", 20 );
}

function GetPosOffsetTopLeft( e, topLeft )
{
 var total = topLeft ? e.offsetTop : e.offsetLeft;
 while( e = e.offsetParent ) total += (topLeft ? e.offsetTop : e.offsetLeft);	
 return total;
}

var HMenu_HideDelay     = 250; // delais en ms
var HMenu_CurrentObject = null;
var HMenu_IDDelay = "undefined";

function HMenu_Process( oElement, oEvent, align )
{
 if( HMenu_CurrentObject != null ) // hide previous menu
		HMenu_DoHide();

 HMenu_CancelDelayHide();
 
 if( document.getElementById && (HMenu_CurrentObject = document.getElementById( oElement.id + "_SubMenu" )) )
		{
		 oElement.onmouseout = function() { HMenu_DoDelayHide(); };
		 
		 if( !HMenu_CurrentObject.contains )
			HMenu_CurrentObject.contains = function( oChild )
																	  {
																	   if( !oChild.nodeType ) return false;
																	   if( this == oChild   ) return true;
																		 while( oChild.parentNode ) if( (oChild = oChild.parentNode) == this ) return true;
																		 return false;
																	  };

		 HMenu_CurrentObject.onmouseover = function() { HMenu_CancelDelayHide();    };
		 HMenu_CurrentObject.onmouseout  = function() { if( !this.contains( document.all ? window.event.toElement : oEvent.relatedTarget ) ) HMenu_DoDelayHide(); };
		 HMenu_CurrentObject.onclick     = function() { HMenu_DoDelayHide();    };

 		 HMenu_CurrentObject.style.left = HMenu_CurrentObject.style.top = "-500px";
 		
 		 if( oEvent.type == "click" && oElement.visibility == "hidden" || oEvent.type == "mouseover" )
				HMenu_DoShow();

 		 else if( oEvent.type == "click" )
				HMenu_DoHide();
		 
 		 HMenu_CurrentObject.style.left = GetPosOffsetTopLeft(oElement,0) + (( align == 'right' )? oElement.offsetWidth - HMenu_CurrentObject.offsetWidth : 0 ) + "px";
		 HMenu_CurrentObject.style.top  = GetPosOffsetTopLeft(oElement,1) + oElement.offsetHeight + "px";
		}
}

function HMenu_DoShow()
{
 if( !HMenu_CurrentObject ) return;
 HMenu_CurrentObject.style.visibility='visible';
 
 if( !document.all || !document.all.tags ) return;
  
 var sel = document.all.tags("SELECT");
 for( i=0 ; i< sel.length ; i++ )
 		{
 		 sel[i].HMenuPrevVisibility = sel[i].style.visibility;
 		 sel[i].style.visibility = 'hidden';
 		}
}

function HMenu_DoHide()
{
 if( !HMenu_CurrentObject ) return;
 HMenu_CurrentObject.style.visibility='hidden';

 if( !document.all || !document.all.tags ) return;
  
 var sel = document.all.tags("SELECT");
 for( i=0 ; i< sel.length ; i++ )
 		{
 		 sel[i].style.visibility = sel[i].HMenuPrevVisibility;
		 sel[i].HMenuPrevVisibility = '';
 		}
}

function HMenu_DoDelayHide()
{
 HMenu_IDDelay = setTimeout( "HMenu_DoHide()",  HMenu_HideDelay );
}

function HMenu_CancelDelayHide()
{
 if( HMenu_IDDelay != "undefined" )
			clearTimeout( HMenu_IDDelay );
 HMenu_IDDelay = "undefined";
}
