if (typeof $ == 'undefined') {}
else{
    //var JNC_$ = $.noConflict();
    jQuery(document).ready(function($) {



		/*n*/


			$("#contactLink").click(function(){
				$("#contactForm").slideToggle("slow");
			});

			$("input#email").focus(function () {
				  $("input#email").removeClass("mandatory").addClass("ok");
				  $("label#email").removeClass("mandatory").addClass("ok");
			});
			$("input#email").blur(function() {
				if (this.value == ''){
					this.value = (this.defaultValue ? this.defaultValue : '');
					$(this).removeClass("ok").addClass("mandatory");
					$("label#email").removeClass("ok").addClass("mandatory");
				}
			});
			$("#privacy").click(function(){
				if ($("#privacy").is(":checked")){
					$("#privacy").removeClass("unchecked").addClass("checked");
				}
				else{
					$("#privacy").removeClass("checked").addClass("unchecked");
				}
			});


		/*function closeForm(){
		   $("#messageSent").show("slow");
		   setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 2000);
		}*/

		window.validateSign = function(f){
			var espressione = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
			var email=f.email.value;
			if(!espressione.test(email)){
				alert("Indirizzo email non valido");
				return false;
			}

			if(!f.privacy.checked){
				alert("Per favore, compila tutti i campi obbligatori");
				return false;
			}
			//closeForm();
		}

		/*endn*/

        $.datepicker.setDefaults( {
            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',
            dateFormat: 'dd/mm/yy',
            firstDay: 1,
            isRTL: false,
            showMonthAfterYear: false,
            yearSuffix: ''
        });
        
        $('#arrDate').datepicker({
            dateFormat: 'dd-mm-yy',
            defaultDate: 2,
            minDate: 0,
            hideIfNoPrevNext: true
        });
        var d2 = new Date();
        d2.setDate(d2.getDate());
        $('#arrDate').val($.datepicker.formatDate('dd-mm-yy', d2));
        $('#arrDate').change(function() {
            var arr = $.datepicker.parseDate("dd-mm-yy", $('#arrDate').val());
            /*arr = new Date( arr.getFullYear(), arr.getMonth(), arr.getDate()+1 ); */
            arr.setDate(arr.getDate() + 1);
            $('#depDate').val($.datepicker.formatDate('dd-mm-yy', arr));
        });

        $('#depDate').datepicker({
            dateFormat: 'dd-mm-yy',
            defaultDate: null,
            minDate: 1,
            hideIfNoPrevNext: true
        });
        var d1 = new Date();
        d1.setDate(d1.getDate() + 1);
        $('#depDate').val($.datepicker.formatDate('dd-mm-yy', d1));
        $('.a2').attr('disabled', 'disabled');
        $('#numRooms').change(function() {
            var nr = parseInt($('#numRooms option:selected').attr('value'));
            $('.a2').attr('disabled', '');
            $('.a' + (nr + 1)).attr('disabled', 'disabled');
        });
        
        var nr = parseInt($('#numRooms option:selected').attr('value'));
        $('.a2').attr('disabled', '');
        $('.a' + (nr + 1)).attr('disabled', 'disabled');
        $('#prenotazione').submit(function() {
            var dep = $.datepicker.parseDate("dd-mm-yy", $('#depDate').val());
            var arr = $.datepicker.parseDate("dd-mm-yy", $('#arrDate').val());
            if (dep.getTime() < arr.getTime()) {
                alert("La data di partenza non può precedere quella di arrivo");
                return false;
            }
            var h = $('#hotel').val();
            if (h == '--') {
                alert("Selezionare un hotel per procedere");
                return false;
            }
            return true;
        });

        var menuitems = $('div#colonna1 > .moduletable > ul.menu > li, div#colonna2 > .moduletable > ul.menu > li');
        
        menuitems.each(function(){
            if($(this).attr('class') == 'item66' || $(this).attr('class') == 'item67')
                $(this).children('a > span').css('font-size', '16px');
        });


        menuitems.hover(function(){
            $(this).children('a > span').css('color', '#fff');
        }, function(){
            $(this).children('a > span').css('color', '#000');
        });

    
        $('.weekend').click(function(){
            $('#weekend').show();
            $('#anticipo').hide();
            $('.box-puntodidomanda').hide();
            return false;
        });

        $('.anticipo').click(function(){
            $('#anticipo').show();
            $('#weekend').hide();
            $('.box-puntodidomanda').hide();
            return false;
        });

        $('.puntodomandaform').click(function(){
			$('.box-puntodidomanda').show();
            $('#anticipo').hide();
            $('#weekend').hide();
            return false;
        });

        $('#chiudiweekend').click(function(){
           $('#weekend').hide();
           return false;
        });

        $('#chiudianticipo').click(function(){
           $('#anticipo').hide();
           return false;
        });

        $('#chiudipuntodomandaform').click(function(){
           $('.box-puntodidomanda').hide();
           return false;
        });
	});
	
    /*function testPop() {
        var popup = new Liferay.Popup ({
            header: 'Codice promozionale', 
            modal: false,
            width: 350,
            height: 200,
            xy: ['center', 100]
        });
        popup.html("<div style='padding:0px 20px'><h1>Codice promozionale</h1><p>Se sei in possesso di un codice promozionale, inseriscilo in questo punto della prenotazione per usufruire degli esclusivi vantaggi.<p></div>"); /*Vuoi sapere come ottenere un codice promozionale? Clicca qui */
    /*}

    function ModifyPop() {
        var popup = new Liferay.Popup ({
            header: 'Modifica Prenotazione', 
            modal: false,
            width: 350,
            height: 200,
            xy: ['center', 100]
        });
        popup.html("<div style='padding:0px 20px'><h1>Modifica Prenotazioni</h1><p>Per la modifica di prenotazioni già effettuate si prega di contattare direttamente l'Hotel, preferibilmente via email. <br> <br><a href='http://www.ideahotel.it/web/guest/tutte-le-citta'>Vai all'elenco contatti degli Hotel </a><p></div>");
    }*/
}
