/****** User may alter these to change the fade effect ********/
var FadeInStep 	= 12;
var FadeOutStep = 12;
/****** Don't alter anything else **************/
document.write('<STYLE TYPE="text/css">.imgFader{ position:relative; filter:alpha(opacity=0); -moz-opacity:0.0 }</STYLE>');

if(!window.allsoo)
	allsoo=new Object();

allsoo.RolloverObjects=new Array();

allsoo.Rollover = function(name, img)
{
	allsoo.RolloverObjects[name]=new Image();
	allsoo.RolloverObjects[name].img_src = img;	
	if(!allsoo.Rollover.postLoad)
		allsoo.RolloverObjects[name].src = img;
}
allsoo.Rollover.postLoad = false;
allsoo.Rollover.loadImages = function()
{
	var i;
	for(i in allsoo.RolloverObjects)
	{
		r=allsoo.RolloverObjects[i];
		r.src=r.img_src;
	}
}
allsoo.Rollover.error = function(n)
{
		alert("allsoo.Rollover - An Error has been detected\n"
			+ "----------------------------------\n"
			+ "You must define a allsoo.Rollover in your document\n"
			+ "allsoo.Rollover(\""+n+"\",\"your_on_img.gif\")\n"
			+ "(check the spelling of your allsoo.Rollovers)");
}
/*******************************************************************
*
* Function    : getImg
*
* Description : In Netscape 4 images could be in layers so we might
*		    have to recurse the layers to find the image
*
*****************************************************************/
allsoo.getImg = function(n, d) 
{
	var img = d.images[n];
	if(!img && d.layers)  
		for(var i=0 ; !img && i<d.layers.length ; i++)
			img=allsoo.getImg(n,d.layers[i].document);
	return img;
}
/*******************************************************************
*
* Function    : findImg
*
* Description : gets the image from the document and reports an
*		    error if it cannot find it.
*
*****************************************************************/
allsoo.findImg = function(n, d) 
{
	var img = allsoo.getImg(n, d);

	/*** Stop emails because the image was named incorrectly ***/
	if(!img)
	{
		alert("allsoo.findImg - An Error has been detected\n"
			+ "----------------------------------\n"
			+ "You must define an image in your document\n"
			+ "<IMG SRC=\"your_image.ext\" NAME=\""+n+"\">\n"
			+ "(check the NAME= attribute of your images)");

		return(new Image());
	}
	return img;
}

allsoo.ImageFadeRunning=false;
allsoo.ImageFadeInterval=30;


allsoo.imgFadeIn = function(img, imgSrc)
{
	if(img) 
	{
		if(img.state == null) 
		{
			img.state = "OFF";
			img.index = 0;
			img.next_on    = null;
		}

		if(img.state == "OFF")
		{
			/*** Vers 1.7 only load the ON image once ever ***/
			if(img.src.indexOf(imgSrc) == -1)
				img.src=imgSrc;

			img.currSrc = imgSrc;
			img.state = "FADE_IN";
			allsoo.startFading();
		}
		else if( img.state == "FADE_IN_OUT"
			|| img.state == "FADE_OUT_IN"
			|| img.state == "FADE_OUT")
		{
			if(img.currSrc == imgSrc)
				img.state = "FADE_IN";
			else
			{

				img.next_on = imgSrc;
				img.state="FADE_OUT_IN";
			}
		}
	}
}

allsoo.imgFadeOut = function(img)
{
	if(img)
	{
		if(img.state=="ON")
		{
			img.state="FADE_OUT";
			allsoo.startFading();
		}
		else if(img.state == "FADE_IN")
		{
			img.state="FADE_IN_OUT";
		}
		else if(img.state=="FADE_OUT_IN")
		{
			img.next_on == null;
			img.state = "FADE_OUT";
		}
	}
}

allsoo.startFading = function()
{
	if(!allsoo.ImageFadeRunning)
		allsoo.ImageFadeAnimation();
}

