

/*
 * jQuery UI Effects 1.7.2
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Effects/
 */
jQuery.effects||(function(d){d.effects={version:"1.7.2",save:function(g,h){for(var f=0;f<h.length;f++){if(h[f]!==null){g.data("ec.storage."+h[f],g[0].style[h[f]])}}},restore:function(g,h){for(var f=0;f<h.length;f++){if(h[f]!==null){g.css(h[f],g.data("ec.storage."+h[f]))}}},setMode:function(f,g){if(g=="toggle"){g=f.is(":hidden")?"show":"hide"}return g},getBaseline:function(g,h){var i,f;switch(g[0]){case"top":i=0;break;case"middle":i=0.5;break;case"bottom":i=1;break;default:i=g[0]/h.height}switch(g[1]){case"left":f=0;break;case"center":f=0.5;break;case"right":f=1;break;default:f=g[1]/h.width}return{x:f,y:i}},createWrapper:function(f){if(f.parent().is(".ui-effects-wrapper")){return f.parent()}var g={width:f.outerWidth(true),height:f.outerHeight(true),"float":f.css("float")};f.wrap('<div class="ui-effects-wrapper" style="font-size:100%;background:transparent;border:none;margin:0;padding:0"></div>');var j=f.parent();if(f.css("position")=="static"){j.css({position:"relative"});f.css({position:"relative"})}else{var i=f.css("top");if(isNaN(parseInt(i,10))){i="auto"}var h=f.css("left");if(isNaN(parseInt(h,10))){h="auto"}j.css({position:f.css("position"),top:i,left:h,zIndex:f.css("z-index")}).show();f.css({position:"relative",top:0,left:0})}j.css(g);return j},removeWrapper:function(f){if(f.parent().is(".ui-effects-wrapper")){return f.parent().replaceWith(f)}return f},setTransition:function(g,i,f,h){h=h||{};d.each(i,function(k,j){unit=g.cssUnit(j);if(unit[0]>0){h[j]=unit[0]*f+unit[1]}});return h},animateClass:function(h,i,k,j){var f=(typeof k=="function"?k:(j?j:null));var g=(typeof k=="string"?k:null);return this.each(function(){var q={};var o=d(this);var p=o.attr("style")||"";if(typeof p=="object"){p=p.cssText}if(h.toggle){o.hasClass(h.toggle)?h.remove=h.toggle:h.add=h.toggle}var l=d.extend({},(document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle));if(h.add){o.addClass(h.add)}if(h.remove){o.removeClass(h.remove)}var m=d.extend({},(document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle));if(h.add){o.removeClass(h.add)}if(h.remove){o.addClass(h.remove)}for(var r in m){if(typeof m[r]!="function"&&m[r]&&r.indexOf("Moz")==-1&&r.indexOf("length")==-1&&m[r]!=l[r]&&(r.match(/color/i)||(!r.match(/color/i)&&!isNaN(parseInt(m[r],10))))&&(l.position!="static"||(l.position=="static"&&!r.match(/left|top|bottom|right/)))){q[r]=m[r]}}o.animate(q,i,g,function(){if(typeof d(this).attr("style")=="object"){d(this).attr("style")["cssText"]="";d(this).attr("style")["cssText"]=p}else{d(this).attr("style",p)}if(h.add){d(this).addClass(h.add)}if(h.remove){d(this).removeClass(h.remove)}if(f){f.apply(this,arguments)}})})}};function c(g,f){var i=g[1]&&g[1].constructor==Object?g[1]:{};if(f){i.mode=f}var h=g[1]&&g[1].constructor!=Object?g[1]:(i.duration?i.duration:g[2]);h=d.fx.off?0:typeof h==="number"?h:d.fx.speeds[h]||d.fx.speeds._default;var j=i.callback||(d.isFunction(g[1])&&g[1])||(d.isFunction(g[2])&&g[2])||(d.isFunction(g[3])&&g[3]);return[g[0],i,h,j]}d.fn.extend({_show:d.fn.show,_hide:d.fn.hide,__toggle:d.fn.toggle,_addClass:d.fn.addClass,_removeClass:d.fn.removeClass,_toggleClass:d.fn.toggleClass,effect:function(g,f,h,i){return d.effects[g]?d.effects[g].call(this,{method:g,options:f||{},duration:h,callback:i}):null},show:function(){if(!arguments[0]||(arguments[0].constructor==Number||(/(slow|normal|fast)/).test(arguments[0]))){return this._show.apply(this,arguments)}else{return this.effect.apply(this,c(arguments,"show"))}},hide:function(){if(!arguments[0]||(arguments[0].constructor==Number||(/(slow|normal|fast)/).test(arguments[0]))){return this._hide.apply(this,arguments)}else{return this.effect.apply(this,c(arguments,"hide"))}},toggle:function(){if(!arguments[0]||(arguments[0].constructor==Number||(/(slow|normal|fast)/).test(arguments[0]))||(d.isFunction(arguments[0])||typeof arguments[0]=="boolean")){return this.__toggle.apply(this,arguments)}else{return this.effect.apply(this,c(arguments,"toggle"))}},addClass:function(g,f,i,h){return f?d.effects.animateClass.apply(this,[{add:g},f,i,h]):this._addClass(g)},removeClass:function(g,f,i,h){return f?d.effects.animateClass.apply(this,[{remove:g},f,i,h]):this._removeClass(g)},toggleClass:function(g,f,i,h){return((typeof f!=="boolean")&&f)?d.effects.animateClass.apply(this,[{toggle:g},f,i,h]):this._toggleClass(g,f)},morph:function(f,h,g,j,i){return d.effects.animateClass.apply(this,[{add:h,remove:f},g,j,i])},switchClass:function(){return this.morph.apply(this,arguments)},cssUnit:function(f){var g=this.css(f),h=[];d.each(["em","px","%","pt"],function(j,k){if(g.indexOf(k)>0){h=[parseFloat(g),k]}});return h}});d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(g,f){d.fx.step[f]=function(h){if(h.state==0){h.start=e(h.elem,f);h.end=b(h.end)}h.elem.style[f]="rgb("+[Math.max(Math.min(parseInt((h.pos*(h.end[0]-h.start[0]))+h.start[0],10),255),0),Math.max(Math.min(parseInt((h.pos*(h.end[1]-h.start[1]))+h.start[1],10),255),0),Math.max(Math.min(parseInt((h.pos*(h.end[2]-h.start[2]))+h.start[2],10),255),0)].join(",")+")"}});function b(g){var f;if(g&&g.constructor==Array&&g.length==3){return g}if(f=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(g)){return[parseInt(f[1],10),parseInt(f[2],10),parseInt(f[3],10)]}if(f=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(g)){return[parseFloat(f[1])*2.55,parseFloat(f[2])*2.55,parseFloat(f[3])*2.55]}if(f=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(g)){return[parseInt(f[1],16),parseInt(f[2],16),parseInt(f[3],16)]}if(f=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(g)){return[parseInt(f[1]+f[1],16),parseInt(f[2]+f[2],16),parseInt(f[3]+f[3],16)]}if(f=/rgba\(0, 0, 0, 0\)/.exec(g)){return a.transparent}return a[d.trim(g).toLowerCase()]}function e(h,f){var g;do{g=d.curCSS(h,f);if(g!=""&&g!="transparent"||d.nodeName(h,"body")){break}f="backgroundColor"}while(h=h.parentNode);return b(g)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]};d.easing.jswing=d.easing.swing;d.extend(d.easing,{def:"easeOutQuad",swing:function(g,h,f,j,i){return d.easing[d.easing.def](g,h,f,j,i)},easeInQuad:function(g,h,f,j,i){return j*(h/=i)*h+f},easeOutQuad:function(g,h,f,j,i){return -j*(h/=i)*(h-2)+f},easeInOutQuad:function(g,h,f,j,i){if((h/=i/2)<1){return j/2*h*h+f}return -j/2*((--h)*(h-2)-1)+f},easeInCubic:function(g,h,f,j,i){return j*(h/=i)*h*h+f},easeOutCubic:function(g,h,f,j,i){return j*((h=h/i-1)*h*h+1)+f},easeInOutCubic:function(g,h,f,j,i){if((h/=i/2)<1){return j/2*h*h*h+f}return j/2*((h-=2)*h*h+2)+f},easeInQuart:function(g,h,f,j,i){return j*(h/=i)*h*h*h+f},easeOutQuart:function(g,h,f,j,i){return -j*((h=h/i-1)*h*h*h-1)+f},easeInOutQuart:function(g,h,f,j,i){if((h/=i/2)<1){return j/2*h*h*h*h+f}return -j/2*((h-=2)*h*h*h-2)+f},easeInQuint:function(g,h,f,j,i){return j*(h/=i)*h*h*h*h+f},easeOutQuint:function(g,h,f,j,i){return j*((h=h/i-1)*h*h*h*h+1)+f},easeInOutQuint:function(g,h,f,j,i){if((h/=i/2)<1){return j/2*h*h*h*h*h+f}return j/2*((h-=2)*h*h*h*h+2)+f},easeInSine:function(g,h,f,j,i){return -j*Math.cos(h/i*(Math.PI/2))+j+f},easeOutSine:function(g,h,f,j,i){return j*Math.sin(h/i*(Math.PI/2))+f},easeInOutSine:function(g,h,f,j,i){return -j/2*(Math.cos(Math.PI*h/i)-1)+f},easeInExpo:function(g,h,f,j,i){return(h==0)?f:j*Math.pow(2,10*(h/i-1))+f},easeOutExpo:function(g,h,f,j,i){return(h==i)?f+j:j*(-Math.pow(2,-10*h/i)+1)+f},easeInOutExpo:function(g,h,f,j,i){if(h==0){return f}if(h==i){return f+j}if((h/=i/2)<1){return j/2*Math.pow(2,10*(h-1))+f}return j/2*(-Math.pow(2,-10*--h)+2)+f},easeInCirc:function(g,h,f,j,i){return -j*(Math.sqrt(1-(h/=i)*h)-1)+f},easeOutCirc:function(g,h,f,j,i){return j*Math.sqrt(1-(h=h/i-1)*h)+f},easeInOutCirc:function(g,h,f,j,i){if((h/=i/2)<1){return -j/2*(Math.sqrt(1-h*h)-1)+f}return j/2*(Math.sqrt(1-(h-=2)*h)+1)+f},easeInElastic:function(g,i,f,m,l){var j=1.70158;var k=0;var h=m;if(i==0){return f}if((i/=l)==1){return f+m}if(!k){k=l*0.3}if(h<Math.abs(m)){h=m;var j=k/4}else{var j=k/(2*Math.PI)*Math.asin(m/h)}return -(h*Math.pow(2,10*(i-=1))*Math.sin((i*l-j)*(2*Math.PI)/k))+f},easeOutElastic:function(g,i,f,m,l){var j=1.70158;var k=0;var h=m;if(i==0){return f}if((i/=l)==1){return f+m}if(!k){k=l*0.3}if(h<Math.abs(m)){h=m;var j=k/4}else{var j=k/(2*Math.PI)*Math.asin(m/h)}return h*Math.pow(2,-10*i)*Math.sin((i*l-j)*(2*Math.PI)/k)+m+f},easeInOutElastic:function(g,i,f,m,l){var j=1.70158;var k=0;var h=m;if(i==0){return f}if((i/=l/2)==2){return f+m}if(!k){k=l*(0.3*1.5)}if(h<Math.abs(m)){h=m;var j=k/4}else{var j=k/(2*Math.PI)*Math.asin(m/h)}if(i<1){return -0.5*(h*Math.pow(2,10*(i-=1))*Math.sin((i*l-j)*(2*Math.PI)/k))+f}return h*Math.pow(2,-10*(i-=1))*Math.sin((i*l-j)*(2*Math.PI)/k)*0.5+m+f},easeInBack:function(g,h,f,k,j,i){if(i==undefined){i=1.70158}return k*(h/=j)*h*((i+1)*h-i)+f},easeOutBack:function(g,h,f,k,j,i){if(i==undefined){i=1.70158}return k*((h=h/j-1)*h*((i+1)*h+i)+1)+f},easeInOutBack:function(g,h,f,k,j,i){if(i==undefined){i=1.70158}if((h/=j/2)<1){return k/2*(h*h*(((i*=(1.525))+1)*h-i))+f}return k/2*((h-=2)*h*(((i*=(1.525))+1)*h+i)+2)+f},easeInBounce:function(g,h,f,j,i){return j-d.easing.easeOutBounce(g,i-h,0,j,i)+f},easeOutBounce:function(g,h,f,j,i){if((h/=i)<(1/2.75)){return j*(7.5625*h*h)+f}else{if(h<(2/2.75)){return j*(7.5625*(h-=(1.5/2.75))*h+0.75)+f}else{if(h<(2.5/2.75)){return j*(7.5625*(h-=(2.25/2.75))*h+0.9375)+f}else{return j*(7.5625*(h-=(2.625/2.75))*h+0.984375)+f}}}},easeInOutBounce:function(g,h,f,j,i){if(h<i/2){return d.easing.easeInBounce(g,h*2,0,j,i)*0.5+f}return d.easing.easeOutBounce(g,h*2-i,0,j,i)*0.5+j*0.5+f}})})(jQuery);;/*
 * jQuery UI Effects Slide 1.7.2
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Effects/Slide
 *
 * Depends:
 *	effects.core.js
 */
