$(document).ready(function(){
	
	// apro il box per fare il login
	$('.loginbox').toggle(
		function() {
			$('#loginbox').animate({height:'toggle',opacity:'toggle'},250)
			$('.select_lang').hide()
		},
		function() {
			$('#loginbox').animate({height:'toggle',opacity:'toggle'},100)
			$('.select_lang').hide()
		}
	)
	
	// nascondo i valori dei campi al click del mouse
	$('#loginbox input[type=text],#loginbox input[type=password]').click(function(){
		$(this).val('')
	})
	
	// apro il box per fare scegliere la lingua
	$('.current_lang span').toggle(
		function() {
			$('.select_lang').animate({height:'toggle',opacity:'toggle'},250)
			$('#loginbox').hide()
		},
		function() {
			$('.select_lang').animate({height:'toggle',opacity:'toggle'},150)
			$('#loginbox').hide()
		}
	)
	
	$('.navi li').hover(
		function() {
			$('ul',this).animate({height:'toggle',opacity:'toggle'})
		},
		function() {
			$('ul',this).hide()
		}
	)

$("a.fancybox").fancybox({
    'overlayShow': true,    'transitionIn': 'fade',    'transitionOut': 'fade',    'centerOnScroll': true});
	
	$( "#datepicker" ).datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd-mm-yy'
	})
	
	$('#tab_lista_partite').click(function(){
		$('#cerca_partite').hide()
		$('#lista_partite').fadeIn()
	})
	
	$('#tab_cerca_partite').click(function(){
		$('#lista_partite').hide()
		$('#cerca_partite').fadeIn()
	})
	
	var dates = $( "#from, #to" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 3,
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
		
	
	
})
