/*******************************************************************************
 * Global-space variables - to be initialize when the DOM is loaded 
 *******************************************************************************/
window.videoArray  = null;
window.tabReferrer = null;
window.tabDefaults = null;
window.tabMgr		= null;
window.subTabMgr	= null;

window.vanityTabDefault = null;
window.videoTabDefault = null;

window.nbaVideo = function(){}

nbaVideo.getReferrerVal = function(){	
	return window.location.pathname + window.location.hash;
}
var currCVPTabName;
var currCVPSubTabName;

/*******************************************************************************
 * Pass-through function to load playlist Array on the base page
 *******************************************************************************/
var loadVideoArray = function(oVidArray){
	loadVideo(oVidArray);
}

nbaVideo.showTeamSection = function(oTeamName){
	
	var vidContainerElm = $(tabMgr.getVidContainer());
	var docPath = "/.element/ssi/sect/1.1/video/" ;
	var docFile = "team." + oTeamName;
	var docExt  = ".html";
	var docFull	=  docPath + docFile + docExt;
	var oAjax = new nbaVideo.AjaxUpdater(vidContainerElm.id, docFull, {method: 'get', evalScripts: true, contentDiv:vidContainerElm});
}

/*******************************************************************************
 * Initialization function to setup main tabs  after DOM is loaded
 *******************************************************************************/
var nbaTabInit = function(){
	tabMgr		= new nbaVideo.TabManager();	
	tabReferrer = new nbaVideoReferrerHASH();
	
	//check for vanity URL map
	vanityTabDefault = tabReferrer.getTabDefaults(nbaVideo.getReferrerVal());
	if (vanityTabDefault != null) {
		tabDefaults = vanityTabDefault;
	}else{
		
		try
		{
			var tmpKey = videoMapKey; //Erica Reed will be creating a global VAR for this
									  //and should exist in the page somewhere
			tabDefaults = tabReferrer.getTabDefaults(tmpKey);
		}
		catch(_eRR)
		{
			tabDefaults = null;
		}
	}
	tabMgr.tabInit('tabMgr', tabDefaults, 'nbaTabsMain', 'nbaVideoContainer');
	
	//Check if main tab default is for teams and if so load the specific team section.
	if( tabDefaults != null){
		if( tabDefaults.mainTab == 'teams' && tabDefaults.subTab != "NONE"){
			nbaVideo.showTeamSection(tabDefaults.teamName);
		}
	}
	
}

/*******************************************************************************
 * Initialization function to setup sub tabs after DOM is loaded
 *******************************************************************************/
var nbaSubTabInit = function(oTabsContainer, oSubNavContainer){
	subTabMgr	= new nbaVideo.TabManager();			
	subTabMgr.tabInit('subTabMgr', tabDefaults, oTabsContainer, oSubNavContainer);
}

/*******************************************************************************
 * On initial file load this function is used to set additional parameters 
 * specific to file count (number of physically files), the directory map
 * and file name prefix or naming convention
 *******************************************************************************/
var nbaTabsParam = function(oIsMainTabs) {
	var tabFileCount 	= (String($('nbaVideoFileCount').innerHTML)).replace('^[ \s]+|[ \s]+$', ''); 
	var tabFilePath  	= (String($('nbaVideoFilePath').innerHTML)).replace('^[ \s]+|[ \s]+$', ''); 
	var tabFillNameMap 	= (String($('nbaVideoFileMap').innerHTML)).replace('^[ \s]+|[ \s]+$', ''); 
	if(oIsMainTabs){
		tabMgr.setTabParams(tabFileCount, tabFilePath, tabFillNameMap)
	}else{
		currCVPSubTabName = tabFillNameMap;
		subTabMgr.setTabParams(tabFileCount, tabFilePath, tabFillNameMap)
	}
}
		
/*******************************************************************************
 * Class to wrap Ajax.Updater to provide a more elegant approach to error
 * reporting.
 *******************************************************************************/
nbaVideo.AjaxUpdater = Class.create(Ajax.Updater, {
  initialize: function($super, container, url, options) {
    $super({success:container},url,nbaVideo.AjaxOptions(options));
  }
})

/*******************************************************************************
 * Option object to pass to Ajax.Updater wrapper
 *******************************************************************************/
