
/*	jQuery: scripts for formating layout
----------------------------------------------------------*/

$(document).ready(
        function()
        {
			/*	screen resolution detection
			----------------------------------------------*/	
			//if ((screen.width<=1024) && (screen.height<=768)){$("body").attr("id","lowres")}
			/*	slideshows
			----------------------------------------------*/
			$("#banner .slideshow").cycle({ 
				fx:     'fade', 
				timeout: 5000,
				pause:   1 
			});
			$("#banner .news-slideshow").cycle({ 
				fx:     'fade', 
				speed:  400, 
				timeout: 7000,
				pause:   1,
				next:   '#next', 
   				prev:   '#prev'
			});
			
			/*	last/ first elements
			----------------------------------------------*/
				$('#main-menu li:last-child, #news li:last-child, #footer ul li:last-child').addClass("last-child");
				$('#user-menu li:first-child, #footer ul li:first-child').addClass("first-child");
				
			/*	table styles
			----------------------------------------------*/
				$(".styles tr:odd").addClass("odd")
			
			/*	clearing inputs
			----------------------------------------------*/
				defKeyword = 'znajdź w serwisie';
				$("#keyword").focus(function() {
					if($(this).val() == defKeyword) $(this).val('');
				});
				$("#keyword").blur(function() {
					if($(this).val() == '') $(this).val(defKeyword);
				});
				
			/*	misc links
			----------------------------------------------*/
			$("#misc a.print").click(function(){javascript:window.print();return false;});
			$("#misc a.scrolltop").click(function(){$('html, body').animate({scrollTop:0}, 'slow');return false;});
				
			/*	tabs
			----------------------------------------------*/
				// hide tabs
				$("#infos .tab:gt(0)").hide();
				// actions
				var sterings = '#hor-menu';
				$(sterings+" a").click(function() {
					var id = $(this).parent().attr("id");
					
					$(sterings+" a.active").removeClass('active');
					$(this).addClass('active');
					
					currentpicture = $(sterings+" a").index(this);
					
					$("#infos .tab").hide();
					$("#infos .tab."+id).show();
					
					return false;
				});
				// auto changing
				// timer = window.setInterval("nextpicture()", "4000");
			/*	superfish
			----------------------------------------------*/
				$("#main-menu ul").superfish();
				$("#main-menu .sf-with-ul").next("ul").addClass("test");
				$(".test .sf-sub-indicator").show();
return false;
});// end of $(document).ready()

var currentpicture = 0;


function nextpicture() {
	currentpicture++;
	//alert(currentpicture);
	var count = $("#infos .tab").size();
	var sterings = '#hor-menu';
	if(currentpicture == count) currentpicture = 0;
	var next = currentpicture + 1;
	
	var id = $(this).parent().attr("id");
	
	$(sterings+" a.active").removeClass('active');
	$(sterings+" #t-"+next+" a").addClass('active');
	
	$("#infos .tab").hide();
	$("#infos .tab.t-"+next).show();
	
	return false;
}

