var datepicker = true;tjq(document).ready(function() {var availableDates = new Array();availableDates[0] = new Array();availableDates[0][0] = '20170401';availableDates[0][1] = '20171031';tjq( "#bookSearch input[name=date_from]" ).datepicker('option', 'beforeShowDay', highlightDays);tjq( "#bookSearch input[name=date_to]" ).datepicker('option', 'beforeShowDay', highlightDays); function highlightDays(d) {var dmy,year,month,day = '';year = d.getFullYear(); month = (d.getMonth()+1); if(d.getMonth()<9) month='0'+month;if(d.getDate()<10) day='0'; day+=d.getDate(); dmy = year+''+month+''+day;if( ((dmy >= availableDates[0][0]) && (dmy <= availableDates[0][1]))){return [true, '','Available'];} else { return [false,'','unAvailable']; } }tjq( ".hasDatepicker" ).datepicker( "option", "dateFormat", "dd/mm/yy" );tjq( ".hasDatepicker" ).datepicker( "option", "changeMonth", "true" );tjq( ".hasDatepicker" ).datepicker( "option", "changeYear", "true" );tjq( "#bookSearch input[name=date_from]" ).val('');tjq( "#bookSearch input[name=date_to]" ).val('');tjq( "#bookSearch input[name=date_from]" ).datepicker( "option", "defaultDate", +10 );tjq( "#bookSearch input[name=date_to]" ).datepicker( "option", "defaultDate", +10 );tjq( "#bookSearch input[name=date_from]" ).datepicker("option", "maxDate", new Date(2017, 10-1, 31));tjq( "#bookSearch input[name=date_to]" ).datepicker("option", "maxDate", new Date(2017, 10-1, 31));}); tjq('#bookSearch').on('change', '.mchildren', function() {tjq('.new_mages').remove();for(i=1; i <= tjq('.mchildren option:selected').val(); i++) {var $template = tjq('#bookTemplate'),$clone = $template.clone().removeClass('hide').addClass('new_mages').removeAttr('id').insertBefore($template),$option = $clone.find('[name="mages[]"]');$option.val('');}});tjq('#bookSearch').on('each', '.mchildren', function() {tjq('.new_mages').remove();for(i=1; i <= tjq('.mchildren option:selected').val(); i++) {var $template = tjq('#bookTemplate'),$clone = $template.clone().removeClass('hide').addClass('new_mages').removeAttr('id').insertBefore($template),$option = $clone.find('[name="mages[]"]');$option.val('');}});tjq('#bookSearch .mchildren').focus(function() {for(i=1; i <= (tjq('.mchildren option:selected').val() - tjq('.new_mages').length); i++) {var $template = tjq('#bookTemplate'),$clone = $template.clone().removeClass('hide').addClass('new_mages').removeAttr('id').insertBefore($template),$option = $clone.find('[name="mages[]"]');$option.val('');}});var date_from = tjq( "#bookSearch input[name=date_from]" );var date_to = tjq( "#bookSearch input[name=date_to]" );var children = tjq("#mchildren");var allFields = tjq( [] ).add( date_from ).add( date_to ).add( children );var dateRegex = /^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$/;function checkRegexp( o, regexp ) {if ( !( regexp.test( o.val() ) ) ) {tjq('label[for="'+ o.attr('name') +'"]').css( "color", "#FFF" );tjq('label[for="'+ o.attr('name') +'"]').css( "background-color", "#F00" );return false;} else {tjq('label[for="'+ o.attr('name') +'"]').css( "color", "" );tjq('label[for="'+ o.attr('name') +'"]').css( "background-color", "" );return true;}}function checkAges( o, o2 ) {var a_o2 = o2.split(",");if ((o.val() > 0) && ((o2 == '') || (o.val() != a_o2.length ))) {tjq('label[for="'+ o.attr('name') +'"]').css( "color", "#FFF" );tjq('label[for="'+ o.attr('name') +'"]').css( "background-color", "#F00" ); return false;} else {tjq('label[for="'+ o.attr('name') +'"]').css( "color", "" );tjq('label[for="'+ o.attr('name') +'"]').css( "background-color", "" );return true;}}var ChildrenAges = "";var arrPrices = null;function priceFinder() {var valid = true;allFields.css( "color", "" );allFields.css( "background-color", "" );ChildrenAges = "";tjq('.mages option:selected').each(function(){if(tjq(this).val() != "") {ChildrenAges += (ChildrenAges!="") ? ","+tjq(this).val() : tjq(this).val(); }});valid = valid && checkAges( children, ChildrenAges);valid = valid && checkRegexp( date_from, dateRegex);valid = valid && checkRegexp( date_to, dateRegex);if ( valid ) {tjq("#priceFinder").html("
"+"
"+"45% Complete"+"
"+"
");arrPrices = null;tjq.ajax({type: "GET",url: "/pricefinder/", data: {ProductID: "4024,5006,5007,5008,5301", PageID: "856", checkAvailability: "true", arrDate: replaceAll(tjq("#bookSearch input[name=date_from]").val(),"/", "/"), depDate: replaceAll(tjq("#bookSearch input[name=date_to]").val(),"/", "/"), adults: tjq("#madults option:selected").val(), children: ChildrenAges, orderBy: "cheapestProductPrice", splitHotDeals: "true", currentLanguage: "3",CurrentDepartment: "3",forceNoCacheJS: (new Date().valueOf())}}).done(function (data) {var arrIncluding = new Array();var valid = true;allFields.removeClass( "ui-state-error" );tjq("#priceFinder").text("");eval(data);var NewInnerHTML = "";if (PriceState=="notavailable"){NewInnerHTML = "
L'informatique indique que l'établissement est hélas complet pour les dates demandées, ou la configuration de votre famille fait que notre serveur n'arrive pas à calculer une solution intéressante, ou encore un séjour minimum est demandé. N'hésitez pas à contacter un de nos conseillers (ils sont francophones), il ou elle fera beaucoup mieux que le meilleur des programmes informatiques. [demandes@vacances-en-sardaigne.fr]
";}else if(PriceState=="nopriceavailable"){NewInnerHTML = "
Tarif non disponible de façon automatique. Cliquez sur demande, ou téléphonez, nous nous ferons un plaisir de vous renseigner
";}else if(PriceState=="nochildren"){NewInnerHTML = "
Nous sommes désolés mais cet établissement n'accepte les enfants qu'ŕ partir d'un certain âge, ŕ ce propos le prix ne pourra pas ętre calculé de façon automatique, cliquez "sur demande" et nous vous répondrons le plus rapidement possible
";}else if(PriceState=="notavailable_cm"){NewInnerHTML = "

Hélas, l'informatique indique qu'il n'y a pas de chambres disponibles à cette époque.
Prochaine disponibilité le: "+DataDispo+" .
Merci de nous contacter par mail ou téléphone afin que nous puissions vous adresser un devis personnalisé ou des alternatives pour la période choisie
";}else{var lastProdID = 0; var thisProdID = 0;var countPrices = 1;var mySearchDates = searchDatesString();var mySearchPersons = searchPersonString();for(pr=0; pr < arrPrices.length; pr++){var prodName = ""; var extMsg = ""; var priceclassName = ""; var offers = ""; var bookInfo = ""; var displayPrice = "";var Price = "";var nonRefundable = false;var pricevariationDescr = '';var fullDescription = '';for(i=0; i < arrPrices[pr].length; i++){if(arrPrices[pr][i][0]=="fullDescProduct") prodName = arrPrices[pr][i][1];if(arrPrices[pr][i][0]=="extMsg") extMsg = arrPrices[pr][i][1];if(arrPrices[pr][i][0]=="priceClassName") priceclassName = arrPrices[pr][i][1];if(arrPrices[pr][i][0]=="displayPrice") displayPrice = arrPrices[pr][i][1];if(arrPrices[pr][i][0]=="Price") Price = arrPrices[pr][i][1];if(arrPrices[pr][i][0]=="offers") offers = arrPrices[pr][i][1];if(arrPrices[pr][i][0]=="ProductID1") thisProdID = arrPrices[pr][i][1];if(arrPrices[pr][i][0]=="NonRefundable" && arrPrices[pr][i][1] == "true") nonRefundable = true;fullDescription = '';pricevariationDescr = '';if(arrPrices[pr][i][0]=="Allotment"){if(arrPrices[pr][i][1]=="true"){bookInfo = ' '+decode("R&eacute;server imm&eacute;diatement")+'';}else{bookInfo = ' '+decode("Disponible apr&egrave;s confirmation")+'';}if (priceclassName.length>0) bookInfo = '
' + bookInfo;}}prodName = prodName;if(displayPrice=="NoPriceAvailable") displayPrice = "";if(displayPrice=="") bookInfo = "Tarif non disponible de façon automatique. Cliquez sur demande, ou téléphonez, nous nous ferons un plaisir de vous renseigner";if(displayPrice==""){var bookWord = "Reinseignez Vous";var bookOnClick = "request";}else{var bookWord = "Réserver";var bookOnClick = "booking";}if(displayPrice=="NotEnoughProducts"){bookInfo = "Tarif non disponible de façon automatique. Cliquez sur demande, ou téléphonez, nous nous ferons un plaisir de vous renseigner"; }else{if(thisProdID==lastProdID){countPrices++; }else{if(NewInnerHTML != "") {NewInnerHTML = NewInnerHTML + "";NewInnerHTML = NewInnerHTML + "";}var ServiceRooms = new Array();var ServiceRoom = "";if (typeof ServiceRooms[thisProdID] !== "undefined")ServiceRoom = ServiceRooms[thisProdID];var ImageRooms = new Array();var ImageRoom = "";if (typeof ImageRooms[thisProdID] !== "undefined")ImageRoom = ImageRooms[thisProdID];NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";if(ImageRoom!="") {NewInnerHTML = NewInnerHTML + "\"\"";} else {}NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "

"+prodName+"

";NewInnerHTML = NewInnerHTML + "
"; NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
"+mySearchPersons+"
";NewInnerHTML = NewInnerHTML + "
"+mySearchDates+"
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML+"
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
"; lastProdID = thisProdID;}if(extMsg.length>0){priceclassName = priceclassName + "
" + extMsg + " " +fullDescription;}var norefundabletext = (nonRefundable) ? "Non remboursable" : "";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
"+priceclassName+"
"+ bookInfo +"
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + ""+offers+"";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + " "+displayPrice+""+norefundabletext+"";NewInnerHTML = NewInnerHTML + " ";NewInnerHTML = NewInnerHTML + " ";NewInnerHTML = NewInnerHTML + "
";if(bookOnClick == "booking") {NewInnerHTML = NewInnerHTML + " "+decode(bookWord).toUpperCase()+"";} else {NewInnerHTML = NewInnerHTML + " "+decode(bookWord).toUpperCase()+"";}NewInnerHTML = NewInnerHTML + "
";Including = '';if (typeof arrIncluding[thisProdID] !== "undefined")Including = arrIncluding[thisProdID];if(Including != '') { NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + Including.replace(/(\r\n|\n|\r)/g,"
");NewInnerHTML = NewInnerHTML + "
";}NewInnerHTML = NewInnerHTML + "
";NewInnerHTML = NewInnerHTML + "
";}}}if (NewInnerHTML=="") { NewInnerHTML = "
L'informatique indique que l'établissement est hélas complet pour les dates demandées, ou la configuration de votre famille fait que notre serveur n'arrive pas à calculer une solution intéressante, ou encore un séjour minimum est demandé. N'hésitez pas à contacter un de nos conseillers (ils sont francophones), il ou elle fera beaucoup mieux que le meilleur des programmes informatiques. [demandes@vacances-en-sardaigne.fr]
"; }var btn_calendar = 'Calendrier';tjq("#priceFinder").append('
'+btn_calendar+'
'+NewInnerHTML+'
'+btn_calendar+'
');});}}tjq(document).on('click','.bookingBtn', function(){var pr = tjq(this).attr("value");for(i=0; i< arrPrices[pr].length; i++){tjq('#bookingForm').append('');if (arrPrices[pr][i][0]=="calcArrivalDate") tjq('#bookingForm').append('');if (arrPrices[pr][i][0]=="calcDepartureDate") tjq('#bookingForm').append('');}tjq('#bookingForm').append('');tjq('#bookingForm').append('');tjq('#bookingForm').append('');tjq('#bookingForm').append('');tjq('#bookingForm').append('');tjq('#bookingForm').append('');document.getElementById("bookingForm").submit();});function searchDatesString(){var searchInfoText = "";var childrenText = "";arrArr = tjq("#bookSearch input[name=date_from]").val().split("/");arrDep = tjq("#bookSearch input[name=date_to]").val().split("/");var jArr = new Date(arrArr[2], arrArr[1]-1, arrArr[0], 12, 0, 0, 0);var jDep = new Date(arrDep[2], arrDep[1]-1, arrDep[0], 13, 0, 0, 0);var arrayWeekdays = ["Di","Lu","Ma","Me","Je","Ve","Sa"];var arrWeekday = arrayWeekdays[jArr.getDay()];var depWeekday = arrayWeekdays[jDep.getDay()];var nbOfNights = parseInt((jDep.getTime()-jArr.getTime())/(24*3600*1000));if (nbOfNights==1){nightsName = "nuit";}else{nightsName = "nuits";}searchInfoText = arrArr[0] + '.' + arrArr[1] + ' (' + arrWeekday + ') - ' + arrDep[0] + '.' + arrDep[1] + ' (' + depWeekday + ')';searchInfoText = searchInfoText + ', ' + nbOfNights + ' ' + nightsName;return searchInfoText;}function searchPersonString(){var searchInfoText = "";var childrenText = "";if(ChildrenAges!=""){arrChildren = ChildrenAges.split(",");nbOfChildren = arrChildren.length;if(nbOfChildren>0){childrenText = ', ' + nbOfChildren + ' Enfant(s) (';newChildren = "";for(ch=0;ch0) newChildren = newChildren + ",";newChildren = newChildren + "" + arrChildren[ch];}arrNewChildren = newChildren.split(",");arrNewChildren.sort(function(a,b){return a-b}); newChildren = "";for(nc=0; nc < arrNewChildren.length; nc++){if(newChildren!="") newChildren = newChildren + ", ";newChildren = newChildren + "" + arrNewChildren[nc];}childrenText = childrenText + newChildren;childrenText = childrenText + ' ans)';}}searchInfoText = tjq("#madults option:selected").val() + ' Adulte(s)' + childrenText;return searchInfoText;}function escapeRegExp(str) {return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");}function replaceAll(str, find, replace) {return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);}function decode(str) {var d = document.createElement("div");d.innerHTML = str; return typeof d.innerText !== 'undefined' ? d.innerText : d.textContent;}function gotoBookmark(tab,bookmark) {tjq( tab ).click();window.location.href = bookmark;}tjq("#more_feed").on("click",function(){if(parseInt(tjq(this).attr("value")) >= parseInt(tjq(this).attr("maxvalue"))) {tjq("#block_feed_"+(parseInt(tjq(this).attr("value"))*10)).css("display","");tjq(this).css("display","none");} else { tjq("#block_feed_"+(parseInt(tjq(this).attr("value"))*10)).css("display","");tjq(this).attr("value", (parseInt(tjq(this).attr("value"))+1));if((parseInt(tjq(this).attr("value"))) >= parseInt(tjq(this).attr("maxvalue")))tjq(this).css("display","none");}});tjq(document).scroll(function() {var y = tjq(this).scrollTop();if (y > 1200) {tjq('#div_btn_search').removeClass('hidden-xs');tjq('#div_btn_search').fadeIn();} else {tjq('#div_btn_search').fadeOut();}});tjq('#btn_search-box').on('click', function() {tjq('html,body').animate({scrollTop: tjq("#search-box").offset().top}, 3000);});