// JavaScript Document
if (!window.app) {
	var app = {};
}
(function($){
					
	function ShowMore(settings){
		this.url = null;
		this.settings = $.extend({}, ShowMore.defaults, settings);
	}
	ShowMore.prototype = {
		
		init: function(opts){
			if (!opts.container) { throw 'Container required'; return false; }
			if (!opts.link) { throw 'Link required'; return false; }
			this.container = opts.container;
			var self = this;
			this.link = opts.link.bind('click.pager', function(e){
				e.preventDefault();
				self.getPage();
			}).css({outline: 0});
			this.total = opts.total;
			this.page = opts.page || 1;
			
			return this;
		},
	
		setUrl: function(url){
			this.url = url;
			return this;
		},
	
		disable: function(){
			this.link.unbind('.pager').hide();
			return this;
		},
		
		getPage: function(){
			var self = this;
			var set = {
				type: 'get',
				url: this.url,
				dataType: 'html',
				success: function(html){
					$(html).appendTo(self.container).hide().fadeIn(); 
					self.page++;
					if (self.page == self.total) {
						self.disable();
					}
				},
				error: function(){}
			};
			$.ajax(set)
			return this;
		}
		
	};
	ShowMore.defaults = {
	};
	window.ShowMore = ShowMore;
	
	$.sifr_resize = function(id, h){
		$("#"+id).height(h).css({position:'relative'});
		$('object', "#"+id).css({position:'absolute',top:0});
	}
	$.bbbbbbb = false;	
	var init = function(){
		
		
		$.bbbbbbb = true;
		$(".tabbed").tabbed({
			tabSelector: '.tabc',
			navSelector: '.tabs li', 
			activeTabClass: 'tabc_active',
			activeNavClass: 'tab_active',
			loadingClass: 'tabc_loading'
		});
		
		$(".prompt").prompt();
		
		$(".gallery_scroll:not(.vertical_scroll, .gallery_ajax)").scrollable({
			elemsRoot: 'ul',
			elems: 'li',
			prev: '.prev',
			next: '.next',
			speed: 500
		});
		
		$(".vertical_scroll").scrollable({
			axis: 'vertical',
			elemsRoot: 'ul',
			elems: 'li',
			prev: '.prev',
			next: '.next',
			speed: 500
		});
		
		$(".gallery_slider").scrollable({
			elemsRoot: '.items',
			elems: '.item',
			auto: true,
			speed: 2700,
			delay: 8000,
			easing: 'easeInQuart'
		});
			
		
	 
	 
		$(".wysiwyg .quote").quote();
		
		$(".recommendLink").recommendLink();
		
		// sifry w tytulach artykułow (BauerBodoniStd)
		$(".main_title").each(function(){ 
			var id = $.uniqueID('sifr_m_'), 
				hdg = $(this).attr('id', id).height(1);
			
			var flash_vars = {
				sw: hdg.width(), 
				txt: encodeURIComponent(hdg.text()).replace(/\'/, '&#39;'),
				t_size: 36,
				div_id: id,
				fun: '$.sifr_resize'
			};
			
			if (hdg.children().eq(0).is("a")) {
				flash_vars.linkTo = hdg.children().eq(0).attr('href');
			}
			hdg.height(33).css({overflow:'hidden'}).flashembed({
				src: $.base_path.swf+'bauer_bodoni.swf', 
				width: '100%', 
				scale: "noscale",
				align: "middle", 
				devicefont: 'false',  
				salign: 'lt',  
				height: '100%',  
				wmode: "transparent",
				menu: 'false',
				allowFullScreen: 'false'
			}, flash_vars)
		});
		
		if (!$.browser.msie || $.browser.version >= 7) {
			
			// sifry w tytulach modulów (BauerBodoniStd)
			$(".sifr_italic").each(function(){
				var id = $.uniqueID('sifr_b_'), 
					hdg = $(this).attr('id', id).height(1);
				
				var flash_vars = {
					sw: hdg.width(), 
				txt: encodeURIComponent(hdg.text()).replace(/\'/, '&#39;'),
					t_size: 28,
					div_id: id,
					fun: '$.sifr_resize'
				};
				if (hdg.children().eq(0).is("a")) {
					flash_vars.linkTo = hdg.children().eq(0).attr('href');
				}
				hdg.height(33).css({overflow:'hidden'}).flashembed({
					src: $.base_path.swf+'bauer_bodoni.swf', 
					width: '100%', 
					scale: "noscale",
					align: "middle", 
					devicefont: 'false',  
					salign: 'lt',  
					height: '100%',  
					wmode: "transparent",
					menu: 'false',
					allowFullScreen: 'false'
				}, flash_vars)
			});
			
			// sifry w tytulach modulów (BauerBodoniStd)
			$(".sifr_italic_small").each(function(){
				var id = $.uniqueID('sifr_b_'), 
					hdg = $(this).attr('id', id).height(1);
				
				var flash_vars = {
					sw: hdg.width(), 
				txt: encodeURIComponent(hdg.text()).replace(/\'/, '&#39;'),
					t_size: 26,
					div_id: id,
					fun: '$.sifr_resize'
				};
				if (hdg.children().eq(0).is("a")) {
					flash_vars.linkTo = hdg.children().eq(0).attr('href');
				}
				hdg.height(33).css({overflow:'hidden'}).flashembed({
					src: $.base_path.swf+'bauer_bodoni.swf', 
					width: '100%', 
					scale: "noscale",
					align: "middle", 
					devicefont: 'false',  
					salign: 'lt',  
					height: '100%',  
					wmode: "transparent",
					menu: 'false',
					allowFullScreen: 'false'
				}, flash_vars)
			});
			
			
			// sifry w tytulach modulów (BauerBodoniStd)
			$(".sifr_georgia").each(function(){
				var id = $.uniqueID('sifr_b_'), 
					hdg = $(this).attr('id', id).height(1);
								
				var flash_vars = {
					sw: hdg.width(), 
				txt: encodeURIComponent(hdg.text()).replace(/\'/, '&#39;'),
					t_size: 22,
					div_id: id,
					fun: '$.sifr_resize'
				};
				if (hdg.children().eq(0).is("a")) {
					flash_vars.linkTo = encodeURIComponent(hdg.children().eq(0).attr('href'));
				}
				hdg.height(33).css({overflow:'hidden', position:'relative'}).flashembed({
					src: $.base_path.swf+'georgia.swf', 
					width: '100%', 
					scale: "noscale",
					align: "middle", 
					devicefont: 'false',  
					salign: 'lt',  
					height: '100%',
					wmode: "transparent",
					menu: 'false',
					allowFullScreen: 'false'
				}, flash_vars);
			});
		}
		// sifry w tytulach modulów (Georgia)
		/*$(".sifr_georgia").each(function(){
			var id = $.uniqueID('sifr_g_'), 
				hdg = $(this).height(20);
							
			var flash_vars = {
				sw: hdg.width(), 
				txt: hdg.text(),
				t_size: 22
			};
			if (hdg.children().eq(0).is("a")) {
//				flash_vars.linkTo = encodeURIComponent(hdg.children().eq(0).attr('href'));
			}
			hdg.empty().append('<span id="'+id+'"></span>');
			var params = {
				allowfullscreen: 'false',
				allowscriptaccess: 'true',
				scale: "noscale",
				align: "middle", 
				devicefont: 'false',  
				salign: 'lt',  
				menu: 'false'
			};
			var attr = {
				id: id+'_',
				name: id+'_'
			};
			
			swfobject.embedSWF($.base_path.swf+'georgia.swf', id, "160", "40", "10.0.0", "", flash_vars, params, attr, function(){
				console.log(this); var s = document.getElementById(id+'_'); console.log(s.getSifrHeight)
		});*/
/*		
		'width', '300',
		'height', '215',
		'src', 'aktualnyNumer',
		'quality', 'high',
		'pluginspage', 'http://www.adobe.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'showall',
		'wmode', 'window',
		'devicefont', 'false',
		'id', 'aktualnyNumer',
		'bgcolor', '#ffffff',
		'name', 'aktualnyNumer',
		'menu', 'true',
		'allowFullScreen', 'false',
		'allowScriptAccess','sameDomain',
		'movie', 'aktualnyNumer',
		'salign', ''
*/
		$("#box_magazinecover").flashembed({
			codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',			
			src: $.base_path.swf+'aktualnyNumer.swf',
			width: '300',
			height: '215',	
			quality: 'high',
			pluginspage: 'http://www.adobe.com/go/getflashplayer',
			align: 'middle',
			play: 'true',
			loop: 'true',
			scale: 'showall',
			wmode: 'window',
			devicefont: 'false',
			id: 'aktualnyNumer',						
			bgcolor: '#ffffff',
			name: 'aktualnyNumer',
			menu: 'true',
			allowFullScreen: 'false',
			allowScriptAccess: 'sameDomain',
			movie: 'aktualnyNumer',
			salign: ''			
		}, { xml_url: $.base_path.boxMagazinecover});
		
		$("#main_flash").flashembed({
			src: $.base_path.swf+'homepage.swf',
			width: '100%', 
			scale: "noscale",
			align: "middle", 
			devicefont: 'false',  
			salign: 'lt',  
			height: '100%',  
			wmode: "transparent",
			menu: 'false',
			allowFullScreen: 'false'
		}, { xml_url: $.base_path.mainPageFlashData});
		
		
		$("#popular_tags").flashembed({
			src: $.base_path.swf+'tags.swf',
			width: '150', 
			scale: "noscale",
			align: "middle", 
			devicefont: 'false',  
			salign: 'lt',  
			height: '400',  
			wmode: "transparent",
			menu: 'false',
			allowFullScreen: 'false'
		}, { xml_url: $.base_path.tags_data});
		
		
	};
	
	if ($.browser.msie && $.browser.version < 7) {
		DD_roundies.addRule('.page_header, .play b');
	}
	
	$(document).ready(init);
	
})(jQuery);

function isReady(){
	return $.bbbbbbb;
}

