var COMPAT_NS    = navigator.appName == 'Netscape';
var COMPAT_OP    = window.opera ? true : false;
var COMPAT_IE    = (!COMPAT_OP && document.all) ? true : false;
var COMPAT_VER   = parseInt(navigator.appVersion);
var COMPAT_DOM   = document.getElementById ? true : false;
var COMPAT_ALPHA = (COMPAT_IE || (COMPAT_NS && COMPAT_DOM)) ? true : false;

function elementById (ElementId)
{
  Ref = COMPAT_IE ? document.all[ElementId] : (COMPAT_DOM ? document.getElementById(ElementId) : null);
  return (Ref);
}

function setAlpha (Element, Value)
{
  if (COMPAT_ALPHA)
  {
    if (typeof(Element) == 'string') { Element = elementById(Element); }
    if (COMPAT_NS) { Element.style.MozOpacity=Value.toString() + "%"; }
    else { Element.style.filter="alpha(opacity=" + Value.toString() + ")"; }
  }
}

function getParentElement (Element)
{
  if (typeof(Element) == 'string') { Element = elementById(Element); }
  return Element.parentElement? Element.parentElement : Element.parentNode;
}

function getClientX()
{
  return ( COMPAT_IE ? window.document['body'].clientWidth : ( ( window.scrollbars ) ? ( window.innerWidth - 16 ) : window.innerWidth ) );
}

function getClientY()
{
  return (COMPAT_IE ? window.document['body'].clientHeight : ( ( window.scrollbars ) ? ( window.innerHeight - 16 ) : window.innerHeight ) );
}

function getScrollX()
{
  return (COMPAT_IE ? window.document['body'].scrollLeft : window.pageXOffset);
}

function getScrollY()
{
  return (COMPAT_IE ? window.document['body'].scrollTop : window.pageYOffset);
}


function setVis (Element, Vis)
{
  Vis = Vis ? "visible" : "hidden" ;
  if (typeof(Element) == 'string') { Element = elementById(Element); }
  Element.style.visibility = Vis;
}

function getVis (Element)
{
  if (typeof(Element) == 'string') { Element = elementById(Element); }
  return (Element.style.visibility ? ((Element.style.visibility.toLowerCase() == "visible") ? true : false) : false);
}

function setPos(Element, X, Y)
{
  if (typeof(Element) == 'string') { Element = elementById(Element); }
  if ( X != null) { X = Math.round ( X ); Element.style.left = X.toString() + "px"; }
  if ( Y != null) { Y = Math.round ( Y ); Element.style.top = Y.toString() + "px"; }
}

function setSize(Element, X, Y)
{
  if (typeof(Element) == 'string') { Element = elementById(Element); }
  if ( X != null ) { X = Math.round ( X ); Element.style.width = X.toString() + "px"; }
  if ( Y != null ) { Y = Math.round ( Y ); Element.style.height = Y.toString() + "px"; }
}

function getWidth( Element ) {
	if( typeof( Element ) == 'string' ) { Element = elementById(Element); }
	return( Element.offsetWidth );
}

function getHeight( Element ) {
	if( typeof( Element ) == 'string' ) { Element = elementById(Element); }
	return( Element.offsetHeight );
}


var fadeTimeout = 0;

function fade (Element, From, To, Step, Delay, OnDone)
{
   if ((((Step < 0)&&(From >= To))||((Step > 0)&&(From <= To))) && COMPAT_ALPHA)
   {
     setAlpha(Element, From); From += Step;
     if (!getVis(Element)) { setVis (Element, true); }
     OnDoneCall = ((OnDone == null) ? ", null" : ", \"" + OnDone + "\"" );
     fadeTimeout = setTimeout("fade(\"" + Element + "\"," + From.toString() + ", " + To.toString() + ", "+ Step.toString() + ", "+
                            Delay.toString() + OnDoneCall + ")", Delay);
    }
    else
    {
       fadeTimeout = 0;
	   if (To != 0) { setVis (Element, true) };
       if (To == 0) { setVis (Element); setAlpha (Element, 100)};
       if (OnDone != null) eval(OnDone);
    }
}