/* This function is used to ajax in the respective content for the full details content */ var AJAX_SEARCH_TIMMER; var AJAX_SEARCH_TIMEOUT = 1000; function ajaxInAccommodationFullDetailsContent (obj, name, category, id) { var tab = obj; if (tab) { $.post ( BASE + "/" + category + "/ajax/get_ajax_" + tab.id + ".php", {name: "" + name + "" , category: "" + category + "", id: "" + id}, function (data) { $("#ajax_content_div").html(data); changeDivStyles(tab.id); } ); } } function changeDivStyles (tab) { if ($("#tabs_container")) { if (tab == "map") { $("#tabs_container").className = "block block-tabs block-pre-map"; //setTimeout("load();", 1000); } else if (tab == "pricing") { $("#tabs_container").className = "block block-tabs block-pre-map"; } else { $("#tabs_container").className = "block block-tabs"; } } if (lastActive == tab) { return; } if ($("#"+lastActive + "_tab").hasClass("active")) { $("#"+lastActive + "_tab").removeClass("active"); if ($("#"+ tab + "_tab")) { $("#"+ tab + "_tab").addClass("active"); } lastActive = tab; $("#hidden_type").val(tab.replace("-", " ").replace("-", " ")) } else { if ($("#"+tab + "_tab")) { $("#"+tab + "_tab").addClass("active"); } lastActive = tab; $("#hidden_type").val(tab.replace("-", " ").replace("-", " ")) } if ($("#tab_text")) { if ($("#"+tab + "_text")) { $("#tab_text").html($("#" + tab + "_text").html()); } } } function ajaxInAccommodationSearchResultsTabs (type, cat, search_term, min_price, max_price, max_people, page, order, rating, allIds, changePageNumbers) { $("#ajax_content_div").html('


Loading...
Loading

'); var tab = $("#"+type); //change the page variable to minus one, because the php seach logic reads the first page as 0 not 1 page = (page == "") ? 0 : page-1; order = (order == "" || order == "undefined" || order == "null") ? "price" : order; var theType = (type == "all") ? "" : type.replace("-", " ").replace("-", " "); if (tab) { $.post ( BASE + "/" + category + "/ajax/get_ajax_search_results.php", {type: ""+theType, key_word: ""+search_term, "min-price": ""+min_price, "max-price": ""+max_price, max_persons: ""+max_people, page: ""+page, order_by: ""+order, category: ""+cat, bct_rating: ""+((rating == undefined) ? "" : rating), all_ids: "" + allIds}, function (data) { if (changePageNumbers!="dontChangePageNumbers") { $("#page div.accomodation-tabs div.bg-inputs input.form-text").val(1); } eval("var response = " + data); $("#ajax_content_div").html(response["html"]); $("#from_results").html(response["from"]); $("#from_results2").html(response["from"]); $("#to_results").html(response["to"]); $("#to_results2").html(response["to"]); $("#total_results").html(response["total"]); $("#total_results2").html(response["total"]); $("#total_pages").html(response["totalPages"]); $("#total_pages2").html(response["totalPages"]); totalPages = response["totalPages"]; if (changePageNumbers!="dontChangePageNumbers") { //this tab is opened the first time so we must be on the first page, therefore we hide the previous tab document.getElementById("paginate_prev").style.display = "none"; document.getElementById("paginate_prev2").style.display = "none"; if (response["totalPages"] > 1) { //there is more than one page, so show the next div so the user can paginate document.getElementById("paginate_next").style.display = "block"; document.getElementById("paginate_next2").style.display = "block"; } else { //there is less than one page, so hide the next div document.getElementById("paginate_next").style.display = "none"; document.getElementById("paginate_next2").style.display = "none"; } } //alert(response["info"]); changeDivStyles(type.replace(" ", "-").replace(" ", "-")); } ); } } function ajaxInDetailedMap (pageID, pageCategory, mapID, theBack) { $.post ( "../ajax/ajax_fetch_map_search.php", {pageid: ""+pageID, category: ""+pageCategory, mapid: ""+mapID, back: ""+theBack}, function (data) { $("#ajax_content_div").html(data); $("#ajax_content_div").css({display:"block"}); } ); } function paginate_search_results (direction, cat) { if (direction == "next") { if (totalPages > currPage) { currPage++; if ($("#page div.accomodation-tabs div.bg-inputs input.form-text")) { $("#page div.accomodation-tabs div.bg-inputs input.form-text").val(currPage); } //check if we on the last page, then hide the next div if (totalPages == currPage) { document.getElementById("paginate_next").style.display = "none"; document.getElementById("paginate_next2").style.display = "none"; } else { //we not on the last page, so show the next div document.getElementById("paginate_next").style.display = "block"; document.getElementById("paginate_next2").style.display = "block"; } //As long as we past the first page, the prev div can show if (currPage > 1) { document.getElementById("paginate_prev").style.display = "block"; document.getElementById("paginate_prev2").style.display = "block"; } ajaxInAccommodationSearchResultsTabs($("#hidden_type").val(), cat, $("#hidden_key_word").val(), $("#hidden_min_price").val(), $("#hidden_max_price").val(), $("#hidden_adults").val(), currPage, $("#sortBy").val(), $("#bct_rating").val(), $("#all_ids").val(), "dontChangePageNumbers"); } else { alert("error in pagination, next div supposed to be hidden"); } } else { if (currPage > 1) { currPage--; if ($("#page div.accomodation-tabs div.bg-inputs input.form-text")) { $("#page div.accomodation-tabs div.bg-inputs input.form-text").val(currPage); } //check if we on the first page, then hide the prev div if (currPage == 1) { document.getElementById("paginate_prev").style.display = "none"; document.getElementById("paginate_prev2").style.display = "none"; } else { //we not on the first page, so show the prev div document.getElementById("paginate_prev").style.display = "block"; document.getElementById("paginate_prev2").style.display = "block"; } //As long as we not yet on the last page, the next div can show if (totalPages > currPage) { document.getElementById("paginate_next").style.display = "block"; document.getElementById("paginate_next2").style.display = "block"; } ajaxInAccommodationSearchResultsTabs($("#hidden_type").val(), cat, $("#hidden_key_word").val(), $("#hidden_min_price").val(), $("#hidden_max_price").val(), $("#hidden_adults").val(), currPage, $("#sortBy").val(), $("#bct_rating").val(), $("#all_ids").val(), "dontChangePageNumbers"); } else { alert("error in pagination, prev div supposed to be hidden"); } } } /** * Return void * Clear value of an input * these cases @ Parameters HtmlIput obj **/ function clearFormValue (obj) { if (obj.value == "E.g Camps Bay, Bantry Bay") obj.value = ""; } /** * Return void * Perform ajax search for retrieve * object prior to clicking searhc **/ function doAjaxAreaSearch (form) { var form_object = document.getElementById (form); var serial_data = $("#" + form).serialize (); if (AJAX_SEARCH_TIMMER) window.clearTimeout (AJAX_SEARCH_TIMMER); AJAX_SEARCH_TIMMER = window.setTimeout (function () { $.post ( BASE + "/tours/ajax/ajax_tours_units_search.php", serial_data, function (data) { $$(form_object.finish_field.value).innerHTML = data; $$(form_object.finish_field.value).style.display = "block"; $('#btn-dest-list').toggleClass('btn-dest-active'); $('#popup-destination-list').toggleClass('destination-list-hide'); redoJQueryCallsForAjaxedResultsContent(); } ); }, AJAX_SEARCH_TIMEOUT); } function redoJQueryCallsForAjaxedResultsContent () { $('#popup-destination-list a.close').click(function(){ $('#btn-dest-list').removeClass('btn-dest-active'); $('#popup-destination-list').addClass('destination-list-hide'); return false; }); } /** * Return void * retrieve name for page objects * and populate fields and ids **/ function updateKeyWordField (form) { var form_object = document.getElementById (form); var serial_data = $("#" + form).serialize (); $.post ( BASE + "/"+category+"/ajax/ajax_accommodation_update_units_search.php", serial_data, function (data) { eval ("data = " + data); form_object.your_destination.value = data ['key_phrases']; } ); } function populateTypeHiddenField() { var theSelectedValue = $(".jquery-selectbox-currentItem"); var theHiddenInput = $("#hiddenType"); if (theSelectedValue) { theHiddenInput.val(theSelectedValue.html()); } return true; }