jNoLogin = true // AJAX login begin window.enabled = false; var xmlHttp = null; var session = 0; function initRequest(url) { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } } function showElement(id, show) { var elem = document.getElementById(id); elem.style.visibility = show ? 'visible' : 'hidden'; } function setElementValue(id, html) { var element = document.getElementById(id); if(element==null){ alert("Element " + id + " is undefined!!!"); } document.getElementById(id).innerHTML = html; } function updateCalendar(dateFrom, dateTo, nights) { document.FHOTEL.COMBO_INIZIOMM_AA.value = dateFrom; document.FHOTEL.combo_finemm_aa.value = dateTo; init_combo_day(document.FHOTEL, "dd/mm/yyyy","Lun,Mar,Mer,Gio,Ven,Sab,Dom","gen,feb,mar,apr,mag,giu,lug,ago,set,ott,nov,dic" ); document.FHOTEL.COMBO_GIORNI.selectedIndex = nights - 1; } function processDoLoginResponse() { if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") { var response = xmlHttp.responseText.replace(/\s+$|^\s+|\n|\t/g, ""); //alert(response); if (response.indexOf("") != -1) { document.getElementById("nation").options[0].text = ""; //alert("cookie support disabled!"); } else { setElementValue("comboNationsSpan", contenutoTag(response, "nations")); setElementValue("comboNightsSpan", contenutoTag(response, "nights")); //alert(contenutoTag(response, "zone")); setElementValue("zoneSpan", contenutoTag(response, "zone")); setElementValue("prezziSpan", contenutoTag(response, "prezzi")); session = parseInt(contenutoTag(response, "session")); maxRooms = parseInt(contenutoTag(response, "maxRooms")); maxPaxRoom = parseInt(contenutoTag(response, "maxPaxRoom")); maxNights = parseInt(contenutoTag(response, "maxNights")); maxTotParticipant = parseInt(contenutoTag(response, "maxPax")); checkInFrom = contenutoTag(response, "dateFrom"); checkInTo = contenutoTag(response, "dateTo"); dateNights = contenutoTag(response, "dateNights"); updateCalendar(checkInFrom, checkInTo, dateNights); initRoomCombos(maxRooms, maxPaxRoom); initBestList(checkInFrom, checkInTo, maxRooms, maxPaxRoom, maxTotParticipant); //showElement("combo_cam", true); //showElement("layer_combo_date", true); disableControls(false); jNoLogin = false; } } } function doLogin() { var url="/cs/ContentServer?pagename=BoscoloB2CSite%2FPage%2FB2B%2FCommon%2FStandalone%2FAjaxLogin&country=GB&id=" + Math.random(); xmlHttp = initRequest(url); xmlHttp.onreadystatechange=processDoLoginResponse; xmlHttp.open("GET", url, true); xmlHttp.send(null); } function disableControls(status) { document.getElementById("nation").disabled = status; document.getElementById("selectDestination").disabled = status; document.getElementById("COMBO_GIORNI").disabled = status; document.getElementById("zona").disabled = status; document.getElementById("destination").disabled = status; window.enabled = !status; // if (window.enabled || 'nologin'=='false') { // document.getElementById("imageFind").innerHTML = document.getElementById("realFind").innerHTML; // document.getElementById("realFind").innerHTML=""; // } } function initBestList(checkInFrom, checkInTo, maxRooms, maxPax, maxNights) { blCheckInFrom = checkInFrom; blCheckInTo = checkInTo; blMaxRooms = maxRooms; blMaxPax = maxPax; blMaxNights = maxNights; } function initRoomCombos(maxRooms, maxPaxRoom) { i_c ('numero','htlprn','htlprn_title','htlprn_bmb','htlprn_bmb_title'); i_l_c("Camere","Camera","Adulti:","Bambini:","matrimoniale
(solo segnalazione)","Doppia uso singola","Età ","
Specificate l'età dei bambini al momento del viaggio. Potrebbero essere previsti sconti."); i_v_c(1, maxRooms, 1, maxPaxRoom, 0, maxPaxRoom + 1, 1); i_a(2); agg(); arrSave(); } function isAlreadyLogged() { return session != 0; } function openPopUpVG() { } function columnLayoutInit() { //alert("columnLayoutInitLOG"); //cancellaCodiceLocalita(); //inizializza(); doLogin(); //fix bottone di ricerca //document.getElementById("imageFind").innerHTML = document.getElementById("realFind").innerHTML; //document.getElementById("realFind").innerHTML=""; } // AJAX login end var timerid = null; var matchStringNation = ""; var matchStringDestination = ""; var millisecondi = 1000; var rigaCorrente = 0; var numeroRighe = 0; var array_des_localita = new Array(); var array_cod_localita = new Array(); var array_des_nazione = new Array(); var currentFieldNameDes = ""; var currentFieldNameCode = ""; var currentDivName = ""; var currentSpanName = ""; function resettaArray() { //alert("resettaArray()"); array_des_localita = new Array(); array_cod_localita = new Array(); currentFieldNameDes = ""; currentFieldNameCode = ""; currentDivName = ""; currentSpanName = ""; } function aggiornaComboNation(keyCode,targ) { //alert("aggiornaComboNation - " + keyCode + " matchStringNation=" + matchStringNation); keyVal = String.fromCharCode(keyCode); matchStringNation = matchStringNation + keyVal; elementCnt = targ.length - 1; for (var i = 0; i < elementCnt; i++) { selectText = targ.options[i].text.toLowerCase(); if (selectText.substr(0,matchStringNation.length) == matchStringNation.toLowerCase()) { targ.options[i].selected = true; caricaLocations(targ); break; } } clearTimeout(timerid); timerid = setTimeout("matchStringNation=''",millisecondi); return false; } function aggiornaComboDestination(keyCode,targ) { //alert("aggiornaComboDestination - " + keyCode + " matchStringDestination=" + matchStringDestination); keyVal = String.fromCharCode(keyCode); matchStringDestination = matchStringDestination + keyVal; elementCnt = targ.length - 1; for (var i = 0; i < elementCnt; i++) { selectText = targ.options[i].text.toLowerCase(); if (selectText.substr(0,matchStringDestination.length) == matchStringDestination.toLowerCase()) { targ.options[i].selected = true; insertDestination(targ.options[i].value,targ.options[i].text); break; } } clearTimeout(timerid); timerid = setTimeout("matchStringDestination=''",millisecondi); return false; } function noenter(event) { try { if(event.keyCode == 13) { return false; } }catch(e){} } var req; var url=""; var locationsCounter=0; var cities=""; var maxTotParticipant = 0; function checkKey(event){ if (event.keyCode == 13) { //alert("jjs/searchhotel:: enter!!!"); submitFhotel(); return false; } } function submitFhotel() { //if ((!enabled && 'true'=='true')|| ('true'=='true')) return; //if (!enabled) return; if ((!enabled && jNoLogin)|| jNoLogin) return; popolaForm(); var d = document.FHOTEL; nCamere = d.combo_camere.value; totParticipant = 0; for (var i=1;i<=nCamere;i++){ totParticipant = totParticipant + parseInt(eval('d.combo_adulti'+i+'.value')) + parseInt(eval('d.combo_bambini'+i+'.value')); } if (totParticipant > maxTotParticipant) { alert('Numero massimo di partecipanti superato'); return; } if(!dateCoerenti(document.forms['FHOTEL'].COMBO_INIZIOMM_AA.value,document.forms['FHOTEL'].combo_finemm_aa.value)) { alert('Data Check-Out non ammessa'); return; } if (trim(document.forms['FHOTEL'].localityId.value) != '') { if(controllaEtaBambini()) { document.getElementById("Search").style.display="none" formsSubmit("hotelQueryGet",document.FHOTEL);toggleLink(this,""); document.forms['FHOTEL'].submit(); } else { alert("Specificate l'età dei bambini al momento del viaggio. Potrebbero essere previsti sconti."); //INS_ETA_BAMBINI } } else { alert("Digita la destinazione"); } } function popolaForm() { try { //alert("popolaForm()"); popolaServizio(); // alfano document.forms['FHOTEL'].nome.value=document.forms['FAGGIUNTIVI'].nome_agg.value; document.forms['FHOTEL'].price.value=document.forms['FAGGIUNTIVI'].price.value; document.forms['FHOTEL'].zona.value=document.forms['FAGGIUNTIVI'].zona.value; popolaStelle(); }catch(e){ alert(e)} } function cancellaCodiceLocalita() { try { document.forms['FHOTEL'].nation.value=""; document.forms['FHOTEL'].localityId.value=""; document.forms['FHOTEL'].destination.value=""; } catch(e){} } createCalendar('Chiudi'); function getElementY(element){ var targetTop = 0; if (element.offsetParent) { while (element.offsetParent) { targetTop += element.offsetTop; element = element.offsetParent; } } else if (element.y) { targetTop += element.y; } return targetTop; } function getElementX(element){ var targetLeft = 0; if (element.offsetParent) { while (element.offsetParent) { targetLeft += element.offsetLeft; element = element.offsetParent; } } else if (element.x) { targetLeft += element.x; } targetLeft += 139; return targetLeft; } function chiudiDiv(divName, spanName) { document.getElementById(divName).style.visibility='hidden'; document.getElementById(spanName).style.border='0px'; document.getElementById(spanName).style.borderStyle='none'; document.getElementById(spanName).style.backgroundColor='transparent'; document.getElementById(spanName).innerHTML=""; showSelect(); } function mostraDiv(innerHtml, messaggio, divName, spanName, fieldNameDes, fieldNameCode) { //alert("mostraDiv " + divName + " " + spanName); document.getElementById(divName).style.display='block'; var htmlSeleziona=creaTestataDiv(messaggio, divName, spanName, fieldNameDes, fieldNameCode); document.getElementById(spanName).innerHTML=htmlSeleziona + "
" + innerHtml; document.getElementById(spanName).style.visibility='visible'; document.getElementById(spanName).style.position='absolute'; document.getElementById(spanName).style.backgroundColor='#ffffff'; document.getElementById(spanName).style.width='220px'; document.getElementById(spanName).style.padding='3px'; document.getElementById(spanName).style.zIndex='10'; document.getElementById(spanName).style.border='3px'; document.getElementById(spanName).style.borderStyle='solid'; //document.getElementById(spanName).style.borderColor='#91BC2D'; prova per mirko document.getElementById(spanName).className="bordoDestinazioni"; hideSelect(); } function creaTestataDiv(messaggio, divName, spanName, fieldNameDes, fieldNameCode) { var html = "
"; html += ""; html += "" + messaggio + ""; html += ""; html += "
"; html += "
"; html += ""; html += "Chiudi "; html += ""; html += ""; html += "
"; html += "
"; return html; } function doCompletion(event) { //alert("doCompletion() " + event.keyCode); if(event.keyCode == 38) { //alert("su"); coloraRigaNumero(rigaCorrente - 1); } else if(event.keyCode == 40) { //alert("giu"); coloraRigaNumero(rigaCorrente + 1); } else if(event.keyCode == 13) { inserisciRiga(); } else { if(document.forms['FHOTEL'].destination.value == "") { chiudiDiv('destinationDiv','destinationSpan'); } else { if (document.forms['FHOTEL'].destination.value.length>2) { resettaArray(); url = "/cs/ContentServer?pagename=BoscoloB2CSite%2FPage%2FB2B%2FCommon%2FStandalone%2FAjaxLocalityPopUp&destination=" + document.forms['FHOTEL'].destination.value + "&pid=1268183547243"; //alert(url); mostraDiv("", 'Ricerca in corso ...', 'destinationDiv', 'destinationSpan', 'destination', 'localityId'); req = initRequest(url); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.status == 200) { //alert("rispostaLog: " + trim(req.responseText)) parsaCitta(trim(req.responseText), 'destinationSpan', 'destination', 'localityId', 'destinationDiv'); } else if(req.status == 204) { chiudiDiv('destinationDiv','destinationSpan'); hideSelect(); } } } req.open("GET", url, true); req.send(null); } } } } String.prototype.capitalize = function(){ //v1.0 return this.replace(/\w+/g, function(a){ return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase(); }); }; function parsaCitta(responseText,spanName,fieldNameDes,fieldNameCode,divName) { //alert("parsaCitta - responseText=" + responseText); numeroRighe = 0; var cities=contenutoTag(responseText,'cities'); var innerHtml = ""; var des_localita = ""; var des_nazione = ""; var cod_localita = ""; while(true) { var city=contenutoTag(cities,'city'); if(city=='') break; else { numeroRighe++; des_localita=contenutoTag(city,'des_localita'); des_nazione=contenutoTag(city,'des_nazione'); cod_localita=contenutoTag(city,'cod_localita'); desNazione = des_nazione.capitalize(); desNazione = desNazione.replace("'"," "); //alert("des_localitaLog: " + des_localita + ", des_nazioneLog: " +des_nazione); array_des_localita[numeroRighe] = des_localita; array_cod_localita[numeroRighe] = cod_localita; array_des_nazione[numeroRighe] = desNazione; currentFieldNameDes = fieldNameDes; currentFieldNameCode= fieldNameCode; currentDivName = divName; currentSpanName = spanName; innerHtml += ""; cities=sottraiTag(cities,'city'); primaLocalita = false; } } innerHtml += "
" + des_localita + ", " + desNazione + "
" if(numeroRighe == 0) innerHtml = 'Nessuna destinazione reperita'; //"Nessuna destinazione reperita"; //alert(innerHtml); mostraDiv(innerHtml, 'Scegli', divName, spanName, fieldNameDes, fieldNameCode); if(numeroRighe>0) { rigaCorrente=1; coloraRigaNumero(rigaCorrente); } } function inserisci(fieldNameDes, fieldNameCode, destinationDes, destinationCode, divName, spanName) { //alert("inserisci"); document.forms['FHOTEL'].elements[fieldNameDes].value=destinationDes; document.forms['FHOTEL'].elements[fieldNameCode].value=destinationCode; document.forms['FHOTEL'].freeSearch.value='S'; chiudiDiv(divName,spanName); } function coloraRigaNumero(numeroRiga) { //alert("coloraRigaNumero() - " + numeroRiga); try { if(numeroRiga >=1 && numeroRiga <= numeroRighe) { rigaCorrente = numeroRiga; coloraRiga(rigaCorrente); } }catch(e){} } function inserisciRiga() { //alert("inserisciRiga() rigaCorrente=" + rigaCorrente); if(rigaCorrente>0) { //document.getElementById('rowPopUp' + rigaCorrente).click(); //alert(array_des_localita[rigaCorrente]); //alert(array_cod_localita[rigaCorrente]); inserisci(currentFieldNameDes, currentFieldNameCode, array_des_localita[rigaCorrente] + ", " + array_des_nazione[rigaCorrente], array_cod_localita[rigaCorrente], currentDivName, currentSpanName); } rigaCorrente = 0; } function coloraRiga(numeroRiga) { //alert("numeroRighe=" + numeroRighe); for(var rowCounter = 1;rowCounter<=numeroRighe;rowCounter++) { //alert("rowCounter " + rowCounter); document.getElementById('rowPopUp' + rowCounter).className='normalRow'; } //alert("evidenzio la riga " + numeroRiga); document.getElementById('rowPopUp' + numeroRiga).className='currentRow'; } function caricaLocations(aField) { //alert("caricaLocations " + aField.value); resetDestination(); url = "/cs/ContentServer?pagename=BoscoloB2CSite%2FPage%2FB2B%2FCommon%2FStandalone%2FAjaxLocationsCombo&codNazioneIso=" + aField.value; req = initRequest(url); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.status == 200) { parsaLocations(trim(req.responseText)); } else if (req.status == 204) { //alert("errore 204"); } } } req.open("GET", url, true); req.send(null); } function chooseDestination(aField) { insertDestination(aField.value,aField.options[aField.selectedIndex].text); } function resetDestination() { insertDestination('',''); } function insertDestination(localityId,destination) { document.forms['FHOTEL'].localityId.value=localityId; document.forms['FHOTEL'].destination.value=destination; document.forms['FHOTEL'].freeSearch.value='N'; } function contenutoTag(codiceXml,nomeTag) { var tagInizio = "<" + nomeTag + ">"; var tagFine = ""; var indiceInizio = codiceXml.indexOf(tagInizio,0); var indiceFine = codiceXml.indexOf(tagFine,0); if(indiceInizio>=0 && indiceFine>=0) { indiceInizio += tagInizio.length; var lunghezza = indiceFine - indiceInizio; return codiceXml.substr(indiceInizio,lunghezza) } else return ""; } function sottraiTag(codiceXml,nomeTag) { var tagFine = ""; var indiceFine = codiceXml.indexOf(tagFine) + tagFine.length; var lunghezza = codiceXml.length - indiceFine; return codiceXml.substr(indiceFine,lunghezza); } function trim(stringa) { re=/\s+$|^\s+/g; return stringa.replace(re,""); } function parsaLocations(responseText) { var locations=contenutoTag(responseText,'locations'); //var comboHtml=""; locationsCounter=0; while(true) { var location=contenutoTag(locations,'location'); if(location=='') break; else { cod_localita=contenutoTag(location,'cod_localita'); des_localita=contenutoTag(location,'des_localita'); locationsCounter++; if(locationsCounter==1) { insertDestination(cod_localita,des_localita); } comboHtml += ""; locations=sottraiTag(locations,'location'); } } comboHtml += ""; document.getElementById("comboLocationsSpan").innerHTML=comboHtml; } var combo_da_nascondere = new Array(); var combo_da_nascondere_agg = new Array(); //combo_da_nascondere.push('combo_camere'); combo_da_nascondere.push('COMBO_GIORNI'); combo_da_nascondere.push('nation'); combo_da_nascondere.push('selectDestination'); combo_da_nascondere_agg.push("zona"); combo_da_nascondere_agg.push("price"); for(var roomCounter=1;roomCounter<=0;roomCounter++) { combo_da_nascondere.push('combo_adulti' + roomCounter); combo_da_nascondere.push('combo_bambini' + roomCounter); for(var kidCounter=1;kidCounter<=6;kidCounter++) { combo_da_nascondere.push('combo_bambini_eta' + roomCounter + kidCounter); } } function hideSelect(){ for(i=0;i