// ver.20090916.001
window.onerror=function(){ return true; }

/*
  Usage: in the html put "var qs = getQuery();" and then grab any of the variables using "qs.variableName"
*/
function getQuery () {
	var args = new Object();
	var qString = location.search.substring(1);
	var argsArray = qString.split("&");

	for (var i = 0; i < argsArray.length; i++){
		var pos = argsArray[i].indexOf('=');
		if (pos == -1) continue;
		var argName = argsArray[i].substring(0, pos);
		var val = argsArray[i].substring(pos + 1);
		args[argName] = unescape(val);
	}
	return args;
}


//BREADCRUMB STUFF
try{ var pathString=location.href; } catch(fp){ var pathString=""; }
 
var legalFooterColor = "#053086";
var chromeWidth = 992;

var legalFtrOpts = ["Register with Radio Disney" , "http://transfer.go.com/cgi/transfer.dll?srvc=dis&goto=https://register.go.com/radioDisney/rd/index&name=g_legalFooter_register", "Radio Disney Guest Services","http://transfer.go.com/cgi/transfer.dll?srvc=dis&goto=https://register.go.com/radioDisney/rd/lists&name=g_legalFooter_guestservices" ];

var doAutoPopHomepagePlayer=false;

//legalFtrLine2='<a href="/about/">About Radio Disney</a> | <a href="/win/rules.html">On-Air Contest/Sweepstakes Rules</a> | <a href="/help/technical.html">Radio Disney Help</a>';



//Auto-Launch Listen Live

var listenNowAutoLaunched = false;
var qs = getQuery();
var query = window.location.search.substring( 1 );


if( query.indexOf('listenNowDcom') != -1 || qs.player == "listenNowDcom" ){
	listenNowDcom();
	listenNowAutoLaunched = true;
}
else if( query.indexOf('listenNowDC') != -1 || qs.player == "listenNowDC" ){
	listenNowDC();
	listenNowAutoLaunched = true;
}
else if( query.indexOf('listenNow') != -1 || qs.player == "listenNow" ){
	listenNow2();
	listenNowAutoLaunched = true;
}

function checkAutoLaunched(){
	return listenNowAutoLaunched;
}

//Listen Live Pop-Up

function thisMovie( movieName ){

    if ( navigator.appName.indexOf( "Microsoft" ) != -1 ) {
		return window[ movieName ];
    } 
	else {
		return document[ movieName ];
    }
}

function mutePlayer(){
	if( thisMovie( "index_player_swf" )){
		thisMovie( "index_player_swf" ).mutePlayer();
	}
}



function listenLive(){
    listenNow();
}


function listenNow(){
	listenNow2();
	callExternalInterface();
}

function listenNow2(){
	var path = "/music/player/listen_live.html";
//	var path = "/music/player/preroll.html";
	launchPlayer( path );
}

function listenNowDcom(){
	var path = "/music/player/listen_live_dcom.html";
	launchPlayer( path );
}

function listenNowDC(){
	var path = "/music/player/listen_live_dc.html";
	launchPlayer( path );
}


function launchPlayer( path ){

	var windowWidth = 860;
	var windowHeight = 590;
	var windowLeft = ( screen.width - windowWidth ) / 2 ;
	var windowTop = (( screen.height - windowHeight ) / 2 ) -50 ;
	var listenWindow = window.open( path, "StreamPlayer", "scrollbars=0,width=" + windowWidth + ",height=" + windowHeight + ",left=" + windowLeft + ",top=" + windowTop );

	try{ 
		listenWindow.moveTo( windowLeft, windowTop );
		listenWindow.focus();
	}catch(e){}
}


function callExternalInterface() {
	if(thisMovie("index_player_swf")){
    		thisMovie("index_player_swf").stopVideo();
    	}
    	
    	if(thisMovie("playerFlash")){
    		thisMovie("playerFlash").stopLiveAudio();
    	}
}


//External Page Warning

