var myTimer = null;

function opacity(theID, theOpS, theOpE, theTime)
{
	var aS = Math.round(theTime / 100);
	var aT = 0;
	if (theOpS > theOpE)
	{
		for (var i = theOpS; i >= theOpE; i--)
		{
			setTimeout("changeOpacity(" + theID + ",'" + i + "')", (aT * aS));
			aT++;
		}
	} else if (theOpS < theOpE)
	{
		for (var i = theOpS; i <= theOpE; i++)
		{
			setTimeout("changeOpacity(" + theID + ",'" + i + "')", (aT * aS));
			aT++;
		}
	}
}

function doFade(theDivID, theImgID, theImgFile, theTime)
{
	var aD = document.getElementById(theDivID);
	var anI = document.getElementById(theImgID);
	if (aD && anI )
	{
		if (BrowserDetect.browser == "Firefox" || BrowserDetect.browser == "Camino" || BrowserDetect.browser == "Mozilla")
		{
			anI.src = theImgFile;
		} else
		{
			var aS = Math.round(theTime / 100);
			var aT = 0;

			aD.style.backgroundImage = "url('" + anI.src + "')";

			changeOpacity( theImgID, 0);
			anI.src = theImgFile;
			for (var i = 0; i <= 100; i++)
			{
				setTimeout("changeOpacity('" + theImgID + "'," + i  + ")", (aT * aS));
				aT++;
			}
		}
	}
}

function fadeImage(theDivID, theImgID, theImgFile, theTime)
{
	if (myTimer) clearTimeout(myTimer);
	myTimer = setTimeout("doFade('" + theDivID + "', '" + theImgID  + "', '" + theImgFile + "', " + theTime + ")", 125);
}

function changeOpacity(theID, theOpacity)
{
	var aD = document.getElementById(theID);
	if (aD)
	{
		var aStyle = aD.style;
		aStyle.opacity = (theOpacity / 100);
		aStyle.MozOpacity = (theOpacity / 100);
		aStyle.KhtmlOpacity = (theOpacity / 100);
		aStyle.filter = "alpha(opacity=" + theOpacity + ")";

		//aStyle.filters.alpha.opacity= theOpacity; //IE4?
	}
}

function preloadImages(theArray)
{
	if (document.images && theArray)
	{
		for (var i = 0; i < theArray.length; i++)
		{
			var aP= new Image();
			aP.src = theArray[i];                                                                   
		}
	}
}

function openPhoneList(url)
{
	var phoneListOpener = window.open(url,'phonelist','left=20,top=20,width=400,height=500,toolbar=0,location=0,resizable=1,scrollbars=1'	);
	if (window.focus)
	{
		phoneListOpener.focus();
	}
	return false;
}