var Eleet = {
	init: function() {
		
		this.flash();
		
		if ($.browser.msie && parseInt($.browser.version) == 6 && !window["XMLHttpRequest"]) {
			this.pngfix();
		}
		
		//this.containerScroll();
		
		this.imageSlider();
		
		this.galleriesInit();
		
		this.entryToogler();
		
		this.expanderInit();
	},
	
	flash: function() {
		var flashvars = { 
            }; 
        var params = { 
        	menu: "false", 
            wmode: "transparent" 
            }; 
        var attributes = { 
            }; 
		
		swfobject.embedSWF("static/swf/intro.swf", "narwal-intro", "560", "800", "9.0.0", "", flashvars, params, attributes);

			
		if($('#container').is('.offert')) {
			var attributes = { 
				offert: "show"
            }; 
		}
		
		swfobject.embedSWF("static/swf/narwal.swf", "top", "800", "350", "9.0.0", "", flashvars, params, attributes);
	},

	pngfix: function() {
		$(document).pngFix();
	},
	
	imageSlider: function() {
		var container = $('#photos');
		
		var items = container.children('li');
		
		var act = 0;
		var num = 3; // ile wyswietlanych
		
		//if(container.is('.short')) num = 3;
		
		var elem;
		
		container.children(':gt('+(num-1)+')').hide();
		
		setInterval(function()
					{
						items = container.children('li');
						
						container.children(':eq('+act+')').slideUp(function()
																	{
																		elem = container.children(':eq('+act+')').html();
						 												container.children(':eq('+act+')').remove();
																		container.append('<li>'+elem+'</li>');
																		container.children(':last-child').hide();
																	});
						
						
						container.children(':eq('+num+')').slideDown();
					}
					, 5000);
	},
	
	containerScroll: function() {
		$('#container').jScrollPane({showArrows:true, scrollbarWidth: 22});
	},
	
	galleriesInit: function() {
		$('#container:not(.main) a:has(img)').lightBox({fixedNavigation:true});
		$('#photos a').lightBox({fixedNavigation:true});
	},
	
	expanderInit: function() {
		$('ul.expander li div').hide();
		
		$('ul.expander li a').click(function()
		{
			$(this).parent().siblings().children('div:visible').slideUp();
			$(this).siblings('div').slideToggle();
			
			return false;
		});
	},
	
	entryToogler: function() {
		$('#container .entry').each(function() {
			$(this).children('p:not(:first)').hide();
			$(this).children('a.more').click(function() {
				$(this).parent().siblings('.active').children('p:not(:first)').slideUp('fast');
				$(this).parent().siblings('.active').removeClass('active');
				$(this).parent().addClass('active');
				$(this).siblings('p:not(:first)').slideToggle('fast');
			});
		});
	}
};

$(document).ready(function() {
	Eleet.init();
});

