var agt		= navigator.userAgent.toLowerCase();
var versInt	= parseInt(navigator.appVersion);
var is_ie	= ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3	= (is_ie && (versInt < 4));
var is_ie4	= (is_ie && (versInt == 4) && (agt.indexOf("msie 4")!=-1) );
var is_aol	= (agt.indexOf("aol") != -1);
var is_aol3	= (is_aol && is_ie3);
var is_aol4	= (is_aol && is_ie4);
var is_aol5	= (agt.indexOf("aol 5") != -1);
var is_aol6	= (agt.indexOf("aol 6") != -1);
var is_comp	= (agt.indexOf("compuserve") != -1);
var is_comp2000	= (agt.indexOf("cs") != -1);
var is_compie	= (is_comp && is_ie);


// this is for opening pop-up windows
function CNN_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	var popupWin = window.open( url, name, widgets );

	if ( popupWin && popupWin.opener )
	{
		if ( openerUrl )
		{
			popupWin.opener.location.href = openerUrl;
		}

		if ( !( is_aol6 || is_aol3 || is_aol4 || is_aol5 || is_compie || is_comp2000 ) )
		{
			popupWin.opener.top.name = "opener";
			popupWin.focus();
		}
	}
}


// _____________________________________________________________________ NASCAR

// old window opening functions
function openPopUp( url, name, widgets ) { CNN_openPopup( url, name, widgets ); }
function pollSubPop( url, name, widgets ) { CNN_openPopup( url, name, widgets ); }
function openWindow( url, name, widgets ) { CNN_openPopup( url, name, widgets ); }
function jumpLink( url, name, widgets, openerUrl ) { CNN_openPopup( url, name, widgets, openerUrl ); }
function med_vod( vidlocation )
{
	CNN_openPopup( vidlocation, '620x460', 'width=620,height=460,scrollbars=no,resizable=no' );
}

// old window closing functions
function closeWindow() { top.close(); }


// ________________________________________________________________ LaunchVideo
function LaunchVideo( url )
{
	var videoUrl = '/multimedia/realone/detectcodes/undetect.html';
	var popupWidth = 700;
	var popupHeight = 420;
	var cookies = getCookies();

	fc_click(url, 'media'); // FireClick Tracking Code

	if ( (is_aol) || (cookies["synacor"]) )	// if AOL or Synacor User
	{
//		videoUrl = '/multimedia/realone/detectcodes/getReal.html';
		videoUrl = url;
// .... comes in as /video/nascar/YYYY/MM/DD/slug.ram
//		var prefixRE = new RegExp( "/video/nascar" );
//		var suffixRE = new RegExp( "\.ram[^/]*" );
//		if ( prefixRE.test( videoUrl ) && suffixRE.test( videoUrl ) )
		var prefix = "/video/nascar";
		var suffix = ".ram";
		if ( ( videoUrl.indexOf( prefix ) != -1 ) && ( videoUrl.indexOf( suffix ) > videoUrl.indexOf( prefix ) ) )
		{
//			videoUrl = videoUrl.replace( prefixRE, '/pr/video' );
//			videoUrl = videoUrl.replace( suffixRE, '_frameset_exclude.html' );
			var preprefix = videoUrl.substring( 0, videoUrl.indexOf( prefix ) );
			var newprefix = '/pr/video';
			var middle = videoUrl.substring( videoUrl.indexOf( prefix ) + prefix.length, videoUrl.indexOf( suffix ) );
			var newsuffix = '_frameset_exclude.html';
			videoUrl = preprefix + newprefix + middle + newsuffix;
			popupWidth = 577;
			popupHeight = 465;
		}
// .... leaves as /pr/video/YYYY/MM/DD/slug_frameset_exclude.html
	}
	else
	{
		var realOneStatus = LV_getRealOneStatus();

		switch ( realOneStatus )
		{
			case 'undetermined':
				videoUrl = '/multimedia/realone/detectcodes/getReal.html';
				break;
			case 'using':
			case 'installed':
				videoUrl = url;
				break;
			case 'notinstalled':
			default:
				if ( detectReal() )
				{
					videoUrl = url;
				}
				else
				{
					videoUrl = '/multimedia/realone/detectcodes/undetect.html';
				}
				break;
		}
	}

	if ( ( videoUrl.indexOf( 'frameset_exclude.html' ) != -1 ) || ( videoUrl.indexOf( '/multimedia/realone/detect' ) != -1 ) )
	{
		CNN_openPopup( videoUrl, '' + popupWidth + 'x' + popupHeight,
			'width=' + popupWidth + ',height=' + popupHeight + ',scrollbars=no,resizable=no' );
	}
	else
	{
		top.location.href = videoUrl;
	}
}


