//Determine browser
var ie = (navigator.appName.indexOf('Microsoft') != -1) ? true : false;
var ns = (navigator.appName.indexOf('Netscape') != -1) ? true : false;
var ns4 = (ns && document.layers) ? true : false;
var ns6 = (ns && document.getElementById) ? true : false;
var dom = (document.getElementById) ? true : false;
var mac = ((navigator.appVersion.indexOf("PPC") >0) || (navigator.appVersion.indexOf("Mac") >0)) ? true : false;


var highRes = false;

if (screen!=null && (screen.width>800)){
	highRes = true;

}


function open_window_ex_link(url, title, options) {
	mywin=window.open(url,title,options);
}
// Array and function necessary for ads to show up in netscape
var ads = new Array();
	function ad(site, page, position, size){
		this.site = site;
		this.page = page;
		this.pos = position;
		this.sz = size;
}

//Variables needed for email a photo
var currentEPhoto = 0;
var imageLoc = new Array();
var imageCap = new Array();
var imageCre = new Array();
var imageAmex = new Array();

//needed for e-card
var imageNameArray = new Array();
var thumbNailLoc = new Array();

//Random Number generator
function Random(N)
	{ return Math.floor( N*Math.random() );	}

//Blank onLoad,init functions
function onLoad() {}
function init(bool) {}
var popupPath = '/popups/';

//Determine if user has registered in the past
function isRegistered() {
	var login = getCookie( "login" );
	if (( login != null ) && ( login != "null" )){
		//User is registered
		return true;
	}
	else {
		//User not registered
		return false;
	}
}

//Redirect to registration
function switchLocation(regLocation) {
	if ((typeof(regLocation) != "undefined") && (regLocation != null))
		window.location = '/' + regLocation + '/' + regLocation + 'registration.html';
	else
		window.location = '/rm/login.jsp?dest=/rm/rmSuccess.html?loc=login';
}

//define secure reg parameters in path
function getMorePathInfo(isPremium, regLocation) {
	var path = '';

	if ((typeof(regLocation) != "undefined") && (regLocation != null))
		path += "®Location=" + regLocation;
	if(!isPremium)
		path += "&reload=true";

	return path;
}
//check for real cookie
function checkRealCookie(){
var check = getCookie("realplayer");
if (check!=null && check != ""){

	if (check == 'gold'){
		return true;
	}

}


}


//check to see if video is more than 7 days old
function checkDate(vidDate){
	if(vidDate == ""){
		return false;

	}
	else{
	var check = new Date(vidDate);
	var now = new Date();
	now.setTime(now.getTime() - 7 * 24 * 60 * 60 * 1000);
		if(now > check){
			return true;
		}
		else{
			return false;
		}
	}
}


//checks for real player, premium, etc.
function checkReal(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, akamai, rpContextWidth){
		clipType = clipType.toLowerCase();
		if(rpContextWidth > 0){
			rpContextWidth = rpContextWidth
		}else{
			rpContextWidth = 630
		}
		if(akamai == "true"){
			if(navigator.appName=="Netscape"){
				varContext = "&rpcontexturl="
			}else{
			varContext = "?rpcontexturl="
			}
		}else{
			varContext = "&rpcontexturl="
		}
		if(!urlExt){
			if(adSponsor > ""){
				urlExt = "http://www.nba.com/insideticket/realone_" + adSponsor + ".html&rpcontextwidth=" + rpContextWidth
			}
			else{
				if(pidType > ""){
					urlExt = "insideticket/promo_context_window.html"
					}else{
					urlExt = "http://www.nba.com/insideticket/promo_context_window.html&rpcontextwidth=" + rpContextWidth
				}
			}
		}
		else if(urlExt > ""){
			urlExt = urlExt + "&rpcontextwidth=" + rpContextWidth
		}
	if(checkDate(vidDate) == true){
		if(checkRealCookie() == true){
			src = src + "&rpcontexturl=" + urlExt
			loadlink(unescape(src), 'yes')
			return true;
		}
		else{
			loadlink(unescape('http://start.real.com/rd?pid=check_nba%3fhref=insideticket.html&url=sub_check.smil'), 'yes')
			return true;
			}
	}
	else if(pidType =="it"){
			src = "http://start.real.com/rd?pid=nba_it&url=play_it.smil%26media_file=" + src + ".rm%26nba_context=" + urlExt + "&pcode=nba&cpath=CNT&rsrc=" + rsrcLink
			loadlink(unescape(src), 'yes')
		return true;
	}
	else if(pidType =="sp"){
		src = "http://start.real.com/rd?pid=nba_sp&url=play_sp.smil%26media_file=" + src + ".rm%26nba_context=" + urlExt + "&pcode=nba&cpath=CNT&rsrc=" + rsrcLink
		loadlink(unescape(src), 'yes')
		return true;
	}
	else if(pidType =="it_live"){
			src = "http://start.real.com/rd?pid=nba_it_live&url=play_it_live.smil%26media_file=" + src + ".rm%26nba_context=" + urlExt + "&pcode=nba&cpath=CNT&rsrc=" + rsrcLink
			loadlink(unescape(src), 'yes')
		return true;
	}
	else if(pidType =="sp_live"){
		src = "http://start.real.com/rd?pid=nba_sp_live&url=play_sp_live.smil%26media_file=" + src + ".rm%26nba_context=" + urlExt + "&pcode=nba&cpath=CNT&rsrc=" + rsrcLink
		loadlink(unescape(src), 'yes')
		return true;
	}
	else if(pidType =="events_live"){
		src = "http://start.real.com/rd?pid=nba_events&url=play_events_live.smil%26media_file=" + src + ".rm%26nba_context=" + urlExt + "&pcode=nba&cpath=CNT&rsrc=" + rsrcLink
		loadlink(unescape(src), 'yes')
		return true;
	}
	else if(pidType =="r1"){
			src = "http://start.real.com/rd?pid=nba_r1&url=alp/play.smil%26team=" + src + "&pcode=nba&cpath=CNT&rsrc=" + rsrcLink
			loadlink(unescape(src), 'yes')
			return true;
	}
	else if(pidType =="temp"){
			src = "http://start.real.com/rd?pid=nba_it&url=geo/block.smil&pcode=nba&cpath=CNT&rsrc=nba.site"
			loadlink(unescape(src), 'yes')
			return true;
	}
	else if(isRealOne() == 'installed' || isRealOne() == 'using'){
		//src = src + "&rpcontexturl=" + urlExt
		if(isPremium){
			if(isRegistered()){
				if(clipType == 'avi'){
				loadlink(unescape(src), 'no')
				return true;
				}
				else if(clipType == 'wmv'){
					return false;
				}
				else if(clipType == 'mov'){
					return false;
				}
				else{
				src = src + varContext + urlExt
				loadlink(unescape(src), 'no')
				return true;
				}
			}
			else{
				if(clipType == 'wmv'){
					pcGateKeeper(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium, regLocation, urlExt, vidDate)
					return false;
				}
				else{
				src = src + varContext + urlExt
				pcGateKeeperReal(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium, regLocation, urlExt, vidDate)
				}
			}
			return true;
		}

		else{
			if(clipType == 'avi'){
				loadlink(unescape(src), 'no')
				return true;
			}
			else if(clipType == 'wmv'){
					return false;
				}
			else if(clipType == 'mov'){
					return false;
				}
			else{
			src = src + varContext + urlExt
			loadlink(unescape(src), 'no')
			return true;
			}
		}
	}
}


