//<script>

/** This script developed for lifefx by Garrett Smith             
*  
*  
*  Many of the functions were grabbed from dhtmlkitchen, and are   
*  © copyright 2001 Garrett Smith                                  
*  Please see DHTML kitchen. 
*  Code that was developed exclusively for lifeFx may not be       
*  duplicated or altered without permission of the author.         
*  See DHTMLkitchen.com for usage instructions and terms of use. */

////////////////////////////////   Browser Detection /////////////////////////////////////////////
var ua= navigator.userAgent;
var OPERA = (ua.indexOf("Opera") > 0) ? true : false;
var OMNI = (ua.indexOf("Omni") > 0) ? true : false;
var MAC = (navigator.platform.indexOf("PPC") > 0) ? true : false;
var WIN = (navigator.platform=="Win32") ? true : false;
var getID =document.getElementById ? true : false;
var IE5_0, IE5,IE6,IE5_5,N4,N5,NS6,MAC_IE5,MOZ;
if(!OPERA && !OMNI){
	IE6 = (ua.indexOf("MSIE 6") > 0) ? true : false;
	IE5_0 = (ua.indexOf("MSIE 5.0") > 0) ? true : false;
	IE5_5 = (ua.indexOf("MSIE 5.5") > 0) ? true : false;
	IE5 = (ua.indexOf("MSIE 5") > 0  || IE6 || IE5_5) ? true : false;
	N4 = (document.layers) ? true : false;
	NS6= N5 = (ua.indexOf("Gecko") > 0) ? true : false;
	MAC_IE5 = (MAC && IE5) ? true : false;
	MAC_IE5_1b = (MAC && ua.indexOf("MSIE 5.1b") >= 0) ? true : false;
	WIN_IE5= IE5 && !MAC;
	MOZ= N5 && !(ua.indexOf("Netscape") > 0) ? true : false;
}
///////////////////////////////__End  Browser Detection__/////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////  Player Function  //////////////////////////////////////////////

var standinTimeout = null;

function ParentPlayStream(streamID)
{
	if (parent.IsReady() )
	{
		if (standinTimeout)
			clearTimeout(standinTimeout);
		if (parent.PlayTheStream)
			parent.PlayTheStream(streamID);
	}
	else
	{
		if (standinTimeout)
			clearTimeout(standinTimeout);
		standinTimeout = setTimeout("ParentPlayStream('"+streamID+"')", 500);
	}
}

function ParentSetStandin(standinID)
{
	if (parent.IsReady() )
	{
		if (standinTimeout)
			clearTimeout(standinTimeout);
		if (parent.SetStandin)
			parent.SetStandin(standinID);
	}
	else
	{
		if (standinTimeout)
			clearTimeout(standinTimeout);
		standinTimeout = setTimeout("ParentSetStandin('"+standinID+"')", 500);
	}
}

function ParentStop()
{
	if (parent && parent.standin && parent.standin.lfxStop)
	{
		parent.standin.bSuppressNext = true;
		parent.standin.lfxStop(true);
	}
}

function LinkWithinPanel(urlID)
{
	var querystr = "";
	ParentStop();
	if (top.navigation)
	{
		if (arguments.length > 1)
			querystr = arguments[1];
		top.navigation.OpenURLInNavigation(urlID, querystr);
	}
}


function OpenURLWithinPanel(urlID)
{
	LinkWithinPanel(urlID);
}

/////////////////////////////////__End Player functions__/////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// frameLoaded functions ////////////////////////////////////////

var resizeableElement = null;

function SetResizeableDiv(elementName)
{
	resizeableElement = elementName;
	RecalcDiv();
	window.onresize = RecalcDiv;
}

function RecalcDiv()
{
	var main;
	var clientHeight = document.body.clientHeight;
	if (resizeableElement != null)
	{
		main = document.getElementById(resizeableElement);

		if (main.style.pixelHeight != clientHeight)
			main.style.pixelHeight = clientHeight;
	}
}


function frameLoaded()
{
	if (top.hasNavigation)
	{
		ParentStop();
		if (top.navigation && top.navigation.SyncPageWithNavigation)
			top.navigation.SyncPageWithNavigation();
		else
			setTimeout("frameLoaded()", 500);
	}
}

function makeId(path) {return path.substring(path.lastIndexOf("/")+1, path.lastIndexOf("."));}

////////////////////////////////__End frameLoaded functions__/////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

function showBody(){document.body.style.visibility= "visible";}


// Handlers for next reminder

var nextReminderCount = 0;
var nextReminderTimer;

