//	ocp_default.js
//	Portions (C) PyrusMalus, 2008.
//	www.pyrusmalus.com


// Email links

function pm_contact(inName, inDomain)
{
	address='mailto:' + inName + '@' + inDomain;
	location = (address);
}


//	Overlay
	
function pm_showOverlayWithName(inDivName)
{
	//	Show the overlay div...
	object = document.getElementById(inDivName);
	object.style.display = "block";
}


function pm_hideOverlayWithName(inDivName)
{
	//	Hide the overlay div...
	object = document.getElementById(inDivName);
	object.style.display = "none";
}


//	Header highlight

var highlightX = 0;
var highlightVx = 3;


function pm_startHighlight()
{
	window.setTimeout("pm_updateHighlight()", 100);
}

function pm_updateHighlight()
{
	object = document.getElementById('highlight');	
	highlightX = highlightX + highlightVx;
	object.style.left = highlightX + "px";
	delay = 5;

	if (highlightX > 960)
	{
		highlightX = 0;
	}
	else
	{
		window.setTimeout("pm_updateHighlight()", delay);
	}
}


//	Fading
	
//	setOpacity takes an object and an opacity value (0..100)
//	and sets the appropriate opacity.

function pm_setOpacity(object, opacity)
{
	if ((opacity >= 0) && (opacity <=100) && (object != null))
	{
		opacity = (opacity == 100 ? 99.999 : opacity);

		//	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 pm_setOpacityForId(objectId, opacity)
{
	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		pm_setOpacity(object, opacity);
	}
}


//	cycleImages: cycle through the images in the named div, fading each one up in turn

function pm_cycleImagesInDiv(inDivId, inInitialDelay, inFadeIncrement, inFadeDelay, inHoldDelay)
{
	if (document.getElementById)
	{
		cycleDiv = document.getElementById(inDivId);
		childCount = cycleDiv.children.length;
		window.setTimeout("pm_cycleIn('" + inDivId + "_" + "', " + 1 + ", " + childCount + ", " + 0 + ", " + inFadeIncrement + ", " + inFadeDelay + ", " + inHoldDelay + ")", inInitialDelay);
	}
}


//	cycleIn: private method which handles the actual fading

function pm_cycleIn(objectIdPrefix, initial, count, opacity, inFadeIncrement, inFadeDelay, inHoldDelay)
{
	objectId = objectIdPrefix + initial;

	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		if (opacity <= 100)
		{
			//	keep fading up image...
			pm_setOpacity(object, opacity);
			opacity += inFadeIncrement;
			window.setTimeout("pm_cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ", " + inFadeIncrement + ", " + inFadeDelay + ", " + inHoldDelay + ")", 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 +")", inHoldDelay);
			}
			else
			{
				//	cycle complete...
				pm_setOpacityForId(objectIdPrefix + "0", 100);
				for (hideIndex = 1; hideIndex < count; hideIndex++)
				{
					pm_setOpacityForId(objectIdPrefix + hideIndex, 0);
				}
				
				initial = 1;
				opacity = 0;
				window.setTimeout("pm_cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ", " + inFadeIncrement + ", " + inFadeDelay + ", " + inHoldDelay +")", inHoldDelay);
			}
		}
	}
}