nbaVideo.AjaxOptions = function (options) {
  return Object.extend({
     asynchronous:false,
     evalScripts:true,
     onException: function(request,exception) {
       Element.hide('nbaAjaxLoading')
       options.contentDiv.innerHTML = '<div id="nbaVidStatusMsg">An exception "' + exception + '" was thrown accessing "' + request.url + '"</div>';
       return true
     },
     on404: function(t) {
       Element.hide('nbaAjaxLoading')
       options.contentDiv.innerHTML = '<div id="nbaVidStatusMsg">' + t.status + ' | Videos Requested ' + t.statusText + '!</div>';
       return true
     },
     onFailure: function(t) {
       Element.hide('nbaAjaxLoading')
       options.contentDiv.innerHTML = '<div id="nbaVidStatusMsg">An unhandled error occured ' + t.status + ': ' + t.statusText + '</div>';
     },
     onLoading:function(request){Element.show('nbaAjaxLoading')},
     onComplete:function(request){window.setTimeout('Element.hide("nbaAjaxLoading");', 100);}
  }, options || {});
}

/*******************************************************************************
 * Tab manager object, which is created on DOM loaded event
 *******************************************************************************/
nbaVideo.TabManager = function()
{
	var mAgent 			= navigator.appName;
	var lastTab			= null;
	var tabsArray		= null;
	var vidContainerElm	= null;
	var tabContainerElm = null;
	var tabFileCount	= 0;
	var tabFilePath		= "";
	var tabFillNameMap	= "";
	var thisObjName		= "";
	
	this.tabInit 		= _tabInit;
	this.setTabParams 	= _setTabParams;
	this.show	 		= _show;
	this.showTabByIndex = _showTabByIndex;
	this.showTabByName	= _showTabByName;
	this.switchPage		= _switchPage;
	this.getVidContainer = _getVidContainer;
	this.getTabContainer = _getTabContainer;
	
	function _getVidContainer()	{
		return (vidContainerElm.id)
	}
	function _getTabContainer()	{
		return (tabContainerElm.id)
	}
	function _setTabParams(oFileCount, oFilePath, oFileMap)
	{
		//Initialize parameter for selected tab
		tabFilePath	 	= oFilePath;
		tabFillNameMap 	= oFileMap
		
		if (!isNaN(oFileCount)){
			tabFileCount = parseInt(oFileCount, 10); //initialize pagination
			
			if( tabFileCount > 0){ //then I have at least one page so initialize the pagination
				_writePageNav(1);
			}else{
				_setPageError("No Videos!");
			}
		}else{
			_setPageError("File Count isNaN | No Videos!");
		}
		
	}
	function _tabInit(oObjName, oTabDefObj, oTabsContainer, oVideoContainer) 
	{
		try
		{
			//as there will be multiple tabs group on the page need to figure out a way to distinguish
			thisObjName = oObjName;
			
			//store the containers for later
			tabContainerElm = $(oTabsContainer);
			vidContainerElm = $(oVideoContainer);
			
			//get all available Tabs
			tabsArray = tabContainerElm.getElementsBySelector('a');
			
			//set onclick event here
			_setOnclickEvents(oObjName)
			
			//now check for any defaults and display the intial tab
			_show(_getInitialTab(oTabDefObj));
			
		}
		catch(eRR){
			alert("Unexpected Error: While initialzing tabs!");	
		}
	}
	
	function _setOnclickEvents(oObjectRef)
	{
		for (var i = 0; i < tabsArray.length; i++){
			tabsArray[i].setAttribute('href', '#');
			tabsArray[i].onclick = new Function(oObjectRef + ".show(" + i + ");return false");
		}
	}
	function _getInitialTab(oDefaultObj) 
	{
		var elmIDArry = null;
		if(oDefaultObj != null)
		{
			for (var i = 0; i < tabsArray.length; i++)
			{
				//alert(tabsArray[i].id);
				elmIDArry = (String(tabsArray[i].id)).split("#")
				if( (String(elmIDArry[1])).toUpperCase() == "MAIN"){
					if (String(elmIDArry[0]) == oDefaultObj.mainTab){
						return i;
					}
				}else{
					if(String(elmIDArry[0]) == oDefaultObj.subTab){
						return i;	
					}
				}
			}
		}
		return 0;
	}
	
	function _showTabByName(oTabName)
	{
		var isFound = false;
		for (var i = 0; i < tabsArray.length; i++)
		{
			var elmIDArry = (String(tabsArray[i].id)).split("#")
			if( (String(elmIDArry[0])).toUpperCase() == (String(oTabName)).toUpperCase()){
				isFound = true;
				_show(i);
				break;
			}
		}
		if (!isFound){
			_setPageError("_showTabByName(): Tab name [ " + oTabName + " ] not found!");	
		}
	}
	
	function _showTabByIndex(tabIndex){
		_show(tabIndex)
	}
	
	function _show(oTabIndex) 
	{
		if ( (oTabIndex >= 0) && (oTabIndex <= tabsArray.length-1) )
		{
			var elm = tabsArray[oTabIndex];
			var elmIdArry   = (String(elm.id)).split("#") 
			var elmIdDoc 	= elmIdArry[0]; //strip out the document names
			
			//deactivate the current tab
			_hideLastClicked();
			
			//active the new tab
			_setClassName(elm, 'active-tab')
			
			//set new to current tab
			lastTab = elm;
			//now ajax the page section		
			_getTabResourceFile(elm, elmIdDoc, tabFilePath)
			
		}else{
			_setPageError("_show(): invalid tab index [ " + oTabIndex + " ]!");	
		}
			
	}
	
	function _hideLastClicked() {
		if(lastTab != null){
			lastTab.removeClassName('active-tab');
		}
	}
	
	function _setClassName(elm, oClassVal){
		elm.addClassName(oClassVal)
	}

	function _getTabResourceFile(oElm, oDocName, oDocPath)
	{
		var docPath = "/.element/ssi/sect/1.1/video/" ;
		var docFile = oDocName;
		currCVPTabName = (oDocName.indexOf('.') > -1) ? oDocName.substr(0,oDocName.indexOf('.')) : oDocName;
		var docExt  = ".html";
		var docFull	=  docPath + docFile + docExt;
		var oAjax = new nbaVideo.AjaxUpdater(vidContainerElm.id, docFull, {method: 'get', evalScripts: true, contentDiv: vidContainerElm});
	}
	
	function _switchPage(oPageNum)
	{
		var pagePath = tabFilePath + tabFillNameMap + oPageNum + ".html";
		var oAjax = new nbaVideo.AjaxUpdater(vidContainerElm.id, pagePath, {method: 'get', evalScripts: true, contentDiv: vidContainerElm});
		_writePageNav(oPageNum);
	}
	
	function _writePageNav(oPageIndex)
	{
		var html		= [];
		var pageMax		= tabFileCount;
		var pageSeq		= 3;
		
		if (tabFileCount != 0)
		{
			if (pageMax > 1)
			{
				html.push('<ul>');
				if (pageMax  <= pageSeq )
				{
					html.push('<li>Pages:&nbsp;</li>');
					for (var i = 1; i <= pageMax; i++){
						html.push( (i == oPageIndex) ? '<li>' + i + '</li>' : '<li><a href="#" onclick="' + thisObjName + '.switchPage(' + i + ');return false">' + i + '</a></li>' );
					}
				}
				else if (oPageIndex <= pageSeq && pageMax > pageSeq)
				{
					for (var i = 1; i <= pageSeq; i++){
						html.push( (i == oPageIndex) ? '<li>' + i + '</li>' : '<li><a href="#" onclick="' + thisObjName + '.switchPage(' + i + ');return false">' + i + '</a></li>' );
					}
					html.push('<li>...</li>',
						'<li><a href="#" onclick="' + thisObjName + '.switchPage(' + (pageMax) + ');return false">' + pageMax + '</a></li>',
						'<li><a href="#" onclick="' + thisObjName + '.switchPage(' + (oPageIndex+1) + ');return false">NEXT</a></li>'
					);
				}
				else if (oPageIndex > pageSeq && (oPageIndex+pageSeq) < pageMax)
				{
					html.push('<li><a href="#" onclick="' + thisObjName + '.switchPage(' + (oPageIndex-1) + ');return false">PREV</a></li>',
						'<li><a href="#" onclick="' + thisObjName + '.switchPage(' + 1 + ');return false">1</a></li>',
						'<li>...</li>'
					);
					for (var i = oPageIndex; i <= (oPageIndex+pageSeq); i++){
						html.push( (i == oPageIndex) ? '<li>' + i + '</li>' : '<li><a href="#" onclick="' + thisObjName + '.switchPage(' + i + ');return false">' + i + '</a></li>' );
					}
					html.push('<li>...</li>',
						'<li><a href="#" onclick="' + thisObjName + '.switchPage(' + (pageMax) + ');return false">' + pageMax + '</a></li>',
						'<li><a href="#" onclick="' + thisObjName + '.switchPage(' + (oPageIndex+1) + ');return false">NEXT</a></li>'
					);
				}
				else 
				{
					html.push('<li><a href="#" onclick="' + thisObjName + '.switchPage(' + (oPageIndex-1) + ');return false">PREV</a></li>',
						'<li><a href="#" onclick="' + thisObjName + '.switchPage(' + 1 + ');return false">1</a></li>',
						'<li>...</li>'
					);
					for (var i = (pageMax-pageSeq); i <= pageMax; i++){
						html.push( (i == oPageIndex) ? '<li>' + i + '</li>' : '<li><a href="#" onclick="' + thisObjName + '.switchPage(' + i + ');return false">' + i + '</a></li>' );
					}
				}
				html.push('</ul>');
				_showPageNav( html.join('') );
			}
		}
	}

	function _showPageNav(oHTMLtext)
	{
		try{
			$('nbaVideoPagination').innerHTML = oHTMLtext;
		}
		catch(eRR){
			var paginationDiv = document.createElement('div');
				paginationDiv.setAttribute('id', 'nbaVideoPagination');
				
			var pagiContentDiv = document.createElement('div');
				pagiContentDiv.setAttribute('id', 'nbaVidPageContent');
				pagiContentDiv.innerHTML = oHTMLtext;
				
				paginationDiv.appendChild(pagiContentDiv)
				vidContainerElm.appendChild(paginationDiv);
		}
	}
	
	function _setPageError(oMsg){
		vidContainerElm.innerHTML = '<div id="nbaVidStatusMsg">' + oMsg + '</div>';
	}
}

