// ORBIT SLIDER (home page)
$(window).load(function() {
	$('#visual').orbit({
		animation: 'horizontal-slide',      // fade, horizontal-slide, vertical-slide, horizontal-push
		animationSpeed: 800,                // how fast animtions are
		timer: true, 			            // true or false to have the timer
		advanceSpeed: 4000, 		        // if timer is enabled, time between transitions 
		pauseOnHover: false, 		        // if you hover pauses the slider
		startClockOnMouseOut: true, 	    // if clock should start on MouseOut
		startClockOnMouseOutAfter: 100,     // how long after MouseOut should the timer start again
		directionalNav: true, 		        // manual advancing directional navs
		captions: false, 			        // do you want captions?
		captionAnimation: 'none', 		    // fade, slideOpen, none
		captionAnimationSpeed: 800, 	    // if so how quickly should they animate in
		bullets: true,			            // true or false to activate the bullet navigation
		bulletThumbs: false,		        // thumbnails for the bullets
		bulletThumbLocation: '',		    // location from this file where thumbs will be
		afterSlideChange: function(){} 	    // empty function 
	});
});
// end ORBIT SLIDER (home page)

$(document).ready(function() {
	
	/* Preload CSS images  - based on http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/*/
	//$.preloadCssImages();
	
	
	/* PNGFIX for IE6 */
	if($.browser.msie && parseFloat($.browser.version) < 7) {
		DD_belatedPNG.fix('a,img,div,li,input');
	}
        
    /*----- z-index IE7------*/
	if($.browser.msie && parseFloat($.browser.version) <= 7){
		$(function() {
			//var zIndexNumber = 9999;
			//$('div').each(function() {
			//	$(this).css('zIndex', zIndexNumber);
			//	zIndexNumber -= 1;
			//});
			$('.white_bar').css("zIndex","9000");
			$('.log_reg_area').css("zIndex","9001");
			$('.basket_bg').css("zIndex","9002");
			$('a.basket_ico').css("zIndex","9003");
		});
	};
    
	
    // ToolTip http://code.drewwilson.com/entry/tiptip-jquery-plugin
	$('.tip').tipTip();
	
	
	// LEFT MENU
	if(($.browser.msie && parseFloat($.browser.version) > 6) || !$.browser.msie) {
		$('#accordion').dcAccordion({
				eventType	 : 'click',
				autoClose	 : true,
				saveState	 : true,
				disableLink	 : false,
				speed	 	 : 'slow',
				showCount	 : true,
				autoExpand	 : true,
				cookie		 : 'dcjq-accordion-1',
				classParent	 : 'dcjq-parent',
				classActive	 : 'active',
				classArrow	 : 'dcjq-icon',
				classCount	 : 'dcjq-count',
				classExpand	 : 'dcjq-current-open'
		});
	};
	
	
	// FILTERS RANGE SLIDER
	
//	$( "#slider-range" ).slider({
//		range: true,
//		min: 0,
//		max: max_price,
//		values: [ 0, max_price ],
//		slide: function( event, ui ) {
//			//$("#amount").val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
//			$("#price_min").val( ui.values[ 0 ] + "zł" );
//			$("#price_max").val( ui.values[ 1 ] + "zł" )
//		}
//	});
//	//$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
//	//	" - $" + $( "#slider-range" ).slider( "values", 1 ) );
//	$("#price_min").val( $( "#slider-range" ).slider( "values", 0 ) + "zł" );
//	$("#price_max").val( $( "#slider-range" ).slider( "values", 1 ) + "zł" );
	
	
	/* ----- Equal Height for blocks ----- */
	function equalHeight(group) {
		var tallest = 0;
		group.each(function() {
			var thisHeight = $(this).height();
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}
	//if(!$.browser.msie || ($.browser.msie && parseFloat($.browser.version) > 6)) {
		equalHeight($(".equal"));
	//}
	

	// CART/BASKET extend
	$(".basket_bg").mouseenter(function() {
		$('.basket_extend').stop(true, true).slideDown();
	}).mouseleave(function() {
		$('.basket_extend').stop(true, true).fadeOut('fast');
	});
	//$(".basket_extend").mouseleave(function() {
	//	$(this).fadeOut();
	//});
    
    
    //Filters toggle
    $(".title_toggle").click(function() {
        $(this).next(".block_toggle").toggle();
    });
    
		
        
    /* ----- Colorbox ----- */
    $(".cbox").colorbox({
        width:	"1000px",
        maxHeight: "95%",
		inline:	true,
		close:	"Zamknij"
	});
	
	$(".cbox_small").colorbox({
		inline:	true,
		width:	"400px",
		height:	"300px",
		close:	"Zamknij"
	});
        
	$(".iframe").colorbox({
		iframe:true,
		width:"1000px",
		innerHeight:"700px",
		close:	"Zamknij"
	});
    
    $(".iframe2").colorbox({
		iframe:true,
		width:"700px",
		innerHeight:"500px",
		close:	"Zamknij"
	});
        
    $(".cbox_out").colorbox({
        innerWidth:  "800px",
        innerHeight: "600px",
		inline:	false,
		close:	"Zamknij"
	});
	
	//$("a[rel='prd_gallery']").colorbox();
    //$(".big").colorbox({rel:'prd_gallery'});
    
    $('a[rel=prd_gallery]').colorbox();
    $('a#openGallery, #image_wrap').click(function(){
        var nr_img = $('.img_items.active').attr('rel');
        $('a[rel=prd_gallery]').eq(nr_img).click();
    });

    
    /* ----- end Colorbox ----- */
        
        
	//Products tabs
	/*$('.prd-tabs a').click(function() {
          $('.tab-cont-prd').hide();
                var linkem = $(this).attr('rel');    
                $(linkem).show();       
                $('.prd-tabs li').removeClass('active');
                $(this).parent().addClass('active');
    });*/
	
	
	$(".scrollable").scrollable();
	
	$(".items img.img_items").click(function() {

	// see if same thumb is being clicked
	if ($(this).hasClass("active")) { return; }

	// calclulate large image's URL based on the thumbnail URL (flickr specific)
	// var url = $(this).attr("src").replace("_t", "");
	var url = $(this).attr("src");

	// get handle to element that wraps the image and make it semi-transparent
	var wrap = $("#image_wrap").fadeTo("medium", 0.5);

	// the large image from www.flickr.com
	var img = new Image();


	// call this function after it's loaded
	img.onload = function() {
		// make wrapper fully visible
		wrap.fadeTo("fast", 1);

		// change the image
		wrap.find("img.img_items").attr("src", url);
	};

	// begin loading the image from www.flickr.com
	img.src = url;

	// activate item
	$(".items img.img_items").removeClass("active");
	$(this).addClass("active");

	// when page loads simulate a "click" on the first image
	}).filter(":first").click();

$('.more-me').click(function() {
		$(this).next('.less-me').show();
		$(this).hide();
		var tabname = $(this).attr('rel');
		$("#"+tabname+"").show();
	});
	$('.less-me').click(function() {
		$(this).prev('.more-me').show();
		$(this).hide();
		var tabname = $(this).attr('rel');
		$("#"+tabname+"").hide();
	});

});


