//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;
	
}

// 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 += "&regLocation=" + 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 + "&amp;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;
}

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;
		}
	}
}

//http://broadband.nba.com/cc/playa.php?content=audio&url=http://boss.streamos.com/wmedia-live/nba/7255/20_nba-chicago_audio_040930.asx&include=audio_default_include.html'),escape('audio'));

function openSecureBroadBand(src,type,video){
src = src + "%26video%3D" + video
tokenPath = "/broadband/Connection.jsp?dest=" + src
loginPath = "/broadband/login.jsp?dest=" + src 
	if(type=='audio'){
		if(!isRegistered()) {	
			pcGateKeeper(escape('vid'),escape('openSecureBroadBand'),escape(src));
			window.open(loginPath,"BroadbandWin", "width=570,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
		}else{
		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");
	}
}
/*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=752,height=583,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
	}
}

function nbaVideo(src,video){

if(video=="team"){
src = src + "%26lc1%3DNBA.com%26lc2%3Dteamsites%26siteid=team";
}
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
tokenPath = unescape(src);
		window.open(tokenPath,"BroadbandWin", "width=752,height=583,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
}


function nbaVideoLP(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=745,height=460,top=100,left=200,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0,copyhistory=0");
}




function nbaVideoShort(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=" + escape("http://broadband.nba.com/cc/playa.php?content=video&url=") + src
		window.open(tokenPath,"BroadbandWin", "width=752,height=583,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 openTeamALP(URL,teamCode){
src =  URL + "%26%74%73%3D%31";
//loginPath = "/broadband/login.jsp?dest=" + src;
tokenPath = "/broadband/Connection.jsp?dest=" + src + "&teamCode=" + teamCode + "&target="+escape(document.location);
loginPath = "/broadband/audio_login_team.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('openSecureBroadBand'),escape(src));
		window.open(loginPath,"BroadbandWin", "width=570,height=377,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
	}else{
		window.open(tokenPath,"BroadbandWin", "width=510,height=377,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);
}

function open_window_ex_link(url, title, options) {
	mywin=window.open(url,title,options);
}
//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 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 );
	}
}


	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"');
		}
}

//-------------------------------------
//recursive function scans through the numerical layers array for a layer with the required id
//------------------------------------
function getRefToDiv(divID) {
    if( document.layers ) { return document.layers[divID].document.layers[divID]; }
    if( document.getElementById ) { return document.getElementById(divID); }
    if( document.all ) { return document.all[divID]; }
    if( document[divID] ) { return document[divID].document[divID]; }
    return false;
}

//----------------------------------
// allows a positioned element be shown
//----------------------------------

function showDiv(divID_as_a_string) {
    var myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) { window.alert('Your Browser version does not support this feature'); return; }
    if( myReference.style ) { myReference.style.visibility = 'visible'; } else {
        if( myReference.visibility ) { myReference.visibility = 'show'; } else {
            window.alert('Your Browser version does not support this feature'); return; } }
}

//----------------------------------
// allows a positioned element be hidden
//----------------------------------

function hideDiv(divID_as_a_string) {
    var myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) { window.alert('Your Browser version does not support this feature');return; }
    if( myReference.style ) { myReference.style.visibility = 'hidden'; } else {
        if( myReference.visibility ) { myReference.visibility = 'hide'; } else {
            window.alert('Your Browser version does not support this feature'); return; } }
}

// 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;
}

// RSS on HomePage
function getMinutesSince(pDate){
	if(curTime) {
	var delay = 120000 //two minutes;
	postTime = new Date (pDate);
	curTime = new Date(curTime);

	postTime = Date.parse(postTime);
	curTime = Date.parse(curTime);

	minSince = curTime - postTime;
	minSince = minSince + delay;
	minSince = minSince / 60000;
	minSince = Math.round(minSince);

	var minStr = "min.";
	showMin = minSince;
	if(minSince >= 1 && minSince <= 60){minStr = "min.";}
	if(minSince >= 60 && minSince <= 90){minStr = "hour"; showMin = minSince / 60;}
	if(minSince >= 90 && minSince <= 1440){minStr = "hours"; showMin = minSince / 60;}
	if(minSince >= 1440 && minSince <= 2880){minStr = "day"; showMin = minSince / 1440;}
	if(minSince >= 2880){minStr = "days"; showMin = minSince / 1440;}

	return document.write("<span class=minAgo> - " + Math.round(showMin) + " " + minStr + " ago</span>");
	}
}

function getURL(teamURL){location.href=teamURL;}

function openCourtSideLS2(codeGame)
  
{
mywin = window.open( 'http://www.nba.com/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' );
  
}
//new global drop down functions
function ddOpen(ddID){
	document.getElementById(ddID).style.visibility = "visible";
}
function ddClose(ddID){
	document.getElementById(ddID).style.visibility = "hidden";
}

function addOnLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}