document.observe("dom:loaded", function(){nbaTabInit();});

// BEGIN video.redux.referrer.js CODE

/*******************************************************************************
 * Deprecated: use nbaVideoReferrerHASH() instead
 *******************************************************************************/
nbaVideoReferrer = function(){
	this.getTabDefaults = _getTabDefaults;
	function _getTabDefaults(oReferrer){return null;}
}

/*******************************************************************************
 * Object to hold vanity URL for main and sub-category defaults 
 *******************************************************************************/
nbaVideoReferrerHASH = function(){
	
	/*VANITY URLs*/
	this['/chrispaul/index.html'] 	= { mainTab: "nbatv", subTab: "nbatv.sub.9" };					
	this['/chrispaul/'] 			= { mainTab: "nbatv", subTab: "nbatv.sub.9" };		
	this['/flipvideo/index.html']	= { mainTab: "featured", subTab: "featured.sub.16" };
	this['/flipvideo/']		= { mainTab: "featured", subTab: "featured.sub.16" };
	this['/chrispaul/'] 			= { mainTab: "nbatv", subTab: "nbatv.sub.9" };		
				
	this['/performance/index.html'] = { mainTab: "tntot", subTab: "tntot.sub.7" };					
	this['/performance/'] 			= { mainTab: "tntot", subTab: "tntot.sub.7" };	
	this['/rtc/']			= { mainTab: "nbatv", subTab: "nbatv.sub.16" };
	this['/rtc/index.html']		= { mainTab: "nbatv", subTab: "nbatv.sub.16" };
					
	this['/strength/index.html'] 	= { mainTab: "tntot", subTab: "tntot.sub.14" };
	this['/strength/']				= { mainTab: "tntot", subTab: "tntot.sub.14" };
	
	this['/video/channels/allstar/index.html'] 		 = { mainTab: "NONE", subTab: "NONE" };
	this['/video/channels/allstar/'] 				 = { mainTab: "NONE", subTab: "NONE" };
	
	this['/video/channels/awardnominees/index.html'] = { mainTab: "featured", subTab: "featured.sub.4" };
	this['/video/channels/awardnominees/'] 			 = { mainTab: "featured", subTab: "featured.sub.4" };
	
	this['/video/channels/finishes/index.html'] = { mainTab: "featured", subTab: "featured.sub.6" };
	this['/video/channels/finishes/'] 			= { mainTab: "featured", subTab: "featured.sub.6" };
	
	this['/video/channels/highflyer/index.html'] = { mainTab: "featured", subTab: "featured.sub.5" };
	this['/video/channels/highflyer/'] 			 = { mainTab: "featured", subTab: "featured.sub.5" };
	
	this['/video/channels/nbatv/index.html'] = { mainTab: "nbatv", subTab: "nbatv.sub.1" };
	this['/video/channels/nbatv/'] 			 = { mainTab: "nbatv", subTab: "nbatv.sub.1" };
	
	this['/video/channels/playoftheday/index.html'] = { mainTab: "featured", subTab: "featured.sub.2" };
	this['/video/channels/playoftheday/'] 			= { mainTab: "featured", subTab: "featured.sub.2" };
	
	this['/video/channels/simulations/index.html'] = { mainTab: "NONE", subTab: "NONE" };
	this['/video/channels/simulations/'] 		   = { mainTab: "NONE", subTab: "NONE" };
	
	this['/video/channels/tntovertime/index.html'] = { mainTab: "tntot", subTab: "tntot.sub.1" };
	this['/video/channels/tntovertime/'] 		   = { mainTab: "tntot", subTab: "tntot.sub.1" };
	
	this['/video/channels/topplays/index.html'] = { mainTab: "topplays", subTab: "topplay.sub.1" };
	this['/video/channels/topplays/'] 			= { mainTab: "topplays", subTab: "topplay.sub.1" };
	
	this['/dailytop10/index.html'] = { mainTab: "topplays", subTab: "topplay.sub.4" };
	this['/dailytop10/'] 		   = { mainTab: "topplays", subTab: "topplay.sub.4" };
	this['/video/playsoftheweek/index.html'] = { mainTab: "topplays", subTab: "topplay.sub.7" };
        this['/video/playsoftheweek/'] = { mainTab: "topplays", subTab: "topplay.sub.7" };
	
	this['/tntovertime/Reggies_Mailbag/index.html'] = { mainTab: "tntot", subTab: "tntot.sub.5" };
	this['/tntovertime/Reggies_Mailbag/'] 			= { mainTab: "tntot", subTab: "tntot.sub.5" };
	
	this['/puppets/index.html'] = { mainTab: "featured", subTab: "featured.sub.13" };
	this['/puppets/'] 			= { mainTab: "featured", subTab: "featured.sub.13" };
	
	this['/correspondent/index.html'] = { mainTab: "featured", subTab: "featured.sub.14" };
	this['/correspondent/'] 			= { mainTab: "featured", subTab: "featured.sub.14" };
		
	/*T2 URL MATCHES*/
	
	this['/video/playoffs/seriesEast1/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.1" };
	this['/video/playoffs/seriesEast1/'] = { mainTab: "playoffs", subTab: "playoffs.sub.1" };
	
	this['/video/playoffs/seriesEast2/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.2" };
	this['/video/playoffs/seriesEast2/'] = { mainTab: "playoffs", subTab: "playoffs.sub.2" };
	
	this['/video/playoffs/seriesEast3/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.3" };
	this['/video/playoffs/seriesEast3/'] = { mainTab: "playoffs", subTab: "playoffs.sub.3" };
	
	this['/video/playoffs/seriesEast4/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.4" };
	this['/video/playoffs/seriesEast4/'] = { mainTab: "playoffs", subTab: "playoffs.sub.4" };
	
	this['/video/playoffs/seriesEast5/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.11" };
	this['/video/playoffs/seriesEast5/'] = { mainTab: "playoffs", subTab: "playoffs.sub.11" };
	
	this['/video/playoffs/seriesEast6/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.12" };
	this['/video/playoffs/seriesEast6/'] = { mainTab: "playoffs", subTab: "playoffs.sub.12" };
	
	this['/video/playoffs/seriesEast7/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.13" };
	this['/video/playoffs/seriesEast7/'] = { mainTab: "playoffs", subTab: "playoffs.sub.13" };
	
	this['/video/playoffs/seriesWest1/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.5" };
	this['/video/playoffs/seriesWest1/'] = { mainTab: "playoffs", subTab: "playoffs.sub.5" };
	
	this['/video/playoffs/seriesWest2/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.6" };
	this['/video/playoffs/seriesWest2/'] = { mainTab: "playoffs", subTab: "playoffs.sub.6" };
	
	this['/video/playoffs/seriesWest3/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.7" };
	this['/video/playoffs/seriesWest3/'] = { mainTab: "playoffs", subTab: "playoffs.sub.7" };
	
	this['/video/playoffs/seriesWest4/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.8" };
	this['/video/playoffs/seriesWest4/'] = { mainTab: "playoffs", subTab: "playoffs.sub.8" };
	
	this['/video/playoffs/seriesWest5/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.9" };
	this['/video/playoffs/seriesWest5/'] = { mainTab: "playoffs", subTab: "playoffs.sub.9" };
	
	this['/video/playoffs/seriesWest6/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.10" };
	this['/video/playoffs/seriesWest6/'] = { mainTab: "playoffs", subTab: "playoffs.sub.10" };
	
	this['/video/playoffs/seriesWest7/index.html'] = { mainTab: "playoffs", subTab: "playoffs.sub.14" };
	this['/video/playoffs/seriesWest7/'] = { mainTab: "playoffs", subTab: "playoffs.sub.14" };
	
	this['/video/playoffs/finals/index.html'] = { mainTab: "playoffs", subTab: "NONE" };
	this['/video/playoffs/finals/'] = { mainTab: "playoffs", subTab: "NONE" };
	
	
	/*NBA GLOBAL NAV MATCHES*/
	
	this['/video/#highlights'] = { mainTab: "highlights", subTab: "NONE" };
	this['/video/highlights/'] = { mainTab: "highlights", subTab: "NONE" };
	this['/video/highlights']  = { mainTab: "highlights", subTab: "NONE" };
	
	this['/video/#mostrecent'] = { mainTab: "mostrecent", subTab: "NONE" };
	this['/video/mostrecent/'] = { mainTab: "mostrecent", subTab: "NONE" };
	this['/video/mostrecent"'] = { mainTab: "mostrecent", subTab: "NONE" };
	
	this['/video/#topplays'] = { mainTab: "topplays", subTab: "NONE" };
	this['/video/topplays/'] = { mainTab: "topplays", subTab: "NONE" };
	this['/video/topplays']  = { mainTab: "topplays", subTab: "NONE" };
	
	this['/video/#nbatv'] = { mainTab: "nbatv", subTab: "NONE" };
	this['/video/nbatv/'] = { mainTab: "nbatv", subTab: "NONE" };		
	this['/video/nbatv"'] = { mainTab: "nbatv", subTab: "NONE" };
	
	this['/video/#tntot'] = { mainTab: "tntot", subTab: "NONE" };
	this['/video/tntot/'] = { mainTab: "tntot", subTab: "NONE" };
	this['/video/tntot']  = { mainTab: "tntot", subTab: "NONE" };
	
	this['/video/#teams'] = { mainTab: "teams", subTab: "NONE" };
	this['/video/teams/'] = { mainTab: "teams", subTab: "NONE" };
	this['/video/teams"'] = { mainTab: "teams", subTab: "NONE" };
	
	this['/video/#featured'] = { mainTab: "featured", subTab: "NONE" };	
	this['/video/featured/'] = { mainTab: "featured", subTab: "NONE" };
	this['/video/featured']  = { mainTab: "featured", subTab: "NONE" };
	
	this['/video/#playoffs'] = { mainTab: "playoffs", subTab: "NONE" };
	this['/video/playoffs/'] = { mainTab: "playoffs", subTab: "NONE" };
	this['/video/playoffs']  = { mainTab: "playoffs", subTab: "NONE" };
	
	this['/video/#barkleyzone'] = { mainTab: "barkleyzone", subTab: "NONE" };
	this['/video/barkleyzone/'] = { mainTab: "barkleyzone", subTab: "NONE" };
	this['/video/barkleyzone']  = { mainTab: "barkleyzone", subTab: "NONE" };
	
	this['/video/#draft'] = { mainTab: "draft", subTab: "NONE" };
	this['/video/draft/'] = { mainTab: "draft", subTab: "NONE" };
	this['/video/draft']  = { mainTab: "draft", subTab: "NONE" };
	
	/*VIDEO MATCHES*/
	
	//Playoffs tab
	this['playoffs.default']  = { mainTab: "playoffs", subTab: "playoffs.sub.1" };
	this['playoffs.eastr1m1'] = { mainTab: "playoffs", subTab: "playoffs.sub.1" };
	this['playoffs.eastr1m2'] = { mainTab: "playoffs", subTab: "playoffs.sub.2" };
	this['playoffs.eastr1m3'] = { mainTab: "playoffs", subTab: "playoffs.sub.3" };
	this['playoffs.eastr1m4'] = { mainTab: "playoffs", subTab: "playoffs.sub.4" };
	this['playoffs.westr1m1'] = { mainTab: "playoffs", subTab: "playoffs.sub.5" };
	this['playoffs.westr1m2'] = { mainTab: "playoffs", subTab: "playoffs.sub.6" };
	this['playoffs.westr1m3'] = { mainTab: "playoffs", subTab: "playoffs.sub.7" };
	this['playoffs.westr1m4'] = { mainTab: "playoffs", subTab: "playoffs.sub.8" };
	this['playoffs.eastsemifinals1'] = { mainTab: "playoffs", subTab: "playoffs.sub.11" };
	this['playoffs.eastsemifinals2'] = { mainTab: "playoffs", subTab: "playoffs.sub.12" };
	this['playoffs.westsemifinals1'] = { mainTab: "playoffs", subTab: "playoffs.sub.9" };
	this['playoffs.westsemifinals2'] = { mainTab: "playoffs", subTab: "playoffs.sub.10" };
	this['playoffs.eastfinals'] 	 = { mainTab: "playoffs", subTab: "playoffs.sub.13" };
	this['playoffs.westfinals'] 	 = { mainTab: "playoffs", subTab: "playoffs.sub.14" };
	this['playoffs.finals'] 	 = { mainTab: "playoffs", subTab: "playoffs.sub.15" };
	this['playoffs.rookiecorrespondent'] 	 = { mainTab: "featured", subTab: "featured.sub.14" };

	//Highlights tab
	this['games.default'] = { mainTab: "highlights", subTab: "NONE" };
	
	//Top Plays tab
	this['topplays.default'] 				= { mainTab: "topplays", subTab: "topplay.sub.1" };
	this['topplays.assistofthenight'] 		= { mainTab: "topplays", subTab: "topplay.sub.2" };
	this['topplays.blockofthenight'] 		= { mainTab: "topplays", subTab: "topplay.sub.3" };
	this['topplays.dailytopten'] 			= { mainTab: "topplays", subTab: "topplay.sub.4" };
	this['topplays.dunkofthenight'] 		= { mainTab: "topplays", subTab: "topplay.sub.5" };
	this['topplays.nightlytopperformance'] 	= { mainTab: "topplays", subTab: "topplay.sub.6" };
	this['topplays.playsoftheweek'] 		= { mainTab: "topplays", subTab: "topplay.sub.7" };
	this['topplays.stealofthenight'] 		= { mainTab: "topplays", subTab: "topplay.sub.8" };
	this['topplays.dailyzap'] 				= { mainTab: "topplays", subTab: "topplay.sub.9" };

	//NBA TV tab
	this['nbatv.default'] 				= { mainTab: "nbatv", subTab: "nbatv.sub.1" };
	this['nbatv.allaccess'] 			= { mainTab: "nbatv", subTab: "nbatv.sub.2" };
	this['nbatv.behindthescenes'] 		= { mainTab: "nbatv", subTab: "nbatv.sub.3" };
	this['nbatv.brotherhood'] 			= { mainTab: "nbatv", subTab: "nbatv.sub.4" };
	this['nbatv.gameanalysis'] 			= { mainTab: "nbatv", subTab: "nbatv.sub.12" };
	this['nbatv.internationalplayers'] 	= { mainTab: "nbatv", subTab: "nbatv.sub.5" };
	this['nbatv.legendsnight'] 			= { mainTab: "nbatv", subTab: "nbatv.sub.6" };
	this['nbatv.onpointwithchrispaul'] 	= { mainTab: "nbatv", subTab: "nbatv.sub.9" };
	this['nbatv.premierenight'] 		= { mainTab: "nbatv", subTab: "nbatv.sub.10" };
	this['nbatv.realnba'] 				= { mainTab: "nbatv", subTab: "nbatv.sub.14" };
	this['nbatv.realtrainingcamp']		= { mainTab: "nbatv", subTab: "nbatv.sub.16" };
	this['nbatv.rewindtheremix'] 		= { mainTab: "nbatv", subTab: "nbatv.sub.15" };
	this['nbatv.ricksrant'] 			= { mainTab: "nbatv", subTab: "nbatv.sub.13" };
	this['nbatv.ahmadsquad'] 			= { mainTab: "nbatv", subTab: "nbatv.sub.ahmadsquad" };
	this['nbatv.valuablepuppets'] 		= { mainTab: "featured", subTab: "featured.sub.13" };

	//TNT OT tab
	this['tntovertime.default'] 		= { mainTab: "tntot", subTab: "tntot.sub.1" };
	this['tntovertime.coachescorner'] 	= { mainTab: "tntot", subTab: "tntot.sub.14" };
	this['tntovertime.insidethenba'] 	= { mainTab: "tntot", subTab: "tntot.sub.3" };
	this['tntovertime.insiderreport'] 	= { mainTab: "tntot", subTab: "tntot.sub.4" };
	this['tntovertime.reggiesmailbag'] 	= { mainTab: "tntot", subTab: "tntot.sub.5" };
	this['tntovertime.strong'] 			= { mainTab: "tntot", subTab: "tntot.sub.7" };
	this['tntovertime.tnthalftime'] 	= { mainTab: "tntot", subTab: "tntot.sub.9" };
	this['tntovertime.tnttipoff'] 		= { mainTab: "tntot", subTab: "tntot.sub.10" };
	this['tntovertime.topfiveofinside'] = { mainTab: "tntot", subTab: "tntot.sub.15" };
	
	//Featured tab
	this['playoftheday.default'] 	= { mainTab: "featured", subTab: "featured.sub.2" };
	this['awardnominees.default'] 	= { mainTab: "featured", subTab: "featured.sub.4" };
	this['highflyer.default'] 		= { mainTab: "featured", subTab: "featured.sub.5" };
	this['finishes.default'] 		= { mainTab: "featured", subTab: "featured.sub.6" };
	this['flipvideodiaries.default'] 		= { mainTab: "featured", subTab: "featured.sub.16" };
	this['pre-season.causeandeffect']		= { mainTab: "featured", subTab: "featured.sub.17" };
	
	//Barkley Zone tab
	this['barkleyzone.default'] 	 = { mainTab: "barkleyzone", subTab: "barkleyzone.sub.1" };
	this['barkleyzone.whereyoubeen'] = { mainTab: "barkleyzone", subTab: "barkleyzone.sub.2" };
	this['barkleyzone.soundoff'] 	 = { mainTab: "barkleyzone", subTab: "barkleyzone.sub.3" };
	this['barkleyzone.askchuck'] 	 = { mainTab: "barkleyzone", subTab: "barkleyzone.sub.4" };
	
	//Draft tab
	this['draft.default'] 	 		 = { mainTab: "draft", subTab: "draft.sub.1" };
	this['draft.lottery'] 			 = { mainTab: "draft", subTab: "draft.sub.2" };
	this['draft.playerhighlights'] 	 = { mainTab: "draft", subTab: "draft.sub.3" };
	this['draft.teamneeds'] 	 	 = { mainTab: "draft", subTab: "draft.sub.4" };
	this['draft.greenroom'] 	 	 = { mainTab: "draft", subTab: "draft.sub.5" };
	this['draft.draftday'] 	 	 	 = { mainTab: "draft", subTab: "draft.sub.6" };
	this['draft.prospectprofile']		= { mainTab: "draft", subTab: "draft.sub.7" };
	this['draft.yearone'] 	 	 	 = { mainTab: "draft", subTab: "draft.sub.8" };
	
	this.getTabDefaults = _getTabDefaults;
	
	function _getTabDefaults(oReferrer){
		if (oReferrer != ""){
			if(typeof this[oReferrer] == 'object'){
				return	this[oReferrer];
			}
		}
		return null;		
	}
}