//real is installed and video is secure
function pcGateKeeperReal(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium, regLocation, urlExt, vidDate){
if(isRegistered()){
		loadlink(unescape(src), 'no')
	}
	else{
	pcType = 'vid';
	linkType = 'videoWin'
		//Not reg. Redirect to login
		//Video content, set cookies
		var vidProperties = '<src>' + unescape(src) + '</src>';
			var premiumCookie = '<pcType>' + pcType + '</pcType>'
			premiumCookie += '<linkType>' + linkType + '</linkType>';
			premiumCookie += '<loc>' + window.location + '</loc>';
			premiumCookie +=  vidProperties;
			SetCookie("NBA_PC", premiumCookie, null, "/");

		attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355,height=500';
		gallery=window.open('/popups/secureVideo.html',newWinName(),attrs);
		gallery.focus();
	}
}


//Premium content gatekeeper (videoWin)
function pcGateKeeper(pcType, linkType, src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation, relatedFrag, relatedTitle, curBGColor,headshot,headshotLink) {
	if(!isRegistered()) {
		//Not reg. Redirect to login
		if(pcType.indexOf("vid") != -1) {
			//Video content, set cookies
			var vidProperties = '<src>' + unescape(src) + '</src>';
			vidProperties += '<cType>' + unescape(clipType) + '</cType>';
			vidProperties += '<tImg>' + unescape(topImage) + '</tImg>';
			vidProperties += '<adSp>' + unescape(adSponsor) + '</adSp>';
			vidProperties += '<brImg>' + unescape(brandImage) + '</brImg>';
			vidProperties += '<brLink>' + unescape(brandImageLink) + '</brLink>';

			if ((typeof(relatedFrag) != "undefined") && (relatedFrag != null))
				vidProperties += '<rFrag>' + unescape(relatedFrag) + '</rFrag>';

			if ((typeof(relatedTitle) != "undefined") && (relatedTitle != null))
				vidProperties += '<rTitle>' + unescape(relatedTitle) + '</rTitle>';

			if ((typeof(curBGColor) != "undefined") && (curBGColor != null))
				vidProperties += '<curBGColor>' + unescape(curBGColor) + '</curBGColor>';


			var premiumCookie = '<pcType>' + pcType + '</pcType>'
			premiumCookie += '<linkType>' + linkType + '</linkType>';
			premiumCookie += '<loc>' + window.location + '</loc>';
			premiumCookie +=  vidProperties;

			SetCookie("NBA_PC", premiumCookie, null, "/");
		}
		//secure audio
		else if(pcType==("aud")) {
			var vidProperties = '<src>' + unescape(src) + '</src>';
			vidProperties += '<cType>' + unescape(clipType) + '</cType>';
			vidProperties += '<tImg>' + unescape(topImage) + '</tImg>';
			vidProperties += '<adSp>' + unescape(adSponsor) + '</adSp>';
			vidProperties += '<brImg>' + unescape(brandImage) + '</brImg>';
			vidProperties += '<brLink>' + unescape(brandImageLink) + '</brLink>';
			vidProperties += '<hShot>' + unescape(headshot) + '</hShot>';
			vidProperties += '<hLink>' + unescape(headshotLink) + '</hLink>';

			var premiumCookie = '<pcType>' + pcType + '</pcType>'
			premiumCookie += '<linkType>' + linkType + '</linkType>';
			premiumCookie += '<loc>' + window.location + '</loc>';
			premiumCookie +=  vidProperties;
			SetCookie("NBA_PC", premiumCookie, null, "/");
		}


		//switchLocation(regLocation);
		/* return false;*/
	}
		return true;

}


//this function is specifically for videoWinSecureWNBA
function pcGateKeeperWNBA(pcType, linkType, src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation, relatedFrag, relatedTitle, curBGColor) {

		if(pcType.indexOf("vid") != -1) {
			//Video content, set cookies
			var vidProperties = '<src>' + unescape(src) + '</src>';
			vidProperties += '<cType>' + unescape(clipType) + '</cType>';
			vidProperties += '<tImg>' + unescape(topImage) + '</tImg>';
			vidProperties += '<adSp>' + unescape(adSponsor) + '</adSp>';
			vidProperties += '<brImg>' + unescape(brandImage) + '</brImg>';
			vidProperties += '<brLink>' + unescape(brandImageLink) + '</brLink>';

			if ((typeof(relatedFrag) != "undefined") && (relatedFrag != null))
				vidProperties += '<rFrag>' + unescape(relatedFrag) + '</rFrag>';

			if ((typeof(relatedTitle) != "undefined") && (relatedTitle != null))
				vidProperties += '<rTitle>' + unescape(relatedTitle) + '</rTitle>';

			if ((typeof(curBGColor) != "undefined") && (curBGColor != null))
				vidProperties += '<curBGColor>' + unescape(curBGColor) + '</curBGColor>';

			var premiumCookie = '<pcType>' + pcType + '</pcType>'
			premiumCookie += '<linkType>' + linkType + '</linkType>';
			premiumCookie += '<loc>' + window.location + '</loc>';
			premiumCookie +=  vidProperties;
			SetCookie("NBA_PC", premiumCookie, null, "/");

			//set the hostname as a cookie (i.e. "linuxweb1w", "www.wnba.com")
			//secureVideoWNBA.js needs to know where to redirect after login/register
			var host = document.location.hostname;
			SetCookie("WSV_HOST", host, null, "/");
		}

	return true;
}
// This javascript grabs the parameters passed in through the URL and splits them up into the URLParams array
var URLParams = new Array();
var paramList = window.location.search;
if (paramList)
	{paramList = paramList.substr(1);
	var ParamPairs = paramList.split("&");
	for (var x = 0; x < ParamPairs.length; x++)
		{var Param = ParamPairs[x].split("=");
		var ParamName = Param[0];
		var ParamValue = Param[1];
		URLParams[ParamName] = ParamValue;
		}
	}
