/* 
 * miz-playutil
 *	tabbed content
 *
 * requires:
 *	jquery.js
 */
 
/*jslint browser: true */
/*global MIZUKI: true, $: false, window: false */
'use strict';

if (typeof MIZUKI === 'undefined') {
	MIZUKI = {};
}

MIZUKI.PlayerUtil = (function () {
	var CONST, MAIN;
	
	CONST = {
		selPlayer: 'object.player-mp3,object.player-mp3-list'
	};
	
	function moveIt(elButton, elPlayer) {
		var wnd, p;
		wnd = window.open('', '_blank');
		wnd.document.write('<html><head><link rel="stylesheet" type="text/css" media="screen" href="http://mizuki.cz/css/standalone.css" /></head><body></body></html>');
		p = $(elPlayer).detach();
		p.appendTo($('body', wnd.document));
		$(elButton).remove();
	}
	
	function initPlayer(elPlayer) {
		$('<a href="#">move to new window</a>').click(function () { 
			moveIt(this, elPlayer); 
		}).insertAfter(elPlayer);
	}
	
	function initAll() {
		$(CONST.selPlayer).each(function () { 
			initPlayer(this); 
		});
	}
	
	MAIN = {};
	MAIN.init = function () {
		initAll();
	};
	//$(initAll);
	return MAIN;
}());