allsoo.ImageFadeAnimation = function()
{
	allsoo.ImageFadeRunning = false;
	for(i=0 ; i<document.images.length ; i++)
	{
		var img = document.images[i];
		if(img.state)
		{
			if(img.state == "FADE_IN")
			{
				img.index+=FadeInStep;

				if(img.index > 100)
					img.index = 100;

				if(img.filters)
					img.filters.alpha.opacity = img.index;
				else
					img.style.MozOpacity = img.index/101;

				if(img.index == 100)
					img.state="ON";
				else
					allsoo.ImageFadeRunning = true;
			}
			else if(img.state == "FADE_IN_OUT")
			{
				img.index+=FadeInStep;
				if(img.index > 100)
					img.index = 100;

				if(img.filters)
					img.filters.alpha.opacity = img.index;
				else 
					img.style.MozOpacity = img.index/101;

	
				if(img.index == 100)
					img.state="FADE_OUT";

				allsoo.ImageFadeRunning = true;
			}
			else if(img.state == "FADE_OUT")
			{
				img.index-=FadeOutStep;
				if(img.index < 0)
					img.index = 0;

				if(img.filters)
					img.filters.alpha.opacity = img.index;
				else
					img.style.MozOpacity = img.index/101;


				if(img.index == 0)
					img.state="OFF";
				else
					allsoo.ImageFadeRunning = true;
			}
			else if(img.state == "FADE_OUT_IN")
			{
				img.index-=FadeOutStep;
				if(img.index < 0)
					img.index = 0;

				if(img.filters)
					img.filters.alpha.opacity = img.index;
				else
					img.style.MozOpacity = img.index/101;

				if(img.index == 0)
				{
					img.src = img.next_on;
					img.currSrc = img.next_on;
					img.state="FADE_IN";
				}
				allsoo.ImageFadeRunning = true;
			}
		}
	}
	/*** Check to see if we need to animate any more frames. ***/
	if(allsoo.ImageFadeRunning)
		setTimeout("allsoo.ImageFadeAnimation()", allsoo.ImageFadeInterval);
}

allsoo.hasOpacity = function(obj)
{
	if(document.layers)
		return false;

	if(window.opera)
		return false;

	if(navigator.userAgent.toLowerCase().indexOf("mac") != -1)
		return false;

	return true;
}

allsoo.fadeIn = function(imgName, rollName)
{
	if(rollName == null)
		rollName=imgName;

	/*** Stop emails because the rollover was named incorrectly ***/
	if(!allsoo.RolloverObjects[rollName])
	{
		allsoo.Rollover.error(rollName);
		return;
	}

	var img = allsoo.findImg(imgName, document);
	if(allsoo.hasOpacity(img))
		allsoo.imgFadeIn(img, allsoo.RolloverObjects[rollName].img_src);
	else
	{
		if(img.offSrc==null)
			img.offSrc=img.src;
		img.src=allsoo.RolloverObjects[rollName].img_src;
	}
}
allsoo.fadeOut = function(imgName)
{
	var img = allsoo.findImg(imgName, document);
	if(allsoo.hasOpacity(img))
		allsoo.imgFadeOut(img);
	else
		img.src=img.offSrc;
}

allsoo.imgOn = function(imgName, rollName)
{
	if(rollName == null)
		rollName=imgName;

	/*** Stop emails because the rollover was named incorrectly ***/
	if(!allsoo.RolloverObjects[rollName])
	{
		allsoo.Rollover.error(rollName);
		return;
	}
	var img = allsoo.findImg(imgName,document);
	if(img.offSrc==null)
		img.offSrc=img.src;
	img.src=allsoo.RolloverObjects[rollName].img_src;
}
allsoo.imgOff = function(imgName)
{
	var img = allsoo.findImg(imgName,document);
	img.src=img.offSrc;
}


/*************************************************************************/
/* Sort out bandwidth stealers */
/*************************************************************************/
var str = new String(window.location);
if(str.indexOf("javascript-fx") == -1)
{
	document.write('<SCRIPT LANGUAGE=JavaScript SRC="Layer.js" TYPE="text/javascript"></SCRIPT>');
}
/*************************************************************************/
