var jq = jQuery.noConflict();



jq(function(){

/*
Polska, klikalna mapa województw - 350px | http://winstonwolf.pl/css,polska.html
script version: 2.3 by Winston Wolf | http://winstonwolf.pl
Copyright (C) 2009 - 2011 Winston_Wolf | All rights reserved
*/
  jq('#mapa').prepend('<span id="loader">Loading ...</span>').addClass('script'); jq('#mapa').find('li').hide();

  var mapUrl=jq('#pl').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");

  var mapImg=new Image();
  jq(mapImg).load(function(){jq('#loader').fadeOut(); jq('#mapa').find('li').fadeIn(); jq('#pl').find('a').prepend('<span class="map" />');
   for(var i=1;i<17;i++){ jq('#pl .map').append('<span class="s'+i+'" />'); }
   if(jq('#mapa').hasClass('tooltip')){jq('#pl').find('li').each(function(){ var tooltipName=jq(this).children('a').text(); var tooltipLeft=jq('.tt').outerWidth()/-2; var tooltipTop=jq('.tt').outerHeight()/-2; jq(this).append('<span class="tt">'+tooltipName+'</span>'); jq('.tt').css({'display':'none','margin-left':tooltipLeft,'margin-top':tooltipTop});});jq('#pl li').hover(function(){jq(this).children(".tt:visible").hide(); jq(this).children(".tt").show(); jq(this).children("a").removeAttr('title');},function(){jq(this).children(".tt").hide();});}
   }).error(function(){jq('#loader').text('Brak mapy!'); jq('#pl span').hide(); jq('#mapa,#pl').css({'height':'auto','left':'0','margin':'0 auto'});
    }).attr('src',mapUrl);
  var loaderPos=jq('#loader').outerWidth()/-2; jq('#loader').css('margin-left',loaderPos);
  jq('#pl').find('li').click(function(){window.location.href=jq(this).children('a').attr('href');});
// koniec mapy




jq('#pageFooter .first').hover(function(e){
  jq('#pl16 a, #pl11 a, #pl14 a, #pl2 a, #pl15 a, #pl4 a, #pl1 a').addClass('active');
  
}, function(){
  jq('#mapa a').removeClass('active');
  
});
jq('#pageFooter .third').hover(function(e){
  jq('#pl3 a, #pl5 a, #pl6 a, #pl7 a, #pl8 a, #pl9 a, #pl10 a, #pl13 a, #pl12 a').addClass('active');
  
}, function(){
  jq('#mapa a').removeClass('active');
  
});



var tabs = [];
var tabContainers = [];
jq('.contentTopNav a').each(function() {
    //if (this.pathname == window.location.pathname) {
        tabs.push(this);
        tabContainers.push(jq(this.hash).get(0));
    //}
});

jq(tabs).click(function() {

    jq(tabContainers).hide().filter(this.hash).show();
    
    jq(tabs).removeClass('selected');
    jq(this).addClass('selected');
    
    return false;
});

jq(".header-slider-slides").carouFredSel({
	//auto : false,
	auto:{
	   duration: 500,
	   pauseDuration: 4000,
	   pauseOnHover: true
	},
	
  scroll : {
         fx : "crossfade"
         },
	prev : ".header-slider-prev",
	next : ".header-slider-next"
});



});

function slideSwitch() {
    var jqactive = jq('#slideshow IMG.active');

    if ( jqactive.length == 0 ) jqactive = jq('#slideshow IMG:last');

    var jqnext =  jqactive.next().length ? jqactive.next()
        : jq('#slideshow IMG:first');

    jqactive.addClass('last-active');

    jqnext.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            jqactive.removeClass('active last-active');
        });
}

jq(function() {
    setInterval( "slideSwitch()", 5000 );
});