(function(a){a.effects.slide=function(b){return this.queue(function(){var e=a(this),d=["position","top","left"];var i=a.effects.setMode(e,b.options.mode||"show");var h=b.options.direction||"left";a.effects.save(e,d);e.show();a.effects.createWrapper(e).css({overflow:"hidden"});var f=(h=="up"||h=="down")?"top":"left";var c=(h=="up"||h=="left")?"pos":"neg";var j=b.options.distance||(f=="top"?e.outerHeight({margin:true}):e.outerWidth({margin:true}));if(i=="show"){e.css(f,c=="pos"?-j:j)}var g={};g[f]=(i=="show"?(c=="pos"?"+=":"-="):(c=="pos"?"-=":"+="))+j;e.animate(g,{queue:false,duration:b.duration,easing:b.options.easing,complete:function(){if(i=="hide"){e.hide()}a.effects.restore(e,d);a.effects.removeWrapper(e);if(b.callback){b.callback.apply(this,arguments)}e.dequeue()}})})}})(jQuery);;


/**
 * Copyright (c) 2009 Ird.pl (http://www.ird.pl/)
 *
 * Version: 1.0
 */

(function($) {
	
	$.fn.sliding = function(options) {
		var slider = this;

		//overwrite default settings
	    var settings = $.extend(false, $.fn.sliding.defaults, options);
	    
	    this.loaded = [];
	    this.timer;
			this.duringAnimation = 0;
	    
	    // create list of slides
	    var list = document.createElement('ul');
	    $(list).addClass("sliding-list");
	    
	    // create list of buttons
	    var buttons = document.createElement('ul');
	    $(buttons).addClass("sliding-buttons-list");
	    
	    $(settings.slides).each(function (i) {
	    	var _this = this;
	    	
	    	if (!settings.forceHTML) {  
		    	// create slide
		    	var element = document.createElement('li');
		    	$(element).addClass("sliding-slide");
		    	$(element).hide();
		    	
		    	// create link
		    	var link = document.createElement('a');
		    	$(link).addClass("sliding-link");
		    	if (typeof this.link == "undefined") {
		    		$(link).css("cursor", "default");
		    	} else {
		    		$(link).attr("href", this.link);
		    		if (typeof this.target == "undefined") {
		    			$(link).attr("target", "_self");
		    		} else {
		    			$(link).attr("target", this.target);
		    		}
		    	}
		    	
		    	// create extra div
		    	if (this.div) {
			    	var div = document.createElement('div');
			    	$(div).addClass("sliding-div");
			    	$(div).html(this.div);
			    	$(element).append(div);
		    	}
		    	
		    	// adding slide to list
		    	$(element).append(link);
		    	$(list).append(element);
		    	
		    	
	    	} else {
	    		$(slider).children("ul:first").addClass("sliding-list");
	    		$(slider).children(".sliding-list").children("li").addClass("sliding-slide");
					$(slider).children(".sliding-list").children(".sliding-slide").each(function() {
						$(this).children("a:first").addClass("sliding-link");
						$(this).children("div:first").addClass("sliding-div");
					});
	    		
	    	}
	    	
	    	//create empty button
	    	var button = document.createElement('li');
	    	var button_link = document.createElement('a');
	    	$(button_link).addClass("sliding-button");
	    	$(button_link).text(i+1);
	    	$(button_link).css("cursor", "default");
	    	
	    	$(button).append(button_link);
	    	$(buttons).append(button);
	    	
	    	// loading image
	    	slider.loaded[i] = 0;
	    	var img = new Image();
	    	$(img).load(function () {
	    		$(this).hide();
	    		
	    		var obj = $(slider).children(".sliding-list").children(".sliding-slide:eq("+i+")").children(".sliding-link");
	    		$(obj).html('');
	    		$(obj).append(this);
	    		$(this).show();

	    		if (i == 0) {
	    			if ($(slider).children(".sliding-list").children(".sliding-slide:eq("+i+")").children("div").hasClass(".sliding-div")) {
	    				$(slider).children(".sliding-list").children(".sliding-slide:eq("+i+")").fadeIn(settings.timeout/6, function () {
		    				$(slider).children(".sliding-list").children(".sliding-slide:eq("+i+")").children("div").slideDown(settings.timeout/24);
		    			});
	    			} else {
	    				$(slider).children(".sliding-list").children(".sliding-slide:eq("+i+")").fadeIn(settings.timeout/6);
	    			}
	    			
	    			$(settings.buttons).children(".sliding-buttons-list").children("li:eq(0)").children(".sliding-button").addClass("sliding-button-selected");
	    			
	    		}
	    		
	    		// preparing button
	    		
	    		var button = $(settings.buttons).children(".sliding-buttons-list").children("li:eq("+i+")").children(".sliding-button");
	    		$(button).addClass("sliding-button-loaded");
	    		$(button).removeClass("sliding-button");
	    		$(button).click(function() {
	    			gotoslide(slider, settings, i);
	    		});
	    		$(button).css("cursor", "pointer");
	    		slider.loaded[i] = 1;
	    		
	    	})
	    	.error(function(){
	    		if (settings.error && settings.error() === false) {
			        return true;
			    }})
	    	.attr('src', _this.pic);
	    	
	    	
	    	
	    });
	    
	    $(slider).append(list);
	    $(settings.buttons).append(buttons);
	    
	    $(".sliding-button").bind('click', function () {
	    	return false;
	    });
	    
	    if (slider.loaded[1] == "1") {
			
			slider.timer = setTimeout(function(){
		    	slide(slider, settings);
		    },settings.timeout);
		} else {
			slider.timer = setTimeout(function(){
		    	gotosleep(slider, settings);
		    },settings.timeout/6);
		}
	};
	
	
	slide = function(slider, settings) {
		slider.duringAnimation = 1;
		
		if (settings.beforeSlide && settings.beforeSlide() === false) {
			return true;
		}
		
		var current = $(slider).children(".sliding-list").children(".sliding-slide:visible");
		var next = $(slider).children(".sliding-list").children(".sliding-slide:visible").next();
		
		if (!$(next).hasClass("sliding-slide")) {
			
			if (settings.loop == false) {
				return true;
			}
			next = $(slider).children(".sliding-list").children(".sliding-slide:first");
		}
		
		var next_index = $(slider).children(".sliding-list").children(".sliding-slide").index(next);

		
		if ($(current).children("div").hasClass(".sliding-div")) {
			$(current).children(".sliding-div").slideUp(settings.timeout/24, function() {
				$(current).fadeOut(settings.timeout/6, function () {
					var current_button = $(settings.buttons).children(".sliding-buttons-list").children("li").children(".sliding-button-selected");
					var next_button = $(current_button).parent().next().children(".sliding-button-loaded");
					$(current_button).removeClass("sliding-button-selected");

					if (!$(next_button).text()) {
						next_button = $(settings.buttons).children(".sliding-buttons-list").children("li:eq(0)").children(".sliding-button-loaded");
					}
					$(next_button).addClass("sliding-button-selected");
					
					$(next).fadeIn(settings.timeout/6, function () {
						$(next).children("div").slideDown(settings.timeout/24);
						
						afterslide(slider, settings, next);
						
					});
				});
			});
		
		} else {
			
			$(current).fadeOut(settings.timeout/6, function () {
				var current_button = $(settings.buttons).children(".sliding-buttons-list").children("li").children(".sliding-button-selected");
	        	var next_button = $(current_button).parent().next().children(".sliding-button-loaded");
	        	$(current_button).removeClass("sliding-button-selected");
	        	if (!$(next_button).text()) {
	        		next_button = $(settings.buttons).children(".sliding-buttons-list").children("li:eq(0)").children(".sliding-button-loaded");
	        	}
	        	$(next_button).addClass("sliding-button-selected");
				
	        	$(next).fadeIn(settings.timeout/6, function () {

	        		$(next).children("div").slideDown(settings.timeout/24);
							
							afterslide(slider, settings, next);
				});
			});
		}
		
			
		
	}
		
	
	gotosleep = function (slider, settings) {
		var next = $(slider).children(".sliding-list").children(".sliding-slide:visible").next();

		if (!$(next).hasClass("sliding-slide")) {
			next = $(slider).children(".sliding-list").children(".sliding-slide:first");
		}
		
		var next_index = $(slider).children(".sliding-list").children(".sliding-slide").index(next);

		
		if (slider.loaded[next_index] == "1") {
			
			slider.timer = setTimeout(function(){
		    	slide(slider, settings);
		    },settings.timeout);
		} else {
			slider.timer = setTimeout(function(){
		    	gotosleep(slider, settings);
		    },settings.timeout/6);
		}
	};
	
	gotoslide = function (slider, settings,  id) {
	
		var current = $(slider).children(".sliding-list").children(".sliding-slide:visible");
		var next = $(slider).children(".sliding-list").children(".sliding-slide:eq("+id+")");
		
		var current_index = $(slider).children(".sliding-list").children(".sliding-slide").index(current);
		
		if ((current_index != id) && (slider.duringAnimation == 0)) { 
			if (settings.beforeSlide && settings.beforeSlide() === false) {
				return true;
			}
		
		
			clearInterval(slider.timer);
			slider.duringAnimation = 1;
			if ($(current).children("div").hasClass(".sliding-div")) {
				$(current).children(".sliding-div").slideUp(settings.timeout/24, function() {
					$(current).fadeOut(settings.timeout/6, function () {
						var current_button = $(settings.buttons).children(".sliding-buttons-list").children("li").children(".sliding-button-selected");
						var next_button = $(settings.buttons).children(".sliding-buttons-list").children("li:eq("+id+")").children(".sliding-button-loaded");
						$(current_button).removeClass("sliding-button-selected");
						$(next_button).addClass("sliding-button-selected");
						
						$(next).fadeIn(settings.timeout/6, function () {
							$(next).children("div").slideDown(settings.timeout/24);
						});
						
						afterslide(slider, settings, next);
					});
				});
			
			} else {
				
				$(current).fadeOut(settings.timeout/6, function () {
					var current_button = $(settings.buttons).children(".sliding-buttons-list").children("li").children(".sliding-button-selected");
					var next_button = $(settings.buttons).children(".sliding-buttons-list").children("li:eq("+id+")").children(".sliding-button-loaded");
					$(current_button).removeClass("sliding-button-selected");
					$(next_button).addClass("sliding-button-selected");
					
					$(next).fadeIn(settings.timeout/6, function () {
						$(next).children("div").slideDown(settings.timeout/24);
					});
					
					afterslide(slider, settings, next);
				});
			}
			
			
			
		}

		
	};
	
	afterslide = function (slider, settings,  next) {
		$(next).children("div").slideDown(settings.timeout/24);
							
		var next2 = $(next).next();
		if (!$(next2).hasClass("sliding-slide")) {

			if (settings.loop == false) {
				return true;
			}
			next2 = $(slider).children(".sliding-list").children(".sliding-slide:first");
		}
	
		var next_index2 = $(slider).children(".sliding-list").children(".sliding-slide").index(next2);
		
		if (slider.loaded[next_index2] == "1") {
			
			slider.timer = setTimeout(function(){
					slide(slider, settings);
				},settings.timeout);
		} else {
			slider.timer = setTimeout(function(){
					gotosleep(slider, settings);
				},settings.timeout/6);
		}
		
		slider.duringAnimation = 0;
		
		if (settings.afterSlide && settings.afterSlide() === false) {
			return true;
		}
	};
	
	
	
	$.fn.sliding.defaults = {
		// array of slides with optional link,target and div parameters
		// ex:
		// [
		// 		{
		//			pic: "http://www.server.com/image.jpg",
		//			[link: "http://www.server.com",]
		//			[target: "_blank"],
		//			[div: "<html>pic description</html>"
		// 		}
		// ]
		slides: [], 		
		// speed of slideshow (higher = slower)
		timeout: 10000,
		// if set to true, slideshow will play automatically
		slideshow: true,
		// if set to true, slideshop will loop to infinity
		loop: true,
		// callback function before slide animation; return false to abort
		beforeSlide: false,
		// callback function after slide animation
		afterSlide: false,
		// jQuery element identification for buttons container
		buttons: ".sliding-buttons",
		// Force to use HTML structure (slides.pic is still needed)
		forceHTML: false,
		// callback function if loading image error occurs
		error: false
    }; 
	
	
})(jQuery);


