﻿function bindCityLanding(a, b) { $.ajax({ type: "POST", url: "Results.aspx/GetCitiesStates", data: '{"state" : "' + a.value + '", "country" : "' + b + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (c) { jQuery("li#dropdown-bottom").show(); jQuery("li#dropdown-bottom span").html("Select City"); jQuery("#ddlDefaultSearchTwo").html(c.d); jQuery("#ddlDefaultSearchTwo").show(); jQuery("#ddlDefaultSearchTwo").attr("onChange", "redirect(this, '" + b + "', '" + a.value + "', false, false, true)") }, error: function () { alert("Error!") } }) } function bindCityDefaultMain(a) { if (!isKeyMarket(a, "")) { $.ajax({ type: "POST", url: "Results.aspx/GetCities", data: '{"country" : "' + a.value + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (b) { jQuery("li#dropdown-bottom").show(); jQuery("li#dropdown-bottom span").html("Select City"); jQuery("#ddlDefaultSearchTwo").html(b.d); jQuery("#ddlDefaultSearchTwo").attr("onChange", "redirect(this, '" + a.value + "', '', false, false, true)") }, error: function () { alert("Error!") } }) } } function bindCityDefault(a) { if (!isKeyMarket(a, "")) { $.ajax({ type: "POST", url: "Results.aspx/GetCities", data: '{"country" : "' + a.value + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (b) { jQuery("#search-dropdown-menu-bottom span").html("Select City"); jQuery("#ddlSearchtwo").html(b.d); jQuery("#ddlSearchtwo").attr("onChange", "redirect(this, '" + a.value + "', '', false, false, true)") }, error: function () { alert("Error!") } }) } } function bindCity(a, b) { $path = getPath(b); $.ajax({ type: "POST", url: $path + "Results.aspx/GetCitiesStates", data: '{"state" : "' + a.value + '", "country" : "' + b + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (c) { jQuery("#search-dropdown-menu-bottom span").html("Select City"); jQuery("#ddlSearchtwo").html(c.d); jQuery("#ddlSearchtwo").attr("onChange", "redirect(this, '" + b + "', '" + a.value + "', false, true, false)") }, error: function () { alert("Error!") } }) } function bindCityGlobal(a) { if (!isKeyMarket(a, "../../")) { $.ajax({ type: "POST", url: "../../Results.aspx/GetCities", data: '{"country" : "' + a.value + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (b) { jQuery("#search-dropdown-menu-bottom span").html("Select City"); jQuery("#ddlSearchtwo").html(b.d); jQuery("#ddlSearchtwo").attr("onChange", "redirect(this, '" + a.value + "', '', false, true, false)") }, error: function () { alert("Error!") } }) } } function isKeyMarket(a, b) { if (a.value == "USA") { window.location = b + "USA.aspx"; return true } if (a.value == "United Kingdom") { window.location = b + "UK.aspx"; return true } if (a.value == "Australia") { window.location = b + "Australia.aspx"; return true } return false } function redirect(a, b, c, d, e, f) { if (d) { window.location = ("District/United-Kingdom/" + a.value + ".aspx").replace(/\s+/g, "-"); return } if (e) { if (b == "USA") window.location = ("../../../Executive-Suites/" + b + "/" + c + "/" + a.value + ".aspx").replace(/\s+/g, "-"); else window.location = ("../../Office-Space/" + b + "/" + a.value + ".aspx").replace(/\s+/g, "-"); return } if (f) { if (b == "USA") window.location = ("Executive-Suites/" + b + "/" + c + "/" + a.value + ".aspx").replace(/\s+/g, "-"); else window.location = ("Office-Space/" + b + "/" + a.value + ".aspx").replace(/\s+/g, "-"); return } } function closeRegistration(a) { $aExpand = "a[name=a-expand-" + a + "]"; $aClose = "a[name=a-close-" + a + "]"; jQuery($aExpand).css("display", "block"); jQuery($aClose).css("display", "none"); $panRegisterAjax = ".pan-" + a; jQuery($panRegisterAjax).slideToggle(400) } function openRegistration(a, b) { $registration = jQuery("#ajax-registration").html(); $clone = jQuery($registration).clone(); jQuery($clone).find("#a-register").attr("href", "javascript:register(" + a + ", " + b + ", '');"); jQuery($clone).find("#txtTitleAjax").attr("class", "title-" + a); jQuery($clone).find("#txtFirstNameAjax").attr("class", "first-" + a); jQuery($clone).find("#txtLastNameAjax").attr("class", "last-" + a); jQuery($clone).find("#txtCompanyNameAjax").attr("class", "company-" + a); jQuery($clone).find("#txtEmailAjax").attr("class", "email-" + a); jQuery($clone).find("#txtTelephoneAjax").attr("class", "telephone-" + a); jQuery($clone).find("#ddlPeopleAjax").attr("class", "people-" + a); jQuery($clone).find("#error").attr("class", "error-" + a); $aExpand = "a[name=a-expand-" + a + "]"; $aClose = "a[name=a-close-" + a + "]"; $panRegister = ".pan-" + a; jQuery($aExpand).css("display", "none"); jQuery($aClose).css("display", "block"); jQuery($panRegister).html($clone); jQuery($panRegister).slideToggle(400) } function saveCentre(a, b) { $country = jQuery("#lblCountryName").html(); $path = getPath($country); $html = jQuery("#updating").html(); $("#basic-modal-content").html($html).modal(); $.ajax({ type: "POST", url: $path + "Results.aspx/UpdateEnquiry", data: '{"centre" : "' + b + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (a) { if (a.d) { window.location = $path + "Login.aspx" } }, error: function () { alert("Error!") } }) } function validateTelephone(a) { var b = /[0-9-()+]{3,20}/; return b.test(a) } function validateEmail(a) { var b = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i; return b.test(a) } function validate(a, b, c, d, e, f, g, h, i) { var j = 0; var k = new Array; var l = "Please include area code."; if (a == "") { k[j] = "<li>Please Select Title</li>"; j = j + 1 } if (b == "") { k[j] = "<li>Please Enter First Name</li>"; j = j + 1 } if (c == "") { k[j] = "<li>Please Enter Last Name</li>"; j = j + 1 } if (d == "") { k[j] = "<li>Please Enter Company</li>"; j = j + 1 } if (e == "") { k[j] = "<li>Please Enter Email</li>"; j = j + 1 } if (!validateEmail(e)) { k[j] = "<li>Incorrect Email Format</li>"; j = j + 1 } if (f == "") { k[j] = "<li>Please Enter Telephone</li>"; j = j + 1 } if (f == l) { k[j] = "<li>Please Enter Telephone</li>"; j = j + 1 } if (!validateTelephone(f)) { k[j] = "<li>Incorrect Telephone format</li>"; j = j + 1 } if (g == "") { k[j] = "<li>Please Enter Office Size</li>"; j = j + 1 } if (j != 0) { $html = "<ul>" + k.join(" ") + "</ul>"; if (i) { jQuery("#error-multi").html($html) } else { jQuery(".error-" + h).html($html) } return false } else return true } function getPath(a) { if (a == "USA") return "../../../"; else return "../../" } function getCentres(a) { var b = new Array; var c = 0; for (i = 0; i < a; i++) { $checkBox = jQuery("#checkbox-" + i); if (jQuery($checkBox).is(":checked")) { b[c] = jQuery($checkBox).val(); c++ } } return b.join() } function register(a, b, c) { $title = jQuery(".title-" + a).val(); $first = jQuery(".first-" + a).val(); $second = jQuery(".last-" + a).val(); $company = jQuery(".company-" + a).val(); $email = jQuery(".email-" + a).val(); $telephone = jQuery(".telephone-" + a).val(); $people = jQuery(".people-" + a).val(); $country = jQuery("#lblCountryName").html(); $multi = false; if (c) { $centreID = getCentres(c); $multi = true } else { $centreID = b } $path = getPath($country); if (validate($title, $first, $second, $company, $email, $telephone, $people, a, $multi)) { $html = jQuery("#updating").html(); $("#basic-modal-content").html($html).modal(); $.ajax({ type: "POST", url: $path + "Results.aspx/SubmitEnquiry", data: '{"centre" : "' + $centreID + '", "country" : "' + $country + '", "title" : "' + $title + '", "firstName" : "' + $first + '", "lastName" : "' + $second + '", "company" : "' + $company + '", "email" : "' + $email + '", "telephone" : "' + $telephone + '", "numberOfPeople" : "' + $people + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (a) { if (a.d) { window.location = $path + "Login.aspx?ID=1" } }, error: function () { alert("Error!") } }) } } $(document).ready(function () { $page = $("body").attr("class"); switch ($page) { case "data-role-results": $("select#ddlSearchOne").uniform(); $("select#ddlSearchtwo").uniform(); break; case "data-role-content": $("select#ddlSearchOne").uniform(); $("select#ddlSearchtwo").uniform(); break; default: $("select").uniform(); break } })
