<!--
// Window.onload Funktion -----------------------------------------------------------------------------------

function winOnLoad(withScrollers) {
	MM_preloadImages(
		'media/navigation/newsOver.gif',
		'media/navigation/top100Over.gif',
		'media/navigation/radioPlayerOver.gif',
		'media/navigation/tvStationOver.gif',
		'media/navigation/playListNRequestOver.gif'
	);
	//loader();
}

// Rollover-Funktionen --------------------------------------------------------------------------------------

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.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];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Refresh --------------------------------------------------------------------------------------------------


function DoRefreshAjax(url) {
  //document.location.href = url;
	var myAjax = new Ajax.Request(url, {method: 'get', onComplete: showCurrentSong}); 
	refreshID = "";
	refreshID = setTimeout("DoRefreshAjax('" + url + "')", 90000);
}

function showCurrentSong(originalRequest) {	
	temp = originalRequest.responseText.split('|---------------|');
	// Song
	currentSong = temp[0];
	try {
		target = document.getElementById('AJAX_currentSong');
		target.innerHTML = currentSong;			
	} catch(e) {}
	// Dedication
	dedication = temp[1];	
	try {
		if(trim(dedication) != '') {			
			target = document.getElementById('AJAX_dedication');
			target.innerHTML = dedication;			
			target.styles.display = 'block';
		} else {
			target = document.getElementById('AJAX_dedication');
			target.innerHTML = '';
			target.styles.display = 'none';
		}
	} catch(e) {}
	// Recently played
	played = temp[2];	
	try {
		target = document.getElementById('AJAX_recentlyPlayed');
		target.innerHTML = played;			
	} catch(e) {}
	// Coming up...
	comingUp = temp[3];	
	try {
		target = document.getElementById('AJAX_comingUp');
		target.innerHTML = comingUp;			
	} catch(e) {}
}



// Song-Info-PopUp ------------------------------------------------------------------------------------------

function getSongInfo(songid) {
	songWin = window.open("popUpSongInfo.php?songID="+songid, "songinfowin", "location=no,status=no,menubar=no,scrollbars=no,resizeable=no,height=390,width=500");
}

// Player-PopUp ------------------------------------------------------------------------------------------

function openPlayer() {
	songWin = window.open("popUpPlayer.php", "playerwin", "location=no,status=no,menubar=no,scrollbars=no,resizeable=no,height=490,width=400");
}

// TV-Popup
// Player-PopUp ------------------------------------------------------------------------------------------

function openTv() {
	songWin = window.open("http://www.rockalarm.tv/flash/", "Rockalarm.tv", "location=yes,status=yes,menubar=yes,scrollbars=yes,resizeable=yes,height=800,width=1000");
}

// Request-Popup --------------------------------------------------------------------------------------------

function request(songid) {
	reqwin = window.open("popUpRequest.php?songid=" + songid, "_AR_request", "location=no,status=no,menubar=no,scrollbars=no,resizeable=yes,height=690,width=500");
}

// PopUp zentrieren -----------------------------------------------------------------------------------------

function centerPopUp(windowWidth, windowHeight) {
	if (parseInt(navigator.appVersion) >= 4) window.moveTo((screen.width/2)-(windowWidth/2),(screen.height/2)-(windowHeight/2));	
}

// Media-Player starten -------------------------------------------------------------------------------------
function startMediaPlayer(id) {
	var obj = document.getElementById(id);
	obj.play();
}
// Media-Player stoppen -------------------------------------------------------------------------------------
function stopMediaPlayer(id) {
	var obj = document.getElementById(id);
	obj.stop();
}

/*
==============================================================================================================
	MEDIA-PLAYER
==============================================================================================================
*/

// Plugins in Netscape laden
if ( navigator.appName == "Netscape" ) {
	//-- This next line ensures that any plugins just installed are updated in 
	//-- the Browser without quitting the browser.
	navigator.plugins.refresh();
	// We don't need the APPLET within IE, and APPLET is treated as an implied
	// end to the OBJECT tag by the IE HTML parser.
	// ***Please note that if you do not need to script events, you can safely 
	// remove the next two lines***
	//document.write("\x3C" + "applet MAYSCRIPT Code=NPDS.npDSEvtObsProxy.class" )
	//document.writeln(" width=0 height=0 name=appObs\x3E \x3C/applet\x3E")
}

if ((navigator.userAgent.indexOf('IE') > -1) && (navigator.platform == "Win32")) {
	bControl = true;
} else {
	try {
		var plugIn = document.getElementById('WMPlayer');
	} catch (e) {}
	bControl = false;
	// The following line of code registers the PlayStateChange event
	// in the appObs applet, so that when a PlayStateChange event occurs,
	// the appObs Applet sends the appropriate callback method.
	try {
		document.appObs.setByProxyDSPlayStateChangeObserver(plugIn,true);
	} catch(e) {
		showStatus();
	}
}



/* Event-Handler ------------------------------------------------------------------------- */ 
function OnDSPlayStateChangeEvt (oldState, newState){
	doPlayStateChanges(oldState,newState);
}		

function doPlayStateChanges(oldState,newState){
	var objPlayer = document.getElementById('WMPlayer');
	if(objPlayer.status) {
		showStatus(objPlayer.status);
	}
}

/* Button-Aktion ------------------------------------------------------------------------- */ 	

// Start Player
function startWMPlayer(id, url) {
	try {
		objPlayer = document.getElementById(id);
		objPlayer.style.visibility = 'visible';		
		if(!objPlayer.URL) {
			objPlayer.URL = url;
		}
		if(objPlayer.playState != 3) {
			objPlayer.controls.play();
		}
		
	} catch(e) {
		showStatus();
	}
}

// Stop Player
function stopWMPlayer(id, ignoreErrors) {
	try {
		var objPlayer = document.getElementById(id);
		objPlayer.controls.stop();
		objPlayer.style.visibility = 'hidden';				
	} catch(e) {
		showStatus(ignoreErrors == true ? ' ' : '');
	}
}

// Show Fullscreen
function displayWMPlayerFullScreen(id) {
	try {
		var obj = document.getElementById(id);
		if(obj.playState == 3) {
			obj.fullScreen=true; 
		} else {
			showStatus('Player is not running yet...');
		}
	} catch(e) {
		showStatus();	
	}
}

// Show Status-Text
function showStatus(text) {
	try {
		var objInfo = document.getElementById('WMPlayerStatus');
		objInfo.innerHTML = typeof text != 'undefined' ? text : 'Player not found - Please click the stream link below!'
	} catch(e) {
	
	}
}



// Trim-Funktionen -------------------------------------------------------------------------

function rTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
			i--;
		}
		s = s.substring(0, i+1);
	}
	return s;
}

function lTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
		j++;
		s = s.substring(j, i);
	}
	return s;
}

function trim(s) {
	return rTrim(lTrim(s));
}
//-->