var xhr;

function get_cities() {
	var place = $("#InstitutionsPlace").val();
	xhr = $.post(baseUrl+"/institution_types/getcities/", {"place":place, "institution_type_id":'0'}, function (data) {
		$(".ajax-loader").hide();
		$(".gmapsx").hide();
		
		var select = $("#InstitutionsGmaps");
		select.html('');
	    $(data).each(function(i) {
	    	select.append('<option value="'+this.id+'"'+( (this.name==place) ? ' selected="selected"' : '' )+'>'+this.name+'</option>');
	    });
	    select_city();
	    
	},
	"json");
}

function select_city() {

	$("#ranking").html('');
	$(".ajax-loader",$("#ranking").parent()).show();

	if (null !== xhr) {
        xhr.abort();
        xhr = null;
    }

	var select = $("#InstitutionsGmaps");
	id = select.val();

	
	xhr = $.post(baseUrl+"/institutions/getbest/", {"id":id, "institution_type_id":'0', "limit":'9'}, function (data) {
		

		if (empty(data)) {
			$(".ajax-loader",$("#ranking").parent()).hide();
			$("#ranking").append('');	
		} else {
			
			$(data).each(function(i) {
	
				//adding institution on list
				if (this.rate == null) {
					this.rate = "0";
				}
	
				rate2 = Math.abs(this.rate);
				var points = "punktów";
				if (rate2 == '1') {
					points = "punkt";
				} else if (((rate2 % 100) > 10) && ((rate2 % 100) < 20)) {
					points = "punktów";
				} else if (((rate2 % 10) > 1) && ((rate2 % 10) <5) ) {
					points = "punkty";
				}
				
				if ( ( rate_str_length = this.rate.toString(10).length ) > 3) {
					rate_str_length = ' pts-' + rate_str_length;
				} else {
					rate_str_length='';
				}
				
				if (i == 0) {
					var addon = ' class="f"';
				} else {
					var addon = '';
				}
				html = '<li'+addon+'><div class="pts'+rate_str_length+'"><span>'+this.rate+'</span><em>'+points+'</em></div><h3><a href="'+baseUrl+'/'+this.name_p+'/'+slug(this.place)+'/'+slug(this.name)+','+this.id+'.html" title="'+this.name+'">'+this.name+'</a></h3><p>'+this.place+', '+this.street+'</p></li>';
				$(".ajax-loader",$("#ranking").parent()).hide();
				$("#ranking").append(html).show();
			});
	
			
		
		}
	    
	},
	"json");

}

