//hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
//marquee
(function(b){b.marquee={version:"1.0.01"};b.fn.marquee=function(o){var a=typeof arguments[0]=="string"&&arguments[0],p=a&&Array.prototype.slice.call(arguments,1)||arguments,i=this.length==0?null:b.data(this[0],"marquee");if(i&&a&&this.length)if(a.toLowerCase()=="object")return i;else if(i[a]){var g;this.each(function(l){var e=b.data(this,"marquee")[a].apply(i,p);if(l==0&&e)if(e.jquery)g=b([]).add(e);else{g=e;return false}else if(e&&e.jquery)g=g.add(e)});return g||this}else return this;else return this.each(function(){new b.Marquee(this, o)})};b.Marquee=function(o,a){function p(c){if(h.filter("."+a.cssShowing).length>0)return false;var f=h.eq(c);b.isFunction(a.beforeshow)&&a.beforeshow.apply(j,[d,f]);c={top:(a.yScroll=="top"?"-":"+")+f.outerHeight()+"px",left:0};d.data("marquee.showing",true);f.addClass(a.cssShowing);f.css(c).animate({top:"0px"},a.showSpeed,a.fxEasingShow,function(){b.isFunction(a.show)&&a.show.apply(j,[d,f]);d.data("marquee.showing",false);i(f)})}function i(c,f){if(k==true)return false;f=f||a.pauseSpeed;if(c.outerWidth()> d.innerWidth())setTimeout(function(){if(k==true)return false;var q=c.outerWidth(),s=q*-1,t=parseInt(c.css("left"),10);c.animate({left:s+"px"},(q+t)*a.scrollSpeed,a.fxEasingScroll,function(){g(c)})},f);else h.length>1&&setTimeout(function(){if(k==true)return false;c.animate({top:(a.yScroll=="top"?"+":"-")+d.innerHeight()+"px"},a.showSpeed,a.fxEasingScroll);g(c)},f)}function g(c){b.isFunction(a.aftershow)&&a.aftershow.apply(j,[d,c]);c.removeClass(a.cssShowing);r()}function l(){k=true;d.data("marquee.showing")!= true&&h.filter("."+a.cssShowing).dequeue().stop()}function e(){k=false;d.data("marquee.showing")!=true&&i(h.filter("."+a.cssShowing),1)}function r(){m++;if(m>=h.length){if(!isNaN(a.loop)&&a.loop>0&&++u>=a.loop)return false;m=0}p(m)}a=b.extend({},b.Marquee.defaults,a);var j=this,d=b(o),h=d.find("> li"),m=-1,n=false,k=false,u=0;b.data(d[0],"marquee",j);this.pause=function(){n=true;l()};this.resume=function(){n=false;e()};this.update=function(){var c=h.length;h=d.find("> li");c<=1&&e()};a.pauseOnHover&& d.hover(function(){if(n)return false;l()},function(){if(n)return false;e()});b.isFunction(a.init)&&a.init.apply(j,[d,a]);r()};b.Marquee.defaults={yScroll:"top",showSpeed:150,scrollSpeed:12,pauseSpeed:7E3,pauseOnHover:true,loop:-1,fxEasingShow:"swing",fxEasingScroll:"linear",cssShowing:"marquee-showing",init:null,beforeshow:null,show:null,aftershow:null}})(jQuery);
//slimbox
(function(a){function t(){var b=l.scrollLeft(),d=l.width();a([e,p]).css("left",b+d/2);D&&a(i).css({left:b,top:l.scrollTop(),width:d,height:l.height()})}function E(b){if(b)a("object").add(F?"select":"embed").each(function(d,f){z[d]=[f,f.style.visibility];f.style.visibility="hidden"});else{a.each(z,function(d,f){f[0].style.visibility=f[1]});z=[]}b=b?"bind":"unbind";l[b]("scroll resize",t);a(document)[b]("keydown",R)}function R(b){b=b.keyCode;var d=a.inArray;return d(b,c.closeKeys)>=0?G():d(b,c.nextKeys)>= 0?H():d(b,c.previousKeys)>=0?I():false}function I(){return A(q)}function H(){return A(r)}function A(b){if(b>=0){j=b;v=g[j][0];q=(j||(c.loop?g.length:0))-1;r=(j+1)%g.length||(c.loop?0:-1);J();e.className="lbLoading";m=new Image;m.onload=S;m.src=v}return false}function S(){e.className="";a(n).css({backgroundImage:"url("+v+")",visibility:"hidden",display:""});a(B).width(m.width);a([B,w,x]).height(m.height);a(K).html(g[j][1]||"");a(L).html((g.length>1&&c.counterText||"").replace(/{x}/,j+1).replace(/{y}/, g.length));if(q>=0)M.src=g[q][0];if(r>=0)N.src=g[r][0];h=n.offsetWidth;k=n.offsetHeight;var b=Math.max(0,C-k/2);e.offsetHeight!=k&&a(e).animate({height:k,top:b},c.resizeDuration,c.resizeEasing);e.offsetWidth!=h&&a(e).animate({width:h,marginLeft:-h/2},c.resizeDuration,c.resizeEasing);a(e).queue(function(){a(p).css({width:h,top:b+k,marginLeft:-h/2,visibility:"hidden",display:""});a(n).css({display:"none",visibility:"",opacity:""}).fadeIn(c.imageFadeDuration,T)})}function T(){q>=0&&a(w).show();r>=0&& a(x).show();a(y).css("marginTop",-y.offsetHeight).animate({marginTop:0},c.captionAnimationDuration);p.style.visibility=""}function J(){m.onload=null;m.src=M.src=N.src=v;a([e,n,y]).stop(true);a([w,x,n,p]).hide()}function G(){if(j>=0){J();j=q=r=-1;a(e).hide();a(i).stop().fadeOut(c.overlayFadeDuration,E)}return false}var l=a(window),c,g,j=-1,v,q,r,D,C,h,k,F=!window.XMLHttpRequest,z=[],m={},M=new Image,N=new Image,i,e,n,B,w,x,p,y,K,L;a(function(){a("body").append(a([i=a('<div id="lbOverlay" />')[0],e= a('<div id="lbCenter" />')[0],p=a('<div id="lbBottomContainer" />')[0]]).css("display","none"));n=a('<div id="lbImage" />').appendTo(e).append(B=a('<div style="position: relative;" />').append([w=a('<a id="lbPrevLink" href="#" />').click(I)[0],x=a('<a id="lbNextLink" href="#" />').click(H)[0]])[0])[0];y=a('<div id="lbBottom" />').appendTo(p).append([a('<a id="lbCloseLink" href="#" />').add(i).click(G)[0],K=a('<div id="lbCaption" />')[0],L=a('<div id="lbNumber" />')[0],a('<div style="clear: both;" />')[0]])[0]}); a.slimbox=function(b,d,f){c=a.extend({loop:false,overlayOpacity:0.4,overlayFadeDuration:200,resizeDuration:200,resizeEasing:"swing",initialWidth:100,initialHeight:100,imageFadeDuration:200,captionAnimationDuration:200,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},f);if(typeof b=="string"){b=[[b,d]];d=0}C=l.scrollTop()+l.height()/2;h=c.initialWidth;k=c.initialHeight;a(e).css({top:Math.max(0,C-k/2),width:h,height:k,marginLeft:-h/2}).show();if(D=F||i.currentStyle&& i.currentStyle.position!="fixed")i.style.position="absolute";a(i).css("opacity",c.overlayOpacity).fadeIn(c.overlayFadeDuration);t();E(1);g=b;c.loop=c.loop&&g.length>1;return A(d)};a.fn.slimbox=function(b,d,f){d=d||function(u){return[u.href,u.title]};f=f||function(){return true};var O=this;return O.unbind("click").click(function(){var u=this,P=0,s,o=0,Q;s=a.grep(O,function(U,V){return f.call(u,U,V)});for(Q=s.length;o<Q;++o){if(s[o]==u)P=o;s[o]=d(s[o],o)}return a.slimbox(s,P,b)})}})(jQuery); /android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)||jQuery(function(a){a("a[rel^='lightbox']").slimbox({},null,function(t){return this==t||this.rel.length>8&&this.rel==t.rel})});

