$(function(){
	$('.slider, .front-slider').tabs('.images > div', {

		// enable "cross-fading" effect
		effect: 'fade',
		fadeInSpeed: 1000,
		fadeOutSpeed: 1000,

		// start from the beginning after the last tab
		rotate: true

	// use the slideshow plugin. It accepts its own configuration
	}).slideshow({
		autoplay: true,
		interval: 5000
	});
	
	if($('#text .find-coffee-shop .selected-city li').hasClass('current_page_item'))
		$('#text .find-coffee-shop .selected-city li.current_page_item').addClass('selected')
	else
		$('#text .find-coffee-shop .selected-city li').eq(0).addClass('selected');
	
	var select_city = $('#text .find-coffee-shop .selected-city').clone();
	
	select_city
		.removeClass('selected-city')
		.addClass('select-city')
		.insertAfter('#text .find-coffee-shop .selected-city');
	
	$('#text .find-coffee-shop .select a').click(function(){
		$('#text .find-coffee-shop .select-city').slideToggle('fast');
		
		if($(this).parents('ul').hasClass('select-city'))
		{
			$('#text .find-coffee-shop .select li').removeClass('selected')
			
			
			$('#text .find-coffee-shop .selected-city li').eq($(this).parents('ul').find('a').index(this)).addClass('selected')
			$(this).parents('li').addClass('selected');
			
		}
		
		return false;
	})
	
	$('#text .find-coffee-shop .select').click(function(){
		$('#text .find-coffee-shop .select-city').slideToggle('fast');
	})
	
	$('.find-coffee-shop .button a').click(function(){
		window.location = $('.find-coffee-shop .selected a').eq(0).attr('href');
		return false;
	})
	
	$('#footer .search input.text')
		.click(function(){
			if($(this).val() == $(this).attr('title'))
				$(this).val('');
		})
		.blur(function(){
			if($(this).val() == '')
				$(this).val($(this).attr('title'));
		})
	
	$.datepicker.setDefaults($.datepicker.regional['fi']);
	
	$('input.datepicker').datepicker({
		minDate: 0,
		dateFormat: 'dd.mm.yy'
	});
	
	$('#happy-day-form').validate();
});