function externalPage( destination ){
	var windowWidth = 370;
	var windowHeight = 240;
	var windowLeft = ( screen.width - windowWidth ) / 2 ;
	var windowTop = (( screen.height - windowHeight ) / 2 ) -50 ;
	var leavingWindow = window.open( "/common/nowleaving.html?redirect=" + destination, "_blank", "scrollbars=0,width=" + windowWidth + ",height=" + windowHeight + ",left=" + windowLeft + ",top=" + windowTop );
	leavingWindow.moveTo( windowLeft, windowTop );
	leavingWindow.focus();


}

//Old RD function GOurl();

function GOurl( destination ){
	externalPage ( destination );
}

function GOurl1( destination ){
	externalPage ( destination );
}

//ypSlideOutMenu Settings

stationposition=(navigator.appName.match(/microsoft/gi)!=null)?778:800;
var menus = [			
	new ypSlideOutMenu("music", "down", 246, -51, 296, 450),
	new ypSlideOutMenu("artists", "down", 338, -51, 296, 450),
	new ypSlideOutMenu("win", "down", 430, -51, 296, 450),
	new ypSlideOutMenu("play", "down", 614, -51, 296, 450),
	new ypSlideOutMenu("speak", "down", 706, -51, 296, 450),
	new ypSlideOutMenu("family", "down", 798, -51, 296, 450),
	new ypSlideOutMenu("station", "down", stationposition, -12, 340, 345),
];

ypSlideOutMenu.writeCSS();


//Station Selector Menu Scrollbar

function initStationScroll(){
	var wndo1 = new dw_scrollObj( "stationContentClip", "stationScrollit", null );
	wndo1.setUpScrollbar( "stationDragBar", "stationScrollTrack", "v", 0, 0 );
}

function showStation(){
	showLayer( "stationContainer" );
}

function showLayer( lyr_id ){
	var id = document.getElementById( lyr_id );
	if ( document.getElementById ){
		id.style.visibility = "visible";
	}
}

//Image Preloading

function preload() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preload.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//Rollovers

function rollovers() {
	var img, sh, sn, sd
	for (var i = 0; (img = document.images[i]); i++) {
		if (img.getAttribute) {

			sn = img.getAttribute("src");
			sh = img.getAttribute("hsrc");

			if (sn != "" && sn != null) {
				img.n = new Image();
				img.n.src = img.src;
			
				if (sh != "" && sh != null) {
					img.h = new Image();
					img.h.src = sh;
					img.onmouseover = rolloverOn
					img.onmouseout  = rolloverOff
				}
			}
		}
	}
}

function rolloverOn() {
	this.src = this.h.src;
}

function rolloverOff() {
	this.src  = this.n.src;
}

function rolloverUp() {
	var ths = rolloverUp.img;
	ths.src = ths.n.src;
	if (ths.temp) document.onmouseup = ths.temp;
}


//Replace DIV content

function placeContent(str,destination) {
	
	if (document.getElementById)
    {
            // this is the way the standards work
            document.getElementById(destination).innerHTML = str;
    }
    else if (document.all)
    {
            // this is the way old msie versions work
            document.all[destination].innerHTML = str;
    }
    else if (document.layers)
    {
            // this is the way nn4 works
           document.layers[destination].innerHTML = str;
    }
}


/*---JOE'S POPUP PLAYER CODE---*/
function params(wut,qp,dflt){ dflt=(dflt==null)?'':dflt; try{r=unescape(wut.match(new RegExp(qp+"=+([^&;]*)"))[1]);}catch(qp){r=dflt;} return r; }
function gid(_id){ return document.getElementById(_id); }
function setFlashVar(_id,_var,_val){
try{ gid(_id).SetVariable(_var,_val); } catch(e){ thisobj=eval("window.document."+_id); thisobj.SetVariable(_var,_val); }
}

function $event(obj,evType,fn){ 
if (obj.addEventListener){ obj.addEventListener(evType, fn, false); return true; } 
else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } 
else { return false; } 
}

function onloadtest(){
try{ new SWFObject( "/media/global/popup-player-sender.swf", "POPUPPLAYERTESTDIV", "1", "1", "8", "#FFFFFF" ).write("POPUPPLAYERTESTDIV"); }
catch(e){ popupPlayerStatusResult("error");  }
}
function setPopupPlayerStuff(){
document.writeln('<div id="POPUPPLAYERTESTDIV"></div>');
testForPopup();
}
function testForPopup(){
if (doAutoPopHomepagePlayer){ $event(window,'load',onloadtest); }
}