//google.load("maps", "2");

$(document).ready(function() {

	
	/*$("#ali").sliding({
		slides: [
			{ 
				pic: baseUrl+"/img/sg_01.png"
			},
			{ 
				pic: baseUrl+"/img/sg_02.png"
			},
			{ 
				pic: baseUrl+"/img/sg_03.png"
			},
			{ 
				pic: baseUrl+"/img/sg_04.png"
			},
			{ 
				pic: baseUrl+"/img/sg_05.png"
			},
			{ 
				pic: baseUrl+"/img/sg_06.png"
			},
			{ 
				pic: baseUrl+"/img/sg_07.png"
			},
			{ 
				pic: baseUrl+"/img/sg_08.png"
			}
		],
		timeout: 5000
	});*/

	$("#InstitutionsPlace").autocomplete(baseUrl+"/users/places", { scroll: true } );
	$("#InstitutionsPlace").result(function(event, data, formatted) {
    	get_cities(); 
    });

	if (google.loader.ClientLocation) {
		var cl = google.loader.ClientLocation;
		var latitude = cl.latitude;
		var longitude = cl.longitude;
	} else {
		var latitude = 52.229797;
		var longitude = 21.011524;
		
	}
	
	xhr = $.post(baseUrl+"/institution_types/getcities/", {"x":latitude,"y":longitude, "institution_type_id":'0'}, function (data) {
		var select = $("#InstitutionsGmaps");
		select.html('');
	    $(data).each(function(i) {
	    	select.append("<option value="+this.id+">"+this.name+"</option>");
	    });
	    select_city();
	    
	},
	"json");
	
	$("#ari--").bind('click',function () {
		var current = $("#ari- ul:visible");
		var next = $(current).next();
		if (next.length==0) next = $("#ari- .f");
		$(current).hide("slide", { direction: "left" }, 200, function(){
			$(next).show("slide", { direction: "right" }, 200);
		});
		return false;
	});
	
});