YUI(_CBC_LOADER).use('node', 'event', 'cbc_radio_header', function (Y,result) {
	
	var _Y = Y;
	
	//setup the listen live pop up
	var watchlisten;	
	if (watchlisten = Y.one("#masthead #functionalMod .listen a")) {	
		
		//set up the listen live pop up	
		watchlisten.on('click', function(e) {		
			e.preventDefault();
			var radioPopup = window.open(watchlisten.get('href'), 'radiopopup', 'width=800,height=420,scrollbars=0,resizable=1');
			radioPopup.focus();					
		});	
				
		/* This module allows for radio player popups to be
		 * launched from the radio portal "now playing" module */
	    if (result.success) {
	    
	    	var morestreams = Y.one('#functionalMod a.morestreams');
	    
	    	if (morestreams) {    
	    
				morestreams.on('click',function(e) {
		        	
		        	e.preventDefault();
		
		            var $RM = CBC.radio.menus;
		            var $RS = CBC.radio.streams; 
		            var $RH = CBC.radio.menus.uberHeader.JS;
		            if (!Y.one("overlay")){
		                var overlay = Y.Node.create('<div id="overlay" class="hide" style="height:100%;">&nbsp;</div>');
		                _Y.one('body').append(overlay);
		            }
		
		            // overiding functions from uberplayer radioHeader.js which conflict with
		            // radio portal DOM structure (nodes missing from document)
		            $RH.reset = function (){};
		            $RH.display = function() {};
		
		            $RH.init = function (){
		                var $RH = CBC.radio.menus.uberHeader.JS;
		                $RH.elements.get();
		                $RS.checkCookie();
		                $RH.getDefaultStreamData();
		            };
		            $RH.elements.get = function(){
		                var $RH = CBC.radio.menus.uberHeader.JS;
		                $RH.container	= document.getElementById('radioHeader');
		                $RH.radio1		= document.getElementById('listenradio1');
		                $RH.radio2		= document.getElementById('listenradio2');
		                $RH.radio3		= document.getElementById('listenradio3');
		            };
		            $RH.getDefaultStreamData = function(){
		                var $RS = CBC.radio.streams;
		                var $RH = CBC.radio.menus.uberHeader.JS;
		                _pgCache = $RS.getPgCache();
		                _networkKeys = { radio1: 'cbc_radio_one', radio2: 'cbc_radio_2', radio3: 'cbc_radio_3' };
		                _defaultProgramKeys = { radio1: $RS.getDefaultProgramKey('radio1'), radio2: $RS.getDefaultProgramKey('radio2'), radio3: $RS.getDefaultProgramKey('radio3') };
		                _streams = { radio1: $RS.getStream(_networkKeys['radio1'], _defaultProgramKeys['radio1']), radio2: $RS.getStream(_networkKeys['radio2'], _defaultProgramKeys['radio2']), radio3: $RS.getStream(_networkKeys['radio3'], _defaultProgramKeys['radio3']) };
		                $RH.processCache();
		                $RH.reset();
		            };
		            $RS.playStream = function(urlParams){
		                var $RM = CBC.radio.menus;
		                var $RS = CBC.radio.streams; 
		                var $RH = CBC.radio.menus.uberHeader.JS;
		                var stream;
		                urlParams = $RS.parseParams(urlParams);
		                if (urlParams)
		                stream = $RS.getStream(urlParams.networkKey, urlParams.programKey);
		                $RS.setCookie(urlParams.networkKey, urlParams.programKey);
		                $RM.closeMenu();
		                $RH.getDefaultStreamData();
		                if (stream){
		                    if ($RS.popupplyr){
		                        $RS.popupplyr.close();
		                    }
		                    $RS.popupplyr = window.open('/video/radio-popup.html#/networkKey='+urlParams.networkKey+'&programKey='+urlParams.programKey, 'gnAudioClip','width=800,height=460,scrollbars=0,resizable=0');
		                    $RS.popupplyr.focus();
		                }
		            };
		            $RM.toggleOverlay = function(){
		                YUI().use("node-base", function(Y){
		                    var overlay = Y.one("#overlay");
		                    if (overlay.hasClass("hide")){
		                        overlay.removeClass("hide");
		                        var docHeight = document.body.scrollHeight;
		                        overlay._node.style.height = docHeight+"px";
		                    }else
		                        overlay.addClass("hide");
		                });
		            };
		            $RH.init();
		            CBC.radio.menus.openMenu('allStreams'); 
		        });    
		        
			}
	
	    };
			
			
	} 
	
	return;
			
});
