var url = window.location.href;

//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;

// 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();

//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;
}


//Premium content gatekeeper (videoWin)
function pcGateKeeper(pcType, linkType, src, clipType, topImage, adSponsor, brandImage, brandImageLink, regLocation, relatedFrag, relatedTitle, curBGColor) {
	
	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, "/");
		}

		//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)
{
	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)
{
	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 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;
		}
	}
}
	/* Start Dan's include */
	
	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');	
		
		}
	}
	}
	}

}
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;     
			
	}
	
//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
				urlExt = "http://www.nba.com/broadband/asb_include.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%3fmedia_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%3fmedia_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%3fmedia_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%3fmedia_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%3fmedia_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%3fteam=" + 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;
			}
		}
	}
}


// Popup video player
function videoWin(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, vidLoc, akamai, rpContextWidth)
{
	if(!checkReal(src, clipType, topImage, adSponsor, brandImage, brandImageLink, isPremium,  regLocation, urlExt, vidDate, pidType, rsrcLink, akamai, rpContextWidth)){
	
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();
	}
	else{
	//do nothing
	}
	
}

	/* End Dan's include */


//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)
{

	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';
	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) {
  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) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function openBroadBand(src,type,video){
if(video==""||typeof(video)=="undefined"){
	video = "blank";
}
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");
	}
}

//global drop down nav
function ddTeamLinks(ddID,ddHeight,ddWidth){
	document.getElementById(ddID).style.height = ddHeight;
	document.getElementById(ddID).style.width = ddWidth;
}
function ddTeamClose(ddID){
	parent.document.getElementById(ddID).style.height = ddHeight;
	parent.document.getElementById(ddID).style.width = 50;
}
function ddTeamCloseWide(ddID){
	parent.document.getElementById(ddID).style.height = ddHeight;
	parent.document.getElementById(ddID).style.width = 70;
}
function getURL(teamURL){location.href=teamURL;}