function popupPlayerStatusResult(_status){
if (_status=="error" && query=="" && navigator.appName!="Netscape"){
if (!eval(params(document.cookie,'player_popped','false'))){
try{ setFlashVar("index_player_swf","mutePlayer","true"); thisMovie( "index_player_swf" ).mutePlayer(); }catch(e){}
listenNow2();
//launchPlayer( "/music/player/listen_live.html" );
//launchPlayer( "/music/player/preroll.html" );
cookiedate=new Date(); cookiedate.setMinutes(cookiedate.getMinutes()+2);
document.cookie='player_popped=true; path=/; expires='+cookiedate.toGMTString()+';';
}
} else if (_status=="status"){
try{ setFlashVar("index_player_swf","mutePlayer","true"); thisMovie( "index_player_swf" ).mutePlayer(); }catch(e){}
}
}

function plantPopupCookie(){
try{ if (eval(params(document.cookie,'player_popped','false'))){
cookiedate=new Date(); cookiedate.setMinutes(cookiedate.getMinutes()+2);
document.cookie='player_popped=true; path=/; expires='+cookiedate.toGMTString()+';';
}}catch(e){}
}

if (doAutoPopHomepagePlayer){
plantPopupCookie();
setInterval("plantPopupCookie()",90000);
}


function params(wut,qp,dflt){ dflt=(dflt==null)?'':dflt; try{r=unescape(wut.match(new RegExp(qp+"=+([^&;]*)"))[1]);}catch(qp){r=dflt;} return r; }
function gid(_id){ return document.getElementById(_id); }
function inner(_gid,_text){ gid(_gid).innerHTML=_text; }
function $flash(ef){ //new $flash({ movie:'', w:'100%', h:'173', bgcolor:'', base:'', vars:'', id:'' }).render();
ef.w=(ef.w==null)?'590':ef.w; ef.h=(ef.h==null)?'450':ef.h; ef.id=(ef.id==null)?'flashmovie':ef.id; ef.wmode=(ef.wmode==null)?'opaque':ef.wmode;
sendback={}
flashstr='<object id="'+ef.id+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ef.w+'" height="'+ef.h+'"><param name="movie" value="'+ef.movie+((ef.vars!=null)?'?'+ef.vars:'')+'"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="'+ef.wmode+'"><param name="scale" value="noscale"><param name="allowScriptAccess" value="always"><param name="show" value="#ffffff">';
if (ef.base!=null){flashstr+='<param name="base" value="'+ef.base+'">'; }
if (ef.salign!=null){flashstr+='<param name="salign" value="'+ef.salign+'">'; }
if (ef.bgcolor!=null){flashstr+='<param name="bgcolor" value="'+ef.bgcolor+'">'; }
if (ef.vars!=null){flashstr+='<param name="flashVars" value="'+ef.vars+'">'; }
flashstr+='<embed name="'+ef.id+'" id="'+ef.id+'" src="'+ef.movie+((ef.vars!=null)?'?'+ef.vars:'')+'" menu="false" quality="high" pluginspage="//www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ef.w+'" height="'+ef.h+'" swLiveConnect="true" wmode="'+ef.wmode+'" scale="noscale" allowScriptAccess="always"';
if (ef.base!=null){flashstr+=' base="'+ef.base+'"'; }
if (ef.salign!=null){flashstr+=' salign="'+ef.salign+'"'; }
if (ef.bgcolor!=null){flashstr+=' bgcolor="'+ef.bgcolor+'"'; }
if (ef.vars!=null){flashstr+=' FlashVars="'+ef.vars+'"'; }
flashstr+='></embed></object>';
sendback.toString=function(){ return flashstr; }
sendback.render=function(){ document.writeln(flashstr); }
sendback.inner=function(targetgid){ gid(targetgid).innerHTML=flashstr; }
return sendback;
}

var isLanding=false;