jQuery(function() {
		
		$("#slides").slideshow({
				elems: "> .slide",
				nums: "> ul.n",
				speed: 1000,
				interval: 10000
		})
		$("#slides2").slideshow({
				elems: "> .slide",
				nums: "> ul.n",
				speed: 1500,
				interval: 3500
		})
		
		
		
		
		$(document).ready(function(){
				$(document).pngFix();
				$("div.gallery-box .big-foto a").fancybox({
					transitionIn: 'fade',
					transitionOut: 'fade',
					titlePosition: 'over',
					zoomOpacity: true,
					overlayShow: true,
					zoomSpeedIn: 500,
					zoomSpeedOut: 500,
					autoScale: false
				});
				$("a.zoom").fancybox({
					transitionIn: 'fade',
					transitionOut: 'fade',
					titlePosition: 'over',
					zoomOpacity: true,
					overlayShow: true,
					zoomSpeedIn: 500,
					zoomSpeedOut: 500,
					autoScale: false
				});
				$("a.ask-btn").fancybox({
					transitionIn: 'fade',
					type: 'iframe',
					transitionOut: 'fade',
					titleShow: 'false',
					zoomOpacity: true,
					overlayShow: true,
					zoomSpeedIn: 500,
					zoomSpeedOut: 500,
					width: 470,
					height: 550,
					autoScale: false
				});
				
				 $('.piko-icon img').each(function () {
				 		 $(this).css({
								position:'relative',
								left: ($('.piko-icon').width() - $(this).outerWidth())/2,
								top: 0
						 });
				 });

				
				
		});

    $("form.search input.query").focus(function () {
         $(this).attr("value","");
    });
			
		if ($.browser.msie) {
			$("tr:first-child, td:first-child, th:first-child").addClass("first-child")
			$("tr:last-child, td:last-child, th:last-child").addClass("last-child")
			//$("li:first-child").addClass("first-child")
			//$("li:last-child").addClass("last-child")
			if (parseInt($.browser.version) <= 6) {
				
			}
		}
		$("li:first-child").addClass("first-child")
		$("li:last-child").addClass("last-child")
});


(function($) {
	$.fn.slideshow = function (opt) {
		return this.each(function () {
			var interval = null
			var $this = $(this);
			var elems = $this.find(opt.elems);
			var nums = $this.find(opt.nums);

			if (elems.length < 2) return;
			elems.hide().css({ position: "absolute", top: 0, left: 0 }).addClass("slide")
			     .eq(0).show().addClass("current");
			nums.find("li:first a").addClass("current");

			function switchTo(elem) {
				elems.filter(".current").fadeOut(opt.speed);
				elems.removeClass("current")
				elem.addClass("current").fadeIn(opt.speed);
				nums.find("li a")
					.removeClass("current")
					.filter(function() {
						return $(this).attr("href") == "#" + elem.attr("id")
					})
					.addClass("current")
			}
			function next() {
				var e = elems.filter(".current");
				if (e.next().is(".slide"))
					switchTo(e.next());
				else
					switchTo(elems.filter(":first"));
			}
			function prev() {
				var e = elems.filter(":visible");
				if (e.prev().is(".slide"))
					switchTo(e.prev());
				else
					switchTo(elems.filter(":last"));
			}
			nums.find("li a").click(function() {
				if (interval) clearInterval(interval)
				switchTo($($(this).attr("href")))
				return false
			});
			interval = setInterval(next, opt.interval)
		})
	}
})(jQuery);

