/* ================================= */
/* PO ZAŁADOWANIU DOM                */
/* ================================= */

/* 
	funkcja generuje nowy adres z hashem - #
*/
function link(adres) {	
	/*var wzorzec= /\#[a-z]{0,}/i;*/
	var wzorzec= /\#[\S]{0,}/i;
	document.location.href = document.location.href.replace(wzorzec,"") + adres;
}

$(function() {

/* KATEGORIE MENU */

	var sub = $('#menu-3 li ul').before('<span><img src="'+sciezka+'icons/more.png"></span>');

	$('#menu-3 li span').click(

	function() {

		$(this).next().slideToggle('normal');

		var x = $(this).html();
		var y;

		if (x == '<IMG src="'+sciezka+'icons/more.png">' || x == '<img src="'+sciezka+'icons/more.png">')
		{y = '<IMG src="'+sciezka+'icons/less.png">';}

		if (x == '<IMG src="'+sciezka+'icons/less.png">' || x == '<img src="'+sciezka+'icons/less.png">')
		{y = '<IMG src="'+sciezka+'icons/more.png">';}

		$(this).html(y);

	});
	
/* PRODUKT-SZCZEGÓŁY TABS */

	//When page loads...
	$(".produkt-szczegoly-tab").hide(0); //Hide all content
	
	$("ul.produkt-szczegoly-tabs li:first").addClass("active").show(0); //Activate first tab
	$(".produkt-szczegoly-tab:first").show(0); //Show first tab content

	//On Click Event
	$("ul.produkt-szczegoly-tabs li").click(function() {

		$("ul.produkt-szczegoly-tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".produkt-szczegoly-tab").hide(0); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content

		// jak link zaczyna sie od # przechodzi do diva, jak nie -> normalny link
		if (activeTab.charAt(0) == "#") {
			$(activeTab).fadeIn(0); //Fade in the active ID content
			return false;
		}

	});
	
/* PROMOCJE/BESTSELLERY/NOWOŚCI TABS */
/*
	//When page loads...
	$(".produkty-scroller").hide(0); //Hide all content
	$("ul.produkty-scroller-tabs li:first").addClass("active").show(0); //Activate first tab
	$(".produkty-scroller:first").show(0); //Show first tab content

	//On Click Event
	$("ul.produkty-scroller-tabs li").click(function() {

		$("ul.produkty-scroller-tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".produkty-scroller").hide(0); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(0); //Fade in the active ID content
		return false;
	});
*/
/* PANEL-KLIENTA TABS */

	//When page loads...
	//$(".klient-tab").hide(0); //Hide all content
	//$("ul.panel-klienta-tabs li:first").addClass("active").show(0); //Activate first tab
	//$(".klient-tab:first").show(0); //Show first tab content
	/*
	//On Click Event
	$("ul.panel-klienta-tabs li").click(function() {

		$("ul.panel-klienta-tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".klient-tab").hide(0); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content

		// jak link zaczyna sie od # przechodzi do diva, jak nie -> normalny link
		if (activeTab.charAt(0) == "#") {
			$(activeTab).fadeIn(0); //Fade in the active ID content
			return false;
		}

	});
	*/

/* WYSZUKIWARKA */

	//$('#wyszukiwanie-zaawansowane').css('display','none');
		var x;
		var y;
		var z;
		x = $('#wyszukiwanie-zaawansowane').css('display');
		if ( x == 'block')  {z = 'url('+sciezka+'icons/less.png)'}
		if ( x == 'none') {z = 'url('+sciezka+'icons/more.png)'}
		//$('#wyszukiwanie-toogle').css('background-image', z);
	
	$('#wyszukiwanie-toogle').click(
	function() {
		var x;
		var y;
		var z;
		x = $('#wyszukiwanie-zaawansowane').css('display');
		if ( x == 'none')  {y = 'block'; z = 'url('+sciezka+'icons/less.png)'}
		if ( x == 'block') {y = 'none'; z = 'url('+sciezka+'icons/more.png)'}
		$('#wyszukiwanie-zaawansowane').css('display', y);
		//$('#wyszukiwanie-toogle').css('background-image', z);
	});

/* PRZYPOMNIENIE HASŁA */
/*
	$('#przypomnienie-form').css('display','none');
	$('#przypomnienie-toogle').css('background-image','url('+sciezka+'icons/more.png)');
	$('#przypomnienie-toogle').click(
	function() {
		var x;
		var y;
		var z;
		x = $('#przypomnienie-form').css('display');
		if ( x == 'none')  {y = 'block'; z = 'url('+sciezka+'icons/less.png)'}
		if ( x == 'block') {y = 'none'; z = 'url('+sciezka+'icons/more.png)'}
		$('#przypomnienie-form').css('display', y);
		$('#przypomnienie-toogle').css('background-image', z);
	});
*/
/* FORM INPUT WATERMARK HINT TEXT INIT */

	$('#top-strip form').hint({attr:'title'});
	//$('#box-newsletter form').hint({attr:'title'});
	//$('#box-logowanie form').hint({attr:'title'});
	//$('#przypomnienie-form form').hint({attr:'title'});
	$('#box-wyszukiwanie form').hint({attr:'title'});

/* BIGGER LINK FIX */

	$('#box-ostatnio-ogladane ul li').biggerlink({otherstriggermaster:false});
	$('#box-nowosci ul li').biggerlink({otherstriggermaster:false});
	$('#box-promocje ul li').biggerlink({otherstriggermaster:false});
	$('#box-bestsellery ul li').biggerlink({otherstriggermaster:false});
	$('#box-news ul li').biggerlink({otherstriggermaster:false});
	$('.produkty-scroller .content .block').biggerlink({otherstriggermaster:false});
	$('#lista-produktow-boxy .produkt-box').biggerlink({otherstriggermaster:false});
	$('#lista-produktow .produkt-row').biggerlink({otherstriggermaster:false});
	
	

/* PRELOAD CSS IMAGES */

	//$.preloadCssImages();

/* LISTA PRODUKTÓW BOXY 


	$('#content > #lista-produktow-boxy').dataTable({

		"bPaginate": true,
		"bLengthChange": true,
		"bFilter": true,
		"bSort": false,
		"bInfo": true,
		"bAutoWidth": false

	});
*/

/* LISTA PRODUKTÓW 

	$('#content > #lista-produktow').dataTable({

		"bPaginate": true,
		"bLengthChange": true,
		"bFilter": true,
		"bSort": true,
		"bInfo": true,
		"bAutoWidth": false

	});
*/

});



/* ================================= */
/* PO ZAŁADOWANIU DOM+OBRAZKI        */
/* ================================= */

$(window).load(function(){
/* COLUMN HEIGHT FIX */
// narazie zastapione dodatkowym div'em "srodek" z border 1px z lewej i prawej strony
	// var column1 = $("#column-1").height();
	// var column2 = $("#column-2").height();
	// var content = $("#content").height();
	// if (content > column1 && content > column2) {
			// $("#column-1").css('min-height',content);
			// $("#column-2").css('min-height',content);
	// } else if (column1>column2) { $("#column-2").css('min-height',column1); }
			// else if (column2>column1) { $("#column-1").css('min-height',column2); }
});

/* ========================================== */
/* PROMOCJE/BESTSELLERY/NOWOŚCI SCROLLER INIT */
/* ========================================== */
/*
function obrazki(sciezka) {

if ( $('#scroll-promocje').length == 1) {

	$('#scroll-promocje').flips({
		speed: 333,
		autorun: 0,
		autorun_delay: 0,
		stop_autorun: true,
		left_arrow: '<img src="'+sciezka+'icons/arrow_left.png">',
		right_arrow: '<img src="'+sciezka+'icons/arrow_right.png">',
		direction: 'right',
		items: 3
	});
};

if ( $('#scroll-bestsellery').length == 1) {
	$('#scroll-bestsellery').flips({
		speed: 333,
		autorun: 0,
		autorun_delay: 0,
		stop_autorun: true,
		left_arrow: '<img src="'+sciezka+'icons/arrow_left.png">',
		right_arrow: '<img src="'+sciezka+'icons/arrow_right.png">',
		direction: 'right',
		items: 3
	});
};

if ( $('#scroll-nowosci').length == 1) {
	$('#scroll-nowosci').flips({
		speed: 333,
		autorun: 0,
		autorun_delay: 0,
		stop_autorun: true,
		left_arrow: '<img src="'+sciezka+'icons/arrow_left.png">',
		right_arrow: '<img src="'+sciezka+'icons/arrow_right.png">',
		direction: 'right',
		items: 3
	});
};

}
*/
/* ==================================================== */
/* POZOSTAWIA OTWARTE KATEGORIE PO PRZELADOWANIU STRONY */
/* ==================================================== */

	$(document).ready( function() {
	/* dzieki 1==0 wylaczony zostalskrypt otwierajacy nacisnieta kategorie i zmiane obrazka */
		if (id_kat > 0 && 1==0) {
			var parents = $("a[href*='_"+id_kat+".html']","#menu-3").parents();
			for(var i = 0; i < parents.length; i++){
			
			  $(parents[i]).css('display','block');
			  obrazek = $(parents[i]).children(':first').next().html();
			  
			  if (obrazek=='<img src="'+sciezka+'icons/more.png">' || 
			  obrazek=='<IMG src="'+sciezka+'icons/more.png">') 
				$(parents[i]).children(':first').next().html('<IMG src="'+sciezka+'icons/less.png">');		 
				
			}
			$("a[href*='"+id_kat+"']").parents(":first").children(":last").css('display','block')
		}
	});	

	
/* ==================================================== */
/* 				KONIEC OTWIERANIA KATEGORII 			*/
/* ==================================================== */	

