jQuery(document).ready(function() { 

	// po kliknieciu przenosi na adres zawarty w title="http://strona.pl"
	jQuery('.setLocation').click(function(e){
		var url = jQuery(this).attr("title");
		window.location.href = url; 
	});
	
	// fancybox
	jQuery("a#inline").fancybox({
		'hideOnContentClick': true 
	}); 
	jQuery("a.fancybox").fancybox({
		'zoomSpeedIn': 300, 
		'zoomSpeedOut': 300, 
		'overlayShow': true,
		'overlayOpacity': 0.7
	});
	
	// jednakowa wysokosc dla wszystkich elemetnow
	jQuery('.category-products ul li .item-info, .equalheights').equalHeights();

	
	jQuery("select.select-setLocation").change(function () {
		jQuery("select.select-setLocation option:selected").click(function(e){
			var url = jQuery(this).attr("value");
			window.location.href = url; 
		});
	})
	
	// przewijana lista partnerow
	jQuery(".scroller").jCarouselLite({
		visible: 10,
		auto: 1,
		speed: 2200
	});
	
	// przezroczystosc dla IE6
	jQuery('.scroller-shadow .r, .scroller-shadow .l').ifixpng();
	
	// poprawki dla IE6
	jQuery('#copyright ul li:first-child').addClass('first-child');
	jQuery('#copyright ul li:last-child').addClass('last-child');
	jQuery('.categories-list li:last-child').addClass('last-child');
	jQuery(".tabbed-content ul li").hover(
		function () {
			jQuery(this).addClass('hover');
		}, 
		function () {
			jQuery(this).removeClass('hover');
		}
    );
	jQuery("#category .category-products ul li .item").hover(
		function () {
			jQuery(this).addClass('hover');
		}, 
		function () {
			jQuery(this).removeClass('hover');
		}
    );

	// tresc w tabach
	jQuery('.tabs').tabs({
		fxFade: true, 
		fxSpeed: 'fast' 
	});
	
	// wlaczanie/wylaczanie elementow
	jQuery("a.edit").toggle(
		function ()
		{
			var href = jQuery(this).attr("href");
			jQuery(href).removeAttr('disabled').removeClass('disabled');
			jQuery(this).empty().append("Save");
			
		},
		function ()
		{
			var href = jQuery(this).attr("href");
			jQuery(href).attr('disabled', 'disabled').addClass('disabled');
			jQuery(this).empty().append("Edit");
			alert('Zapisano');
		}
	 );
	 
	// przechodzi do taba rejestracji po kliknieciu
	jQuery('.tabbed-content label[for=login:register]').click(function(e){
		jQuery('.tabs').enableTab(2);
		jQuery('.tabs').triggerTab(2);
	});
	
	// obrazki w miejscu ankiety (rotator)
	/*
	jQuery('#imageRotator').cycle({
		timeout: 5000
	});
	*/
	
	// tooltip
	var xOffset = 0;
	var yOffset = 25;
	jQuery('body').append('<div id="tooltip"></div>');
	jQuery('#tooltip').load('/versandkosten-popup');
	jQuery('.mwst a').hover(function(e) {
		var position = jQuery(this).position();
		var width = jQuery(this).width();
		jQuery('#tooltip')
			.css("left",(e.pageX - (jQuery('#tooltip').width()/2) - xOffset) + "px")
			.css("top",(e.pageY - jQuery('#tooltip').height() - yOffset ) + "px")
			.fadeIn("fast");
	}, 
	function() {
		jQuery('#tooltip').fadeOut("fast");
	});
}); 