$(document).ready(function(){
	
	// ColorBox event to elements
	$("a[rel='example1']").colorbox({transition:"fade"});
	
	// Example of preserving a JavaScript event for inline calls.
	$("#click").click(function(){ 
		$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		return false;
	});
	
	// codice ema
	//menu
	$(".sottolista").hide();
	$(".menu_location").click(function(){
		// $("[figlio="+$(this).attr("id")+"]").toggle("slow");
		$("[figlio="+$(this).attr("id")+"]").slideToggle("fast");
	});
	
	// Tabs schede hotel
	$(".tab2").removeClass("tabAttivo");
	$(".tab").click(function(){
		$(".tab").removeClass("activeTab");
		$(this).addClass("activeTab");
		$(".scheda").removeClass("tabAttivo");
		$("."+$(this).attr("scheda")).addClass("tabAttivo");
	});
	
	// Contatti Form
	var partenza = $("#location").val() + "";
	var cliccate = partenza.split("|");
	for (i in cliccate){
		var id = cliccate[i].split(":");
		$("[id_location="+id[0]+"]").addClass("selezionato");
	}
	$(".location-select").click(function(){
		var elemento = ""+$(this).attr("id_location")+": "+$(this).children(".location-citta").html() + ', ' + $(this).children(".location-nome").html() + '|';
		var valore_corrente = $("#location").val() + "";
		if($(this).hasClass("selezionato")){
			$(this).removeClass("selezionato");
			valore_corrente = valore_corrente.replace(elemento,"");
		}else{
			$(this).addClass("selezionato");
			valore_corrente += elemento;
		}
		$("#location").val(valore_corrente);
	});
	// Datepicker x Contatti
	$( "body.it #data-matrimonio" ).datepicker({
		closeText: 'Chiudi',
		prevText: '&#x3c;Prec',
		nextText: 'Succ&#x3e;',
		currentText: 'Oggi',
		monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno',
			'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
		monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu',
			'Lug','Ago','Set','Ott','Nov','Dic'],
		dayNames: ['Domenica','Luned&#236','Marted&#236','Mercoled&#236','Gioved&#236','Venerd&#236','Sabato'],
		dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'],
		dayNamesMin: ['Do','Lu','Ma','Me','Gi','Ve','Sa'],
		weekHeader: 'Sm',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: '',
		dateFormat: 'dd/mm/yy'
	});
	$( "body.en #data-matrimonio" ).datepicker({
		dateFormat: 'dd/mm/yy'
	});
});
