/*
@name        Zobrazení tabulky na plnou šířku stránky
@requires	 jquery.js
@requires	 main.js
@description Tabulka musí být v kontejneru s atributem ID

Example: $(".fullscreen").fullTable({title:aReports[0]});

*/
(function($) {
    $.fn.fullTable = function(options) {
    	// Nastavení s výchozími hodnotami
		options = options || {};
		options.title = options.title || 'Plná velikost pro tabulku'; // Popisek
        options.close = options.close || 'Zavřít';

    	this.each(function() {
            var $f = $(this);
			options.close = options.close+': '+$f.find('caption').text();
            options.title = options.title+': '+$f.find('caption').text();

			$f
			.css('position','relative')
			.wrapInner('<div class="ftContent" id="'+$f.attr('id')+'"></div>')
    		.prepend(' <a style="position:absolute;right:0;top:5px;width:20px;z-index:3" class="ftTrigger" href="#'+$f.attr('id')+'" title="'+options.title+'"><img src="'+sSkin+'fullscreen.gif" alt="'+options.title+'" title="'+options.title+'" /></a>')
    		.removeAttr('id');

            options.width = options.width || ($(document).width() - 60);
            options.height = options.height || ($f.find('table').height() + 60);

            try {
				// Zavěšení události pro zvětšení
				$f.find('.ftTrigger').openDOMWindow({height:options.height,width:options.width,eventType:'click'}).click(function(){ftClose(options);$('#DOMWindowOverlay').click(function(){$('#DOMWindow').find('.close').remove();});});
				// Zavření pomocí Esc a odkazu
        		$(document).keydown(function(e){if(e.which == 27){$.closeDOMWindow();$('#DOMWindow').find('.close').remove();}});
            } catch(e){alert('Not found jquery.DOMWindow.js');}

			function ftClose(options) {
                // Odkaz pro zavření
				$('#DOMWindow')
					.prepend(' <a style="position:absolute;right:0;top:0;z-index:3" class="close" href="#" title="'+options.close+'"><img src="'+sSkin+'ico-close.gif" alt="'+options.close+'" title="'+options.close+'" /></a>')
                	.click(function(){$.closeDOMWindow();$(this).find('.close').remove();});
			}
		});
		return this;
	};
})(jQuery);