var validMail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

function genMenu(){
	$(".mmelem span.mmlink").toggle( function(){
		$(this).addClass("sel");	
		$(this).parent().find(".submenu").show();	
	},function(){
		$(this).removeClass("sel");	
		$(this).parent().find(".submenu").hide();	
	});  	
	$(".mmelem").hoverIntent(
		{
			over:function(){
				var $submenu = $(this).find(".submenu");
				$(".submenu").attr('style','');
				$(".submenu").hide();  	
				$submenu.stop(0,0).show();
				$(".mmlink.curr").addClass("blur");
				$(this).find(".mmlink").removeClass("blur");
  				$(this).find(".mmlink").addClass("sel");
				$(".subLevel").fadeTo(50, 0.2);
			},
			out:function(){
				var $submenu = $(this).find(".submenu");
				$submenu.hide();
				$(this).find(".mmlink").removeClass("sel");
			},
			timeout:200,
			sensitivity:10,
			interval:60
		}
	);
	
	$(".subLevel ul").hoverIntent(
		{
			over:function(){
			   var thisClass = $(this).attr('class');
			   //console.log(thisClass);
				var $submenu = $("div ."+thisClass);
				$(".submenu").attr('style','');
				$(".submenu").hide();  	
				$submenu.stop(0,0).show();
				$(".mmlink.curr").addClass("blur");
				$(this).find(".mmlink").removeClass("blur");
  				$(this).find(".mmlink").addClass("sel");
				$(".subLevel").fadeTo(50, 0.2);
			},
			out:function(){
				var $submenu = $(this).find(".submenu");
				$submenu.hide();
				$(this).find(".mmlink").removeClass("sel");
			},
			timeout:200,
			sensitivity:10,
			interval:160
		}
	);

	$(".menu").hoverIntent({
		over:function(){
		},
		out:function(){
			$(".mmlink").removeClass("blur");
			$(".subLevel").fadeTo(50, 1);
		},
		timeout:200,
		sensitivity:10,
		interval:60
	});
}
   
