$(document).ready(function() {


$(".choosen ul li:nth-child(5n)").addClass("remove");
$(".rotator.multi li.single:nth-child(2n)").addClass("remove");
$("#blogs .cnt ul li:nth-child(3n)").addClass("remove");
$(".rotator.main .right-side ul li:nth-child(2n)").addClass("remove");
$("#product-list ul li").slice(0,4).addClass("remove");
$(".gallery ul li.single:nth-child(3n)").addClass("remove");

$("#menu ul li").mouseenter(function(){
	$(this).addClass("current");
	$(this).find(".groups").addClass("current");
}).mouseleave(function(){
	$(this).removeClass("current");
	$(this).find(".groups").removeClass("current");
	});

$(".scrollable-menu ul li").slice(5).wrapInner("<ul class=\"wrapped\"></ul>");

$(".scrollable-menu .roll .more").click(function() {

	$(this).parent().parent().find("ul.wrapped").slideToggle("normal", function(){
																				
		if ($(this).is(":visible")) {
			$(this).parent().parent().parent().find(".roll .more").html("Mniej...").addClass("less");
		}
		else {
			$(this).parent().parent().parent().find(".roll .more").html("Więcej...").removeClass("less");
		}
});

});


$(".scrollable-menu2 ul li").slice(5).wrapInner("<ul class=\"wrapped2\"></ul>");

$(".scrollable-menu2 .roll .more").click(function() {

	$(this).parent().parent().find("ul.wrapped2").slideToggle("normal", function(){
																				
		if ($(this).is(":visible")) {
			$(this).parent().parent().parent().find(".roll .more").html("Mniej...").addClass("less");
		}
		else {
			$(this).parent().parent().parent().find(".roll .more").html("Więcej...").removeClass("less");
		}
});

});

	
$(".scrollable-paragraph .roll .more").click(function(){
													  
	$(this).parent().parent().find(".full").slideToggle("normal", function(){
																		   
		if ($(this).is(":visible")) {
			$(this).parent().find(".roll .more").html("Mniej...").addClass("less");
		}
		else {
			$(this).parent().find(".roll .more").html("Więcej...").removeClass("less");
		}
});
});

$(".scrollable-paragraph2 .roll .more").click(function(){
													  
	$(this).parent().parent().find(".full").slideToggle("normal", function(){
																		   
		if ($(this).is(":visible")) {
			$(this).parent().find(".roll .more").html("Mniej...").addClass("less");
		}
		else {
			$(this).parent().find(".roll .more").html("Więcej...").removeClass("less");
		}
});
});


$("#product-list .image").mouseenter(function(){
	$(this).find(".preview").show();
}).mouseleave(function(){
	$(this).find(".preview").hide();
});

$("#product-list .preview").click(function(){
	$(this).parent().parent().find(".preview-content").show();
});

$(".preview-content").mouseleave(function(){$(this).hide();});

$(".image_preview").mouseenter(function(){
	$(this).find(".preview_2").show();
}).mouseleave(function(){
	$(this).find(".preview_2").hide();
});

$(".preview_2").click(function(){
    var id_diva = $(this).attr('id');
	$("#preview_content_"+id_diva).show();
});

$(".preview-content_2").mouseleave(function(){$(this).hide();});




$(".rotate.autorotate").each(
	function( intIndex ){
		$(this).cycle({
			fx:     'scrollHorz', 
			cleartype: true,
			cleartypeNoBg: true,
			speed:  2000, 
			timeout: 8000,
//			easing: 'linear',
			continuous: 0,
			sync: 1,
			next: '.nav .autorotatenext'+intIndex,
			prev: '.nav .autorotateprev'+intIndex
			});
});

$(".rotate.autorotate").mouseenter(function(){
	$(this).cycle("pause");
}).mouseleave(function(){$(this).cycle("resume");});

$(".rotate.auto").each(
	function( intIndex ){
		$(this).cycle({
			fx:     'fade', 
			cleartype: true,
			cleartypeNoBg: true,
			speed:  300, 
			timeout: 0,
			next: '.nav .autonext'+intIndex,
			prev: '.nav .autoprev'+intIndex
			});
});


$(".rotator.main .rotate").each(function(){$(this).cycle({
			fx:     'fade', 
			cleartype: true,
			cleartypeNoBg: true,
			speed:  300, 
			timeout: 5000,
			pager: '.controls'
														 
});});

$(".rotator.multi .rotate").each(function(){$(this).cycle({
			fx:     'fade', 
			cleartype: true,
			cleartypeNoBg: true,
			cleartype: true,
			cleartypeNoBg: true,
			speed:  300, 
			timeout: 3000
														 
});});





$('.rotator.blogs').cycle({
			fx: 'scrollHorz',
			timeout: 60000000000000000, 
			speed: 500, 
			cleartype: true,
			cleartypeNoBg: true,
			pager: '#blogs .nav ul',
			pagerAnchorBuilder: function(idx, slide) { 	return '.nav ul li:eq(' + (idx) + ')';}
});

$('.photoslide').after('<ul class="photonav plain">').cycle({ 
    fx:     'fade', 
    speed:  'fast', 
	cleartype: true,
	cleartypeNoBg: true,
    timeout: 0, 
    pager:  '.photonav', 
     
    // callback fn that creates a thumbnail to use as pager anchor 
    pagerAnchorBuilder: function(idx, slide) { 
		var img = $(slide).children().eq(0).attr("src");
    	return '<li><a href="#"><img src="' + img + '" width="70" height="70" /></a></li>'; 
    } 
});


$("a.lightbox").click(function(){
	$("#lightbox").css("filter", "alpha(opacity=90)");
	$("#lightbox").fadeIn(300);
	
	$(".lightbox-pane").fadeIn(300);
	return false
	})
	$("#lightbox, .lightbox-close").click(function(){
		$("#lightbox, .lightbox-pane").fadeOut(300);
		return false
		
});


/* autoclear function for inputs */
$('.autoclear').click(
function() {
if (this.value == this.defaultValue) {
this.value = '';
}
}
);
$('.autoclear').blur(
function() {
if (this.value == '') {
this.value = this.defaultValue;
}
}
);					   

});


