/*
* Plugins JS scripts
/*/



function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
}
});
    group.height(tallest);
}



/*  $.noConflict();*/
$(document).ready(function(){
	$('ul.sdt_menu li').first().addClass('first');	
	$("ul li:nth-child(2)").first().addClass('li2');
	$("ul li:nth-child(3)").first().addClass('li3');
	$("ul li:nth-child(4)").first().addClass('li4');
	$("ul li:nth-child(5)").first().addClass('li5');
	$("ul li:nth-child(6)").first().addClass('li6');
	
	equalHeight($("#foot .subpagesList li"));	
	
	var itemid = $('#foot .subpagesList li');
	var count = $(itemid).size();
	var containerwidth = $('#foot .subpagesList').width();
	var p = $(itemid).css('padding');
	var m = $(itemid).css('margin');
	var b = $(itemid).css("border-top");

	var itemwidth = containerwidth/count-26
	$('#foot .subpagesList li').width(itemwidth);
	//$('#foot .subpagesList li').addClass('b'+b+'_p'+p+'_m'+m)
	
	var h = $("#foot .subpagesList li").outerHeight(true);
	
		$("#foot #headPromo").css({'height' :'55px'});
			
			$("#foot #openBoxy").toggle(
					function () {
						$("#foot #headPromo").animate({'height' : h+"px"},800,'easeOutElastic');
						$("#openBoxy").text("-")
					},  
					function () {
					$("#foot #headPromo").animate({'height' :'55px' },200,'easeOutBack') ;
					$("#openBoxy").text("+")
					}
			);
			
		
			
	
	
$('.caption').each(function(){
	$this.width($this.find('img').width());
});	

  //#imagesList2 
	 $("li.thumb-li").siblings().find("img").height(40);
													
													
$('ul.klient li.selected').next("li").addClass("next");
$('ul.klient li.selected').prev("li").addClass("prev");

$('ul.klient li.next a').clone().addClass("nextLink").html('&rArr;').prependTo("#page span#prevNext");
$('ul.klient li.prev a').clone().addClass("prevLink").html('&lArr;').prependTo("#page span#prevNext");

	 
		

/*Manipulation*/
$("#page .subpagesList li:nth-child(3n)").css({"margin-right":"0px"}).addClass("last").after('<p class="clear">&nbsp;</p>');	
//$("#foot .subpagesList li").css({"width":"240px"});
//$("#foot .subpagesList li:nth-child(4n)").css({"margin-right":"0px"}).addClass("last").after('<p class="clear">&nbsp;</p>');	
$("#foot .subpagesList li:nth-child(4n)").css({"margin-right":"0px"}).addClass("last");	

	
$('#product h4.bredCrumb em').after('<br>').hide();	

$('ul.klient li:first').hide();
/*	
ul.sdt_menu #l1{width : 136px;}
ul.sdt_menu #l2{width : 186px;}
ul.sdt_menu #l3{width : 156px;}
ul.sdt_menu #l4{width : 166px;}
ul.sdt_menu #l5{width : 146px;}
ul.sdt_menu #l6{width : 166px;}
*/
/*Menu drop*/	
$('#sdt_menu > li').hover(
	function () {
			var lw = $(this).width();
		$(this)
		.find('img').stop().animate({'width':+lw+'px','height':'100px','left':'0px'},400,'easeOutBack').andSelf()
		.find('.sdt_wrap').stop().animate({'width':+lw+'px','top':'140px'},500,'easeOutBack').andSelf()
		.find('.sdt_active').stop().animate({'width':+lw+'px','height':'170px'},300).andSelf()
		.find('div.sdt_box').stop().animate({'top':'80px','left':+lw+'px','display':'block'},300).andSelf()
		.find('div#sdt_klientBox').stop().animate({'top':'80px','left':'200px',},300).andSelf();
	}, 
	function () {
		$(this).find('.sdt_active').stop().animate({'height':'0px'},300).andSelf()
		.find('img').stop().animate({'width':'0px','height':'0px','left':'85px'},400).andSelf()
		.find('.sdt_wrap').stop().animate({'top':'25px','display':'block'},500).andSelf()
		.find('div.sdt_box').stop().animate({'top':'-80px','left':'0px','display':'none'},300).andSelf();
	}
);
	
	
	
/*boxy klient*/	
$(function(){
	var div = $('div#newsyBoxKlient'), ul = $('div#newsyBoxKlient ul.subpagesList'), ulPadding = 0;
	var divWidth = div.width();
	
	div.css({overflow: 'hidden'});
	var lastLi = ul.find('li:last-child');
	
	div.mousemove(function(e){
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
});	

/*boxy newsy*/	
$(function(){
	//Get our elements for faster access and set overlay width
	var div = $('div#newsyBox'),
		ul = $('div#newsyBox ul.subpagesList'),
		ulPadding = 0;
	
	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars	
	div.css({overflow: 'hidden'});
	
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
});	


	
	
$("a[rel=lightbox-page],a[rel=lightbox-product]").fancybox({'transitionIn':'elastic','transitionOut':'none','titlePosition':'over',
		'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Foto ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
			


});