$("document").ready(function(){
	
	// menu wyboru miasta
	$(".chCity").hoverIntent(
		{
			over:function(){ 
				$(this).find("ul").fadeIn("slow");
			},
			out:function(){
				$(this).find("ul").fadeOut("slow");
			},
			timeout:100,
			sensitivity:2
		}
	);
	

	
	// RSS
	$(".atom ul").marquee({xScroll: "left"});


	// SLIDER
	$(".ageSlide").slider({
		range: true,
		min: 0,
		max: 14,
		values: [$("#chAgeMin").val(), $("#chAgeMax").val()],
		slide: function(event, ui) {
			$(".ui-slider-handle .uiMax").text('do '+ui.values[1] + ' (lat)');
			$(".ui-slider-handle .uiMin").text('od '+ui.values[0] + ' (lat)');
			$("#chAgeInfo").text('' + ui.values[0] + ' - ' + ui.values[1] + ' (lat)');
			$("#chAge").val(ui.values[0] + '-' + ui.values[1]);
		}
	});
	$("#chAgeInfo").text('' + $(".ageSlide").slider("values", 0) + ' - ' + $(".ageSlide").slider("values", 1) + ' (lat)');
	$("#chAge").val($(".ageSlide").slider("values", 0) + '-' + $(".ageSlide").slider("values", 1));
	$(".ui-slider-handle:last").append("<span class='uitip uiMax'>do "+ $(".ageSlide").slider("values", 1) + " (lat)</span>");
	$(".ui-slider-handle:first").append("<span class='uitip uiMin'>od "+ $(".ageSlide").slider("values", 0) + " (lat)</span>");
	
	
	// Kalendarz
	$("#selDate").datepicker();

	// widget
	$("#checkAll").click(function(){$('.chPack .chTem input').attr('checked','checked')});
	$("#unCheckAll").click(function(){$('.chPack .chTem input').attr('checked','')});
	
	$("#newsWidget").submit(function(){
		var zaznPola = $(this).serializeArray();
		var temat=''; var wiek='';	var kiedy=''; var data='';
		var re = new RegExp('[^0-9-]', 'g');

		jQuery.each(zaznPola,function(){	
			var value = this.value;var name = this.name;
			if (name=='temat[]'){
				temat +=';'+value;	
			}
			else if (name=='wiek'){
				wiek = ';'+value;
			}			
			else if (name=='kiedy[]' && value!=''){
				kiedy += ';'+value;
			}
			else if (name=='data'){
				data = ';'+value.replace(re,'');
			}				
		});
		var strQuery =(temat!='' ? ('temat:'+temat.substr(1)+'_') : '')
			+(wiek  !='' ? ('wiek:'+wiek.substr(1)+'_') : '')
			+(kiedy !='' ? ('kiedy:'+kiedy.substr(1)+'_') : '')
			+(data  !='' ? ('data:'+data.substr(1)+'_') : '');
		var urlQuery = $(this).attr("action").replace("wydarzenia",strQuery);
		location.href=urlQuery;
		return false; 
	});
	
	// zakładki 
	$(".tabCont").hide();
 	$(".tabBox").each(function() {
		 	$(this).find(".tabMenu li").each(function(){
		 			$(this).find("a.tabLink").click(function() {
			 				$(this).parent().parent().parent().find("li").removeClass('selected');
	                  $(this).parent().parent().addClass('selected');
	                  $(this).parent().parent().parent().parent().find(".tabCont").hide();
	                  $(this).parent().parent().parent().parent().find("."+$(this).attr("href").substr(1)).show(); 
	                  return false;
			 			} 
					);
			   	if ($(this).hasClass("selected")) {
						$(this).parent().parent().find("."+$(this).find("a.tabLink").attr("href").substr(1)).show();
					}
			   }
			);
		}  	
	);
	
	// szukajka katalog  
	$(".catalSearch .catalQuery").val("Szukaj w katalogu firm i instytucji").focus( function() {
      	if ($(this).val()=="Szukaj w katalogu firm i instytucji") {
				$(this).val("");         
			}
			$(".catalBox .tab1").addClass('selected');
			$(".catalBox .tab2").removeClass('selected');
			$(".catalBox .tabWrapper .catalTab2").hide();
			$(".catalBox .tabWrapper .catalTab1").show();
		}
	)
	.blur( function() {
      	if ($(this).val()=="") {
				$(this).val("Szukaj w katalogu firm i instytucji");         
			}
		}
	);
	$(".catalSearch").submit(function(){
		if ($(".catalSearch .catalQuery").val()=="Szukaj w katalogu firm i instytucji" || $(".catalSearch .catalQuery").val()=="") {$(".catalSearch .catalQuery").fadeOut("fast").fadeIn("fast"); return false; }
		var strQuery =$(this).find("input[name='slowo']").val().replace("/","");
		var urlQuery = $(this).attr("action").replace("slowo",strQuery);
		location.href=urlQuery; 
		return false;
	});
	
	//szukajka główna
	if ($(".mainSearch .MSInput").val()=='')	$(".mainSearch .MSInput").val("Szukaj w serwisie");
	$(".mainSearch .MSInput").focus( function() {
      	if ($(this).val()=="Szukaj w serwisie") {
				$(this).val("");         
			}
		}
	)
	.blur( function() {
      	if ($(this).val()=="") {
				$(this).val("Szukaj w serwisie");         
			}
		}
	);
	$(".mainSearch").submit(function(){
		if ($(".mainSearch .MSInput").val()=="Szukaj w serwisie" || $(".mainSearch .MSInput").val()=="") {$(".mainSearch .MSInput").fadeOut("fast").fadeIn("fast"); return false; }
		//location.href=urlQuery; 
		//return false;
	});
	
	//newsletter
	$(".newsRegister .newsRegInp").val("Podaj swój e-mail").focus( function() {
      	if ($(this).val()=="Podaj swój e-mail") {
				$(this).val("");         
			}
		}
	)
	.blur( function() {
      	if ($(this).val()=="") {
				$(this).val("Podaj swój e-mail");         
			}
		}
	);
	$(".newsRegister").submit(function(){
		if (validMail.test($(".newsRegister .newsRegInp").val()) == false) {
			$(this).find(".invalidData").fadeIn(500).fadeOut(2000);
			return false;
		}
		if ($(".newsRegister .newsRegInp").val()=="Podaj swój e-mail" || $(".mainSearch .newsRegInp").val()=="") {
				$(".newsRegister .newsRegInp").fadeOut("fast").fadeIn("fast"); 
				return false; 
		}
	});
	
	// tableka 
	$(".catInst tr:odd td").addClass("even"); 
	
});


