var Radio = {
	//sending:false,
	requestSong:function() {
		//if(!Radio.sending) { Radio.sending = true; }
		//else { return false; }
		if($('song_request').value=='') window.alert('You must enter a song to request.');
		else {
			var song_request = escape($('song_request').value);
			//$('song_submit').update('Sending...');
			
			// I moved this here to give the user the illusion that the submission is instantaneous.
			// This way, if it takes a few seconds to submit, the user doesn't have to wait.
			window.alert('Thank you for your request. Feel free to add another one.');
			$('song_request').value = '';
			
			new Ajax.Request(engineURL, {
				method:'get', parameters:{ control:'radio', action:'song_request', request:song_request }, onComplete:function(trans) {
					//window.alert('Thank you for your request. Feel free to add another one.');
					//$('song_submit').update('Submit');
					//$('song_request').value = '';
					//Radio.sending = false;
				}
			});
		}
		return false;
	}
};
Event.observe(window,'load',function(element){
	new Ajax.PeriodicalUpdater('past_ajax', engineURL, { method: 'get', parameters: { control:'radio',action:'past'}, frequency: 10 });
	new Ajax.PeriodicalUpdater('playing_ajax', engineURL, { method: 'get', parameters: { control:'radio',action:'updater'}, frequency: 10 });
	//new Ajax.PeriodicalUpdater('player_ajax', engineURL, { method: 'get', parameters: { control:'radio',action:'player'}, frequency: 10 });
});

var Functions = {
	 popUp: function(URL,x,y) {
		if(!x) { x = 590; }
		if(!y) { y = 360; }
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+x+",height="+y+"');");
	}
};