var mp3_player2_window = ''
	
	// otvori nove okno, pripadne varti otvorene okno
	function get_mp3_player_window() { //v2.1	
		var height	= 340;
		var width	= 460;
	
		if (!mp3_player2_window.closed && mp3_player2_window.location) {
			// okno je uz otvorene, vratime
			return mp3_player2_window
		} else {
			mp3_player2_window = window.open('data/player/index.html' , 'mp3_player2_window_name', 'height='+height+',width='+width+',top='+((screen.availHeight - height) /2)+',left='+((screen.availWidth - width) /2) + ',status=0,resizable=0,scrollbars=0,location=0'); 
			//mp3_player2_window.focus();
			return mp3_player2_window;
		}
	}

var _items_to_be_added_to_playlist = Array();

function mp3_file_play(_mp3_file) {
	// IE workaround
	_items_to_be_added_to_playlist = _mp3_file;
	
	player_window = get_mp3_player_window();
	window.setTimeout(mp3_player_remove_from_playlist, 1500, _mp3_file);
}

function mp3_player_remove_from_playlist(_mp3_file) {
	player_window = get_mp3_player_window();
	
	if (player_window.loading_finished) {
		player_window.document.load_sounds.SetVariable("removefromplaylist", "all");
		window.setTimeout(mp3_player_set_variable_play, 500, _mp3_file);
	} else {
		window.setTimeout(mp3_player_remove_from_playlist, 500, _mp3_file);
	}
}

// poial nebude loaded tak nedokonci nasetovanie
function mp3_player_set_variable_play(_mp3_file) {
	player_window = get_mp3_player_window();
	
	// IE workaround
	if (!_mp3_file) {
		_mp3_file = _items_to_be_added_to_playlist;
		_items_to_be_added_to_playlist = Array();
	}
	
	if (player_window.loading_finished) {
		// sme naloadovani
		player_window.focus();
		
		// * separator
		player_window.document.load_sounds.SetVariable("inputfield", _mp3_file[5]);
		player_window.document.load_sounds.SetVariable("idarray", "1");
		player_window.document.load_sounds.SetVariable("artistarray", _mp3_file[0]);
		player_window.document.load_sounds.SetVariable("songnamearray", _mp3_file[1]);
		player_window.document.load_sounds.SetVariable("labelarray", _mp3_file[2]);
		player_window.document.load_sounds.SetVariable("songdurationarray", _mp3_file[3]);
		player_window.document.load_sounds.SetVariable("linkarray", _mp3_file[4]);
	} else {
		window.setTimeout(mp3_player_set_variable_play, 1500, _mp3_file);
	}
}

function mp3_file_enqueue(_mp3_file) {
	// IE workaround
	_items_to_be_added_to_playlist = _mp3_file;
	
	player_window = get_mp3_player_window();
	window.setTimeout(mp3_player_set_variable_enqueue, 1500, _mp3_file);	
}

function mp3_player_set_variable_enqueue(_mp3_file) {
	player_window = get_mp3_player_window();
	
	// IE workaround
	if (!_mp3_file) {
		_mp3_file = _items_to_be_added_to_playlist;
		_items_to_be_added_to_playlist = Array();
	}
	
	if (player_window.loading_finished) {
		// sme naloadovani
		player_window.focus();
		
		
		// * separator
		player_window.document.load_sounds.SetVariable("inputfield", _mp3_file[5]);
		player_window.document.load_sounds.SetVariable("idarray", "1");
		player_window.document.load_sounds.SetVariable("artistarray", _mp3_file[0]);
		player_window.document.load_sounds.SetVariable("songnamearray", _mp3_file[1]);
		player_window.document.load_sounds.SetVariable("labelarray", _mp3_file[2]);
		player_window.document.load_sounds.SetVariable("songdurationarray", _mp3_file[3]);
		player_window.document.load_sounds.SetVariable("linkarray", _mp3_file[4]);
	} else {
		window.setTimeout(mp3_player_set_variable_enqueue, 1500, _mp3_file);
	}
}