﻿	var ply_wnd = null;
	
	
	function lbfPlayer()
	{
		if(navigator.appName.indexOf("Microsoft") != -1) {
			return window['lbf-player'];
		}
		else{
			return document['lbf-player'];
		}
	}
	
	
	function lbfPlayerPlaylist(pl)
	{
		//console.log(pl);
		var pl_ctrl = jQuery('#lbf-playlist');

		for(var i in pl) {
			pl_ctrl.append('<div id="playlist-track-' + i + '" onclick="lbfPlayerPlayTrack(' + i + ');">' + pl[i]['_artist'] + (pl[i]['_title'] !== undefined ? ' - ' + pl[i]['_title'] : '' ) + '</div>');
		}

		pl_ctrl.jScrollPane();
		
	}
	
	
	function lbfPlayerTrack(num)
	{
		jQuery('#lbf-playlist DIV').removeClass('playing');
		jQuery('#lbf-playlist #playlist-track-' + num).addClass('playing');
	}
	
	
	function lbfPlayerPlayTrack(num)
	{
		if(ply_wnd && !ply_wnd.closed) {
			ply_wnd.lbfPlayer().lbfPlayTrack(num, true);
			ply_wnd.focus();
		}
		else
			lbfPlayer().lbfPlayTrack(num, true);
	
	}
	

	function lbfPlayerPause()
	{
		lbfPlayer().lbfPlayPause(true);
	}
	
	
	function playerNewWindow()
	{
		lbfPlayerPause(); 
		
		if(!ply_wnd || ply_wnd.closed) {
			ply_wnd = window.open('/player_window.php',
				'lbfPlayerWindow',
				'width=320,height=520,resizable=no,scrollbars=no,status=yes');
		}
		else {
			ply_wnd.focus();
		}
	}
	
	

