
//	setOpacity takes an object and an opacity value (0..100)
//	and sets the appropriate opacity.

function pmSetOpacity(object, opacity)
{
	if (object)
	{
		opacity = (opacity == 100 ? 99.999 : opacity);

		if (object.style)
		{
			//	Safari 1.2, Firefox, Mozilla, CSS3...
			object.style.opacity = opacity / 100;

			//	Old Mozilla, Firefox...
			object.style.MozOpacity = opacity / 100;

			//	Old Safari, Konqueror...
			object.style.KHTMLOpacity = opacity / 100;

			//	IE/Win...
			object.style.filter = "alpha(opacity:"+opacity+")";
		}
	}
}

function pmSetOpacityForId(objectId, opacity)
{
	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		pmSetOpacity(object, opacity);
	}
}

function pmSetVisibilityForId(objectId, inIsVisible)
{
	if (document.getElementById)
	{
		object = document.getElementById(objectId);
				
		object.style.visibility = (inIsVisible) ? "visible" : "hidden";
	}
}






function x_initImages()
{
	setOpacityForId("image_1", 0);
	setOpacityForId("image_2", 0);
	setOpacityForId("image_3", 0);
//	cycleIn("image_", 1, 3, 0);
//	fadeIn("image_1", 0);

	window.setTimeout("cycleIn('image_', 1, 3, 0)", 5000);
}


//	fadeIn takes an object and opacity, and uses a timer to 
//	update the opacity until it reaches 100%.

function pmFade(inObjectId, inStartOpacity, inEndOpacity, inIncrement, inDelay)
{
	if (document.getElementById)
	{
		object = document.getElementById(inObjectId);

		if (((inIncrement > 0) && (inStartOpacity <= inEndOpacity)) || ((inIncrement < 0) && (inStartOpacity >= inEndOpacity)))
		{
			pmSetOpacity(object, inStartOpacity);
			inStartOpacity += inIncrement;			
			window.setTimeout("pmFade('" + inObjectId + "', " + inStartOpacity + ", " + inEndOpacity + ", " + inIncrement + ", " + inDelay + ");", inDelay);
		}
	}
}


function cycleIn(objectIdPrefix, initial, count, opacity)
{
	objectId = objectIdPrefix + initial;

	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		if (opacity <= 100)
		{
			setOpacity(object, opacity);
			opacity += 1;
			window.setTimeout("cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ")", 50);
		}
		else
		{
			initial += 1;
			if (initial <= count)
			{
				opacity = 0;
				window.setTimeout("cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ")", 5000);
			}
			else
			{
				setOpacityForId("image_1", 0);
				setOpacityForId("image_2", 0);
				setOpacityForId("image_3", 0);

				window.setTimeout("cycleIn('image_', 1, 3, 0)", 5000);
			}

		}
	}
}

//	Change the style of the element with given id.

function pm_changeElementWithIdStyle(inId, inStyle)
{
	if (document.getElementById)
	{
		object = document.getElementById(inId);
		object.className = inStyle;
	}

}
	
function pm_changeImageWithIdToSrc(inPlaceholderId, inSource)
{
	object = document.getElementById(inPlaceholderId);
	object.src = inSource;
}


//	cycleImages: cycle through the images in the named div, fading each one up in turn

function pm_cycleImagesInDiv(inDivId, inInitialDelay, inFadeIncrement, inFadeDelay, inHoldDelay, inShouldLoop, inRedirectUrl)
{
	if (document.getElementById)
	{
		cycleDiv = document.getElementById(inDivId);
		var imageCount = 0;
		for (var index=0; index < cycleDiv.childNodes.length; index++)
		{
			if ((cycleDiv.childNodes[index].id) && (cycleDiv.childNodes[index].id.substring(0, inDivId.length) == inDivId))
			{
				imageCount++;
			}
		}
		command = "pm_cycleIn('" + inDivId + "_" + "', " + 1 + ", " + imageCount + ", " + 0 + ", " + inFadeIncrement + ", " + inFadeDelay + ", " + inHoldDelay + ", " + inShouldLoop + ", '" + inRedirectUrl + "')";
		window.setTimeout(command, inInitialDelay);
	}
}


//	cycleIn: private method which handles the actual fading

function pm_cycleIn(objectIdPrefix, initial, count, opacity, inFadeIncrement, inFadeDelay, inHoldDelay, inShouldLoop, inRedirectUrl)
{
	objectId = objectIdPrefix + initial;
	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		if (opacity <= 100)
		{
			//	keep fading up image...
			pmSetOpacity(object, opacity);
			opacity += inFadeIncrement;
			window.setTimeout("pm_cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ", " + inFadeIncrement + ", " + inFadeDelay + ", " + inHoldDelay + ", " + inShouldLoop + ", '" + inRedirectUrl + "')", inFadeDelay);
		}
		else
		{
			//	move on to next image...
			initial += 1;
			if (initial <= count)
			{
				opacity = 0;
				window.setTimeout("pm_cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ", " + inFadeIncrement + ", " + inFadeDelay + ", " + inHoldDelay + ", " + inShouldLoop + ", '" + inRedirectUrl + "')", inHoldDelay);
			}
			else
			{
				//	cycle complete...
				if (inShouldLoop)
				{
					//	hide all but first image...
					for (var hideIndex = 1; hideIndex <= count; hideIndex++)
					{
						hideObjectId = objectIdPrefix + hideIndex;
						pmSetOpacityForId(hideObjectId, 0);
					}
					initial = 1;
					opacity = 0;
					command = "pm_cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ", " + inFadeIncrement + ", " + inFadeDelay + ", " + inHoldDelay + ", " + inShouldLoop + ", '" + inRedirectUrl + "')";
					window.setTimeout(command, inHoldDelay);
				}
				else
				{
					if (inRedirectUrl != "")
					{
						window.location = inRedirectUrl;
					}
				}
			}
		}
	}
}

function pm_contact(inName, inDomain)
{
	address='mailto:' + inName + '@' + inDomain;
	location = (address);
}