var pw;

function js_debug(value){
	if (window.console)
		console.log(value);
	else
		alert(value);
}

function toggle_text(obj1, obj2, dom_id) {
  dom_obj = $(dom_id)
	dom_obj.innerHTML = (dom_obj.innerHTML == obj1) ? obj2 : obj1;
}

function show_player_popup(actualplaylist,autostart,song_id){
 	win_id = 'player_popup_win';
 	params = 'width=400,height=240,left=100,top=100,scrollbars=no,toolbar=no,status=no,menubar=no,resizable=yes';
	if (song_id!=undefined) autostart = autostart+'&song_id='+song_id;
	pw=window.open('/player/player?actualplaylist='+actualplaylist+'&autostart='+autostart, win_id, params);
}

// AUSKOMMENTIERT, DA HTML-FERNBEDIENUNG DURCH FLASH ERSETZT WIRD!!!
// /*
// 	This function tries to detect if the player window including the media_player is available
// */
// function is_player_open(){
// 	if (!pw) return false;							// is pw set?
// 	if (pw.closed) return false;				// is pw set, but the window was closed?
// 	try {																// now try to get the media_player_container using $...
// 		player = pw.$('media_player');
// 		js_debug('[OK] media_player seems to be present!')
// 		if (!Object.isFunction(player.sendEvent)) {
// 				js_debug('[] unable to invoke sendEvent()!');
// 				return false;
// 		}
// 		else {
// 			js_debug('[OK] sendEvent() is present!');
// 		}
// 		return true;											// looks as if the player is available!
// 	}
// 	catch(e) {
// 		return false;											// realy bad! player window is there, but the content div is missing :/
// 	}
// }
// 
// /*
// 	This function sends an command to the player window. If the window is not available, it will be opend. When the secound try to
// open the window fails, a message with the given error-message will be displayed.
// */
// function send_player_command(id, error_msg, func, secound_try){
// 	// if the player is *not* open, try to open it...
// 	if (secound_try) {
// 		js_debug('retrying now!');
// 		js_debug('error_msg ' + error_msg);
// 		js_debug('func ' + func);									
// 	}
// 
// 	if (!is_player_open()) {
// 		js_debug('player is not open!');
// 		if (secound_try) {
// 			alert(error_msg);
// 			return;
// 		}
// 		show_player_popup();
// 		setTimeout(	function() {
// 									send_player_command(id, error_msg, func, true);
// 								},
// 								5000);
// 	}
// 	else {
// 		func(pw.$('media_player'));
// 	}
// }

if(top.location.href.search('jsdebug') != -1){
document.write('application wurde geladen<br/>');
}