﻿// JScript File
function openAppunti() {
    var modalNew = window.open("/preferiti.aspx", "world", "scrollbars=1,height=450,width=550,resizable=yes,status=yes,toolbar=no,menubar=no,location=no")
    modalNew.focus();
}
function popup(strUrl) {
    var w = window.open(strUrl, "popup", "width=550,height=450,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
    w.document.focus();
}
function openpopup(strUrl) {
    var w = window.open(strUrl, "popup", "width=550,height=450,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
    w.document.focus();
}

function clearField(fieldName) {
    var field = document.getElementById(fieldName)
    if (field != null)
        field.value = "";
}

$('document').ready(function () {
    $('.contentGallery').cycle({
        fx: 'fade',
        delay: 1000,
        speed: 1000,
        sync: 1
    });
});

function EnsureCalendarFields(id) {
    var selector = (id) ? ('#' + id) : '';
    selector += " .fieldcalendar";
    var dates = $(selector).datepicker({
    	defaultDate: "+0d",
    	changeMonth: true,
    	changeYear: true,
    	dateFormat: "dd/mm/yy",
    	minDate: $(new Date()) + 0,
    	onSelect: function (selectedDate) {
    		var option = $(this).hasClass("date-from-fieldcalendar") ? "minDate" : "maxDate";
    		instance = $(this).data("datepicker");
    		date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings);
    		if (option == "minDate")
    			date.setDate(date.getDate() + 2);
    		else
    			date.setDate(date.getDate() - 0);
    		dates.not(this).datepicker("option", option, date);
    		$(".SeachOptionsBtnChange").click();
    	}
    });
}

function EnsureOpenCloseAreas() {
    $(document).ready(function () {
        $(".open-area-cmd").click(function () {
            var header = $(this).closest(".area-header")
            header.next(".area-detail").show();
            header.hide();
        })

        $(".close-area-cmd").click(function () {
            var detail = $(this).closest(".area-detail")
            detail.prev(".area-header").show();
            detail.hide();
        })

        EnsureBookingBtns();
    });
}

function EnsureBookingBtns() {    
    $(".bookstay").click(function () {
        $(this).slideUp('1500');
    })
}

function ParseScript(control) {
	if (!control) { return; }
	for (var n = 0; n < control.children.length; n++) {
		if (control.children[n].tagName.toLowerCase() == 'script') {
			eval(control.children[n].innerHTML);
		} else {
			ParseScript(control.children[n]);
		}
	}
}