function videoLaunch(URL,include,refer,videoParam){
if (include==null || (typeof(include) == "undefined")){include="WNBA_video_inc.html"}
if (refer==null || refer == ''){refer="wnba"}
if (videoParam==null || (typeof(videoParam) == "undefined")){videoParam="wnba"}
	//gallery=window.open("http:\/\/broadband.wnba.com/playa.php?content=video&url="+URL+"&include="+include+"&refer="+refer+"&videoParam="+videoParam,"VideoLaunch", "width=508, height=419, toolbars=no, scrollbars=no, resizable=yes");
	gallery=window.open("http:\/\/broadband.wnba.com/content.php?filename="+URL+"&include="+include+"&refer="+refer+"&videoParam="+videoParam,"VideoLaunch", "width=508, height=419, toolbars=no, scrollbars=no, resizable=yes");

	gallery.focus();
}
/*
function videoLaunch(URL,include,refer,videoParam){
if (include==null || (typeof(include) == "undefined")){include="WNBA_video_inc.html"}
if (refer==null || refer == ''){refer="wnba"}
src=URL+"%26include%3D"+include+"%26refer%3D"+refer+"%26videoParam%3D"+videoParam
loginPath = "/broadband/wnba_login.jsp?dest=" + "http%3A//broadband.wnba.com/cc/playa.php%3Fcontent%3Dvideo%26url%3D" +src
tokenPath = "/broadband/Connection.jsp?dest=" + "http%3A//broadband.wnba.com/cc/playa.php%3Fcontent%3Dvideo%26url%3D" +src
	if(!isRegistered()) {
		pcGateKeeper(escape('vid'),escape('videoLaunch'),escape(src));
		window.open(loginPath,"VideoLaunch", "width=850,height=672,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
	}else{
		gallery=window.open(tokenPath,"VideoLaunch", "width=850, height=672, toolbars=no, scrollbars=no, resizable=yes");
		gallery.focus();
	}
}*/
function audioLaunch(audioCode,include,refer,videoParam){
if (include==null || (typeof(include) == "undefined")){include="WNBA_video_inc.html"}
if (refer==null || refer == ''){refer="wnba"}
if (videoParam==null || (typeof(videoParam) == "undefined")){videoParam="wnba"}
	gallery=window.open("http://broadband.wnba.com/content.php?liveaudio="+audioCode+"&include="+include+"&refer="+refer+"&videoParam="+videoParam,"AudioLaunch", "width=508, height=419, toolbars=no, scrollbars=no, resizable=yes");
	gallery.focus();
}

