var $wojewodztwo=new Array(16)
$wojewodztwo[1] = "dolnośląskie";
$wojewodztwo[2] = "kujawsko-pomorskie";
$wojewodztwo[3] = "lubelskie";
$wojewodztwo[4] = "lubuskie";
$wojewodztwo[5] = "łódzkie";
$wojewodztwo[6] = "małopolskie";
$wojewodztwo[7] = "mazowieckie";
$wojewodztwo[8] = "opolskie";
$wojewodztwo[9] = "podkarpackie";
$wojewodztwo[10] = "podlaskie";
$wojewodztwo[11] = "pomorskie";
$wojewodztwo[12] = "śląskie";
$wojewodztwo[13] = "świętkorzyskie";
$wojewodztwo[14] = "warmińsko-mazurskie";
$wojewodztwo[15] = "wielkopolskie";
$wojewodztwo[16] = "zachodnio-pomorksie";

$(document).ready(function(){
	$('#fb_slide').tabSlideOut({
		tabHandle: '#fb_logo',
		pathToTabImage: '/images/fb_icon.png',
		imageHeight: '60px',
		imageWidth: '60px',
		tabLocation: 'left',
		topPos: '90px'
	});
});

$(document).ready(function(){
	$woj_akt = 0;
	$start_img = $("#mapa").attr('src');
	var $old;

$(".mapa_area_start").mouseenter(function(){
		var $woj = $(this).attr("id").substring(2);

		if ($woj!=$woj_akt) {
			$("#mapa").attr('src','/images/mapa_funduszy/mapa_s_'+$woj+'.png');
			$woj_akt = $woj;
			$("#woj_wyb").html('<a href="/mapa-funduszy/'+$woj+','+$wojewodztwo[$woj]+'"><span style="color:#810000">&bull;</span> '+$wojewodztwo[$woj]+'</a>');
		}
	});

	$(".mapa_area_blog").mouseenter(function(){
		var $woj = $(this).attr("id").substring(2);
		$old = $("#woj_wyb").html();

		if ($woj!=$woj_akt) {
			$("#mapa").attr('src','/images/mapa_blog/mapa_s_'+$woj+'.png');
			$woj_akt = $woj;
			$("#woj_wyb").html($wojewodztwo[$woj]);
		}
	});
	$(".mapa_area_blog").mouseleave(function(){
		$("#mapa").attr('src',$start_img);
		$woj_akt = 0;
		$("#woj_wyb").html($old);
	});

	$(".mapa_area").mouseenter(function(){
		var $woj = $(this).attr("id").substring(2);

		if ($woj!=$woj_akt) {
			$("#mapa").attr('src','/images/mapa_funduszy/mapa_'+$woj+'.png');
			$woj_akt = $woj;
		}			
	});

	$(".mapa_area").mouseleave(function(){
		$("#mapa").attr('src',$start_img);
		$woj_akt = 0;
	});
	
	//przełączanie strona główna
	$("#b1,#b2,#b3").click(function(){
		var $id = $(this).attr("id");
		b_switch($id);
		$(document).stopTime();
	});

$('marquee').marquee().mouseover(function () {
		$(this).trigger('stop');
	}).mouseout(function () {
		$(this).trigger('start');
	}).mousemove(function (event) {
		if ($(this).data('drag') == true) {
			this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
		}
	}).mousedown(function (event) {
		$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
	}).mouseup(function () {
		$(this).data('drag', false);
	});

});

var $b_on=1;
function b_switch($id) {
	$("#b1,#b2,#b3").removeClass("active");
	$("#"+$id).addClass("active");
	$(".atb").hide();
	$("#at"+$id).show();
	$(".ati").hide();
	$("#ati"+$id).show();
};

preload_mapa_main={
  config:{
    preloaded_images:['mapa_s_1.png', 'mapa_s_2.png', 'mapa_s_3.png','mapa_s_4.png', 'mapa_s_5.png', 'mapa_s_6.png','mapa_s_7.png', 'mapa_s_8.png', 'mapa_s_9.png','mapa_s_10.png', 'mapa_s_11.png', 'mapa_s_12.png','mapa_s_13.png', 'mapa_s_4.png', 'mapa_s_15.png','mapa_s_16.png'],
    images_rel_path:"/images/mapa_funduszy/"
  },
 
  preload_images:function(){
    jQuery.each(preload_mapa_main.config.preloaded_images, function(){
      jQuery("<img>").attr('src', preload_mapa_main.config.images_rel_path + this);
    });
  },
  init:function(){
    this.preload_images();
  }
};

preload_mapa={
  config:{
    preloaded_images:['mapa_1.png', 'mapa_2.png', 'mapa_3.png','mapa_4.png', 'mapa_5.png', 'mapa_6.png','mapa_7.png', 'mapa_8.png', 'mapa_9.png','mapa_10.png', 'mapa_11.png', 'mapa_12.png','mapa_13.png', 'mapa_4.png', 'mapa_15.png','mapa_16.png'],
    images_rel_path:"/images/mapa_funduszy/"
  },
 
  preload_images:function(){
    jQuery.each(preload_mapa_main.config.preloaded_images, function(){
      jQuery("<img>").attr('src', preload_mapa_main.config.images_rel_path + this);
    });
  },
  init:function(){
    this.preload_images();
  }
};

(function($) {
    $.scrollToElement = function( $element, speed ) {

        speed = speed || 750;

        $("html, body").animate({
            scrollTop: $element.offset().top,
            scrollLeft: $element.offset().left
        }, speed);
        return $element;
    };

    $.fn.scrollTo = function( speed ) {
        speed = speed || "normal";
        return $.scrollToElement( this, speed );
    };
})(jQuery);


//drop down menu
var timeout    = 300;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  
	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#tmul > li.drop').bind('mouseover', jsddm_open)
   $('#tmul > li.drop').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;

