/******************************************************************************************************************/
// TABS HANDLE
/******************************************************************************************************************/

function handleTabs(){
	$('.tabs .tab').hide();
	
	$('.tabs .sel').each(function(){
		initid = $(this).find('a').attr('href');
		$(initid).show();
	});
	
	$('.tabs .labels a').click(function(){
		$(this).parents('.labels').find('li').removeClass('sel');
		$(this).parent().addClass('sel');
		
		myid = $(this).attr('href');
		
		$(this).parents('.tabs').find('.tab').hide();
		$(myid).show();
		
		return false;
	});
}

/******************************************************************************************************************/
// On document load...
/******************************************************************************************************************/

$(function(){
	// nivo slider
	$('#slider').nivoSlider({
		effect: 'sliceDown',
		slices: 15,
		animSpeed: 1500,
		pauseTime: 5000,
		directionNav: false,
		directionNavHide: false,
		controlNav: false,
		pauseOnHover: false
	});

	//fancybox
	$('.fancybox').fancybox();	
	$('.iframe').fancybox({
		'width': 800,
		'height': 550
	});	

	// tabs
	handleTabs();
	
	// datepicker
	$('.datepick').datepicker({ 
		showOn: 'both',
		buttonImage: '/wp-content/themes/gerico/images/icon-calendar.gif',
		buttonImageOnly: true,
		monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
		dayNamesMin: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'],
		dateFormat: 'dd/mm/yy',
		currentText: 'Oggi'
	});
	
	// validation
	$('#frm-dates').validate({
		rules: {
			datefrom: { required: true },
			dateto: { required: true },
			persone: { required: true }
		},
		messages: {
			datefrom: '&uarr; inserire una data',
			dateto: '&uarr; inserire una data',
			persone: '&uarr; inserire un numero'
		}
	});

	$('.myform form').validate({
		rules: {
			nome: { required: true },
			email: { required: true },
			citta: { required: true },
			tel: { required: true },
			message: { required: true }
		},
		messages: {
			nome: '&uarr; campo obbligatorio',
			email: '&uarr; campo obbligatorio',
			citta: '&uarr; campo obbligatorio',
			tel: '&uarr; campo obbligatorio',
			message: '&uarr; campo obbligatorio'
		}
	});

});
