var d = document;


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]] = nv[1];
            }
        }
    }
    return hash;
}

var cs = getCookies();
var cnnIDCookie = cs['CNNid'];
var nsfgCookie = cs['nsfg'];





function cnnPlay(driver, driverFullname) {
    // non working code
    //cnnBuildPlayer('cnnPlayer', '/pr/races/audio/' + driver + '.asx', '1', '1');

    var file = '/pr/races/audio/' + driver + '.asx' + '?' + 'CNNid=' + cnnIDCookie + '&nsfg=' + nsfgCookie;
    $("#nascarAudioPlayerDiv").media({ src: file, autoplay: true, width: 1, height: 1, bgColor: "#000000" });

	var h2 = d.createElement('h2');
	h2.id = 'cnnNowPlaying';
	if ((driverFullname == 'Select A Driver') || (driverFullname == null)) {
		h2.appendChild(d.createElement('<br>'));
	} else {
		h2.appendChild(d.createTextNode(driverFullname));
	}
	d.getElementById('cnnHeader').replaceChild(h2, d.getElementById('cnnNowPlaying'));
}

function cnnRedirectParent(url) {
	if (window.opener && !window.opener.closed) {
		window.opener.location = url;
	} else {
		window.open(url);
	}
}
