
		// alert('U been hooked, sucka!')

	    //var bbFlash = document.getElementById("bbFlash");
   	    var hooked = false;
		var adRefreshTimer = null;
		var ticker = 60000;
		var oldAdUrl = "";
		var refreshBanner = false;

   	    function handleFlashEvent(name, param)
   	    {
  			var obj = new Object();
			obj.message = name;
			obj.param = param; 
			var target = "bbFlash"; 
			if (name == "Video.POSITION" || name == "Video.DURATION" 
				|| name == "Video.PLAYSTATE" || name == "Video.ADPLAY")
			{
				if (name == "Video.ADPLAY")
					dojo.debug(name + " - " + param)
				target = "bbController";
			}
              
            setFlashVar('__jsEvent', obj.toJSONString(), target);
   	    }
   	    
   	    function setFlashVar(name, param, target)
   	    {
			if (target == "bbFlash")
			{
				if(window.bbFlash) window.document["bbFlash"].SetVariable(name, param);
	    	    else if(document.bbFlash) document.bbFlash.SetVariable(name, param);
			}
			else
			{
				if(window.vpController) window.document["vpController"].SetVariable(name, param);
	    	    else if(document.vpController) document.vpController.SetVariable(name, param);
			}
   	    }
   	       	    
   	    function bbFlash_DoFSCommand(command, args)
   	    {  
			try
 	        {
		        if (command == "updateVideoInfo")
				{
					//var obj = new Object();	
					//obj.message = "Video.INFO";
					//obj.param = args; 
					var obj = args.parseJSON();
					obj.message = "Video.INFO";
					var target = "vpControl"; 

					setFlashVar('__jsEvent', obj.toJSONString(), target);
				}
				else
				{
					if (command == "playVideo")
					{
						var obj = args.parseJSON();
						dojo.debug('bbFlash_DoFSCommand()' + command + ' ' + obj.item0.id + ' ' + obj.item1.id);		
					}			
					else 
						dojo.debug('bbFlash_DoFSCommand()' + command + ' ' + args);
		        	var scriptCall = command + "(" + args + ")"; 
		            
		        	if (dojo.render.html.moz) setTimeout(scriptCall,20); 
		        	else eval(scriptCall);
					//eval(scriptCall);
				}
	        }
	        catch(e)
	        {
		        dojo.debug("EXCEPTION: bbFlash_DoFSCommand() "+ command + " + " + e.description);
		    }
	    }  
	    
	    function vpController_DoFSCommand(command, args)
   	    {  
 	        try
 	        {
				if (command == "playNext" || command == "playPrevious")
				{
		  			var obj = new Object();	
					
					if (command == "playNext")
						obj.message = "Video.PLAYNEXT";
					else if (command == "playPrevious")
						obj.message = "Video.PLAYPREVIOUS";
					
					obj.param = args; 
					var target = "bbFlash"; 

					setFlashVar('__jsEvent', obj.toJSONString(), target);
				}
				else
				{
   		        	if (command != "getPosition")
						dojo.debug("vpController_DoFSCommand() " + command + " + " + args);
		        	var scriptCall = command + "(" + args + ")"; 
		        	if (dojo.render.html.moz) setTimeout(scriptCall,20); 
		        	else eval(scriptCall);
					//eval(scriptCall);

				}
	        }
	        catch(e)
	        {
		        dojo.debug("EXCEPTION: bbFlash_DoFSCommand() "+ command + " + " + e.description);
		    }
	    } 
	    
	    function selector_DoFSCommand(command, args)
   	    {  
 	        try
 	        {
		        dojo.debug("selector_DoFSCommand " + command + " + " + args);
		        var scriptCall = command + "(" + args + ")"; 
		        if (dojo.render.html.mozilla) setTimeout(scriptCall,10); 
		        else eval(scriptCall);
	        }
	        catch(e)
	        {
		        dojo.debug("EXCEPTION: bbFlash_DoFSCommand() "+ command + " + " + e.description);
		    }
	    } 
	    
		function HandleSelectorCommand(arg)
		{
			stop();
			if (window.opener != null && arg.orgId == 7)
			{
				window.opener.location.href = arg.url;
				window.close();
			}
			else
			{
				window.location.href = arg.url;
			}
		}
 
		function onMouseOver()
		{
			handleFlashEvent('VideoControls.SHOW', true);
		}
   	    
		function playVideo(arg)
		{
		}
   	    
   	    function setFullScreen(val)
   	    {
   	    }
   	    
  	    function resize()
   	    {
   	    }
		
		function showVideo(live)
		{
			if (live)		
				document.getElementById("liveBug").style.visibility = "visible";
			else
				document.getElementById("liveBug").style.visibility = "hidden";			
		}
		
		function hideVideo()
		{
				document.getElementById("liveBug").style.visibility = "hidden";						
		}
   	    
        function resizeWindow(size)
        {
	        return;
	        
	        var new_width = new_height = 0;
        	
	        if (window.screen.width==800 && window.screen.height==600 )
	        { 
		        new_width = window.screen.availWidth;
		        new_height = window.screen.availHeight;
		        try {
			        window.resizeTo( new_width, new_height );
			        window.moveTo(0,0);			
		        } catch(e) {
			        window.resizeBy( window.screen.availWidth - new_width, window.screen.availHeight - new_height );
			        window.moveBy(-window.screenLeft,-window.screenTop);			
		        }
	        }
	        else
	        {
		        new_width = 900;
		        new_height = 650;
                if (window.opener)
                {
		            current_width = new_width;
		            current_height = new_height;
	            }
	            else
	            {
		                // Width and height now set by offestWidth & offsetHeight of centerTable for inpage player
		                current_width = document.getElementById("centerTable").offsetWidth;
		                current_height = document.getElementById("centerTable").offsetHeight;
		        }
		        try { //move window if it will be off-screen with new dimensions	
			        var move_x = (window.screenLeft + new_width > window.screen.availWidth) ? (window.screen.availWidth - new_width - window.screenLeft - 10) : 0;
			        var move_y = (window.screenTop + new_height > window.screen.availHeight) ? (window.screen.availHeight - new_height - window.screenTop - 20) : 0; 
			        //window.moveBy( move_x, move_y ); 
			        window.resizeBy( (new_width - current_width), (new_height - current_height) ); //resizeTo() includes chrome
			        //window.resizeTo( new_width, new_height); 
		        } catch(e)
		        {
		            dojo.debug("EXCEPTION: resizeWindow()" + e.message);
		        } 
	        }
        }

       
        if (window.addEventListener)
	    {    
		    window.addEventListener("onresize",resizeWindow,false);
	    }
	    else
	    {   
		    window.attachEvent("onresize",resizeWindow);
	    }

        
        function showAd()
        {
        }

        function setVolume(arg)
        {
			setVolume2(arg.value);
        }
		
		function setVolume2(val)
        {
        }

        
        function sendBrowseEvent(cmd)
        {
        }
        
        function getPosition()
        {
        }
        
   	    function setPosition2(pos)
   	    {
   	    }

   	    function setPosition(arg)
   	    {
			setPosition2(arg.value);
   	    }
   	    
   	    function play()
   	    {
   	    }
   	    
   	    function pause()
   	    {
   	    }
   	    
   	    function mute2(val)
   	    {
   	    }

   	    function mute(arg)
   	    {
			mute2(arg.value);
   	    }
		
		function stop()
		{
			
		}

   	    
   	    function playNext()
   	    {
            setFlashVar("video.nextVideo", "1");
   	    }
   	    
   	    function playPrevious()
   	    {
   	        setFlashVar("video.prevVideo", "1");
   	    }

        function refreshTopBanner()
        {
            //document.getElementById("adFrame").contentWindow.location.reload();
            //adRefreshTimer = setTimeout("refreshTopBanner()", 60000);
			
			setCoAd(oldAdUrl); 
        }	

        function hideBanner()
        {
             document.getElementById("topAd").style.visibility = "hidden";
             adRefreshTimer = setTimeout("refreshTopBanner()", 80000); 
	 
        }

         function showBanner()
        {
  			document.getElementById("logo").style.top = "0";
 			document.getElementById("logo").style.left = "0";
            document.getElementById("logo").style.visibility = "visible";
            document.getElementById("loader").style.visibility = "hidden";
            document.getElementById("channelSelector").style.visibility = "visible";
			document.getElementById("TBN").style.visibility = "visible";
			document.getElementById("topAd").style.visibility = "visible";
            document.getElementById("PlayerHolder").style.visibility = "visible";
            document.getElementById("vpController").style.visibility = "visible";
            document.getElementById("footer").style.visibility = "visible";
            document.getElementById("copyright").style.visibility = "visible";
            //document.getElementById("vpControllerBG").style.visibility = "visible";
            document.getElementById("videoFrame").style.visibility = "visible";
            document.getElementById("clipstackBG").style.visibility = "visible";
            
        }
		
		function setCoAd(adTag)
		{
			oldAdUrl = adTag;
			clearTimeout(adRefreshTimer);
			if (dojo.render.html.mozilla) document.getElementById("adFrame").src = adTag;
			else adFrame.location.replace(adTag);
			if (refreshBanner)
				adRefreshTimer = setTimeout("refreshTopBanner()", ticker); 			
		}
		
		function trackPage()
		{
			//s_dc(s_account);  // necessary for dynamic reporting. 
			//s.channel = ""; // filter out player page from site sections report
			//Reporter.makeOmnitureCall('generic_page' );			
		}
		
		function ReportPlayVideo(current, bufferedEvent)
		{
			ReporterHBX.reportPlayVideo(current, bufferedEvent);			
		}
		
		function HandleNewItem()
		{
			//Reporter.reportVideoEnd();	//one start, last one must end
		}		
        
        function doHook()
   	    {
            if (hooked) return;
	        
	        var pControl = new PlayerController("Player");
   	        
   	        dojo.event.connect(pControl, "onFlashEvent", this,"handleFlashEvent");
			dojo.event.connect(pControl, "onVideoReporting", this,"ReportPlayVideo");
			dojo.event.connect(pControl, "onCurrentItem", this,"HandleNewItem");
			dojo.event.connect(pControl, "onSetCoAd", this,"setCoAd");       	    
			dojo.event.connect(pControl, "onShowVideo", this,"showVideo");       	    
			dojo.event.connect(pControl, "onHideVideo", this,"hideVideo");       	    
			dojo.event.connect(this, "playVideo", pControl, "playVideo");
       	    dojo.event.connect(this, "getPosition", pControl, "getPosition");
       	    dojo.event.connect(this, "setFullScreen", pControl, "setFullscreen");
       	    dojo.event.connect(this, "setPosition2", pControl, "setPosition");
       	    dojo.event.connect(this, "setVolume2", pControl, "setVolume");
       	    dojo.event.connect(this, "play", pControl, "play");
       	    dojo.event.connect(this, "pause", pControl, "pause");
       	    dojo.event.connect(this, "mute2", pControl, "mute");
       	    dojo.event.connect(this, "stop", pControl, "stop");
			
			ReporterHBX.playerController = pControl;
			
			// if (!pControl.config.scriptBasedBanner)
			//	oldAdUrl = pControl.config.bannerUrl + pControl.config.bannerZone + pControl.config.bannerOtherValue;
			// else
			//	oldAdUrl = pControl.config.scriptBasedBanner;
			// 
			//refreshBanner = pControl.config.refreshBanner;
			//setCoAd(oldAdUrl);
			//
			//pControl.config.startServeAds = g_leadingAd;
			
   	        hooked = true;
   	    }
   	    
   	    function startTimer()
   	    {
   	    	setTimeout("refreshAdBanner()",120000);
   	    }
   	    
   	    function refreshAdBanner()
   	    {   	    	
   	    	if (dojo.render.html.mozilla) document.getElementById("adFrame").src = "adTopBanner2.html";
   	    	else adFrame.location.replace("adTopBanner2.html");
   	    	setTimeout("refreshAdBanner()",60000);
   	    }
   	    
   	    
   	    



