" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
} //fine function
function formSubmit( page, perpage, onlyPaginate ) {
myUrl = "";
myUrlGet = "";
$( "input.search" ).each( function() {
if ( myUrl != "" ) myUrl += "|";
myUrl += "&" + $( this ).attr( "name" ) + "=" + encodeURIComponent($( this ).val());
});
$( "input.inputT" ).each( function() {
var that = $( this );
if ( that.val() != "" ) {
myUrl += "|" + that.attr( "id" ) + "-" + that.val().replace( / /g, "+" );
myUrlGet += "&" + that.attr( "name" ) + "=" + encodeURIComponent(that.val().replace( / /g, "+" ));
}
});
$( "#prc, #dis" ).each( function() {
var that = $( this );
myUrl += "|" + that.attr( "id" ) + "-" + that.val();
myUrlGet += "&" + that.attr( "name" ) + "=" + encodeURIComponent(that.val());
});
$( ".titleSearch select, #formSearch select" ).each( function() {
var that = $( this );
if ( that.children( "option" ).length > 0 ) {
// Personalizzazione per select regioni/città assieme
if(that.attr('id') == 'region-city-select'){
// var areaType = that.attr('name').replace('bform[filter][','');
// areaType = areaType.replace('_id]','');
// myUrl += "|" + areaType + "-" + that.val();
myUrl += "|" + that.attr( "name" ) + "-" + that.val();
} else {
myUrl += "|" + that.attr( "id" ) + "-" + that.val().replace( "|", ":" );
}
myUrlGet += "&" + that.attr( "name" ) + "=" + encodeURIComponent(that.val());
}
});
$( ".boxOptionAside form input[type='checkbox']" ).each( function() {
var that = $( this );
if ( that.is( ":checked" ) ) {
myIdS = that.attr( "id" ).split( "_" );
if ( myUrl.indexOf( "|" + myIdS[0] + "-" ) === -1 ) {
myUrl += "|"+ myIdS[0] + "-" + myIdS[1];
}
else {
myUrl += "," + myIdS[1];
}
myUrlGet += "&" + that.attr( "name" ) + "=" + encodeURIComponent(that.val());
}
});
if ( onlyPaginate == true ) {
page = page != undefined ? page : 1;
perpage = perpage != undefined ? perpage : 10;
}
else {
page = 1;
perpage = 10;
}
myUrl += '|pg-'+ page +'|perpage-'+ perpage;
myUrlGet += '&bform[paginate][pg]='+ encodeURIComponent(page) +'&bform[paginate][perpage]='+ encodeURIComponent(perpage);
if ( $( ".boxPOI > ul li.sel" ).length > 0 ) {
myUrlGet += "&bform[filter][zone_id][" + $( ".boxPOI > ul li.sel" ).attr( "class" ).split( " " )[0].split( "_" )[1] + "]=1";
}
myUrl = myUrl.replace( /\'/g, "" );
myUrlGet = myUrlGet.replace( /\'/g, "" );
location.href = '#' + myUrl;
loadResults( myUrlGet, page, perpage );
}
function setSearch( init ) {
mySearch = (location.hash).replace('#','');
mySearch = mySearch.replace(/\%7C/g,'|');
mySearch = mySearch.split('|');
allSearch = new Array();
myUrlGet = '';
isDebug = (location.hash.search('debug') != -1)? true : false;
$('.boxOptionAside form span > input').removeAttr('checked');
// console.log(mySearch);
for(var kMySearch in mySearch){
var myMMV = mySearch[kMySearch];
if(myMMV!=undefined && myMMV!='' && myMMV.length > 3){
myExplodeSearch = myMMV.split('-');
if(myExplodeSearch[0].length == 2 && myExplodeSearch[0]!='ns'){
allSearch[myExplodeSearch[0]] = myExplodeSearch[1].split(',');
} else {
allSearch[myExplodeSearch[0]] = myExplodeSearch[1];
}
}
}
for(var kAllSearch in allSearch){
// console.log(kAllSearch);
if(kAllSearch == 'prc' || kAllSearch == 'dis'){
minMax = allSearch[kAllSearch];
minMax = minMax.split(';');
if($('#'+ kAllSearch).val()!=undefined && $('#'+ kAllSearch).val()!=''){
valMinMax = ($('#'+ kAllSearch).val()).split(';');
$('#'+ kAllSearch).val(allSearch[kAllSearch]);
if(minMax[1]*1 > valMinMax[0]*1){
var misL = (kAllSearch == 'dis') ? 'Km' : '€' ;
var misA = (kAllSearch == 'dis') ? 0.1 : 1 ;
$("#"+ kAllSearch).slider({
from: parseInt(minMax[0]*1),
to: parseInt(minMax[1]*1),
step: misA,
smooth: true,
round: 1,
dimension: " "+ misL,
limits: false,
scale: [parseInt(minMax[0]*1)+' '+misL, parseInt(minMax[1]*1)+' '+misL],
callback : function(){
formSubmit();
}
});
} else {
$('#'+ kAllSearch).slider('value', minMax[0]*1, minMax[1]*1);
}
myUrlGet += '&'+ $('#'+ kAllSearch).attr('name') +'='+ encodeURIComponent(allSearch[kAllSearch]);
}
} else if(kAllSearch=='pg' || kAllSearch=='perpage'){
if(allSearch[kAllSearch]!=undefined){
myValRep = allSearch[kAllSearch];
myUrlGet += '&bform[paginate]['+ kAllSearch +']='+ encodeURIComponent(allSearch[kAllSearch]);
}
} else if((kAllSearch).length == 2 && kAllSearch != 'ns'){
for(var kSubSearch in allSearch[kAllSearch]){
$('#'+ kAllSearch +'_'+ allSearch[kAllSearch][kSubSearch]).prop('checked', true).parent('label').addClass('active');
myUrlGet += '&'+ $('#'+ kAllSearch +'_'+ allSearch[kAllSearch][kSubSearch]).attr('name') +'='+ encodeURIComponent($('#'+ kAllSearch +'_'+ allSearch[kAllSearch][kSubSearch]).val());
}
} else if((kAllSearch).length == 2 && kAllSearch=='ns'){
myValRep = allSearch[kAllSearch];
if(myValRep*1==NaN) myValRep = myValRep.replace('+',' ');
$('#'+ kAllSearch).val(myValRep);
myUrlGet += '&'+ $('#'+ kAllSearch).attr('name') +'='+ encodeURIComponent(allSearch[kAllSearch]);
} else if((kAllSearch).length == 3){
$('input[name="'+ kAllSearch +'"]').val(allSearch[kAllSearch]);
myUrlGet += '&'+ kAllSearch +'='+ encodeURIComponent(allSearch[kAllSearch]);
} else if(kAllSearch=='order'){
if(allSearch[kAllSearch]!=undefined){
myValRep = allSearch[kAllSearch];
if(myValRep*1==NaN) myValRep = myValRep.replace(':','|');
$('select[name="bform[structure_'+ kAllSearch +']"]').val(myValRep);
myUrlGet += '&bform[structure_'+ kAllSearch +']='+ encodeURIComponent(allSearch[kAllSearch]);
}
} else if((kAllSearch).length > 0){
if(allSearch[kAllSearch] != undefined && kAllSearch != 'indexOf'){
myValRep = allSearch[kAllSearch];
if(myValRep*1==NaN) myValRep = myValRep.replace(':','|');
$('input[name="'+ kAllSearch +'"], select[name="'+ kAllSearch +'"]').val(myValRep);
myUrlGet += '&'+ kAllSearch +'='+ encodeURIComponent(allSearch[kAllSearch]);
}
}
}
myUrlGet = myUrlGet.replace(/\'/g, "");
if ( init == true && myUrlGet == "" ) {
if ( typeof( window['bform'] ) != "undefined" ) {
if ( typeof( bform['filter']['city_name'] ) != "undefined" && bform['filter']['city_name'] != undefined && bform['filter']['city_name'] != "" ) {
myUrlGet += "&bform[filter][city_name]=" + encodeURIComponent(bform['filter']['city_name']) ;
}
if ( typeof( bform['filter']['city_id'] ) != "undefined" && bform['filter']['city_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['city_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][city_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['region_id'] ) != "undefined" && bform['filter']['region_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['region_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][region_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['province_id'] ) != "undefined" && bform['filter']['province_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['province_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][province_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['structure_id'] ) != "undefined" && bform['filter']['structure_id'] != "undefined" && bform['filter']['structure_id'] != "" ) {
myUrlGet += '&bform[filter][structure_id]=' + parseInt(bform['filter']['structure_id']);
}
if ( typeof( bform['filter']['zone_id'] ) != "undefined" && bform['filter']['zone_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['zone_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][zone_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['type_id'] ) != "undefined" && bform['filter']['type_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['type_id'] ) {
if ( kSubCity != 'indexOf' ) {
// Setto le label corrette a seconda della selezione ricerca
if ( kSubCity == 0 ) {
optTextS = trad['app_cam_s'];
optTextP = trad['app_cam_p'];
labelText = trad['app_cam_l'];
} else if (kSubCity < 3 ) {
optTextS = trad['cam_s'];
optTextP = trad['cam_p'];
labelText = trad['cam_l'];
} else {
optTextS = trad['app_s'];
optTextP = trad['app_p'];
labelText = trad['app_l'];
}
$( '.boxRoom #numRooms_01' ).siblings( 'label' ).text( labelText );
$( '.boxRoom #numRooms_01 option' ).each( function() {
myOpt = $( this );
oldLabel = myOpt.text();
optVal = myOpt.val();
if ( optVal == 1 ) {
newLabel = myOpt.text().replace( oldLabel , optVal +' '+ optTextS );
} else {
newLabel = myOpt.text().replace( oldLabel , optVal +' '+ optTextP );
}
myOpt.text( newLabel );
});
myUrlGet += '&bform[filter][type_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['style_id'] ) != "undefined" && bform['filter']['style_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['style_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][style_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['rating_id'] ) != "undefined" && bform['filter']['rating_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['rating_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][rating_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['apartment_type_id'] ) != "undefined" && bform['filter']['apartment_type_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['apartment_type_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][apartment_type_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['club_id'] ) != "undefined" && bform['filter']['club_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['club_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][club_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['amenity_id'] ) != "undefined" && bform['filter']['amenity_id'] != "undefined" ) {
for ( var kSubCity in bform['filter']['amenity_id'] ) {
if ( kSubCity != 'indexOf' ) {
myUrlGet += '&bform[filter][amenity_id]['+ kSubCity +']=1';
}
}
}
if ( typeof( bform['filter']['structure_name'] ) != "undefined" && bform['filter']['structure_name'] != "undefined" && bform['filter']['structure_name']!='')
{
myUrlGet += '&bform[filter][structure_name]=' + encodeURIComponent(bform['filter']['structure_name']);
}
}
}
loadResults( myUrlGet );
if ( init == true ) {
setTimeout( function(){
/**
* INIZIALIZZAZIONE CAMPI FORM SEARCH SECONDO I PARAMETRI SELEZIONATI IN PRECEDENZA
*/
if ( typeof( window['bform'] ) != "undefined" ) {
// CHECKIN
if ( typeof( bform['checkin'] ) != "undefined" && bform['checkin'] != "undefined" && bform['checkin']!='')
{
$( 'input[name="bform[checkin]"]', '#formSearch' ).val( bform['checkin'] );
}
// CHECKOUT
if ( typeof( bform['checkout'] ) != "undefined" && bform['checkout'] != "undefined" && bform['checkout']!='')
{
$( 'input[name="bform[checkout]"]', '#formSearch' ).val( bform['checkout'] );
}
// Zona
if ( typeof( bform['filter']['zone_id'] ) != "undefined" && bform['filter']['zone_id'] != "undefined" ) {
for(var kSubCity in bform['filter']['zone_id']){
if(kSubCity!='indexOf'){
$('#zo_'+ kSubCity).prop('checked', true);
}
}
}
// Tipologia
if ( typeof( bform['filter']['type_id'] ) != "undefined" && bform['filter']['type_id'] != "undefined" ) {
for(var kSubCity in bform['filter']['type_id']){
// Checkbox Aside
if(kSubCity!='indexOf'){
$('#ty_'+ kSubCity).prop('checked', true);
}
// Select barra top
$( 'select[name="bform[filter][type_id]"]', '#formSearch' ).val(kSubCity).trigger("change");
}
}
// Stile vacanza
if ( typeof( bform['filter']['style_id'] ) != "undefined" && bform['filter']['style_id'] != "undefined" ) {
for(var kSubCity in bform['filter']['style_id']){
if(kSubCity!='indexOf'){
$('#hs_'+ kSubCity).prop('checked', true);
$('#ai_'+ kSubCity).parent().addClass('active');
$('#ai_'+ kSubCity).prop('checked', true);
}
}
}
// Rating
if ( typeof( bform['filter']['rating_id'] ) != "undefined" && bform['filter']['rating_id'] != "undefined" ) {
for(var kSubCity in bform['filter']['rating_id']){
if(kSubCity!='indexOf'){
$('#ra_'+ kSubCity).siblings('label').addClass('sel');
$('#ra_'+ kSubCity).prop('checked', true);
}
}
}
// Tipologia Appartamenti
if ( typeof( bform['filter']['apartment_type_id'] ) != "undefined" && bform['filter']['apartment_type_id'] != "undefined" ) {
for(var kSubCity in bform['filter']['apartment_type_id']){
if(kSubCity!='indexOf'){
$('#at_'+ kSubCity).prop('checked', true);
}
}
}
// Club prodotto
if ( typeof( bform['filter']['club_id'] ) != "undefined" && bform['filter']['club_id'] != "undefined" ) {
for(var kSubCity in bform['filter']['club_id']){
if(kSubCity!='indexOf'){
$('#cl_'+ kSubCity).siblings('label').addClass('sel');
$('#cl_'+ kSubCity).prop('checked', true);
}
}
}
// Amenities
if ( typeof( bform['filter']['amenity_id'] ) != "undefined" && bform['filter']['amenity_id'] != "undefined" ) {
for(var kSubCity in bform['filter']['amenity_id']){
if(kSubCity!='indexOf'){
$('#cl_'+ kSubCity).siblings('label').addClass('sel');
$('#hs_'+ kSubCity).siblings('label').addClass('sel');
$('#am_'+ kSubCity).siblings('label').addClass('sel');
$('#am_'+ kSubCity).prop('checked', true);
$('#cl_'+ kSubCity).prop('checked', true);
$('#hs_'+ kSubCity).prop('checked', true);
$('#ami_'+ kSubCity).parent().addClass('active');
$('#ami_'+ kSubCity).prop('checked', true);
$('#ai_'+ kSubCity).parent().addClass('active');
$('#ai_'+ kSubCity).prop('checked', true);
owlCarousellThemeIndex = $('#ai_'+ kSubCity).parent().index();
$(window).load(function(){
// Porto lo slider dei temi in posizione (Personalizzazione per freebooking)
$('.slider-icons-div').trigger('to.owl.carousel',[owlCarousellThemeIndex,1,true]);
});
}
}
}
// Ricerca per nome struttura
if ( typeof( bform['filter']['structure_name'] ) != "undefined" && bform['filter']['structure_name'] != "undefined" && bform['filter']['structure_name']!='')
{
$('#aside-search-by-name-input').val(bform['filter']['structure_name']);
}
// Ricerca per nome città
if ( typeof( bform['filter']['city_name'] ) != "undefined" && bform['filter']['city_name'] != "undefined" && bform['filter']['city_name']!='')
{
$('#cityname').val(bform['filter']['city_name']);
}
// Città
if ( typeof( bform['filter']['city_id'] ) != "undefined" && bform['filter']['city_id'] != "undefined" )
{
for( var kSubCity in bform['filter']['city_id'] ) {
// Personalizzazione per select regioni/città assieme
if($('#region-city-select').length>0 && parseInt(kSubCity)>0){
$('#region-city-select').prop('name','bform[filter][city_id]');
$('#region-city-select').find('[data-type="city"]').filter('[value="'+ kSubCity +'"]').prop('selected',true);
$('#region-city-select').find('[data-type="city"]').trigger('change');
// Personalizzazione per immagini visual Freebooking
$("
", {
src: 'https://cdn.freebookingitalia.it/abs/city_cover/'+kSubCity+'.jpg',
error: function() {
},
load: function(el) {
$('#tmpHead').css({
'background-image':'url('+el.target.src+')',
'background-size':'cover',
});
}
});
break;
}
if ( kSubCity != 'indexOf' && parseInt(kSubCity)>0 ) {
$('#cy_'+ kSubCity).prop('checked', true);
$( 'input[name="bform[filter][city_id]"][' + kSubCity + ']' ).val( 1 );
$( 'input[name^="bform[filter][city_id]"]' ).removeAttr('disabled');
$( 'input[name^="bform[filter][region_id]"]' ).attr("disabled", true);
$( 'input[name^="bform[filter][structure_id]"]' ).attr("disabled", true);
// Select barra search
$( 'select[name="bform[filter][city_id]"]', '#formSearch' ).val(kSubCity).trigger("change");
}
}
}
// Regione (?)
if ( typeof( bform['filter']['region_id'] ) != "undefined" && bform['filter']['region_id'] != "undefined" )
{
for( var kSubCity in bform['filter']['region_id'] ) {
// Personalizzazione per select regioni/città assieme
if($('#region-city-select').length>0 && parseInt(kSubCity)>0){
$('#region-city-select').prop('name','bform[filter][region_id]');
$('#region-city-select').find('[data-type="region"]').filter('[value="'+ kSubCity +'"]').prop('selected',true);
$('#region-city-select').find('[data-type="city"]').trigger('change');
break;
}
if ( kSubCity != 'indexOf' && parseInt(kSubCity)>0) {
$( 'input[name="bform[filter][region_id]"]['+ kSubCity +']' ).val( 1 );
$( 'input[name^="bform[filter][city_id]"]' ).attr("disabled", true);
$( 'input[name^="bform[filter][region_id]"]' ).removeAttr('disabled');
$( 'input[name^="bform[filter][structure_id]"]' ).attr("disabled", true);
}
}
}
// Ricerca per id struttura
if ( typeof( bform['filter']['structure_id'] ) != "undefined" && bform['filter']['structure_id'] != "undefined" && parseInt(bform['filter']['structure_id'])>0)
{
$( 'input[name^="bform[filter][structure_id]"]' ).attr( "name", "bform[filter][structure_id]").val( parseInt(bform['filter']['structure_id'] ));
$( 'input[name^="bform[filter][city_id]"]' ).attr("disabled", true);
$( 'input[name^="bform[filter][region_id]"]' ).attr("disabled", true);
$( 'input[name^="bform[filter][structure_id]"]' ).removeAttr('disabled');
}
if ( typeof( bform['numRooms'] ) != "undefined" && bform['numRooms'] != "undefined" && parseInt(bform['numRooms'])>0)
{
$( "input[name='bform[numRooms]']" ).val( parseInt(bform['numRooms']) );
// Numero delle camere
$('#numRooms_button-' + parseInt(bform['numRooms'])).trigger('click');
// Numero degli ospiti
var roomNumber = 1;
var childnumber = 0;
for(var room in bform['reqRooms'] ) {
$('#room_adults-' + roomNumber + '-' + bform['reqRooms'][room]['adults'] ).trigger('click');
if (bform['reqRooms'][room]['child'] && bform['reqRooms'][room]['child'] > 0) {
$('#room_children-' + roomNumber + '-' + bform['reqRooms'][room]['child'] ).trigger('click');
if ( bform['reqRooms'][room]['childAge'].length > 0) {
childnumber = 0;
for(var ageData in bform['reqRooms'][room]['childAge']) {
childnumber++;
$('#room_children_age-' + roomNumber + '-' + childnumber ).val(bform['reqRooms'][room]['childAge'][ageData]);
$('#label_room_children_age-' + roomNumber+ '-' + childnumber ).text(bform['reqRooms'][room]['childAge'][ageData]);
}
}
}
roomNumber++;
}
}
}
}, 100);
}
}
function loadResults( myUrlFilter, page, perpage ) {
if ( ! loadFirstTime ) {
startBlockUI( msg1, msg2 );
}
myUrlFilter = String( myUrlFilter );
myUrl = location.hash.replace( "#", "" );
var keySID = 'ABS_MMONE_SEARCH';
var sIdValue = "";
mySid = location.search.replace( "?", "" ).split( "&" );
for( var mykey in mySid ) {
if ( mySid[mykey] != undefined && mySid[mykey].length > 3 ) {
mySearchK = mySid[mykey];
mySearchK = mySearchK.split( "=" );
if ( mySearchK[0] == keySID ) {
sIdValue = mySearchK[1];
}
}
}
if ( myUrlFilter.search( 'paginate' ) == -1 ) {
page = page != undefined ? page : 1 ;
perpage = perpage != undefined ? perpage : 10 ;
myUrlFilter += '&bform[paginate][pg]='+ encodeURIComponent(page) +'&bform[paginate][perpage]='+ encodeURIComponent(perpage);
myUrlFilter = myUrlFilter.replace( /\'/g, "" );
}
if ( typeof( window['bform'] ) != "undefined" ) {
if ( typeof( bform['filter']['poi'] ) != "undefined" && bform['filter']['poi'] != undefined ) {
myUrlFilter += '&bform[filter][poi]='+ encodeURIComponent(bform['filter']['poi']);
myUrlFilter = myUrlFilter.replace( /\'/g, "" );
}
}
if ( $( '.boxMapAside' ).length == 1 ) {
mk = new Array();
}
myUrlFilter = myUrlFilter.replace( /:/g,'|' );
myUrlBaseUrl = "/search/loadResults.php";
// Gestisco la lingua per il loadResults
if(typeof window.trad !== 'undefined' && typeof window.trad['iso3'] !== 'undefined' && window.trad['iso3'] !== 'ita' ){
myUrlBaseUrl = '/' + trad['iso3'] + myUrlBaseUrl;
}
myUrlToLoad = "sId="+ encodeURIComponent(sIdValue) + myUrlFilter + '&mmdebug=1' ;
/*if ( $( 'select[name^="bform[filter][zone_id]"]', '#boxSearch' ).val() != 0 ) {
myUrlToLoad += "&bform[filter][show_structure_list]=1";
}*/
if ( loadFirstTime ) {
$( '#searchHotel' ).fadeTo( 400, 0.3 );
$.unblockUI();
if ( typeof( window['bform'] ) != "undefined" ) {
if ( typeof( bform['filter']['poi'] ) != "undefined" && bform['filter']['poi'] != undefined ) {
$( ".orderStructureBy" ).val( "distance_from_poi|asc" );
myUrlToLoad += "&bform[structure_order]=distance_from_poi|asc";
}
}
}
myUrlToLoad = encodeURI(myUrlBaseUrl) + '?' + myUrlToLoad;
//console.log( myUrlToLoad );
$( '#searchHotel' ).parent().load( myUrlToLoad, function() {
activeSimulate = true;
setInfoHide();
setHref();
if ( loadFirstTime ) {
$( '#searchHotel' ).fadeTo( 0, 0.3 );
$( '#searchHotel' ).fadeTo( 400, 1, function() {
absSearch.goToPos( '.contSearch' );
//console.log(window['bform']);
if ( typeof( window['bform']['mode'] ) != "undefined" && window['bform']['mode'] != 'list' ) {
if( typeof( bform['init'] ) != "undefined" ) {
// absSearch.goToPos( '#boxFormSearch' );
}
}
});
loadFirstTime = false;
$.unblockUI();
}
else {
$( '#searchHotel' ).hide().fadeIn( 600, function() {
absSearch.goToPos( '.contSearch' );
});
$.unblockUI();
}
if ( $( '.boxMapAside' ).length == 1 ) {
loadGeneralMap( mapPoiGeo );
}
else if ( $( '#mapBigZoneS' ).length == 1 ) {
$( '#mapBigZoneS' ).empty();
loadGeneralMap( "", zone_id );
}
absSearch.doSimulateBooking();
});
window.ABS_setMinisiteBackUrl();
}
// if ( $( '.boxMapAside' ).length == 1 ) {
// loadGeneralMap( mapPoiGeo );
// }
//Shadowbox.init({language:iso2ForAll, overlayColor: '#1B5086', overlayOpacity: '0.8', continuous: true});
function setHref(){
$('.paginator_cont a').unbind('click');
$('.paginator_cont a').bind('click', function(evt){
// Gestione parametri paginazione SEO Friendly
evt.preventDefault();
page = 1 ;
perpage = 10 ;
if(typeof bform != 'undefined'){
if(typeof bform['paginate'] != 'undefined'){
if(typeof bform['paginate']['perpage'] != 'undefined') perpage = bform['paginate']['perpage'] ;
}
}
if(typeof $(this).data('page') != 'undefined') page = $(this).data('page');
formSubmit(page, perpage, true);
return false;
});
}
function includeSB(id,iso2){
if(activeSimulate){
var keySID = 'ABS_MMONE_SEARCH';
var sIdValue = '';
mySid = ((location.search).replace('?','')).split('&');
for(var mykey in mySid){
if(mySid[mykey]!=undefined){
mySearchK = String(mySid[mykey]);
mySearchK = mySearchK.split('=');
if(mySearchK[0]==keySID) sIdValue = mySearchK[1];
}
}
$.ajax({
url: "/search/simulatebooking.php?stid="+id+"&ajax=true&iso2="+iso2+"&spage[lg]="+iso2+"&sId="+sIdValue,
success: function(data) {
$('#room_'+ id).html(data);
$('#room_'+ id).hide().fadeIn(1000, function(){
$('#room_'+ id).css({background:'none'});
});
}
});
}
}
/**
* FORM RICHIESTA INFORMAZIONI STRUTTURA DA LISTA SEARCH
* @param {jqueryObj} myForm : form relativo
*/
function checkFormStructure(myForm){
var error = false;
var errorText = '';
var FiltroMail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
var elems = $('.formReq',myForm);
var elemsLg = elems.length;
i=0;
for (i; i<=elemsLg-1; i++) {
var $el = $(elems[i]);
// Controllo mail
if($el.attr('name')=='email'){
if(!FiltroMail.test($el.val())){
error = true;
errorText += $el.data('error-text')+'\n';
}
} else if(typeof $el.attr('type') != 'undefined' && $el.attr('type')=='checkbox'){
// Controllo input checkbox
if(!$el.is(':checked')){
error = true;
errorText += $el.data('error-text')+'\n';
}
} else {
// Controllo input text
if($el.val()=='' || $el.val().length<3){
error = true;
errorText += $el.data('error-text')+'\n';
}
}
}
if(error){
// In caso di errore notifico l'utente
swal({
type:'warning',
allowOutsideClick: true,
title: trad['Attention'],
text: errorText
});
} else {
// In caso di successo invio i dati al mailer
$.ajax({
type: 'POST',
url: '/assets/mailers/mailer_structures.php',
cache: false,
data: myForm.serialize(),
success: function(response) {
if (response == "OK") {
// Email inviata
$('#structure-modal').modal('hide');
swal({
type:'success',
allowOutsideClick: true,
timer: 3000,
title: '',
text: trad['Request_sent_with_success']
});
// Tracciamento Analytics
mm_track_event('VisualizzaContatti - Form Struttura', 'Mail', $('#cf_structure').val());
} else {
// Email non inviata
swal({
type:'warning',
allowOutsideClick: true,
timer: 3000,
title: trad['Attention'],
text: errorText
});
}
}
});
}
}
/**
* PULSANTI INFORMAZIONE STRUTTURA
*/
function setInfoHide(tooltipWrap){
if(typeof tooltipWrap == 'undefined') tooltipWrap = '#searchHotel'
$('.infoHide > a').each(function(){
$(this).tooltip({
container: tooltipWrap,
});
$(this).bind('click', function(){
var $el = $(this);
var structureName = (typeof $el.parent().data('strname') != 'undefined') ? $el.parent().data('strname') : 'NO STRUCTURE NAME' ;
if($el.hasClass('popInfo')){
// Telefono + Fax
var infoToShow = $el.data('info');
var popOverTxt = jbase64.decode($el.data('str'+infoToShow));
$(this).tooltip('hide')
.attr('data-original-title', popOverTxt)
.tooltip('fixTitle');
setTimeout(function(){
$el.tooltip('show');
},500);
// Tracciamento Analytics
mm_track_event('VisualizzaContatti', infoToShow, structureName);
} else if($el.hasClass('website')){
// Sito web
var strWebsite = jbase64.decode($el.data('strweb'));
var strWebsiteHttp = (strWebsite.indexOf('http://') == -1) ? 'http://' : '' ;
// Tracciamento Analytics
mm_track_event('VisualizzaContatti', 'www', structureName);
window.open(strWebsiteHttp+strWebsite);
} else if($el.hasClass('email')){
// Form contatti struttura
var strEmail = jbase64.decode($el.data('strmail'));
$('#cf_emaildes').val(strEmail);
$('#cf_structure').val(structureName);
$('#structure-modal').modal('show');
}
});
});
}
/**
* funzione modifica trattamento e visualizzazione prezzo
* @param {Object} boarselect
*/
function calculateBoarding(boarselect){
var searchHotel = $("#searchHotel");
var boarding = $(".td_pric select", searchHotel);
var boardingprice = $(".td_pric span", searchHotel);
if (boarding.length > 0) {
boarding.each(function(i){
var thPrev = $(this);
uuid = (($(this).parents('tr').attr('class')).replace('hider','').replace('haveOffers','')).replace(/^\s+|\s+$/g,'');
datarow = uuid.split("_");
structureid = datarow[0];
listid = datarow[1];
roomid = datarow[2];
if (prices[structureid] != undefined && prices[structureid][listid] != undefined && prices[structureid][listid][roomid] != undefined && prices[structureid][listid][roomid][boarselect] != undefined) {
$(thPrev).val(boarselect);
}
});
}
if (boardingprice.length > 0) {
boardingprice.each(function(i){
priceroom = this;
uuid = (($(this).parents('tr').attr('class')).replace('hider','').replace('haveOffers','')).replace(/^\s+|\s+$/g,'');
addNameOffers(uuid);
});
}
}
function closeAllFilters(){
$('#addOptions > ul > li').each(function(){
if($(this).children('.side-collapse-btn').length > 0){
if($('input[type="checkbox"]:checked', $(this)).length == 0) $(this).addClass('toOpen').children('.side-collapse-wrap').slideUp(0);
$(this).children('.side-collapse-btn').unbind("click");
$(this).children('.side-collapse-btn').bind('click', function(){
if(!$(this).siblings('.side-collapse-wrap').is(':visible')){
$(this).siblings('.side-collapse-wrap').slideDown(350);
$(this).parent().removeClass('toOpen');
} else {
$(this).siblings('.side-collapse-wrap').slideUp(350);
$(this).parent().addClass('toOpen');
}
});
}
});
}
function loadGeneralMap(geo, zone_id){
if ($('#mapSmallSearch').length == 0) return;
var bounds = [];
if (typeof asideMapOBJ === 'undefined') {
// Map istance
asideMapOBJ = L.map('mapSmallSearch', {
attributionControl: false,
scrollWheelZoom: false
});
asideMapOBJ.setView([42.319463, 12.450120], 10);
// Map tiles
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: ''
}).addTo(asideMapOBJ);
asideMapLayerOBJ = L.layerGroup().addTo(asideMapOBJ);
}
var myMap = asideMapOBJ;
asideMapLayerOBJ.clearLayers();
if (typeof mk === 'object') {
for (var i in mk) {
var STR = mk[i];
STR.geoSplit = STR.geo.split('|');
STR.lat = parseFloat(STR.geoSplit[0]);
STR.lon = parseFloat(STR.geoSplit[1]);
var structureIcon = L.icon({
iconUrl: '/images/staticv2/asideMap/ico_' + STR.let + '.png',
iconSize: [25, 31],
iconAnchor: [12, 31],
});
var myMarker = L.marker([
STR.lat,
STR.lon
], {
icon: structureIcon
});
bounds.push([STR.lat, STR.lon]);
myMarker.addTo(asideMapLayerOBJ);
}
asideMapOBJ.fitBounds(bounds);
asideMapOBJ.setZoom(13);
}
return false;
}
function showMaps(stid){
activeShadBox.init({urlP:'/assets/'+ iso2ForAll +'/mapBig.html?stid='+stid, classAdd:'mapB'});
}
function showRoom(elm){
$('tr.hider', $(elm).siblings('table')).css({display:'table-row'});
$(elm).css({display:'none'});
}
// Base64
var jbase64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=jbase64._utf8_encode(input);while(i
>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}output=output+this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4);}return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}if(enc4!=64){output=output+String.fromCharCode(chr3);}}output=jbase64._utf8_decode(output);return output;},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}return utftext;},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}return string;}};
// Serialize
function unserialize(data){var that=this,utf8Overhead=function(chr){var code=chr.charCodeAt(0);if(code<128){return 0}if(code<2048){return 1}return 2},error=function(type,msg,filename,line){throw new that.window[type](msg,filename,line)},read_until=function(data,offset,stopchr){var i=2,buf=[],chr=data.slice(offset,offset+1);while(chr!=stopchr){if((i+offset)>data.length){error("Error","Invalid")}buf.push(chr);chr=data.slice(offset+(i-1),offset+i);i+=1}return[buf.length,buf.join("")]},read_chrs=function(data,offset,length){var i,chr,buf;buf=[];for(i=0;i3){s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,sep)}if((s[1]||"").length