$(document).ready(function(){

	/* Main Menu */
	$("div.menu_item").mouseenter(function() {
		$('div.menu_item').removeClass('menu_item_h');
		$(this).addClass('menu_item_h');
		$(this).children(".menu_item_drop").css('display', 'block');
		//$(this).children(".menu_item_drop").fadeIn(200);

	});
	$("div.menu_item").mouseleave(function() {
		$('div.menu_item').removeClass('menu_item_h');
		$(this).children(".menu_item_drop").css('display', 'none');
		//$(this).children(".menu_item_drop").fadeOut(200);
	});

	/* Slider */
	if($('#slider').length>0){
		$('#slider').cycle({
			fx:      'fade',
			speed:	 850,
			timeout: 8000,
			pager:   '#slidePages',
			cleartypeNoBg:true
		});
	}

	if($('#city_attractions').length>0){
		$('#city_attractions').cycle({
			fx:      'scrollHorz',
			speed:	 1500,
			timeout: 30000,
			pager:   '#city_acttractions_pages',
			cleartypeNoBg:true,
			before: function(currSlideElement, nextSlideElement, options, forwardFlag) {
				$('#city_acttractions_pages a').css('color','#000000');

			    var offset = parseInt((options.nextSlide >= 9) ? 3 : 0);

			    $('#pages_marker').animate({
					left: (options.nextSlide * $('#city_acttractions_pages a').outerWidth()) + offset
				}, options.speed);
			},
			after: function(currSlideElement, nextSlideElement, options, forwardFlag) {
				$('#city_acttractions_pages a.activeSlide').animate({
					color: '#ffffff'
				}, 200);
			}

		});

		$("#city_acttractions_pages a:last-child").css({border: 0});
	}

	CalendarEventLoad();

});

/* Calendar event loadinig */
function CalendarEventLoad(){

	$("table.calendar a.calendarLnik").mouseenter(function() {
		$(this).tinyTips('show', '');
		var date = $(this).attr('rel');
		$.post("ajax.php", {
			 action: 'loadCalendarEvents',
			 args:[date]
			},
			 function(data) {
				if(data != ''){
					$('.tinyTip .content').html(data);
				} else {
					$('.tinyTip .content').html('Brak wydarzeń');
				}
			 }
		);
	});
	$("table.calendar a.calendarLnik").mouseleave(function() {
		$(this).tinyTips('hide');
	});
}


