$(document).ready(function(){
	
	$(".goTop, .advertAnal, .send, .passageBuy, .passageProduct img, .ourProduct .seeMore, .diariesPhotosList a img, .productImages a img, .userAvatar, .fade").hover(
      function () {
        $(this).fadeTo("fast", 0.6);
      }, 
      function () {
        $(this).fadeTo("fast", 1);
      }
	);
	
	$("ol.topTen li").each(function (i) {
		i = i+1;
		$(this).prepend('<span class="counter">'+i+'</span>');
   });
   
	$(function(){
		$('.recommendedArts').loopedSlider({
			container: '.recommendedArtsContent',
			slides: '.slides',
			pagination: '.pagination',
			autoStart: 4500,
			restart: 5000,
			fadespeed: 0,
			containerClick: false
		});
	});
	
 	$(function () {
		var tabContainers = $(".userMenuBarBottom  .subMenu");
		tabContainers.hide().filter(".on").show();
			
		$(".userMenu li.withSub a").hover(function () {
			tabContainers.hide();
			// tabContainers.filter(this.hash).show();
			
			tabContainers.filter('#'+$(this).attr('rel')).show();
			$(".userMenu li a").removeClass("on");
			$(this).addClass("on");
			return false;
		}).filter(".on").hover();
	});
	
	$(function () { 
		var tabContainers = $(".mainBarBottom .subMenu");
		tabContainers.hide().filter(".on").show();
			
		$(".mainMenu li.withSub a").hover(function () {
			tabContainers.hide();
			//tabContainers.filter(this.hash).show();
			tabContainers.filter($(this).attr('rel')).show();
			$(".mainMenu li a").removeClass("on");
			$(this).addClass("on");
			return false;
		}).filter(".on").hover();
	});

	$(".mainList li:last-child, .forumLatestContent li:last, .listRight li:last").addClass("lastLi");
	$("ol.topTen li:last, .footerUpper li:last, .subMenu li:last-child, .forumSection .forumHeaderLine ul li:last").addClass("last");
	$(".formFields .specialBox:last-child").addClass("last");
	//$(".dietAdvices .dietAdvice:last").addClass("last");
	$(".productCategories ul li:last-child").addClass("last");
	$(".forumPosts .left:first").css("background","none");
	
	$("table.productIngredients tr:last").addClass("last");
	$("table.productIngredients tr:last td:first").addClass("bgLeftFix");
	$("table.productIngredients tr:last td:last").addClass("bgRightFix");
	
	$('.forumCategory .threads, .forumCategory .posts, .forumCategory .lastpost, .forumCategory .topicAuthor, .forumCategory .optionCheckboxSmall , .forumCategory .forumNameView').vAlign();
	// $('.getPad').css('padding-top' , $('.forumCategory .posts').css('padding-top'));
	
	
	$(".forumAddPhoto img.send").click(function(){
		$(".forumAddPhotoOptions").slideToggle("fast");
		 return false;
	});
	
	// $(".forumPost").each(function (i) {
		// if ($(this).children(".right").height()+20 < $(this).children(".left").height()) {
			// $(this).children(".right").children(".postBottomLinks ").addClass("makeBottom");
		// }
		
   // }); 
   // // // // // // $(".forumPost").each(function (i) {
	  // // // // // // var ile = jQuery(".right p img.postPicture", this).length;
	  // // // // // // var licznik=0;
	  // // // // // // if(ile>0) { 
	    // // // // // // jQuery(".right p img.postPicture", this).each(function(){
		  // // // // // // $(this).load(function(){ 
			// // // // // // //zaladowany
			// // // // // // licznik++
		  // // // // // // });
	    // // // // // // });
		// // // // // // if(ile==licznik){
		  // // // // // // if ($(this).children(".right").height()+20 < $(this).children(".left").height()) {
			// // // // // // $(this).children(".right").children(".postBottomLinks ").addClass("makeBottom");
		  // // // // // // };
		// // // // // // };
	  // // // // // // };
	
	  // // // // // // if(ile==0){
		// // // // // // if ($(this).children(".right").height()+20 < $(this).children(".left").height()) {
			// // // // // // $(this).children(".right").children(".postBottomLinks ").addClass("makeBottom");
		// // // // // // };
	  // // // // // // };
   	// // // // // // });
	
	$(".forumPost").each(function (i) {
      var ile = jQuery(".right .postText img", this).length;  
      var licznik=0;
      if(ile>0) {
        jQuery(".right .postText img.postPicture", this).each(function(){
          $(this).load(function(){
            //zaladowany
            licznik++
          });
        });
        if(ile==licznik){
          if ($(this).children(".right").height()+20 < $(this).children(".left").height()) {
            $(this).children(".right").children(".postBottomLinks ").addClass("makeBottom");
          };
        };
      };
   
      if(ile==0){
        if ($(this).children(".right").height()+20 < $(this).children(".left").height()) {
            $(this).children(".right").children(".postBottomLinks ").addClass("makeBottom");
        };
      };
       });

	
	
	/* ZMIENIONY: BK - 08/01/2010 */
 	$(function () {
		var tabContainers2 = $(".forumAddPhotoOptions form , div#optionInternet, div#optionDisk");
		tabContainers2.hide().filter(":first").show();
		$('.forumAddPhotoOptions, #optionDisk').show();
			
		$(".forumAddPhotoOptions ul li a").click(function () {  
			tabContainers2.hide();
			tabContainers2.filter(this.hash).show();
			$(".forumAddPhotoOptions ul li a").removeClass("on");
			$(this).addClass("on");
			return false;
		}).filter(":last").click();
	});
	
	
	$('.focusClick').click(function() {
		if(jQuery.trim($(this).val()) == 'login' || jQuery.trim($(this).val()) == 'wyszukiwarka') {
			$(this).val(''); 
		}
		else if($(this).attr('name') == 'user_password') { 
			$(this).val('');
		}
	});
	
	// $('.focusClick').mouseout(function() {
		// if(jQuery.trim($(this).val()) == '') {
			// if($(this).attr('name') == 'user_username') { 
				// $(this).val('login');
			// }
			// else if($(this).attr('name') == 'user_password') { 
				// $(this).val('hasło');
			// }
			// else {
				// $(this).val('wyszukiwarka');
			// }
		// }
	// });
	/* KONIEC ZMIAN */


 });
 
 function limitChars(textid, limit, infodiv) {
 
    var text = $('#'+textid).val(); 
	var textlength = text.length;
	if(textlength+1 > limit) {  
		$('#'+textid).val(text.substr(0,limit));
		$('#'+infodiv).html(0);
		return false;
	}
	else { 
		$('#'+infodiv).html(limit - textlength); 
	}
}
 
 
 (function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('padding-top', mh);
	});
};
})(jQuery);

 