function videoLaunchSponsor(URL,include,mediaType,sponsor){
if (include==null || (typeof(include) == "undefined")){include="WNBA_video_inc.html"}
if (mediaType==null || mediaType == ''){mediaType="real"}
	if (mediaType=="real"){
		gallery=window.open("http:\/\/broadband.wnba.com/cc/playa.php?url=http://boss.streamos.com/real/wnba/wnba/"+URL+"&include="+include+"&video="+sponsor,"VideoLaunchSponsor", "width=507, height=429, toolbars=no, scrollbars=no, resizable=yes");
	}else{
		gallery=window.open("http:\/\/broadband.wnba.com/cc/playa.php?url=http://boss.streamos.com/wmedia/wnba/wnba/"+URL+"&include="+include+"&video="+sponsor,"VideoLaunchSponsor", "width=507, height=429, toolbars=no, scrollbars=no, resizable=yes");
	}
	gallery.focus();
}
function videoLiveLaunch(videoCode,teamCode,teamCode2,include,refer,videoParam){
if (include==null || (typeof(include) == "undefined")){include="WNBA_video_inc.html"}
if (refer==null || refer == ''){refer="wnba"}
if (videoParam==null || (typeof(videoParam) == "undefined")){videoParam="wnba"}
src=videoCode+"&teamCode="+teamCode+"&teamCode2="+teamCode2+"&include="+include//+"%26refer%3D"+refer+"%26videoParam%3D"+videoParam
loginPath = "/broadband/wnba_login.jsp?dest=/broadband/WNBAZipCheck.jsp%3Ftarget=" +src
//un-comment and replace line below after playoffs
//tokenPath = "/broadband/WNBAZipCheck.jsp?target=" + "http%3A//broadband.wnba.com/cc/playa.php%3Fcontent%3Dvideo%26url%3Dhttp%3A//boss.streamos.com/wmedia-live/wnba/" +src
tokenPath = "/broadband/Connection.jsp?dest=" +	"http%3A//broadband.wnba.com/cc/playa.php%3Fcontent%3Dvideo%26url%3Dhttp%3A//boss.streamos.com/wmedia-live/wnba/" +src

	if(!isRegistered()) {
		pcGateKeeper(escape('vid'),escape('videoLiveLaunch'),escape(src));
		window.open(loginPath,"VideoLiveLaunch", "width=850,height=672,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
	}else{
		gallery=window.open(tokenPath,"VideoLiveLaunch", "width=850, height=672, toolbars=no, scrollbars=no, resizable=yes");
		gallery.focus();
	}
	teamCode="";
	teamCode2="";
}
function audioLaunchSecure(audioCode,include,sponsor){
if (include==null || (typeof(include) == "undefined")){include="/broadband/audio_include.html"}
src=audioCode+"%26include%3D"+include+"%26video%3D"+sponsor
loginPath = "/broadband/wnba_login.jsp?dest=" + "http%3A//broadband.wnba.com/cc/playa.php%3Fcontent%3Daudio%26url%3Dhttp%3A//boss.streamos.com/wmedia-live/wnba/" +src
tokenPath = "/broadband/Connection.jsp?dest=" +	"http%3A//broadband.wnba.com/cc/playa.php%3Fcontent%3Daudio%26url%3Dhttp%3A//boss.streamos.com/wmedia-live/wnba/" +src
	if(!isRegistered()) {
		pcGateKeeper(escape('vid'),escape('audioLaunchSecure'),escape(src));
		window.open(loginPath,"AudioLaunch", "width=507,height=410,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
	}else{
		gallery=window.open(tokenPath,"AudioLaunch", "width=507, height=410, toolbars=no, scrollbars=no, resizable=yes");
		gallery.focus();
	}
}

function videoWNBA05(URL,mediaType,secure,sponsor,include,teamCode,teamCode2){
if (mediaType==null || mediaType == '' || mediaType=='real'){mediaType="real"}else{mediaType="wmedia"}
if (include==null || (typeof(include) == "undefined")){include=""}
if (secure==null || secure == ''){secure="no"}
if(teamCode==null || teamCode=="undefined" || teamCode==""){zipCheck = ""}else{zipCheck = "/broadband/WNBAZipCheck2.jsp?target="}
src=URL+"&teamCode="+teamCode+"&teamCode2="+teamCode2+"&video="+sponsor+"&include="+include
medtype = "&media="+mediaType
loginPath = "/broadband/wnba_login.jsp?dest=" + zipCheck + src + medtype
tokenPath = zipCheck + "/broadband/Connection.jsp?dest=" + "http%3A//broadband.wnba.com/cc/playa.php%3Fcontent%3Dvideo%26url%3Dhttp%3A//boss.streamos.com/"+mediaType+"/wnba/wnba/" +src
			gallery=window.open(tokenPath,"videoWNBA05", "width=850, height=672, toolbars=no, scrollbars=no, resizable=yes");
			gallery.focus();
}

function videoAllDecade(URL,mediaType,secure,sponsor,include,teamCode,teamCode2){
if (mediaType==null || mediaType == '' || mediaType=='real'){mediaType="real"}else{mediaType="wmedia"}
if (include==null || (typeof(include) == "undefined")){include=""}
if (secure==null || secure == ''){secure="no"}
if(teamCode==null || teamCode=="undefined" || teamCode==""){zipCheck = ""}else{zipCheck = "/broadband/WNBAZipCheck2.jsp?target="}
src=URL+"&teamCode="+teamCode+"&teamCode2="+teamCode2+"&video="+sponsor+"&include="+include
medtype = "&media="+mediaType
loginPath = "/broadband/wnba_login.jsp?dest=" + zipCheck + src + medtype
tokenPath = zipCheck + "/broadband/Connection.jsp?dest=" + "http%3A//broadband.wnba.com/cc/playa.php%3Fcontent%3Dvideo%26url%3Dhttp%3A//boss.streamos.com/"+mediaType+"/wnba/" +src
			gallery=window.open(tokenPath,"videoWNBA05", "width=750, height=590, toolbars=no, scrollbars=no, resizable=yes");
			gallery.focus();
}

var videoParam= URLParams['videoParam'];

function videoWinRel(src, clipType, topImage, adSponsor, brandImage, brandImageLink, relatedFrag, isPremium, regLocation, relatedTitle, curBGColor, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
		if(isPremium)
		pcGateKeeper('vid', 'videoWinRel', src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation, relatedFrag, relatedTitle, curBGColor)
		path = popupPath + "vidPopup_related.html";

	path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor + "&relatedFrag=" + relatedFrag + "&relatedTitle=" + relatedTitle + "&curBGColor=" + curBGColor;
	path += getMorePathInfo(isPremium, regLocation);

	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=522';
	brand(462,462,brandImage,brandImageLink);
	gallery=window.open(path,'player',attrs);
	gallery.focus();
}


//need a different function to handle WNBA Secure Video (Related) because of the login cookie on NBA domain
function videoWinRelSecureWNBA(src, clipType, topImage, adSponsor, brandImage, brandImageLink, relatedFrag, isPremium, regLocation, relatedTitle, curBGColor, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
		if(isPremium)
	pcGateKeeperWNBA('vid', 'videoWinRel', src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation, relatedFrag, relatedTitle, curBGColor)
	path = "http://www.nba.com/popups/vidPopup_related_SecureWNBA.html";

	path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor + "&relatedFrag=" + relatedFrag + "&relatedTitle=" + relatedTitle + "&curBGColor=" + curBGColor;
	path += getMorePathInfo(isPremium, regLocation);

	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=522';
	brand(472,472,brandImage,brandImageLink);
	gallery=window.open(path,'player',attrs);
	gallery.focus();
}


function videoWin(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai, rpContextWidth)
{
if(pidType >""){
if(pidType == "r1"){pidPath = "play"}else if(pidType == "temp"){pidPath = "block"}else{pidPath = "play_" + pidType}
	src = "http://start.real.com/rd?pid=nba_" + pidType + "&url="+ pidPath + ".smil%26media_file=" + src + ".rm%26nba_context=" + urlExt + "&pcode=nba&cpath=CNT&rsrc=nba"// + rsrcLink
	//src = "http://start.real.com/rd?pid=nba_it&url=play_it.smil%26media_file=" + src + ".rm%26nba_context=" + urlExt + "&pcode=nba&cpath=CNT&rsrc=" + rsrcLink
	SetCookie("clipSRC", src, null, "/");
}
	if(vidLoc > ""){
		vidLoc = vidLoc.substring((vidLoc.indexOf('nba.com/'))+8);
		var section = vidLoc.substring(0,vidLoc.indexOf('/'));
	}else{
		query = '' + this.location;
		query = query.substring((query.indexOf('nba.com/')) + 8);
		var section = query.substring(0,query.indexOf('/'));
	}
		function checkteams(){
		for (i=0;i<29;i++){
		if(checkteams.arguments[i] == section){
			vidplayer = "old"
			i = 30
		}
		else{
			vidplayer = "new"
		}
		}
		}
		checkteams("celtics", "heat", "nets", "knicks", "magic", "sixers", "wizards", "hawks", "bulls", "cavaliers", "pistons", "pacers", "bucks", "hornets", "raptors", "mavericks", "nuggets", "rockets", "grizzlies", "timberwolves", "spurs","jazz", "warriors", "clippers", "lakers", "suns", "blazers", "kings", "sonics")
		if(vidplayer == "old"){
			playerType = "vidPopup.html";
		}else{
			playerType = "vidPopup_related_content.html";
		}
	if(isPremium)

		pcGateKeeper('vid', 'videoWin', src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation)

		path = popupPath + playerType;

		path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
		path += getMorePathInfo(isPremium, regLocation);

		attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
		brand(462,462,brandImage,brandImageLink);
		gallery=window.open(path,newWinName(),attrs);
		gallery.focus();
}

//broadband
//REMOVE THIS FUNCTION (openSecureBroadBandInside) APRIL 25th
function openSecureBroadBandInside(src,type,video){
if(video!=null||"undefined"!=typeof(video)){
	src = src + "%26video%3D" + video
}
loginPath = "/broadband/login.jsp?dest=" + src
tokenPath = "/broadband/Connection.jsp?dest=" + src
	if(type!='text'){
		if(!isRegistered()) {
			pcGateKeeper(escape('vid'),escape('openSecureBroadBand'),escape(src));
			if(type=='audio'){
				window.open(loginPath,"BroadbandWin", "width=510,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
			}else{
				window.open(loginPath,"BroadbandWin", "width=850,height=612,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
			}
		}else{
			if(type=='audio'){
				window.open(tokenPath,"BroadbandWin", "width=510,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
			}else{
				window.open(tokenPath,"BroadbandWin", "width=850,height=612,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
			}
		}
	} else {
		if(!isRegistered()) {
			document.location="/broadband/login_full.jsp?dest="+ src ;
		}else{
			document.location=tokenPath;
		}
	}
}

function openSecureBroadBand(src,type,video){
if(video!=null||"undefined"!=typeof(video)){
	src = src + "%26video%3D" + video
}
loginPath = "/broadband/login.jsp?dest=" + src
tokenPath = "/broadband/Connection.jsp?dest=" + src
	if(type!='text'){
		if(!isRegistered()) {
			pcGateKeeper(escape('vid'),escape('openSecureBroadBand'),escape(src));
			if(type=='audio'){
				window.open(loginPath,"BroadbandWin", "width=510,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
			}else{
				window.open(loginPath,"BroadbandWin", "width=850,height=612,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
			}
		}else{
			if(type=='audio'){
				window.open(tokenPath,"BroadbandWin", "width=510,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
			}else{
				window.open(tokenPath,"BroadbandWin", "width=850,height=612,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
			}
		}
	} else {
		if(!isRegistered()) {
			document.location="/broadband/login_full.jsp?dest="+ src ;
		}else{
			document.location=tokenPath;
		}
	}
}

function openSecureLive(src,type){
loginPath = "/broadband/login.jsp?dest=" + src
tokenPath = "/broadband/Connection.jsp?dest=" + src
	if(type!='text'){
		if(!isRegistered()) {
			pcGateKeeper(escape('vid'),escape('openSecureLive'),escape(src));
			if(type=='audio'){
				window.open(loginPath,"BroadbandWin", "width=510,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
			}else{
				window.open(loginPath,"BroadbandWin", "width=652,height=379,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
			}
		}else{
			if(type=='audio'){
				window.open(tokenPath,"BroadbandWin", "width=510,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
			}else{
				window.open(tokenPath,"BroadbandWin", "width=652,height=379,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
			}
		}
	} else {
		if(!isRegistered()) {
			document.location="/broadband/live_games_login.jsp?dest=" + src ;
		}else{
			document.location=tokenPath;
		}
	}
}


function openBroadBand(src,type,video){
src = src + "%26video%3D" + video
tokenPath = "/broadband/Connection.jsp?dest=" + src
	if(type=='audio'){
		window.open(tokenPath,"BroadbandWin", "width=510,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
	}else{
		window.open(tokenPath,"BroadbandWin", "width=850,height=612,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
	}
}

//team video
function openTeamVideo(URL,teamCode,vidType){
src =  URL  //+ "&vidType=" + vidType;
//loginPath = "/broadband/login.jsp?dest=" + src;
tokenPath = "/broadband/ZipCheck.jsp?dest=" + src + "&teamCode=" + teamCode + "&target="+escape(document.location);
loginPath = "/broadband/BroadbandLoginTeam.jsp?dest=" + src + "&teamCode=" + teamCode + "&target="+escape(document.location);
//tokenPath = "http://linuxweb1/rm/register.jsp?dest=" + escape=(src) + "RegType=TeamVideo";


	if(!isRegistered() && teamCode) {
	pcGateKeeper(escape('vid'),escape('openTeamVideo'),escape(src));
		window.open(loginPath,"BroadbandWin", "width=520,height=340,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
	}else{
		window.open(tokenPath,"BroadbandWin", "width=320,height=240,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
	}
}

function audioLeaguePass(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
	if(!checkReal(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, akamai)){
		window.open('http://www.nba.com/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
	}
}


function videoWinFlash(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
	if(navigator.userAgent.indexOf('NT')){
		path = popupPath + "vidPopup.html";
		path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
		path += getMorePathInfo(isPremium, regLocation);
		attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
		brand(462,462,brandImage,brandImageLink);
		gallery=window.open(path,newWinName(),attrs);
		gallery.focus();
	}else{
		path = popupPath + "vidPopup.html";
		path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
		path += getMorePathInfo(isPremium, regLocation);
		attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
		brand(462,462,brandImage,brandImageLink);
		gallery=window.open(path,newWinName(),attrs);
		gallery.focus();
	}
}
function videoWinFlashAkamai(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
src = "rtsp://a389.r.akareal.net/ondemand/7/389/6101/v0001/nba.download.akamai.com/6101/" + src + ".rm"
	if(navigator.userAgent.indexOf('NT')){
		path = popupPath + "vidPopup.html";
		path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
		path += getMorePathInfo(isPremium, regLocation);
		attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
		brand(462,462,brandImage,brandImageLink);
		gallery=window.open(path,newWinName(),attrs);
		gallery.focus();
	}else{
		path = popupPath + "vidPopup.html";

		path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
		path += getMorePathInfo(isPremium, regLocation);

		attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
		brand(462,462,brandImage,brandImageLink);
		gallery=window.open(path,newWinName(),attrs);
		gallery.focus();
		}
}

function videoWinLego(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
	if(isPremium)

		pcGateKeeper('vid', 'videoWinLego', src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation)

		path = popupPath + "vidPopup_lego.html";

		path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
		path += getMorePathInfo(isPremium, regLocation);

		attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
		brand(462,462,brandImage,brandImageLink);
		gallery=window.open(path,newWinName(),attrs);
		gallery.focus();
}

// Popup video player
function videoWinSprite(src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation, isPremium, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
	if(isPremium)
		pcGateKeeper('vid', 'videoWinSprite', src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation)

	path = "http://www.nba.com" + popupPath + "vidSpritePopup.html";

	path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
	path += getMorePathInfo(isPremium, regLocation);

	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
	brand(462,462,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),attrs);
	gallery.focus();
}

// Popup video player
function videoWinHistory(src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation, isPremium, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
	if(isPremium)
		pcGateKeeper('vid', 'videoWinHistory', src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation)

	path = popupPath + "vidPopup_history.html";

	path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
	path += getMorePathInfo(isPremium, regLocation);

	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
	brand(462,462,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),attrs);
	gallery.focus();
}

//need a different function to handle WNBA Secure Video because of the login cookie on NBA domain
function videoWinSecureWNBA(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium, regLocation, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai)
{
	if(isPremium)
		pcGateKeeperWNBA('vid', 'videoWin', src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation)

	path = "http://www.nba.com/popups/vidPopupSecureWNBA.html";

	path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
	path += getMorePathInfo(isPremium, regLocation);

	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
	brand(462,462,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),attrs);
	gallery.focus();
}




//Real media window
function rmWin(src, title, brandImage, brandImageLink, isPremium, regLocation)
{
	if(isPremium)
		pcGateKeeper('vid', 'rmWin', src, '', '', '', brandImage, brandImageLink, regLocation)

	selectTemplate('RM');
	path += "&src=" + src;
	path += getMorePathInfo(isPremium, regLocation);

	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
	brand(462,462,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),attrs);
	gallery.focus();

}

//Avi window
function aviWin(src,title,brandImage,brandImageLink, isPremium, regLocation) {

	if(isPremium)
		pcGateKeeper('vid', 'aviWin', src, '', '', '', brandImage, brandImageLink, regLocation)

	selectTemplate('AVI');
	path += "&src=" + src + "&title=" +title;
	path += getMorePathInfo(isPremium, regLocation);

	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=355';
	brand(462,462,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),attrs);
	gallery.focus();

}

//Quicktime movie window
function movWin(src,title,brandImage,brandImageLink, isPremium, regLocation) {
	if(isPremium)
		pcGateKeeper('vid', 'movWin', src, '', '', '', brandImage, brandImageLink, regLocation)

	selectTemplate('MOV');
	path += "&src=" + src + "&title=" +title;
	path += getMorePathInfo(isPremium, regLocation);

	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=355';
	brand(462,462,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),attrs);
	gallery.focus();

}

//Popup audio window
function audioWin(src,clipType,topImage,headshot,headshotLink,adSponsor,brandImage,brandImageLink)
{
	path = popupPath + "audPopup.html";
	path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&headshot=" + headshot + "&headshotLink=" + headshotLink + "&adSponsor=" + adSponsor;
	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
	//attrs = 'height=400';
	brand(268,268,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),'height=412,toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355');
	gallery.focus();
}


function audioWinSecure(src,clipType,topImage,headshot,headshotLink,adSponsor,brandImage,brandImageLink,isPremium,regLocation)
{
	playerType = "audPopup.html";
	if(isPremium)

		pcGateKeeper('aud', 'audioWinSecure',src,clipType,topImage,adSponsor,brandImage,brandImageLink,isPremium,regLocation,'','','',headshot,headshotLink)
		path = popupPath + playerType;

		path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&adSponsor=" + adSponsor;
		path += getMorePathInfo(isPremium, regLocation);

		attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
		brand(462,462,brandImage,brandImageLink);
		gallery=window.open(path,newWinName(),attrs);
		gallery.focus();
}


function audioWinHistory(src,clipType,topImage,headshot,headshotLink,adSponsor,brandImage,brandImageLink)
{
	path = popupPath + "audPopup_history.html";
	path += "?clipType=" + clipType + "&src=" + src + "&topImage=" + topImage + "&headshot=" + headshot + "&headshotLink=" + headshotLink + "&adSponsor=" + adSponsor;
	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable=no,width=355';
	brand(268,268,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),attrs);
	gallery.focus();

}
//Real audio window
function raWin(src,title,brandImage,brandImageLink, isPremium, regLocation) {
	selectTemplate('RA');
	path += "&src=" + src + "&title=" +title;
	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=355';
	brand(427,347,brandImage,brandImageLink);
	gallery=window.open(path,newWinName(),attrs);
	gallery.focus();
}

//Generic Open-Window function
function open_window_ex(url, title, height, width, options) {
    var path = url;
    if( url.search(/^http:/) == -1 ) {
        path = "/popups/" + url;
    } else {
        var nbaDomain = new RegExp("/^http:\/\/www.nba.com\/([.*]*)/");
        var result = url.match(nbaDomain);
        if( result != null ) {
            path = "/popups/" + result[1];
        } else {
            path = url;
        }
    }
    var opts = '';
	if(options == null || options == "null")
		opts = 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=yes, resizable=yes';
    else
		opts = options;

	opts += ',width=' + width;
    opts += ',height=' + height;
    mywin=window.open(path,title,opts);
}

//Reason: Real player on ie will explode if re-opened in same window
function newWinName() {
	return('vidWin' +(new Date).valueOf());
}

function brand(bSize,noBSize,brandImage,brandImageLink) {
   if (brandImage != '') {
       path += "&brandImage="+brandImage;

	   if (brandImageLink != '')
	   		path += "&brandImageLink="+brandImageLink;

	   attrs += ",height="+bSize;
   }
   else {
       attrs += ",height="+noBSize;
   }
}

function selectTemplate(clipType) {
	if((clipType == 'RA') || (clipType=='RM'))
		path = popupPath + 'vidPopup_rn.html'
	else
		path = popupPath + 'vidPopup_ms.html'
	path+= '?clipType=' + clipType;
}

//Cookie Functions
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {

if(name == "path" || name == "expires" || name == "domain" || name == "version") {
	name = "badCookieName";
}
 var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
	if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;

  }
  return null;
}


function SetCookie (name,value,expires,path,domain,secure) {

if(name == "path" || name == "expires" || name == "domain" || name == "version") {
	name = "badCookieName";
}

  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//real premium
//document.write('<OBJECT ID="IERPCtl" WIDTH=0 HEIGHT=0 CLASSID="CLSID:FDC7A535-4070-4B92-A0EA-D9994BCC0DC5"></OBJECT>');
function isRealOne() {
	RealOneInst = 'undetermined';
	var agt=navigator.userAgent.toLowerCase();
	var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
					&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
					&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	if (is_nav) {
		IERPCtl = 0;
	}
	if (navigator.plugins) {
		if ((navigator.userAgent.charAt(8)) >= ('3')) {
			var nPlayerInstalled=2;
			var i=0;
			while (navigator.plugins[i]){
				if (((navigator.plugins[i].name) == 'RealOne Player Version Plugin') || ((navigator.plugins[i].name).indexOf('RealPlayer')>-1)){
					nPlayerInstalled=1;
					szPlayerVersion=navigator.plugins[i].description;
					break;
					}
					i++;
				}

				if ( nPlayerInstalled == 2 ){
					var nRPVersion = IERPCtl.RealPlayerVersion;
					if ( nRPVersion == null ){
						nPlayerInstalled=2;
					}
					else {
						nPlayerInstalled=1;
					}
				}
			}
			if (nPlayerInstalled == 1){
				RealOneInst = 'installed';
			}
			if (nPlayerInstalled == 2){
				RealOneInst = 'notinstalled';

			}
		} else {
			RealOneInst = 'undetermined';
		}
		if (RealOneInst == 'installed') {
				if (agt.indexOf("(r1 ") != -1) {
						RealOneInst = 'using';
				}
		}
		return RealOneInst;

	}
	function loadlink(page,premium) {
		var agt=navigator.userAgent.toLowerCase();
		var is_aol = (agt.indexOf("aol") != -1);
		var checkbrowser = isRealOne();
		if (is_aol){
			if (checkbrowser == 'using' || checkbrowser == 'installed') {
				 window.location = (page);
			}
			else{
				//window.location="aol.html"
				window.open('http://www.nba.com/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
			}
		}
		else{
			var checkbrowser = isRealOne(); // here's where people with R1 will go
			if (checkbrowser == 'using') {
				 window.location = (page);

			}
			if (checkbrowser == 'installed') {  // here's where people with R1 will go
				//check for netscape, reroute link through real, netscape can't handle rtsp
				if(navigator.appName=="Netscape" && premium == "no"){
						page = "http://start.real.com/rd?url=" + page
				}
				window.location = (page);

			}
			if (checkbrowser =='undetermined' || checkbrowser =='notinstalled') {
			// now the tricky part : people we're not sure about yet

			numPlugins = navigator.plugins.length;
			oldRealPlayer = 'false';
			for (i = 0; i < numPlugins; i++)
			{
			  plugin = navigator.plugins[i];
			  if (plugin.name.substring(0,10)=="RealPlayer")
			  {
			  oldRealPlayer = 'true';
			  }
			}
		}
		if (navigator.userAgent.indexOf("Mac") != -1) {

			if (oldRealPlayer == 'true'){
				window.location = (page);
			} else {
				if (premium == 'yes') {
					if (checkbrowser =='undetermined' || checkbrowser =='notinstalled') {
						window.open('http://www.nba.com/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
					}
					else{
						window.open('http://start.real.com/rd?pid=check_nba%3fhref=insideticket.html&url=sub_check.smil');
					}
				}
				if (premium == 'no') {

				}
			}
		}

		else {if (navigator.userAgent.indexOf("95") != -1) {
			oldRealPlayer = 'false';
			document.writeln('<script language="VBscript">');
			document.writeln('on error resume next');
			document.writeln('RealPlayerG2 = not IsNull(CreateObject("rmocx.RealPlayer G2 Control"))');
			document.writeln('if (RealPlayerG2) then');
			document.writeln('oldRealPlayerIE=\"true\"');
			document.writeln('else');
			document.writeln('oldRealPlayerIE=\"false\"');
			document.writeln('end if');
			document.writeln('</scr' + 'ipt>');

			numPlugins = navigator.plugins.length;
			for (i = 0; i < numPlugins; i++)
			{
			plugin = navigator.plugins[i];
			if (plugin.name.substring(0,10)=="RealPlayer")
			{
			oldRealPlayer = 'true';
			}
		}
			if (oldRealPlayer == 'true' || oldRealPlayerIE == 'true'){
				window.location = (page);
			} else {
			if (premium == 'yes') {
				if (checkbrowser =='undetermined' || checkbrowser =='notinstalled') {
						window.open('http://www.nba.com/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
					}
					else{
						window.open('http://start.real.com/rd?pid=check_nba%3fhref=insideticket.html&url=sub_check.smil');
					}
			}
			if (premium == 'no') {

			}
			}
		}


		else {if (navigator.userAgent.indexOf("Win") != -1) {
		if (checkbrowser == 'using' || checkbrowser =='installed') {
			window.location = (page);
				} else {
				if (premium == 'yes') {
					if (checkbrowser =='undetermined' || checkbrowser =='notinstalled') {
						window.open('http://www.nba.com/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
					}
					else{
						window.open('http://start.real.com/rd?pid=check_nba%3fhref=insideticket.html&url=sub_check.smil');
					}
				}
				if (premium == 'no') {

				}
			   }
		} else {

			window.open('otherOS.html','r1popup','width=250,height=160,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');

		}
	}
	}
	}

}
// for aol hat
function redir3(theForm)
{
	var anyString;
	var index;
	index=theForm.URL.selectedIndex
	anyString=theForm.URL.options[index].value;

	if (anyString.substring(0,3) == "aol"){
	   window.location=theForm.URL.options[index].value;
	   theForm.URL.focus();
	}
	else
	    {
	window.location=theForm.URL.options[index].value;
	}

	 return (false);
}

function openCourtSide(codeGame) {
	window.open( '/courtsidelive/csl_popup.html?game='+codeGame,'CourtsideLive','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=12,screenY=12,top=12,left=12,copyhistory=no,width=410,height=500' );
}
function openGallery(xmlfile) {
	window.open( 'http://www.nba.com/jm.jsp?ref=amex_galleries&dest=/photogallery/gallery_detect.html?xmlfile='+xmlfile,'NBA_Photos','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=25,screenY=25,top=25,left=25,copyhistory=no,width=740,height=604' );
}
function openGalleryThumb(xmlfile,team)	{
	window.open( '/jm.jsp?ref=Thumb_galleries&dest=/photogallery/gallery_detectThumb.html?xmlfile='+xmlfile+'&teamHeader='+team,'NBA_Photos','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=25,screenY=25,top=25,left=25,copyhistory=no,width=740,height=604' );
}
function openFlashGallery(xmlfile,team)	{
	window.open( '/jm.jsp?ref=flash_gallery&dest=/photogallery/flashGalleryDetect.html?xmlfile='+xmlfile+'&teamHeader='+team,'NBA_Photos','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=25,screenY=25,top=25,left=25,copyhistory=no,width=740,height=630' );
}
function openFlashGalleryTest(xmlfile,team)	{
	window.open( '/jm.jsp?ref=flash_gallery&dest=/photogallery/flashGalleryDetectTest.html?xmlfile='+xmlfile+'&teamHeader='+team,'NBA_Photos','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=25,screenY=25,top=25,left=25,copyhistory=no,width=740,height=630' );
}
function openFlashGallery(xmlfile,team,spnsr)
	{window.open( '/jm.jsp?ref=flash_gallery&dest=/photogallery/flashGalleryDetect.html?xmlfile='+xmlfile+'&teamHeader='+team+'&spnsr='+spnsr,'NBA_Photos','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=25,screenY=25,top=25,left=25,copyhistory=no,width=740,height=630' );}

version = parseInt(navigator.appVersion);
function mostPhotoPop(photoGalSite,photoGalTeamHeader) {
	var w=740;
	//var w=590;
	var h=604;
	if(photoGalSite==''){photoGalSite='NBA';}
	if(photoGalTeamHeader==''){photoGalTeamHeader='none';}
	photoGalPage = '/photogallery/mostPhotoPopup.html?sitestart='+photoGalSite+'&teamHeader='+photoGalTeamHeader+'&startTime=weekly';
	if(navigator.appName == "Netscape" && version < 5){
		var newWindow = window.open(photoGalPage,'testing','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=25,screenY=25,top=25,left=25,copyhistory=no,resizable=yes');
	} else {
		var newWindow = window.open(photoGalPage,'testing','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,screenX=25,screenY=25,top=25,left=25,copyhistory=no,width='+w+',height='+h );
	}
}
// *
// * Disable aol browser redirect
// *
//check for aol browser and redirect to aol.wnba.com
//var browserType = navigator.userAgent
//var url = window.location.href
//if((browserType.indexOf("AOL") != -1)) {
//	if((url.indexOf("aol.wnba.com") == -1) && (url.indexOf("scores.nba.com") == -1) && (url.indexOf("search.wnba.com"))){
//	domLength = url.indexOf("com/")+4;
//	newLoc = url.substring(domLength,url.length)
//	document.location = "http://aol.wnba.com/" + newLoc
//	}
//}


	function testIsValidObject(objToTest) {
		if (null == objToTest) {
			return false;
		}
		if ("undefined" == typeof(objToTest) ) {
			return false;
		}
		return true;

	}



var xmlhttp=false;
/*@cc_on
@if (@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
@else
	xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}



function antiCache(tempUrl) {
	if (document.all) {
		ts = new Date().valueOf();
			return tempUrl+"?ts=" + ts;
	}
	return tempUrl;
}


function showLayer(layerName){
		if(document.layers){
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
		}else{
		eval('document.getElementById('+ "'" + layerName + "'" +').style.visibility = "visible"');
		}
}

function hideLayer(layerName){
		 if(document.layers){
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
		}else{
		eval('document.getElementById('+ "'" + layerName + "'" +').style.visibility = "hidden"');
		}
}

//checks to see if link originated from nba section or team
function checkteams(){

	query = '' + this.location;
	if(query.indexOf('linuxpub1')>1){
		query = query.substring((query.indexOf('linuxpub1w/')) + 11);
	}else if(query.indexOf('linuxpub2')>1){
		query = query.substring((query.indexOf('linuxpub2w/')) + 11);
	}else if(query.indexOf('linuxpubw')>1){
		query = query.substring((query.indexOf('linuxpubw/')) + 11);
	}else{
		query = query.substring((query.indexOf('wnba.com/')) + 9);
	}
	var section = query.substring(0,query.indexOf('/'));

		for (t=0;t<12;t++){

			if(checkteams.arguments[t] == section){
				wnbaSiteVar = "%26wnbasite%3D" + checkteams.arguments[t];
			t = 12
			}

		}

	if(typeof(wnbaSiteVar)=="undefined"){wnbaSiteVar = "%26wnbasite%3Dwnba"}
	return wnbaSiteVar;

}

checkteams("sky", "sun", "shock", "liberty", "fever", "mystics", "comets", "monarchs", "sparks", "storm", "silverstars", "lynx", "mercury")

function getEscapedUrlParameters(url) {
	var url = unescape(url);
	var url_split = url.split("?", 2);

	var parameters = {};

	if (url_split[1]) {
		var query_string_params = (url_split[1]).split("&");

		for(var i=0; i < query_string_params.length; i++) {
			var param_split = query_string_params[i].split("=");
			parameters[param_split[0]] = param_split[1];
		}
	}

	return parameters;
}

function wnbaVideo(src,video){
	var player_url = "http://www.wnba.com/wnbaplayer/wnbacom/";
	var escaped_player_url = escape(player_url);
	
	if (!src) { src = escaped_player_url; }
	src = src.substr(src.indexOf(escaped_player_url));

	var unescaped_url_params = getEscapedUrlParameters(src);

	if (unescaped_url_params["url"] != undefined && (/.*\.asx$/).test(unescaped_url_params["url"])) {
		window.location = unescaped_url_params["url"];
	} else {
		if (src != escaped_player_url) { src += "%26"; }
		else { src += "%3F"; }
		
		src = src + "video%3D" + video;
		if (unescaped_url_params["wnbasite"] == undefined) { src = src + checkteams(); }
		tokenPath = unescape(src);
		gallery=window.open(tokenPath,"BroadbandWin", "width=752,height=650,top=50,left=50,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
		gallery.focus();
	}
}

function nbaVideo(src,video){
	wnbaVideo(src,video);
}



function wnbaVideoLP(src,video){

if(video=="team"){
src = src + "%26lc1%3DNBA.com%26lc2%3Dteamsites";
}
if(src.indexOf("/nbacom/tnt/")>0||src.indexOf("/nbacom/tnt_soundoff/")>0){
	src = src + "%26video%3D" + "blank" + "%26tab%3D" + "tntchannel"
}else if(src.indexOf("/nbacom/allstar/")>0){
	src = src + "%26video%3D" + "blank" + "%26tab%3D" + "allstarchannel"
}else{
	src = src + "%26video%3D" + video
}
tokenPath = "/broadband/Connection.jsp?dest=" + src
		window.open(tokenPath,"BroadbandWin", "width=752,height=650,top=50,left=50,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
}

function wnbaVideoShort(src){
	var player_url = "http://www.wnba.com/wnbaplayer/wnbacom/";
	if (src) {
		src = player_url + "?content=video&url=" + src;
		
		wnbaVideo(escape(src),escape("blank"));
		return;
	}
	
	wnbaVideo(src,escape("blank"));
}

function printPage(){
window.print();
}

// team schedules dropdown links
function goHere(formName, selectName) {
	var dLink = eval('document.' + formName + '.' + selectName + '.options[document.' + formName + '.' + selectName + '.selectedIndex].value');
	if (dLink != '') window.location.href = '' + dLink;
}