// _____________________________________________________________ LaunchRacecast
function LaunchRacecast( url )
{
	var cookies = getCookies();

	var racecastUrl = '';
//	is_aol = 1;
	if ( is_aol )							// if using AOL, shortcut
	{
		aolRacecast( url );
	}
	else
	{
		if ( ( navigator.platform.toLowerCase().indexOf( 'win' ) == -1 ) || (cookies["synacor"]) )
		{
//			racecastUrl = '/multimedia/realone/detectcodes/detect.mac.html';
			htmlRacecast( url );
		}
		else
		{
			var realOneStatus = LV_getRealOneStatus();

			switch ( realOneStatus )
			{
				case 'undetermined':
					racecastUrl = '/multimedia/realone/detectcodes/undetect.html';
					break;
				case 'using':
				case 'installed':
//					alert("here");
					racecastUrl = realRacecast( url );
					break;
				case 'notinstalled':
				default:
					racecastUrl = '/multimedia/realone/detectcodes/getReal.html';
					break;
			}
		}
	}

	if ( racecastUrl.indexOf( '/multimedia/realone/detect' ) != -1 )
	{
		CNN_openPopup( racecastUrl, '700x420', 'width=700,height=420,scrollbars=no,resizable=no' );
	}
	else
	{
		if ( racecastUrl )
		{
			top.location.href = racecastUrl;
		}
	}
}


// ________________________________________________________________ realRacecast
function realRacecast( param )
{
	var realUrl = '';

	switch (param) 
	{
		case 'pc' :					// PC CUP RACE
			realUrl = '/races/pitcommand/video/pitcommand.welcome.r1.ram';
			break;

		case 'pcr' :					// PC 2.0 CUP RACE
			realUrl = '/races/pitcommand/2.0/cup/race/launch_race.ram';
			break;

		case 'pcq' :					// PC 2.0 CUP QUAL
			realUrl = '/races/pitcommand/2.0/cup/qual/launch_qual.ram';
			break;

		case 'wcr' :					// LL CUP RACE
			realUrl = '/races/leaderboard/cup/race/launch_race.ram';
			break;

		case 'wcq' :					// LL CUP QUAL
			realUrl = '/races/leaderboard/cup/qual/launch_qual.ram';
			break;

		case 'wcp1' :					// LL CUP PRACTICE1
			realUrl = '/races/leaderboard/cup/practice1/launch_practice1.ram';
			break;

		case 'wcp2' :					// LL CUP PRACTICE2
			realUrl = '/races/leaderboard/cup/practice2/launch_practice2.ram';
			break;

		case 'wcp3'	:				// LL CUP PRACTICE3
			realUrl = '/races/leaderboard/cup/practice3/launch_practice3.ram';
			break;

		case 'bgr' :					// LL NBS RACE
			realUrl = '/races/leaderboard/bg/race/launch_race.ram';
			break;

		case 'bgq' :					// LL NBS QUAL
			realUrl = '/races/leaderboard/bg/qual/launch_qual.ram';
			break;
	}
//	var appWindow = window.open( realUrl );
	return realUrl;
}


