All pastes #15868 Raw Edit

Unnamed

public text v1 · immutable
#15868 ·published 2005-06-26 03:06 UTC
rendered paste body
<!--//--><![CDATA[//><!--

var on = new Array(document.getElementsByTagName("*").length);

var faded = 50;
var full = 100;

var smoothness = 10;
var speed = 10;
	
function getElementByClassName(name)
{
	var root = document.getElementsByTagName("*");
            
	for (i=0; i<root.length;i++)
	{
		if(root[i].className.indexOf(name) != -1)
			return root[i];
	}
	return false;
}
function attachAction(element,objid)
{	
	element.onmouseover=function()
	{
		on[objid] = true;
		fadeIn(objid,faded);
	}
	element.onmouseout=function()
	{
		on[objid] = false;
		fadeOut(objid,full);
	}
	setOpacity(element,faded);
}

function fadeIn(objid,opacity) {
      obj = getElementByClassName('fader_'+objid);
	if (opacity <= full && on[objid]) {
		setOpacity(obj, opacity);
		opacity += smoothness;
		window.setTimeout("fadeIn('"+objid+"',"+opacity+")",speed);
	}
}

function fadeOut(objid,opacity) {
      obj = getElementByClassName('fader_'+objid);
	if (opacity >= faded && !on[objid]) {
		setOpacity(obj, opacity);
		opacity -= smoothness;
		window.setTimeout("fadeOut('"+objid+"',"+opacity+")",speed);
	}
}

function setOpacity(obj, opacity) {
  
	opacity = (opacity == full)?99.999:opacity;
  
	obj.style.filter = "alpha(opacity:"+opacity+")";
	obj.style.KHTMLOpacity = opacity/full;
	obj.style.MozOpacity = opacity/full;
	obj.style.opacity = opacity/full;
}


function createFader() {
     
	var root = document.getElementsByTagName("*");
            
	for (i=0; i<root.length;i++)
	{
		if(root[i].className == "fader")
		{
			root[i].className += ' fader_'+i;
			attachAction(root[i],i);
		}
	}
}
        
window.onload=createFader;

//--><!]]>