var maxOpacity = 10;

function setMaxOpacity(value)
{
	maxOpacity = value;
}

function setOpacity( value, strControl ) {
	if (value <= maxOpacity)
	{
		if (document.getElementById(strControl) != null){
			oControl = document.getElementById(strControl);
			oControl.style.opacity = value / 10;
			oControl.style.filter = 'alpha(opacity=' + value * 10 + ')';
		}
	}
}

function fadeInPopup(strControl) {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout( 'setOpacity(' + (i / 10) + ',"' + strControl + '")' , i * 2 );
}

function fadeOutPopup(strControl) {
 for( var i = 0 ; i <= 100 ; i++ ) {
   setTimeout( 'setOpacity(' + (10 - i / 10) + ',"' + strControl + '")' , i * 2);
 }

 setTimeout('closePopup("' + strControl + '")', 500 );
}

function closePopup(strControl) {
	if (document.getElementById(strControl) != null){
		oControl = document.getElementById(strControl);
		oControl.style.display = "none";
	}
}

function firePopup(strControl) {
	if (document.getElementById(strControl) != null){
		setOpacity(0, strControl);
		oControl = document.getElementById(strControl);
		oControl.style.display = "inline";
		fadeInPopup(strControl);
	}
}

// Get the container elemant when the mouse leaves...
function mouseLeaves (element, evt) {
	if (typeof evt.toElement != 'undefined' && typeof element.contains != 'undefined') {
			return !element.contains(evt.toElement);
	}
	else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
		return !contains(element, evt.relatedTarget);
	}
}

// Check whether the containee is in the container
function contains (container, containee) {
	while (containee) {
		if (container == containee) {
			return true;
		}
		containee = containee.parentNode;
	}
	return false;
}

function hideElement (element) {
	if (element.style) {
		element.style.display = 'none';
	}
}

function showElement (element) {
	if (element.style) {
		element.style.display = 'inline';
	}
}