// ________________________________________________________________ aolRacecast
function aolRacecast( param )
{
	var aolUrl = '';
	
	switch (param) 
	{
		case 'pc' :					// PC CUP RACE
			aolUrl = '/pr/aol/pitcommand/pitcommand_frameset_exclude.html';
			break;

		case 'pcr' :					// PC 2.0 CUP RACE
			aolUrl = '/pr/aol/pitcommand/2.0/cup/race/frameset_race_exclude.html';
			break;

		case 'pcq' :					// PC 2.0 CUP QUAL
			aolUrl = '/pr/aol/pitcommand/2.0/cup/qual/frameset_qual_exclude.html';
			break;
			
		case 'wcr' :					// LL CUP RACE
			aolUrl = '/pr/races/leaderboard/aol/cup/race/frameset_race_exclude.html';
			break;

		case 'wcq' :					// LL CUP QUAL
			aolUrl = '/pr/races/leaderboard/aol/cup/qual/frameset_qual_exclude.html';
			break;

		case 'wcp1'	:				// LL CUP PRACTICE1
			aolUrl = '/pr/races/leaderboard/aol/cup/practice1/frameset_practice1_exclude.html';
			break;

		case 'wcp2'	:				// LL CUP PRACTICE2
			aolUrl = '/pr/races/leaderboard/aol/cup/practice2/frameset_practice2_exclude.html';
			break;

		case 'wcp3'	:				// LL CUP PRACTICE3
			aolUrl = '/pr/races/leaderboard/aol/cup/practice3/frameset_practice3_exclude.html';
			break;

		case 'bgr' :					// LL NBS RACE
			aolUrl = '/pr/races/leaderboard/aol/bg/race/frameset_race_exclude.html';
			break;

		case 'bgq' :					// LL NBS QUAL
			aolUrl = '/pr/races/leaderboard/aol/bg/qual/frameset_qual_exclude.html';
			break;
	}

	var appWindow = window.open( aolUrl );
	return appWindow;
}


// ________________________________________________________________ htmlRacecast
function htmlRacecast( param )
{
	var htmlUrl = '';
	
	switch (param) 
	{
		case 'pc' :					// PC CUP RACE
			htmlUrl = '/pr/aol/pitcommand/pitcommand_frameset_exclude.html';
			break;

		case 'pcr' :					// PC 2.0 CUP RACE
			htmlUrl = '/pr/pitcommand/2.0/cup/race/frameset_race_exclude.html';
			break;

		case 'pcq' :					// PC 2.0 CUP QUAL
			htmlUrl = '/pr/pitcommand/2.0/cup/qual/frameset_qual_exclude.html';
			break;
			
		case 'wcr' :					// LL CUP RACE
			htmlUrl = '/pr/races/leaderboard/cup/race/frameset_race_exclude.html';
			break;

		case 'wcq' :					// LL CUP QUAL
			htmlUrl = '/pr/races/leaderboard/cup/qual/frameset_qual_exclude.html';
			break;

		case 'wcp1'	:				// LL CUP PRACTICE1
			htmlUrl = '/pr/races/leaderboard/cup/practice1/frameset_practice1_exclude.html';
			break;

		case 'wcp2'	:				// LL CUP PRACTICE2
			htmlUrl = '/pr/races/leaderboard/cup/practice2/frameset_practice2_exclude.html';
			break;

		case 'wcp3'	:				// LL CUP PRACTICE3
			htmlUrl = '/pr/races/leaderboard/cup/practice3/frameset_practice3_exclude.html';
			break;

		case 'bgr' :					// LL NBS RACE
			htmlUrl = '/pr/races/leaderboard/bg/race/frameset_race_exclude.html';
			break;

		case 'bgq' :					// LL NBS QUAL
			htmlUrl = '/pr/races/leaderboard/bg/qual/frameset_qual_exclude.html';
			break;
	}

	var appWindow = window.open( htmlUrl );
	return appWindow;
}

//____________________________________________________________________
// Get Cookies
function getCookies() 
{
	var hash = new Array;
	if (document.cookie != null) 
	{
		var a = document.cookie.split('; ');
		for (var i=0; i < a.length; i++) 
		{
			var nv = a[i].split('=');
			if (nv[1] != null) 
			{
				hash[nv[0]] = unescape(nv[1]);
			}
		}
	}
	return hash;
}

// ______________________________________________________________________ Apple
// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;


function canDetectPlugins() {
	if ( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
		return true;
	}
	return false;
}

function detectFlash() {
	pluginFound = detectPlugin( 'Shockwave', 'Flash' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectActiveXControl( 'ShockwaveFlash.ShockwaveFlash.1' );
	}
	return pluginFound;
}

function detectDirector() {
	pluginFound = detectPlugin( 'Shockwave', 'Director' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectActiveXControl( 'SWCtl.SWCtl.1' );
	}
	return pluginFound;
}

