function y_init() { Event.observe(document.onresize ? document : window, "resize", y_adjust_layout); y_adjust_layout(); y_init_cal(); } function y_adjust_layout() { var viewportWidth = document.viewport.getWidth(); var links = $('ylinks'); if (links == undefined) { return; } var params = {}; if (page == 'search') { params['top'] = '190px'; } else if (page == 'detail') { params['top'] = '150px'; } var linksWidth = links.getWidth(); var leftPos = viewportWidth - linksWidth; params['left'] = leftPos + 'px'; links.setStyle(params); } function y_init_cal() { if ($('data_arrivo') != undefined) { Calendar.setup({ trigger : "data_arrivo", inputField : "data_arrivo", dateFormat : "%m/%d/%Y", disabled: function(date) { if (date == undefined) return false; var asString = Calendar.printDate(date, '%Y-%m-%d'); return asString < '2010-08-01'; }, onSelect : function() { var date = this.selection.get(); date = Calendar.intToDate(date); date = Calendar.printDate(date, "%Y-%m-%d"); $("arrivo").value = date; this.hide(); } }); } if ($('data_partenza') != undefined) { Calendar.setup({ trigger : "data_partenza", inputField : "data_partenza", dateFormat : "%m/%d/%Y", disabled: function(date) { if (date == undefined) return false; var asString = Calendar.printDate(date, '%Y-%m-%d'); return asString < '2010-08-01'; }, onSelect : function() { var date = this.selection.get(); date = Calendar.intToDate(date); date = Calendar.printDate(date, "%Y-%m-%d"); $("partenza").value = date; this.hide(); } }); } } var PhotoGallery = { create: function(id, images) { this.current = 0; this.id = id; this.images = images; $('foto').src = 'office/album/large500/' + this.id + "/" + images[0]; }, next: function() { if ((this.images.length - 1) > this.current) { this.current++; } else { this.current = 0; } $('foto').src = 'office/album/large500/' + this.id + "/" + this.images[this.current]; }, prev: function() { if (this.current > 0) { this.current--; } else { this.current = this.images.length - 1; } $('foto').src = 'office/album/large500/' + this.id + "/" + this.images[this.current]; }, goto: function(p) { if (p >= 0 && p < this.images.length) { this.current = p; $('foto').src = 'office/album/large500/' + this.id + "/" + this.images[this.current]; } } }; function y_search_by_name() { $('name-search').show(); $('adv-search').hide(); } function y_search_advanced() { $('name-search').hide(); $('adv-search').show(); } function y_check_email(email) { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; return reg.test(email); } function y_check_book() { var text = ""; if ($('nome').getValue().blank()) { text += "* Name is missing\n"; } if ($('cognome').getValue().blank()) { text += "* Surname is missing\n"; } if ($('regione').getValue().blank()) { text += "* Country is missing\n"; } if ($('email').getValue().blank()) { text += "* Email is missing\n"; } else if (!y_check_email($('email').getValue())) { text += "* Email not valid\n"; } if ($('telefono').getValue().blank()) { text += "* Phone number is missing\n"; } if (!text.empty()) { alert(text); return false; } if ($('consenso').getValue() != 'on') { alert('* Accept Term and Condition'); return false; } return true; } function y_check_contactus() { var text = ""; if ($('email').getValue().blank()) { text += "* Email is missing\n"; } else if (!y_check_email($('email').getValue())) { text += "* Email not valid\n"; } if (!text.empty()) { alert(text); return false; } return true; }