function userEvent(eventNumber)
{
	// generic user event, used by many pages
	if (eventNumber == 80)
	{
		// event for next reminder, set to remind in 5 sec
		nextReminderTimer = setTimeout("nextEventHandler()", 5000);
	}
	// for other events, if there is a specificUserEventHandler in the page, call it
	else if (window.specificUserEvent != null)
		specificUserEvent(eventNumber);
}

function callNextEventHandler()
{
	nextEventHandler();
}

function nextEventHandler()
{
	var nextobj = document.getElementById("nextbtn");
	nextobj.style.visibility = "visible";
	// first time, please select next, then set to remind in 30 sec
	if (nextReminderCount == 0)
	{
		ParentPlayStream("clickNext");
		if (nextReminderTimer)
			clearTimeout(nextReminderTimer);
		nextReminderTimer = setTimeout("callNextEventHandler()", 10000);
		nextReminderCount++;
	}
	// 2nd time, next reminder clip, then set to remind in 60 sec
	else if (nextReminderCount == 1)
	{
		ParentPlayStream("nextReminder");
		if (nextReminderTimer)
			clearTimeout(nextReminderTimer);
		nextReminderTimer = setTimeout("callNextEventHandler()", 20000);
		nextReminderCount++;
	}
	// 3rd time, next reminder clip, then no more reminders
	else if (nextReminderCount == 2)
	{
		if (nextReminderTimer)
			clearTimeout(nextReminderTimer);
		ParentPlayStream("nextReminder");
		nextReminderCount++;
	}
}

function nextButtonOver()
{
	document.images["nextbutton"].src = "./SilverStream/Objectstore/Images/nextbuttonhover.gif";
}

function nextButtonOut()
{
	document.images["nextbutton"].src = "./SilverStream/Objectstore/Images/nextbutton.gif";
}
function nextButtonDown()
{
	document.images["nextbutton"].src = "./SilverStream/Objectstore/Images/nextbuttonpressed.gif";
}

function OutputNextButton(target, title)
{
	document.write ('<div id="nextbtn" style="visibility:hidden">');
	document.write ('<a href="Javascript:LinkWithinPanel(\'' + target + '\');" title="' + title + '" onmouseover="nextButtonOver()" onmouseout="nextButtonOut()" onmousedown="nextButtonDown()">');
	document.write ('<img id="nextbutton" src="./SilverStream/Objectstore/Images/nextbutton.gif" border=0></a>');
	document.write ('</div>');
}

///// From here down are Garrett's functions - not sure we still need them.
//////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////    Fading functions       ///////////////////////////////////////////
function fadeTo(obj, i, step){
	if(arguments[3]) obj.fadeTofn= arguments[3];
	if(getOpacity(obj)== i){
		if(obj.fadeTofn){eval(obj.fadeTofn)}
		return;
	}
	setTimeout("fadeTo("+obj.id+","+(i)+","+step+");", 50);
	setOpacity(obj,(obj.opacity+step));
}
function getOpacity(block){
	if(WIN_IE5) return parseInt(block.filters["alpha"].opacity);
	else if(NS6) return parseInt(block.style.MozOpacity);
	else return 100;
}
function setOpacity(block, opacity){
	block.opacity= opacity;
	if(WIN_IE5) block.style.filter="alpha(opacity="+opacity+")";
	else if(NS6) block.style.MozOpacity=opacity+ "%";
}

function fadeMainOut(fn,i)
{
	fadeTo(main, 0, i, fn);
}
function goNext(url,i)
{
	if(i == null)
		i= -10;
	if (parent)
	{
		parent.bSuppressNext = true;
		parent.lfxStop(true);
	}
	fadeMainOut("self.location.href='"+url+"'",i);
}
////////////////////////////___End Fading functions____///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////  Window function  //////////////////////////////////////////////////


//global child window
var childWin;
function populateChildWindow(URL) {
	if(!Boolean(childWin)) 
		childWin = window.open(URL,"childWin","scrollbars=yes,resizable=yes,width=250,height=100");
	else if(childWin.closed) 
		childWin = window.open(URL,"childWin","scrollbars=yes,resizable=yes,width=250,height=100");
	else (childWin.location.href = URL);
	
	if(childWin.focus) childWin.focus();
}
function loadParent(url){if(window.opener) window.opener.location.href= url;}

// getFullPath()  gets the full path of the file without the filename. 
function getFullPath(){return self.location.href.substring(0, self.location.href.lastIndexOf("/")+1);}

/////////////////////////////__ End Window functions__////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

function debug(obj){
var x=0, rv="";
	for(x in obj){
		rv+= obj+"."+x+"= "+obj[x]+"; \n";
	}
	return rv;
}