function detectQuickTime() {
	pluginFound = detectPlugin( 'QuickTime' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectQuickTimeActiveXControl();
	}
	return pluginFound;
}

function detectReal() {
	pluginFound = detectPlugin( 'RealPlayer' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = ( detectActiveXControl('rmocx.RealPlayer G2 Control') ||
			detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
			detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)')
		);
	}
	return pluginFound;
}

function detectRealOne() {
	pluginFound = detectPlugin( 'RealOne Player Version Plugin') || detectPlugin( 'RealPlayer Version Plugin' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectRealOneActiveXControl();
	}
	return pluginFound;
}

function detectWindowsMedia() {
	pluginFound = detectPlugin( 'Windows Media' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectActiveXControl( 'MediaPlayer.MediaPlayer.1' );
	}
	return pluginFound;
}

function detectPlugin() {
	// allow for multiple checks in a single pass
	var daPlugins = arguments;
	// consider pluginFound to be false until proven true
	var pluginFound = false;
	// if plugins array is there and not fake
	if ( navigator.plugins && navigator.plugins.length > 0 ) {
		var pluginsArrayLength = navigator.plugins.length;
		// for each plugin...
		for ( var pluginsArrayCounter = 0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
			// loop through all desired names and check each against the current plugin name
			var numFound = 0;
			for ( var namesCounter = 0; namesCounter < daPlugins.length; namesCounter++ ) {
				// if desired plugin name is found in either plugin name or description
				if ( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
					(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
					// this name was found
					numFound++;
				}
			}
			// now that we have checked all the required names against this one plugin,
			// if the number we found matches the total number provided then we were successful
			if ( numFound == daPlugins.length ) {
				pluginFound = true;
				// if we've found the plugin, we can stop looking through at the rest of the plugins
				break;
			}
		}
	}
	return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ( (navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1) ) {
	document.writeln( '<script language="VBscript">' );

	document.writeln( '\'do a one-time test for a version of VBScript that can handle this code' );
	document.writeln( 'detectableWithVB = False' );
	document.writeln( 'If ScriptEngineMajorVersion >= 2 then' );
	document.writeln( '  detectableWithVB = True' );
	document.writeln( 'End If' );

	document.writeln( '\'this next function will detect most plugins' );
	document.writeln( 'Function detectActiveXControl( activeXControlName )' );
	document.writeln( '  on error resume next' );
	document.writeln( '  detectActiveXControl = False' );
	document.writeln( '  If detectableWithVB Then' );
	document.writeln( '     detectActiveXControl = IsObject( CreateObject( activeXControlName ) )' );
	document.writeln( '  End If' );
	document.writeln( 'End Function' );

	document.writeln( '\'and the following function handles QuickTime' );
	document.writeln( 'Function detectQuickTimeActiveXControl()' );
	document.writeln( '  on error resume next' );
	document.writeln( '  detectQuickTimeActiveXControl = False' );
	document.writeln( '  If detectableWithVB Then' );
	document.writeln( '    detectQuickTimeActiveXControl = False' );
	document.writeln( '    hasQuickTimeChecker = false' );
	document.writeln( '    Set hasQuickTimeChecker = CreateObject( "QuickTimeCheckObject.QuickTimeCheck.1" )' );
	document.writeln( '    If IsObject( hasQuickTimeChecker ) Then' );
	document.writeln( '      If hasQuickTimeChecker.IsQuickTimeAvailable( 0 ) Then ' );
	document.writeln( '        detectQuickTimeActiveXControl = True' );
	document.writeln( '      End If' );
	document.writeln( '    End If' );
	document.writeln( '  End If' );
	document.writeln( 'End Function' );

	document.writeln( '\'and the following function handles RealOne' );
	document.writeln( 'Function detectRealOneActiveXControl()' );
	document.writeln( '  on error resume next' );
	document.writeln( '  detectRealOneActiveXControl = False' );
	document.writeln( '  If detectableWithVB Then' );
	document.writeln( '    detectRealOneActiveXControl = False' );
	document.writeln( '    hasRealOneVersionPlugin = false' );
	document.writeln( '    Set hasRealOneVersionPlugin = CreateObject( "IERPCtl.IERPCtl.1" )' );
	document.writeln( '    If IsObject( hasRealOneVersionPlugin ) Then' );
	document.writeln( '      If hasRealOneVersionPlugin.RealPlayerVersion Then ' );
	document.writeln( '        detectRealOneActiveXControl = True' );
	document.writeln( '      End If' );
	document.writeln( '    End If' );
	document.writeln( '  End If' );
	document.writeln( 'End Function' );

	document.writeln( '<\/scr' + 'ipt>' );
}


// _______________________________________________________________________ Real

function LV_getRealOneStatus()	// returns ('undetermined'|'installed'|'notinstalled'|'using')
{
	var RealOneInst = 'undetermined';

	if ( canDetectPlugins() )
	{
		if ( detectRealOne() )
		{
			RealOneInst = 'installed';
			if ( agt.indexOf( '(r1 ' ) != -1 )
			{
				RealOneInst = 'using';
			}
		}
		else
		{
			RealOneInst = 'notinstalled';
		}
	}

	return RealOneInst;
}


/***** OLD LAUNCH REAL CHANNEL CODE THAT SHOULDN'T BE USED, BUT UNFORTUNATELY IS *****/

//////////////////////////////////////////////RealOne lib///////////////////////////////////////////////////
var vidurl = location.search.substring(1,location.search.length);
var MacPPC = (navigator.platform=='MacPPC') ? true : false;
var netscapeDOM = (document.layers) ? true : false;

//Loads Splash screen when user does not have RealOne installed
function noReal() {
RaceCastNo = window.open('','RaceCastNo','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=700,height=420');
RaceCastNo.location.href = '/multimedia/realone/detectcodes/getReal.vid.html';
window.close('RaceCastTest');
}

//Launches RealChannel 2-pan ram after detection
function RealChannel(vid) {
//top.opener.location.href = vid;
top.opener.location.href = vid;
window.close();
}

//Loads Splash screen when we cannot determine if the user has RealOne or not
function und() {
RaceCastNo = window.open('','RaceCastNo','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=700,height=420');
RaceCastNo.location.href = '/multimedia/realone/detectcodes/undetect.html';
window.close('RaceCastTest');
}

//RealOne channel 2pan Detection Launcher.  Takes the URL of the video location
//url == vidurl passed from the script
function LaunchRealChannel(url) {

fullurl = '/multimedia/realone/detect/sniff.exclude.html?' + url;
fullurlmac = '/multimedia/realone/detect/sniff.mac.ns4.exclude.html?' + url;
//fullurlmac = '/multimedia/realone/detectcodes/detect.mac.html';

//if (MacPPC && netscapeDOM) {
if (MacPPC) {
//window.open(fullurlmac,'RaceCastMac','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=700,height=420'); }
window.open(fullurlmac,'RaceCastMac','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=700,height=420'); }
else {
//window.open(fullurl,'RaceCastTest','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=790,height=400');
window.open(fullurl,'RaceCastTest','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=790,height=500');
}
}

//Launches RaceCast popup upon RealOne Player detection
function Real() {
var url = "http://www.nascar.com/pr/racecast/wc/qual/qualcast_frameset_exclude.html";
location.href = url;
}

//Launches RaceCast detection script
//function launchRacecast() {
//if (MacPPC && netscapeDOM) {
//if (MacPPC) {
//window.open('/multimedia/realone/detectcodes/detect.mac.html','RaceCastMac','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=700,height=420'); }
//else {
//window.open('/multimedia/racecast/sniff.exclude.html','RaceCastTest','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=790,height=400');
//}
//}

//Launches RaceCast detection script
function launchRacecast(url) {
fullurl = '/races/racecast/sniff/sniff.exclude.html?' + url;
fullurlmac = '/multimedia/realone/detectcodes/detect.mac.html';
//if (MacPPC && netscapeDOM) {
if (MacPPC) {
window.open('/multimedia/realone/detectcodes/detect.mac.html','RaceCastMac','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=700,height=420'); }
else {
window.open(fullurl,'RaceCastTest','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=1,height=1');
}
}
//////////////////////////////////////////////RealOne lib///////////////////////////////////////////////////

/*****************************************************
///// DHTML Code for Top Navigation //////////////////
*****************************************************/
ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 250
ypSlideOutMenu.hideDelay = 1000
ypSlideOutMenu.minCPUResolution = 10
// constructor
function ypSlideOutMenu(id, dir, left, top, width, height)
{
	this.ie = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	if (this.ie || this.ns4 || this.dom) 
	{
		this.id = id
		this.dir = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType = dir == "right" || dir == "down" ? "-" : "+"
		this.dim = this.orientation == "h" ? width : height
		this.hideTimer = false
		this.aniTimer = false
		this.open = false
		this.over = false
		this.startTime = 0
		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")
		ypSlideOutMenu.Registry[id] = this
		var d = document
		var strCSS = '<style type="text/css">';
		strCSS += '#' + this.id + 'Container { visibility:hidden; '
		strCSS += 'left:' + left + 'px; '
		strCSS += 'top:' + top + 'px; '
		strCSS += 'overflow:hidden; z-index:10000; }'
		strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
		strCSS += 'width:' + width + 'px; '
		strCSS += 'height:' + height + 'px; '
		strCSS += 'clip:rect(0 ' + width + ' ' + height + ' 0); '
		strCSS += '}'
		strCSS += '</style>'
		d.write(strCSS)
		this.load()
	}
}

ypSlideOutMenu.prototype.load = function() 
{
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp
	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else 
	{
		this.container = obj1
		this.menu = obj2
		this.style = this.ns4 ? this.menu : this.menu.style
		this.homePos = eval("0" + this.dirType + this.dim)
		this.outPos = 0
		this.accelConst = (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 
// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
		this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")
//set initial state
		this.endSlide()
	}
}

ypSlideOutMenu.showMenu = function(id)
{
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]
	if (obj.container) 
	{
		obj.over = true
		for (menu in reg) if (id != menu) ypSlideOutMenu.hide(menu)
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
}

ypSlideOutMenu.hideMenu = function(id)
{
	var obj = ypSlideOutMenu.Registry[id]
	if (obj.container) 
	{
		if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
	}
}

ypSlideOutMenu.hideAll = function()
{
	var reg = ypSlideOutMenu.Registry
	for (menu in reg) 
	{
		ypSlideOutMenu.hide(menu);
		if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
	}
}

ypSlideOutMenu.hide = function(id)
{
	var obj = ypSlideOutMenu.Registry[id]
	obj.over = false
	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	obj.hideTimer = 0
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}

ypSlideOutMenu.prototype.startSlide = function(open) 
{
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime() 
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}

ypSlideOutMenu.prototype.slide = function() 
{
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else 
	{
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-") d = -d
		else if (this.open && this.dirType == "+") d = -d
		else if (!this.open && this.dirType == "-") d = -this.dim + d
		else d = this.dim + d
		this.moveTo(d)
	}
}

ypSlideOutMenu.prototype.endSlide = function() 
{
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) 
	{
		this.startSlide(this.over)
	}
}

ypSlideOutMenu.prototype.setVisibility = function(bShow) 
{ 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}

ypSlideOutMenu.prototype.moveTo = function(p) 
{ 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}

ypSlideOutMenu.prototype.getPos = function(c) 
{
	return parseInt(this.style[c])
}

ypSlideOutMenu.prototype.onactivate = function() { }
ypSlideOutMenu.prototype.ondeactivate = function() { }

/****** POSITION DIVS *******/

/* (id, dir, left, top, width, height) */
var menus = [
	new ypSlideOutMenu("menu1", "down", 49, 27, 170, 200),
	new ypSlideOutMenu("menu2", "down", 94, 27, 170, 200),
	new ypSlideOutMenu("menu3", "down", 152, 27, 170, 200),
	new ypSlideOutMenu("menu4", "down", 201, 27, 170, 200),
	new ypSlideOutMenu("menu5", "down", 328, 27, 170, 200),
	new ypSlideOutMenu("menu6", "down", 446, 27, 170, 200),
	new ypSlideOutMenu("menu7", "down", 488, 27, 170, 200),
	new ypSlideOutMenu("menu8", "down", 590, 27, 170, 200)
]

for (var i = 0; i < menus.length; i++) 
{
	menus[i].onactivate = new Function("document.getElementById('act" + i + "').className='active';");
	menus[i].ondeactivate = new Function("document.getElementById('act" + i + "').className='';");
}