// Funkcja zwijaczek w wydarzeniach
function setSlideDate(){
	$('.slideDateCont').each(function(index){
		var $header = $(this).parent().find('.dateHeader');
		$header.append('<span class="slideAction slideDown">zwiń</span>');		
		if (index>3) {
			$(this).hide();
			var countElem = $(this).find('.zajawka2').size();
			if (countElem>0) $header.find('.slideAction').addClass('slideUp').removeClass('slideDown').text('rozwiń'+' ('+countElem+')');
		}
		
	});
	$('.dateHeader').click(function(){		
		var $container = $(this).parent().find('.slideDateCont');	
		var countElem = $container.find('.zajawka2').size();
		if ($container.is(':visible')){
			$container.slideUp();
			$(this).find('.slideAction').addClass('slideUp').removeClass('slideDown').text('rozwiń'+' ('+countElem+')');
		}
		else {
		   $container.slideDown();
		   $(this).find('.slideAction').addClass('slideDown').removeClass('slideUp').text('zwiń');
		}
	} );
}



//----------------------
// ---- STEPCAROUSEL
var stepcarousel={
	ajaxloadingmsg: '<div style="margin: 1em; font-weight: bold"><img src="ajaxloadr.gif" style="vertical-align: middle" />  czekaj...</div>',
	defaultbuttonsfade: 0.4, 
	configholder: {},
	getCSSValue:function(val){ 
		return (val=="auto")? 0 : parseInt(val)
	},

	getremotepanels:function($, config){ 
		config.$belt.html(this.ajaxloadingmsg)
		$.ajax({
			url: config.contenttype[1], 
			async: true,
			error:function(ajaxrequest){
				config.$belt.html('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
			},
			success:function(content){
				config.$belt.html(content)
				config.$panels=config.$gallery.find('.'+config.panelclass)
				stepcarousel.alignpanels($, config)
			}
		})
	},

	getoffset:function(what, offsettype){
		return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]
	},

	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]+", "i"); 
		if (document.cookie.match(re)) 
			return document.cookie.match(re)[0].split("=")[1] 
		return null
	},

	setCookie:function(name, value){
		document.cookie = name+"="+value
	},

	fadebuttons:function(config, currentpanel){
		config.$leftnavbutton.fadeTo('fast', currentpanel==0? this.defaultbuttonsfade : 1)
		config.$rightnavbutton.fadeTo('fast', currentpanel==config.lastvisiblepanel? this.defaultbuttonsfade : 1)
	},

	addnavbuttons:function(config, currentpanel){
		config.$leftnavbutton=$('<img src="'+config.defaultbuttons.leftnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Back '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
		config.$rightnavbutton=$('<img src="'+config.defaultbuttons.rightnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Forward '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
		config.$leftnavbutton.bind('click', function(){ 
			stepcarousel.stepBy(config.galleryid, -config.defaultbuttons.moveby)
		})
		config.$rightnavbutton.bind('click', function(){ 
			stepcarousel.stepBy(config.galleryid, config.defaultbuttons.moveby)
		})
		if (config.panelbehavior.wraparound==false){
			this.fadebuttons(config, currentpanel)
		}
		return config.$leftnavbutton.add(config.$rightnavbutton)
	},

	stopautostep:function(config){					
		clearTimeout(config.steptimer)
		clearTimeout(config.resumeautostep)
	},

	alignpanels:function($, config){
		var paneloffset=0
		config.paneloffsets=[paneloffset] 
		config.panelwidths=[] 
		config.$panels.each(function(index){ 
			var $currentpanel=$(this)
			$currentpanel.css({float:'none', position:'absolute', left: paneloffset+'px'}) 
			$currentpanel.bind('click', function(e){return config.onpanelclick(e.target)})
			paneloffset+=stepcarousel.getCSSValue($currentpanel.css('marginRight')) + parseInt($currentpanel.get(0).offsetWidth || $currentpanel.css('width')) 
			config.paneloffsets.push(paneloffset) 
			config.panelwidths.push(paneloffset-config.paneloffsets[config.paneloffsets.length-2]) 
		})
		config.paneloffsets.pop() 
		var addpanelwidths=0
		var lastpanelindex=config.$panels.length-1
		config.lastvisiblepanel=lastpanelindex
		for (var i=config.$panels.length-1; i>=0; i--){
			addpanelwidths+=(i==lastpanelindex? config.panelwidths[lastpanelindex] : config.paneloffsets[i+1]-config.paneloffsets[i])
			if (config.gallerywidth>addpanelwidths){
				config.lastvisiblepanel=i 
			}
		}
		config.$belt.css({width: paneloffset+'px'}) 
		config.currentpanel=(config.panelbehavior.persist)? parseInt(this.getCookie(window[config.galleryid+"persist"])) : 0
		config.currentpanel=(typeof config.currentpanel=="number" && config.currentpanel<config.$panels.length)? config.currentpanel : 0
		if (config.currentpanel!=0){
			var endpoint=config.paneloffsets[config.currentpanel]+(config.currentpanel==0? 0 : config.beltoffset)
			config.$belt.css({left: -endpoint+'px'})
		}
		if (config.defaultbuttons.enable==true){ 
			var $navbuttons=this.addnavbuttons(config, config.currentpanel)
			$(window).bind("load resize", function(){ 
				config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
				config.$leftnavbutton.css({left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px'})
				config.$rightnavbutton.css({left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px'})
			})
		}
		if (config.autostep && config.autostep.enable){ 	
			var $carouselparts=config.$gallery.add(typeof $navbuttons!="undefined"? $navbuttons : null)
			$carouselparts.bind('click', function(){
				stepcarousel.stopautostep(config)
				config.autostep.status="stopped"
			})
			$carouselparts.hover(function(){ 
				stepcarousel.stopautostep(config)
				config.autostep.hoverstate="over"
			}, function(){ //onMouseout
				if (config.steptimer && config.autostep.hoverstate=="over" && config.autostep.status!="stopped"){
					config.resumeautostep=setTimeout(function(){
						stepcarousel.autorotate(config.galleryid)
						config.autostep.hoverstate="out"
					}, 500)
				}
			})
			config.steptimer=setTimeout(function(){stepcarousel.autorotate(config.galleryid)}, config.autostep.pause) 
		} 
		this.statusreport(config.galleryid)
		config.oninit()
		config.onslideaction(this)
	},

	stepTo:function(galleryid, pindex){ 
		var config=stepcarousel.configholder[galleryid]
		config.autostep.status="stopped" 
		if (typeof config=="undefined"){
			
			return
		}
		stepcarousel.stopautostep(config)
		var pindex=Math.min(pindex-1, config.paneloffsets.length-1)
		var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset)
		if (config.panelbehavior.wraparound==false && config.defaultbuttons.enable==true){ 
			this.fadebuttons(config, pindex)
		}
		config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
		config.currentpanel=pindex
		this.statusreport(galleryid)
	},

	stepBy:function(galleryid, steps){ 
		var config=stepcarousel.configholder[galleryid]
		if (typeof config=="undefined"){
			return
		}
		stepcarousel.stopautostep(config)
		var direction=(steps>0)? 'forward' : 'back' 
		var pindex=config.currentpanel+steps 
		if (config.panelbehavior.wraparound==false){ 
			pindex=(direction=="back" && pindex<=0)? 0 : (direction=="forward")? Math.min(pindex, config.lastvisiblepanel) : pindex
			if (config.defaultbuttons.enable==true){ 
				stepcarousel.fadebuttons(config, pindex)
			}	
		}
		else{ 
			if (pindex>config.lastvisiblepanel && direction=="forward"){
				pindex=(config.currentpanel<config.lastvisiblepanel)? config.lastvisiblepanel : 0
			}
			else if (pindex<0 && direction=="back"){
				
				pindex=(config.currentpanel>0)? 0 : config.lastvisiblepanel 
			}
		}
		var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset) 
		if (pindex==0 && direction=='forward' || config.currentpanel==0 && direction=='back' && config.panelbehavior.wraparound==true){ 
			config.$belt.animate({left: -config.paneloffsets[config.currentpanel]-(direction=='forward'? 100 : -30)+'px'}, 'normal', function(){
				config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
			})
		}
		else
			config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
		config.currentpanel=pindex
		this.statusreport(galleryid)
	},

	autorotate:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		if (config.$gallery.attr('_ismouseover')!="yes"){
			this.stepBy(galleryid, config.autostep.moveby)
		}
		config.steptimer=setTimeout(function(){stepcarousel.autorotate(galleryid)}, config.autostep.pause)
	},

	statusreport:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		var startpoint=config.currentpanel 
		var visiblewidth=0
		for (var endpoint=startpoint; endpoint<config.paneloffsets.length; endpoint++){ 
			visiblewidth+=config.panelwidths[endpoint]
			if (visiblewidth>config.gallerywidth){
				break
			}
		}
		startpoint+=1 
		endpoint=(endpoint+1==startpoint)? startpoint : endpoint 
		var valuearray=[startpoint, endpoint, config.panelwidths.length]
		for (var i=0; i<config.statusvars.length; i++){
			window[config.statusvars[i]]=valuearray[i] 
			config.$statusobjs[i].text(valuearray[i]+" ") 
		}
	},

	setup:function(config){		
		document.write('<style type="text/css">\n#'+config.galleryid+'{overflow: hidden;}\n</style>')
		jQuery(document).ready(function($){
			config.$gallery=$('#'+config.galleryid)
			config.gallerywidth=config.$gallery.width()
			config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
			config.$belt=config.$gallery.find('.'+config.beltclass) 
			config.$panels=config.$gallery.find('.'+config.panelclass) 
			config.panelbehavior.wraparound=(config.autostep && config.autostep.enable)? true : config.panelbehavior.wraparound 
			config.onpanelclick=(typeof config.onpanelclick=="undefined")? function(target){} : config.onpanelclick 
			config.onslideaction=(typeof config.onslide=="undefined")? function(){} : function(beltobj){$(beltobj).stop(); config.onslide()} //attach custom "onslide" event handler
			config.oninit=(typeof config.oninit=="undefined")? function(){} : config.oninit 
			config.beltoffset=stepcarousel.getCSSValue(config.$belt.css('marginLeft')) 
			config.statusvars=config.statusvars || []  
			config.$statusobjs=[$('#'+config.statusvars[0]), $('#'+config.statusvars[1]), $('#'+config.statusvars[2])]
			config.currentpanel=0
			stepcarousel.configholder[config.galleryid]=config 
			if (config.contenttype[0]=="ajax" && typeof config.contenttype[1]!="undefined") 
				stepcarousel.getremotepanels($, config)
			else
				stepcarousel.alignpanels($, config) 
		}) 
		jQuery(window).bind('unload', function(){ 
			if (config.panelbehavior.persist){
				stepcarousel.setCookie(window[config.galleryid+"persist"], config.currentpanel)
			}
			jQuery.each(config, function(ai, oi){
				oi=null
			})
			config=null
		})
	}
}

//Old elem
var flash = {   
		show: function(path,width,height,id,title,alter,params){
			document.write(flash.build(path,width,height,id,title,alter,params));
		},
		param: function(params) {
			var tab = new Array();
			var obj = new Object();
			obj.list = new Array();
			if(params !='') {
				params = params.split(' ').join('');
				tab = params.split(',');
				for(var i=0; i<tab.length;i++) {
					obj[tab[i].split('="')[0]] = tab[i].split('="')[1].split('"')[0];
					obj.list.push(tab[i].split('=')[0]);
				}
			} else obj = '';
			return obj;
		},
		build: function(path,width,height,id,title,alter,params) {
			var txt; 
			txt = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"';
			txt += ' title="'+title+'"';
			txt += ' alt="'+alter+'"';
			txt += ' width="'+width+'" height="'+height+'"';
			txt += ' id="'+id+'"';
			txt += ' style="'+flash.param(params)['style']+'">';
			txt +='<param name="movie" value="'+path+'" />';
			for(var i=0; i<flash.param(params)['list'].length;i++) {
				if(flash.param(params)['list'][i] != 'style') {
					txt +='<param name="'+flash.param(params)['list'][i]+'" value="'+flash.param(params)[flash.param(params)['list'][i]]+'"/>';
				}
			}			
			txt += '<embed src="'+path+'"';
			txt += ' width="'+width+'" height="'+height+'"';
			txt += ' title="'+title+'"';
			txt += ' alt="'+alter+'"';
			txt += ' id="emb_'+id+'"';
			for(var i=0; i<flash.param(params)['list'].length;i++) {
				if(flash.param(params)['list'][i] != 'style') {
					txt +=' '+flash.param(params)['list'][i]+'="'+flash.param(params)[flash.param(params)['list'][i]]+'"';
				}
			}			
			txt +=' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			txt +='</object>';
			return txt;
		}
	}
ObiektXMLHttp = false;
if (window.XMLHttpRequest) {
    ObiektXMLHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
    ObiektXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
}

function getData(zrodlo, cel) {
    if(ObiektXMLHttp) {
        var cel = document.getElementById(cel);
        ObiektXMLHttp.open("GET", "/" + zrodlo + "&r="+Math.random());
        
        ObiektXMLHttp.onreadystatechange = function() {
            if (ObiektXMLHttp.readyState == 4) {
                cel.innerHTML = ObiektXMLHttp.responseText;
            }
        }
        ObiektXMLHttp.send(null);
    }
}


function Set_Cookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ){
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

