// 
// Common Random/1 Java Scripts
//		common to all screens
//


// This function will attempt to locate a named frame's
// owner based on current document, then parent document, 
// and finally by top.document
function locateOwner( elemName )
{
	ownerDoc = document;

    iframepopup = getElement( elemName, ownerDoc );
    if( iframepopup )
		return ownerDoc;
		
	if( parent )
	{
		ownerDoc = parent.document;
		iframepopup = getElement( elemName, ownerDoc );
		if( iframepopup )
			return ownerDoc;
	}
	
	if( top )
	{
		ownerDoc = top.document;
		iframepopup = getElement( elemName, ownerDoc );
		if( iframepopup )
			return ownerDoc;
	}
	
	return null;
}



// This function is called to load the popup frame based on the
// passed altname. In addition to loading the frame, it acts
// on the other DIVs listed in the function.
function doPopup( altname )
{
	ownerDoc = locateOwner( 'popupframe' );
	if( ownerDoc == null )
	{
		alert( "This is an unsupported browser for this site.");
		return;
	}

	iframepopup = getElement( 'popupframe', ownerDoc );
	iframepopup.src="2A25F4F8-06B5-4CF5-98F2-8A364E75E854.html"+altname;

	toggleLayer( 'inactive', 1, ownerDoc );
	toggleLayer( 'popupimage', 1, ownerDoc );
	toggleLayer( 'popup', 1, ownerDoc );
}



// This function will close the current popup window
// and it assumes that the owning documetn contanis
// the all the elemetns acted upon in the function. 
function closePopup()
{
	ownerDoc = locateOwner( 'popupframe' );
	if( ownerDoc == null )
	{
		alert( "This is an unsupported browser for this site.");
		return;
	}
	
    iframepopup = getElement( 'popupframe', ownerDoc );
    iframepopup.src="popupframe.fsp";

	toggleLayer( 'inactive', 0, ownerDoc );
	toggleLayer( 'popup', 0, ownerDoc );
	toggleLayer( 'popupimage', 0, ownerDoc );
}



// Called to launch a popup audio or popup window based on an altname
function doLaunch( altname )
{
	ownerDoc = locateOwner( 'launchframe' );
	if( ownerDoc == null )
	{
		alert( "This is an unsupported browser for this site.");
		return;
	}

	iframepopup = getElement( 'launchframe', ownerDoc );
    if( iframepopup== null )
    {
		alert( "This is an unsupported browser for this site.");
		return;
    }

	// Need to append date because Safari is a piece ... and assume cached.
	date = new Date();
	iframepopup.src="9DEB6D68-9090-4A85-8C26-E6DBE9D3E5A9.html"+altname+"&date="+ date;
}



// Called to launch an object based on a URL
function doLaunchUrl( url )
{
	ownerDoc = locateOwner( 'launchframe' );
	if( ownerDoc == null )
	{
		alert( "This is an unsupported browser for this site.");
		return;
	}


	iframepopup = getElement( 'launchframe', ownerDoc );
    if( iframepopup== null )
    {
		alert( "This is an unsupported browser for this site.");
		return;
    }

	iframepopup.src=url;
}

var selectedPodcast=-1;

// Zero-based div selection
function selectPodcast( id )
{
	if( id < 0 )
		id = totalPodcasts-1;
	else if( id == totalPodcasts )
		id = 0;
	
	// Do nothing if item requested is already selected
	if( id==selectedPodcast )
		return;

	if( selectedPodcast != -1 )
		toggleLayer( "podcast:"+selectedPodcast, 0, null );
	toggleLayer( "podcast:"+id, 1, null );

	selectedPodcast = id;
}



function doPost( forumid )
{
	iframepopup = getElement( 'popupframe', null );
	if( iframepopup==null )
    {
		alert( "This is an unsupported browser for this site.");
		return;
    }

	iframepopup.src="4371464F-BAE8-4FA8-BACE-28750F21E293.html"+forumid;

	toggleLayer( 'inactive', 1, null );
	toggleLayer( 'popupimage', 1, null );
	toggleLayer( 'popup', 1, null );
}

oSet = null;
function dofocus( obj )
{
	if( oSet == obj )
	obj.className = "submenu_overon";
	else
		obj.className = "submenu_over";
}
function doblur( obj )
{
	if( oSet == obj )
		obj.className = "submenu_on";
	else
		obj.className = "submenu_up";
}
function doset( obj )
{
	if( oSet )
		oSet.className = "submenu_up";
		 
	obj.className = "submenu_on";
	oSet = obj;
}
