$(document).ready(function(){
   
	var NavOn = false;
	
	$('#catNav ul li').mouseenter(function () {
		if(NavOn==false)
		{
			$('ul',this).slideDown('fast');
			NavOn = true;	
		} else {
			NavOn = false;
		}
	});
	
	$('#catNav ul li').mouseleave(function () {
		if(NavOn==true)
		{
			$('ul',this).fadeOut(500);
			NavOn = false;
		} else {
			NavOn = true;
		}  
	});

	var zIndexNumber = 500;
	$('#catNav ul li').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 1;
	});

	var str = $("h2.header").text();
	if(str==''){ $('div#information').css('display', 'none'); }


	$('#catpromo ul li').mouseenter(function () {
		var check = $("p.opisProd",this).text();

		if(check!=''){
			$('div.slideBlock',this).animate({ 
	        top: "79px",
	        opacity: 0.8
			}, 500 );
		}
      
	});
	
	$('#catpromo ul li').mouseleave(function () {
		$('div.slideBlock',this).animate({ 
        top: "122px",
        opacity: 0.7
        }, 500 );

	});
	
	$('.cForm').validationEngine();
	
	$('.cForm').css("opacity",0.8);
	$('.cForm').mouseenter(function () {
		
			$(this).animate({
	        opacity: 0.8
	        }, 500 );
		
      
	});
	
	$('.cForm').mouseleave(function () {
		$(this).animate({ 
        opacity: 0.5
        }, 500 );

	});




    $(function () {
        $('.bubbleInfo').each(function () {
            var distance = 10;
            var time = 250;
            var hideDelay = 500;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger', this);
            var info = $('.popup', this).css('opacity', 0);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    return;
                } else {
                    beingShown = true;
                    info.css({
                        bottom: 0, //45
                        left: -127, //85
                        display: 'block'
                    }).animate({
                        bottom: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        bottom: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            }); 
        }); 
    });

	$('#mapShopsCityList ul li').each(function (index) {
		
		var currentId = $(this).attr('id');
		var theCity;
		var distance = 10;
        var time = 50;
        var hideDelay = 100;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var trigger = $('.trigger', theCity);
        var info = $('.popup', theCity).css('opacity', 0);

		$(this).click(function () {
			$(this).css("backgroundColor","#FFF");
			var currentId = $(this).attr('id');
			var theCity;
			
			switch (currentId)
			{
			case 'c01': theCity = "#Bydgoszcz"; break;
			case 'c02': theCity = "#Bytom"; break;
			case 'c03': theCity = "#Gdansk"; break;
			case 'c04': theCity = "#Gizycko"; break;
			case 'c05': theCity = "#Gorzow"; break;
			case 'c06': theCity = "#Kalisz"; break;
			case 'c07': theCity = "#Katowice"; break;
			case 'c08': theCity = "#Kielce"; break;
			case 'c09': theCity = "#Koszalin"; break;

			case 'c10': theCity = "#Krakow"; break;
			case 'c11': theCity = "#Leszno"; break;
			case 'c12': theCity = "#Lubin"; break;
			case 'c13': theCity = "#Lublin"; break;
			case 'c14': theCity = "#Lodz"; break;
			case 'c15': theCity = "#Olsztyn"; break;
			case 'c16': theCity = "#Pila"; break;
			case 'c17': theCity = "#Poznan"; break;
			case 'c18': theCity = "#Lubon"; break;
			case 'c19': theCity = "#Rzeszow"; break;

			case 'c20': theCity = "#Szczecin"; break;
			case 'c21': theCity = "#Torun"; break;
			case 'c22': theCity = "#Warszawa"; break;
			case 'c23': theCity = "#Wroclaw"; break;
			case 'c24': theCity = "#ZG"; break;
			case 'c25': theCity = "#Elblag"; break;
			
			
			}

			
			

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger', theCity);
            var info = $('.popup', theCity).css('opacity', 0);



            if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    return;
                } else {
                    beingShown = true;
                    info.css({
                        bottom: 0, //45
                        left: -127, //85
                        display: 'block'
                    }).animate({
                        bottom: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;

            }).mouseleave(function () {
				$(this).css("backgroundColor","transparent");
				if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        bottom: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
	});	
			
			
				
});

if(!isRunningIE6OrBelow){
	$(function(){
		$.fn.supersized.options = {  
			startwidth: 1200,  
			startheight: 900,
			vertical_center: 1,
			slideshow: 0,
			navigation: 0,
			transition: 2, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
			pause_hover: 0,
			slide_counter: 1,
			slide_captions: 1,
			slide_interval: 3000  
		};
	    $('#supersize').supersized(); 
	});
}

