document.write('<script language="JavaScript1.1" src="http://i.a.cnn.net/nascar/.element/js/2.0/global.js" type="text/javascript"><\/script>') /* 02/01/07 Site redesign */

var agt     = navigator.userAgent.toLowerCase();
var is_aol  = (agt.indexOf("aol") != -1);


// 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 );

    window.top.name = "opener";

    if ( popupWin && popupWin.opener )
    {
        if ( openerUrl )
        {
            popupWin.opener.location = openerUrl;
            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, type )
{
    var videoUrl = url;
    var popupWidth = 577;
    var popupHeight = 465;
    var cookies = getCookies();
// .... comes in as /video/nascar/YYYY/MM/DD/slug.ram
    var prefixRE = /^\/((pr\/)?video)\/(nascar|audio|garagepass|nascartoday)\//;
    var suffixRE = /\.(((np\.|r1\.)?smil|ram)[^\/]*)?$/;
    var prefix = prefixRE.exec( videoUrl );
    var suffix = suffixRE.exec( videoUrl );

    if ( arguments.length > 1 && type == 'public' )
    {
        if ( videoUrl.indexOf( 'nascar247' ) != -1 ) { popupWidth = 730; popupHeight = 460; } 
		videoUrl = "/video" + videoUrl.replace( suffixRE, "_frameset_exclude.html" );
    }
    else if ( prefix && prefix.length > 2 && prefix[3] != 'nascar' )
    {
        switch( prefix[3] )
        {
            case 'audio':
                // don't touch those audio one-offs
                break;
            case 'garagepass':
                videoUrl = "/pr/video/audio/garagepass_frameset_exclude.html";
                break;
            case 'nascartoday':
                videoUrl = "/pr/video/audio/nascartoday_frameset_exclude.html";
                break;
        }
    }
    else if ( suffix )
    {
        if ( prefix )
        {
            videoUrl = videoUrl.replace( prefixRE, "/pr/video/" ).replace( suffixRE, "_frameset_exclude.html" );
        }
        else
        {
            videoUrl = "/pr/video" + videoUrl.replace( suffixRE, "_frameset_exclude.html" );
        }
// .... leaves as /pr/video/YYYY/MM/DD/slug_frameset_exclude.html
    }

    if ( videoUrl.indexOf( 'frameset_exclude.html' ) != -1 )
    {
        CNN_openPopup( videoUrl+'?product=video', '' + popupWidth + 'x' + popupHeight, 'width=' + popupWidth + ',height=' + popupHeight + ',scrollbars=no,resizable=yes' );
    }
    else
    {
        top.location.href = videoUrl;
    }

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

    if ( location.pathname.indexOf( '/' ) == location.pathname.lastIndexOf( '/' ) && document.getElementById && document.getElementById( "tp_vidmodule1" ) )
    {
    // if first / is in same position as last / we're in no subdirectories
        if ( vidmodule && vidmodule.setSoundEnabled && navigator.platform.toLowerCase().indexOf( 'win' ) > -1)
        {
            vidmodule.setSoundEnabled(false);
        }
    }
}


// _____________________________________________________________ LaunchRacecast
function LaunchRacecast( url )
{
    var racecastUrl     = "";
	racecastUrl = htmlRacecast( url );
    
	// OPEN Application
    if (racecastUrl)
    {
        CNN_openPopup(racecastUrl,'TrackPass','width=792,height=522,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes');
    }
}

// ________________________________________________________________ aolRacecast
function aolRacecast( param )
{
    var aolUrl = '';

    switch (param)
    {
        case 'pc' :                 // PC CUP RACE
            aolUrl = '/pr/aol/pitcommand/2.0/cup/race/frameset_race_exclude.html?product=pc';
            break;

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

        case 'pcq' :                    // PC 2.0 CUP QUAL
            aolUrl = '/pr/aol/pitcommand/2.0/cup/qual/frameset_qual_exclude.html?product=pc';
            break;

        case 'wcr' :                    // LL CUP RACE
            aolUrl = '/pr/races/leaderboard/aol/cup/race/frameset_race_exclude.html?product=ll';
            break;

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

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

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

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

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

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

    return aolUrl;
}


// ________________________________________________________________ htmlRacecast
function htmlRacecast( param )
{
    var htmlUrl = '';

    switch (param)
    {
        case 'pc' :                 // PC CUP RACE
            htmlUrl = '/pr/pitcommand/2.0/cup/race/frameset_race_exclude.html?product=pc';
            break;

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

        case 'pcq' :                    // PC 2.0 CUP QUAL
            htmlUrl = '/pr/pitcommand/2.0/cup/qual/frameset_qual_exclude.html?product=pc';
            break;

        case 'wcr' :                    // LL CUP RACE
            htmlUrl = '/pr/races/leaderboard/cup/race/frameset_race_exclude.html?product=ll';
            break;

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

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

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

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

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

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

    return htmlUrl;
}

//____________________________________________________________________
// 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 Menu Items///////////////////////
///// As of 12/21/05, the nav code was pulled out of main.js and placed into siteConfig.js///////////////////////
///// This allows us to deploy simple nav changes without Change Control///////////////////////
///// See http://bugzilla.turner.com/show_bug.cgi?id=23218/////
///// http://aruba.turner.com/change_control/edit.php?ccid=34898&action=EditChange ////
*****************************************************/

document.write('<script language="JavaScript1.1" src="http://i.a.cnn.net/nascar/.element/1.0/ssi/code/siteConfig.js" type="text/javascript"><\/script>')

/*****************************************************
///// finish DHTML Code for Menu Items////////////////
*****************************************************/

/*****************************************************
///// DHTML Code for Top Navigation //////////////////
*****************************************************/
ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 2
ypSlideOutMenu.hideDelay = 25
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", 45, 27, 170, 200),
    new ypSlideOutMenu("menu2", "down", 88, 27, 170, 200),
    new ypSlideOutMenu("menu3", "down", 143, 27, 170, 200),
    new ypSlideOutMenu("menu4", "down", 188, 27, 170, 200),
    new ypSlideOutMenu("menu5", "down", 353, 27, 170, 200),
    new ypSlideOutMenu("menu6", "down", 416, 27, 170, 200),
    new ypSlideOutMenu("menu7", "down", 501, 27, 170, 200),
    new ypSlideOutMenu("menu8", "down", 551, 27, 170, 200),
    new ypSlideOutMenu("menu9", "down", 517, 27, 170, 200),
    new ypSlideOutMenu("menu10", "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='';");
}

/* Swaps A/V Tabs in Broadband Modules */
var panels = new Array('modbbV' , 'modbbA');
var selectedTab = null;
function bbandTab(tab, name)
{
  for(i = 0; i < panels.length; i++)
  {
    document.getElementById(panels[i]).style.display = (name == panels[i]) ? 'block':'none';
  }
  return false;
}


//CSI functions
var cnnCSIs = new Array();
var cnnUseDelayedCSI = 0;
var localUserAgent = navigator.userAgent.toLowerCase();
if((localUserAgent.indexOf('msie')>-1) && (localUserAgent.indexOf('mac')>-1)){cnnUseDelayedCSI = 1;}

function cnnAddCSI(id,source,args,breakCache)
{
    if(!args) { args='';}
    breakCache = ( !breakCache && ( source.charAt( 0 ) == '/' ) ) ? false : true;
    if(cnnUseDelayedCSI)
    {
        var newCSI = new Object();
        newCSI.src = source;
        newCSI.id  = id;
        newCSI.args = args;
        newCSI.breakCache = breakCache;
        cnnCSIs[cnnCSIs.length]=newCSI;
    }
    else
    {
        var today = new Date();
        var currTime = today.getTime();
        var iframeArgs = ( breakCache ) ? '&time='+currTime : '';
        if(args)
        {
            iframeArgs=iframeArgs+'&'+args;
        }
        var iframeHtmlSrc='<iframe src="'+source+'?domId='+id+iframeArgs+'" name="iframe'+id+'" id="iframe'+id+'" width="0" height="0" align="right" style="visibility:hidden"></iframe>';
        document.write(iframeHtmlSrc);
    }
}

function cnnUpdateCSI(html, id)
{
    var htmlContainerObj = document.getElementById( id ) || document.all[ id ];
    if(htmlContainerObj)
    {
        htmlContainerObj.innerHTML = html;
    }
    //force a refresh of the content area
    var htmlContentArea = document.body;
    if(htmlContentArea)
    {
        var previousTopVal = htmlContentArea.style.top || '0px';
        htmlContentArea.style.top = '1px';
        htmlContentArea.style.top = previousTopVal;
    }
}

function cnnHandleCSIs()
{
    if(document.body && document.body.innerHTML && cnnUseDelayedCSI)
    {
        var iframeOwner = document.getElementById( 'csiIframe' ) || document.all[ 'csiIframe' ];
        var iframeHtmlSrc = '';

        for(var incCounter=0;incCounter<cnnCSIs.length;incCounter++)
        {
            var src = cnnCSIs[incCounter].src;
            var id = cnnCSIs[incCounter].id;
            var today = new Date();
            var breakCache = cnnCSIs[incCounter].breakCache;
            var currTime = today.getTime();
            var args = ( breakCache ) ? '&time='+currTime : '';
            if(cnnCSIs[incCounter].args)
            {
                args=args+'&'+cnnCSIs[incCounter].args;
            }
            iframeHtmlSrc+='<iframe src="'+src+'?domId='+id+args+'" name="iframe'+id+'" id="iframe'+id+'" width="0" height="0" align="right"></iframe>';
        }
        if(iframeOwner)
        {
            iframeOwner.innerHTML=iframeHtmlSrc;
        }
    }
}

var cnnEnableCL = true;

//domain fix
var cnnDocDomain = '';
if(location.hostname.indexOf('.nascar.com')>0) {cnnDocDomain='nascar.com';}
if(location.hostname.indexOf('turner.com')>0) {if(document.layers){cnnDocDomain='turner.com:'+location.port;}else{cnnDocDomain='turner.com';}}
if(cnnDocDomain) {document.domain = cnnDocDomain;}

// End CSI functions

// _____________________________________________________________ WebMonkey code
/*
WM_setCookie(), WM_readCookie(), WM_killCookie()
A set of functions that eases the pain of using cookies.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
*/

// This next little bit of code tests whether the user accepts cookies.
function WM_browserAcceptsCookies() {
	var WM_acceptsCookies = false;
	if ( document.cookie == '' ) {
		document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
		if ( document.cookie.indexOf( 'WM_acceptsCookies=yes' ) != -1 ) {
			WM_acceptsCookies = true;
		} // If it succeeds, set variable
	} else { // there was already a cookie
		WM_acceptsCookies = true;
	}
	
	return ( WM_acceptsCookies );
}

function WM_setCookie( name, value, hours, path, domain, secure ) {
	if ( WM_browserAcceptsCookies() ) { // Don't waste your time if the browser doesn't accept cookies.
		var numHours = 0;
		var not_NN2 = ( navigator && navigator.appName
					&& (navigator.appName == 'Netscape')
					&& navigator.appVersion
					&& (parseInt(navigator.appVersion) == 2) ) ? false : true;

		if ( hours && not_NN2 ) { // NN2 cannot handle Dates, so skip this part
			if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
				numHours = hours;
			} else if ( typeof(hours) == 'number' ) { // calculate Date from number of hours
				numHours = ( new Date((new Date()).getTime() + hours*3600000) ).toGMTString();
			}
		}
		
		document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
	}
} // WM_setCookie

function WM_readCookie( name ) {
	if ( document.cookie == '' ) { // there's no cookie, so go no further
	    return false;
	} else { // there is a cookie
	    var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
		var NN2Hack = firstChar + name.length;
		if ( (firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=') ) { // if you found the cookie
			firstChar += name.length + 1; // skip 'name' and '='
			lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
			if (lastChar == -1) lastChar = theBigCookie.length;
			return unescape( theBigCookie.substring(firstChar, lastChar) );
		} else { // If there was no cookie of that name, return false.
			return false;
		}
	}	
} // WM_readCookie

function WM_killCookie( name, path, domain ) {
	var theValue = WM_readCookie( name ); // We need the value to kill the cookie
	if ( theValue ) {
		document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
	}
} // WM_killCookie

// SEARCH FUNCTIONS FOR SUPERSTORE RADIO BUTTONS
var d = document;
function checkAction(){
	if (d.getElementById('nascarSearch').checked) {
		d.ncar_search.action = "http://search.nascar.com/pages/search/advanced.jsp";
	} else if (d.getElementById('superstoreSearch').checked){
		d.ncar_search.keywords.value = d.ncar_search.QueryText.value;
		d.ncar_search.action = "http://store.nascar.com/entry.point";
	}
}
