PageSourceSearch

https://www.sulekhaevents.ca/common/js/header.js?ver=0.0.0.3.3

js sulekhaevents.ca collected 2026-10-08 14:39:40 UTC 145,814 bytes, 2,814 lines download raw bytes

1var Isoverlay = 0, Iscurtain = 0;
2var service = "", googleservice = "";
3var isfirsttimeuser = "";
4var ckusrloc = "", ckusrcity = "", sulloglink = "", loginversion = "2";
5var getdimensionone = "", slocdetail = "";
6
7var gProtocol = (('http:' == document.location.protocol) ? 'http://' : 'https://');
8var vrlocsetdata = "";
9var liselect = "";
10var getnavclass = "";
11$SUL = jQuery.noConflict();
12var gblscrolltextappend = "";
13var ckusrloc = "", ckusrcity = "", ckusrcountry = "", sulloglink = "", loginversion = "2", slocdetail = "";
14var cklat = "", cklong = "";
15var isvalidated = false;
16
17function adjustStyle(width) {
18    width = parseInt(width);
19    if (width < 480) {
20        document.write("<link id=\"size-stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"https://d3aew4oo17ml6.cloudfront.net/common/css/narrow.css?r=20.201.201\" />");
21    }
22    else if ((width >= 480) && (width < 1025)) {
23        document.write("<link id=\"size-stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"https://d3aew4oo17ml6.cloudfront.net/common/css/normal.css?r=20.201.200\" />");
24    } else if ((width >= 1025) && (width <= 1280)) {
25        document.write("<link id=\"size-stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"https://d3aew4oo17ml6.cloudfront.net/common/css/medium.css?r=20.201.200\" />");
26    } else if ((width >= 1281) && (width < 1450)) {
27        document.write("<link id=\"size-stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"https://d3aew4oo17ml6.cloudfront.net/common/css/wide.css?r=20.201.200\" />");
28    }
29    else {
30        document.write("<link id=\"size-stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"https://d3aew4oo17ml6.cloudfront.net/common/css/widest.css?r=20.201.200\" />");
31    }
32}
33//adjustStyle($SUL(this).width());
34
35function adjustStylev2(width) {
36    width = parseInt(width);
37    if (width < 480) {
38        $SUL("#size-stylesheet").attr("href", "https://d3aew4oo17ml6.cloudfront.net/common/css/narrow.css?r=20.201.201");
39
40    }
41    else if ((width >= 480) && (width < 1025)) {
42        $SUL("#size-stylesheet").attr("href", "https://d3aew4oo17ml6.cloudfront.net/common/css/normal.css?r=20.201.200");
43
44    } else if ((width >= 1025) && (width <= 1280)) {
45        $SUL("#size-stylesheet").attr("href", "https://d3aew4oo17ml6.cloudfront.net/common/css/medium.css?r=20.201.200");
46
47    } else if ((width >= 1281) && (width < 1450)) {
48        $SUL("#size-stylesheet").attr("href", "https://d3aew4oo17ml6.cloudfront.net/common/css/wide.css?r=20.201.200");
49
50    }
51    else {
52        $SUL("#size-stylesheet").attr("href", "https://d3aew4oo17ml6.cloudfront.net/common/css/widest.css");
53
54    }
55}
56
57$SUL(window).resize(function () {
58    //adjustStylev2($SUL(this).width());
59});
60
61//function replacespl(dirname) {
62//    return dirname.toLowerCase().replace(/[^a-z0-9]+/ig, "-"); /*finds all sequences of non alphanumeric characters.*/
63//}
64function replacespl(dirname) {
65    try {
66        if (typeof dirname !== 'string') {
67            throw new TypeError("Input must be a string");
68        }
69        return dirname.toLowerCase().replace(/[^a-z0-9]+/ig, "-"); // Finds all sequences of non-alphanumeric characters.
70    } catch (error) {
71        console.error("An error occurred in replacespl:", error.message);
72        return null; // Return null or any default value as fallback
73    }
74}
75function getCookieV2(c_name) {
76    var c_value = document.cookie;
77    var c_start = c_value.indexOf(" " + c_name + "=");
78    if (c_start == -1) {
79        c_start = c_value.indexOf(c_name + "=");
80    }
81    if (c_start == -1) {
82        c_value = null;
83    }
84    else {
85        c_start = c_value.indexOf("=", c_start) + 1;
86        var c_end = c_value.indexOf(";", c_start);
87        if (c_end == -1) {
88            c_end = c_value.length;
89        }
90        c_value = unescape(c_value.substring(c_start, c_end));
91    }
92    return c_value;
93}
94
95
96function feedbackwithnameclick() {
97    setTimeout(function () {
98        $SUL('.quote-carousel .feedname').each(function (e) {
99            var feedTxt = $SUL(this).find('.feeder').text();
100            $SUL('.quote-carousel .owl-pagination .owl-page').eq(e).children('span').attr('data-content', feedTxt);
101        });
102    }, 600);
103}
104
105/*<div class="owl-buttons"><div class="owl-prev">prev</div><div class="owl-next">next</div></div>*/
106/*events slider*/
107function fnfootmenu() {
108    $SUL('.mrefoot').on('click', function () {
109        $SUL('.mrefoot').hide();
110        $SUL('#footmenu').slideDown("slow");
111    });
112    if ($SUL('#lifeedback').length > 0) {
113        $SUL('.fbktrigger').on('click', function () {
114            fnfbkshow();
115        });
116    }
117}
118
119function fndropmenushowhide() {
120    $SUL('.navigator .ntitle').click(function () {
121        $SUL('.navigator .ntitle').removeClass('active');
122        $SUL('ul.navsub').slideUp('slow');
123        if ($SUL(this).next().is(':hidden')) {
124            $SUL(this).addClass('active');
125            $SUL(this).next().slideDown('slow').css('overflow', 'auto');
126        }
127    });
128
129    $SUL('.navigator .ntitle').mouseover(function () {
130        $SUL(this).addClass('over');
131    }).mouseout(function () {
132        $SUL(this).removeClass('over');
133    });
134}
135function fnmenushowclose() {
136    $SUL('div.hammenu-hd').find('a').on('click', function () {
137        if ($SUL('html').hasClass("menu-nav"))
138            $SUL('html').removeClass("menu-nav");
139        else
140            $SUL('html').addClass("menu-nav");
141    });
142    $SUL('div.hamclose').find('em').on('click', function () {
143        $SUL('html').removeClass("menu-nav");
144
145        $SUL('body').removeClass("in-scrolll");
146        $SUL('nav .navigator').removeClass("inline-scroll");
147
148
149    });
150}
151
152function fnscrollsearchtxtappend() {
153    gblscrolltextappend = "<div class=\"search-hd\"> <div class=\"search-wrapper\"> <div class=\"src-hd-bx\"> <span class=\"select-wrapper\"> <select id=\"drpcmnsearch\" name=\"drpcmnsearch\" class=\"custom-select\"> <option value=\"ALL\">ALL</option> <option value=\"Events\">Events</option> <option value=\"Roommates\">Roommates</option> <option value=\"Rentals\">Rentals</option> <option value=\"IT Training\">IT Training</option> <option value=\"Jobs\">Jobs</option> <option value=\"Day Care\">Day Care</option> <option value=\"Local Biz\">Local Biz</option> <option value=\"Services\">Services</option><option value=\"Property\">Property</option> <option value=\"Lawyers\">Lawyers</option> <option value=\"Classifieds\">Classifieds</option> <option value=\"Travel\">Travel</option> </select> <span class=\"holder\">All</span></span></div> <span class=\"src-hd-axn\"><a id=\"atopsearch\" href=\"javascript:void(0);\" class=\"btn\"><i class=\"fa fa-search\"></i><b>Search</b></a> </span><span class=\"mobsrclose\"><i class=\"fa fa-times\"></i></span> <div class=\"src-hd-wrp\"> <div class=\"src-hd-text\"> <input  class=\"relative\" type=\"text\" id=\"txtussearch\" name=\"txtussearch\" maxlength=\"35\" placeholder=\"Enter the keyword to search\"> <div class=\"loaderhome ustxtfetching hide\">  <input type=\"hidden\" id=\"cx\" name=\"cx\" value=\"partner-pub-3470583419345383:4094399283\" /> <input type=\"hidden\" id=\"cof\" name=\"cof\" value=\"FORID:10\" /> <input type=\"hidden\" id=\"GblSearch_h\" name=\"GblSearch_h\" value=\"\" /> </div> </div> </div> <div class=\"search-suggest-hd\" id=\"div_topsearch_result\" style=\"display: none;\"><span class=\"sugg\">Search Suggestions</span> <div id=\"div_hdrsearch_result\" class=\"wraper\"></div> </div> </div> </div>";
154    $SUL('div.location-hd').after(gblscrolltextappend);
155    $SUL("select.custom-select").change(function () {
156        var selectedOption = $SUL(this).find(":selected").text();
157        $SUL(this).next("span.holder").text(selectedOption);
158    }).trigger('change');
159
160}
161
162
163function fnmainsearchdivappend() {
164    $SUL('#divmainsrch').after('<div class=\"drop-result-wraper service-wraper\" id=\"div_topsearchmain_result\"> <div class=\"wraprelate\"> <div id="div_hdrsearchmain_result" class=\"wraper\">  </div> </div> </div>');
165    $SUL('#divmainlocation').append('<div class=\"drop-result-wraper service-wraper\" id=\"div_locationmain_result\"> <div class=\"wraprelate\"> <div id="div_paglocationmain_result" class=\"wraper\">  </div> </div> </div>');
166}
167
168function BackToTop() {
169    var btphtml = "<a id=\"BacktoTop\" title=\"Back to top\" href=\"javascript:void(0);\" class=\"cd-top\"><span><b><i class=\"fa fa-long-arrow-up\"></i></b></span></a>";
170    $SUL(document.body).append(btphtml);
171    $SUL.event.add(window, "scroll", function () {
172        if ($SUL(this).scrollTop() > 400) { $SUL("#BacktoTop").addClass("cd-top cd-is-visible"); }
173        if ($SUL(this).scrollTop() < 400) { $SUL("#BacktoTop").addClass("cd-top").removeClass("cd-is-visible"); }
174    });
175    $SUL('#BacktoTop').click(function () {
176        $SUL('body,html').animate({
177            scrollTop: 0
178        }, 1000);
179        return false;
180    });
181}
182function fnlocsetdata() {
183    vrlocsetdata = '<div class=\"dropdown-content\"> <span class=\"close\"><span id=\"clscty\" class=\"clsoeico\">X</span></span> <div class=\"mainhd\">Choose your location</div> <div class=\"form-wraper\"> <div class=\"form-wrap\" id=\"form-wrap\"> <div class=\"form-wrapin\"> <input type=\"text\" id=\"txtcountry\" name=\"txtcountry\" value=\"\" placeholder=\"Canada\" readonly=\"readonly\" /> <div class=\"drop-result-wraper city-wraper\" id=\"divcountry\"> <div class=\"wraprelate\"> <div class=\"wraper\"> <ul class=\"result-menu\"> <li><a href=\"javascript:void(0);\"><i>Canada</i></a></li></ul> </div> </div> </div> </div> </div> <div class=\"formtext relative\"> <input type=\"text\" class=\"relative\" id=\"txtprefcty\" name=\"txtprefcty\" placeholder=\"Enter a Zip Code or City\" /> <div class=\"loaderhome ustxtfetching hide\">  </div> </div> <span class=\"dummy\"></span><span class=\"formcta\"><a href=\"javascript:void(0);\" class=\"btn btn-red uploc\" title=\"Update Location\">Update Location</a></span> </div>  <div class=\"citymetro\"> <div class=\"cm-inner \"> <p class=\"citymar\"> Metro </p> <ul class=\"content-2\"> <li><a title=\"Calgary Metro Area\" onclick=\"fncommoncitibymetrourl(\'calgary-metro-area\');\" href=\"javascript:void(0);\"> Calgary Metro Area <i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"Charlottetown Metro Area\" onclick=\"fncommoncitibymetrourl(\'charlottetown-metro-area\');\" href=\"javascript:void(0);\"> Charlottetown Metro Area <i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"Edmonton Metro Area\" onclick=\"fncommoncitibymetrourl(\'edmonton-metro-area\');\" href=\"javascript:void(0);\"> Edmonton Metro Area <i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"Halifax Metro Area\" onclick=\"fncommoncitibymetrourl(\'halifax-metro-area\');\" href=\"javascript:void(0);\"> Halifax Metro Area <i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"Montreal Metro Area\" onclick=\"fncommoncitibymetrourl(\'moncton-metro-area\');\" href=\"javascript:void(0);\"> Montreal Metro Area<i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"Saskatoon Metro Area\" onclick=\"fncommoncitibymetrourl(\'saskatoon-metro-area\');\" href=\"javascript:void(0);\"> Saskatoon Metro Area<i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"ST Johns Metro Area\" onclick=\"fncommoncitibymetrourl(\'st-johns-metro-area\');\" href=\"javascript:void(0);\"> ST Johns Metro Area <i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"St.John\'s Metro Area\" onclick=\"fncommoncitibymetrourl(\'st-john-s-metro-area\');\" href=\"javascript:void(0);\"> St.John\'s Metro Area <i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"Toronto Metro Area\" onclick=\"fncommoncitibymetrourl(\'toronto-metro-area\');\" href=\"javascript:void(0);\"> Toronto Metro Area <i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"Vancouver Metro Area\" onclick=\"fncommoncitibymetrourl(\'vancouver-metro-area\');\" href=\"javascript:void(0);\"> Vancouver Metro Area <i class=\"fa fa-angle-right\"></i></a></li> <li><a title=\"Winnipeg Metro Area\" onclick=\"fncommoncitibymetrourl(\'winnipeg-metro-area\');\" href=\"javascript:void(0);\"> Winnipeg Metro Area <i class=\"fa fa-angle-right\"></i></a></li> </ul> </div> <div id=\"divctyld\" class=\"cm-inner\"> <p> Top Cities </p> <ul class=\"content-3 relative\">  <li>  <a href=\"javascript:void(0);\" title=\"Sulekha Toronto\" onclick=\'selectCityV2({\"label\":\"Toronto, ON\",\"title\":\"Toronto\",\"country\":\"canada\",\"countrycode\":\"CA \",\"statecode\":\"ON\",\"state\":\"Ontario \",\"city\":\"Toronto\",\"zipcode\":\"M3B 0A3\",\"latitude\":\"43.745906\",\"longitude\":\"-79.352188\",\"citystatecodeurl\":\"toronto-on\",\"metrourl\":\"toronto-metro-area\"},1)\'> Toronto </a>  </li> <li>  <a href=\"javascript:void(0);\" title=\"Sulekha Vancouver\" onclick=\'selectCityV2({\"label\":\"Vancouver, BC\",\"title\":\"Vancouver\",\"country\":\"canada\",\"countrycode\":\"CA \",\"statecode\":\"BC\",\"state\":\"British Columbia \",\"city\":\"Vancouver\",\"zipcode\":\"V5K 0A1\",\"latitude\":\"49.289956\",\"longitude\":\"-123.040784\",\"citystatecodeurl\":\"vancouver-bc\"},1)\'> Vancouver</a></li> </ul> </div> </div>  <div class=\"go-to-other\"> <ul> <li class=\"uk-gl\"><a title=\"Sulekha Global - US/CA\" href=\"https://us.sulekha.com/\"><span class=\"flag-icon flag-icon-us\"></span>Stay on Global Sulekha</a></li><li class="uk-gl"><a title="Sulekha Canada" href="https://ca.sulekha.com/"><span class="flag-icon flag-icon-ca"></span>CA Sulekha</a></li> <li class=\"india-fl\"><a title=\"Sulekha India\" href=\"http://sulekha.com/\"><span class=\"flag-icon flag-icon-in\"></span> India Sulekha</a></li></ul> </div> </div>';
184}
185function fnshowlocationlist() {
186    ckusrloc = getCookieV2('sulusrloc'); ckusrcity = ckusrloc.split("::")[4]; ckusrcountry = ckusrloc.split("::")[0];
187    cklat = ckusrloc.split("::")[6]; cklong = ckusrloc.split("::")[7];
188    var gbllocation = $SUL.trim($SUL('#gbllocation').html());
189    if (gbllocation == "") {
190        $SUL('#gbllocation').html(vrlocsetdata);
191        fntabshowpopularcity();
192        fncountrycityshow();
193        //fnmobileviewsearch();
194        fnaddactlocclass();
195        $SUL.getScript('/common/js/usScrollbar.js', function () {
196            if (typeof (mCustomScrollbar) != undefined && typeof (mCustomScrollbar) != 'undefined') {
197                $SUL(".content-2").mCustomScrollbar({
198                    scrollButtons: { enable: true },
199                    theme: "light-thick",
200                    scrollbarPosition: "outside"
201                });
202                $SUL(".content-3").mCustomScrollbar({
203                    scrollButtons: { enable: true },
204                    theme: "light-thick",
205                    scrollbarPosition: "outside"
206                });
207            }
208        });
209        //$SUL.ajax({
210        //    url: "/html/locationlistv2.html", cache: false, success: function (data) {
211
212        //    }
213        //});
214    }
215    else {
216
217    }
218    $SUL('div.location-hd').find('a.location').on('click', function () {
219        $SUL('#gbllocation').show();
220        $SUL('body').addClass("blurbody");
221        //$SUL('body').addClass("overlay-black");
222        $SUL('#city-list-autoone').hide();
223        if ($SUL('#txtprefcty').length > 0) {
224            $SUL('#txtprefcty').val("");
225        }
226        fnhidesearchautocompletelist();
227
228    });
229    /*if (getCookieV2("firstUserUS") == "1")
230        $SUL('div.location-hd').find('a.location').trigger('click');*/
231}
232function fnhidelocationlist() {
233    if ($SUL('#gbllocation').length > 0) {
234        $SUL('#gbllocation').hide();
235        $SUL('body').removeClass("blurbody");
236        //$SUL('body').removeClass("overlay-black");
237    }
238}
239
240
241
242function validatecontactnumResp(id) {
243    if ($SUL("#" + id).length > 0) {
244        $SUL("#" + id).bind('focusout', function (event) {
245            if (Sulekha.Common.trim($SUL("#" + id).val()) == '') {
246                $SUL("#" + id + "Div").removeClass("alert");
247            }
248            else {
249                var digit = alldigitallowed($SUL("#" + id).val());
250                if (!digit) {
251                    $SUL("#" + id + "Div").removeClass("alert").addClass("alert");
252                    isvalidated = false;
253                }
254                else {
255                    $SUL("#" + id + "Div").removeClass("alert");
256                    isvalidated = true;
257                }
258
259            }
260        });
261        $SUL("#" + id).bind('focusout', function () {
262            if ($SUL("#" + id + "Div").length == 1) {
263                if ($SUL("#" + id).val().length < 10) {
264                    $SUL("#" + id + "Div").removeClass("alert").addClass("alert");
265                    isvalidated = false;
266                }
267            }
268        });
269    }
270}
271
272function alldigitallowed(n) {
273    if (/(\d)\1{2}\1{3}\1{4}/.test(n)) { return false; }
274    return true;
275}
276
277function getaplnk(pos) {
278
279    if (pos == undefined)
280        pos = "";
281
282    Sulekha.Validate.number('txtusmobile' + pos, 'txtusmobile' + pos, "Enter numbers only");
283    validatecontactnumResp("txtusmobile" + pos);
284
285    $SUL('#getaplnk' + pos).on('click', function () {
286        if (isvalidated) {
287            $SUL("#txtusmobile" + pos + "Div").removeClass("alert");
288            $SUL.ajax({
289                type: "POST",
290                url: "/common/objprocess.aspx?type=snp&usmob=" + $SUL('#txtusmobile' + pos).val().trim() + "&uscountrycode=" + $SUL('#selUsCountryCode' + pos).val(),
291                cache: false,
292                dataType: "json",
293                success: getaplnksuccess(pos),
294                error: getaplnkfailure
295            });
296        }
297        else {
298            $SUL("#txtusmobile" + pos + "Div").removeClass("alert").addClass("alert");
299        }
300    });
301    $SUL('#txtusmobile' + pos).on('focusout', function () {
302        var mobnumval = $SUL('#txtusmobile' + pos).val().trim();
303        var patt = new RegExp(/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/);
304        if (mobnumval.length > 9) {
305            if (!patt.test(mobnumval)) {
306                $SUL('#txtusmobile' + pos).val("");
307                isvalidated = false;
308            }
309        }
310        if (mobnumval.length == 0) {
311            $SUL("#lbl_usmobile" + pos).text(" Your mobile number ");
312        }
313        else {
314            $SUL("#lbl_usmobile" + pos).text("");
315        }
316    });
317
318    $SUL('#txtusmobile' + pos).off('focusin');
319    $SUL('#txtusmobile' + pos).on('focusin', function () {
320        $SUL("#txtusmobile" + pos + "_success").removeClass("show hide").addClass("hide");
321    });
322}
323function getaplnksuccess(pos) {
324    if ($SUL("#txtusmobile" + pos + "_success").length == 1) {
325        $SUL("#txtusmobile" + pos + "_success").html("<i class=\"fa fa-thumbs-o-up\">  </i> Link sent successfully");
326        $SUL("#txtusmobile" + pos + "_success").removeClass("show hide").addClass("show");
327    }
328
329}
330function getaplnkfailure() {
331
332}
333
334
335function fnhidesearchautocompletelist() {
336    if ($SUL('#div_topsearch_result').length > 0)
337        $SUL('#div_topsearch_result').hide();
338    if ($SUL('#div_topsearchmain_result').length > 0)
339        $SUL('#div_topsearchmain_result').hide();
340}
341
342function fnhidepagelocation() {
343    if ($SUL('#div_locationmain_result').length > 0)
344        $SUL('#div_locationmain_result').hide();
345}
346
347
348
349function fntophoverappdwl() {
350    $SUL('header').find('div.mobshowapptog').toggle();
351}
352
353
354
355
356function footerAccordion() {
357    $SUL('footer ul li ul').hide();
358    $SUL('footer .mainmenu').unbind().on('click', function () {
359        if (!($SUL(this).hasClass('active'))) {
360            $SUL('footer .mainmenu').removeClass('active');
361            $SUL('footer ul li ul').slideUp();
362        }
363        $SUL(this).toggleClass('active');
364        $SUL(this).next('ul').slideToggle();
365    });
366    /*if ($SUL(window).width() <= 992) {
367        $SUL('footer ul li ul').hide();
368        $SUL('footer .mainmenu').unbind().on('click', function () {
369            if (!($SUL(this).hasClass('active'))) {
370                $SUL('footer .mainmenu').removeClass('active');
371                $SUL('footer ul li ul').slideUp();
372            }
373            $SUL(this).toggleClass('active');
374            $SUL(this).next('ul').slideToggle();
375        });
376    } else {
377        $SUL('footer .mainmenu').removeClass('active').unbind();
378        $SUL('footer ul li ul').slideDown();
379    }*/
380}
381
382
383
384
385function fnmobileviewsearch() {
386    $SUL('a.shwsrch').on('click', function (e) {
387        $SUL('body').toggleClass("mobsrc");
388    });
389    $SUL('span.mobsrclose').on('click', function (e) {
390        $SUL('body').removeClass("mobsrc");
391    });
392}
393
394function fncountrycityshow() {
395    $SUL('#txtcountry').on('click', function () {
396        $SUL('#divcountry').show();
397        $SUL('#city-list-autoone').hide();
398    });
399    $SUL('#txtprefcty').on('click', function () {
400        $SUL('#divcountry').hide();
401    });
402    $SUL('#divcountry').find('ul.result-menu a').on('click', function () {
403        $SUL('#txtcountry').val($SUL(this).text());
404        $SUL('#divcountry').hide();
405        $SUL('#txtprefcty').val("");
406        ckusrcountry = $SUL(this).text();
407        if (ckusrcountry == "USA")
408            ckusrcountry = "united states";
409        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
410    });
411    /*autocomp*/
412    if ($SUL("#txtprefcty").length > 0) {
413        $SUL("#txtprefcty").after("<div id=\"city-list-autoone\" style=\"display:none\" class=\"drop-result-wraper city-wraper\"><div class=\"wraprelate\"><div class=\"wraper\"><input type=\"hidden\" id=\"selectedcityurl\" value=\"\" /><input type=\"hidden\" id=\"hdnselmetrourl\" value=\"\" /><input type=\"hidden\" id=\"currentPrefCountry\" value=\"\" /><ul  class=\"result-menu\" id=\"sul-cityone\"></ul></div></div></div>");
414        $SUL('#currentPrefCountry').val(ckusrcountry);
415    }
416    //$SUL('#globalcitypopup').find('select.stylds').on('change', function () {
417    //    //        $SUL('#prefctychg').find('span.select').html($SUL('#prefctychg').find('select.styled option:selected').text());
418    //    $SUL('#txtprefcty').val("");
419    //    ckusrcountry = $SUL('#globalcitypopup').find('select.stylds option:selected').text();
420    //    if (ckusrcountry == "USA")
421    //        ckusrcountry = "united states";
422    //});
423    $SUL("#txtprefcty").bind('keyup', function (event) {
424        if (event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 27) {
425            var cityval = "";
426            cityval = $SUL("#txtprefcty").val();
427            if (cityval.length > 1 && (ckusrcountry.toLowerCase() == 'united kingdom' || ckusrcountry.toLowerCase() == 'uk')) {
428                Sulekha.Auth.JSONGetData("https://www.sulekha.co.uk/common/common.aspx?type=searchcity&term=" + cityval + "&currentPrefCountry=" + ckusrcountry + "&callback=searchCityV2");
429            }
430            else if (cityval.length > 1 && ckusrcountry.toLowerCase() == 'uae') {
431                Sulekha.Auth.JSONGetData("https://www.sulekha.ae/common/common.aspx?type=searchcity&term=" + cityval + "&currentPrefCountry=" + ckusrcountry + "&callback=searchCityV2");
432            }
433            else if (cityval.length > 1) {
434                Sulekha.Auth.JSONGetData(gProtocol + "myaccount.sulekha.com/common/searchv2.aspx?term=" + cityval + "&currentPrefCountry=" + ckusrcountry + "&callback=searchCityV2");
435            }
436            else {
437                if ($SUL('#sul-city').length > 0)
438                    $SUL('#sul-city').html("");
439                if ($SUL('#sul-cityone').length > 0)
440                    $SUL('#sul-cityone').html("");
441                $SUL('#city-list-autoone').slideUp("fast");
442            }
443        }
444    });
445    $SUL("#txtprefcty").bind('focus', function (event) {
446        textval = $SUL("#txtprefcty").val().trim();
447        if (textval.length < 1) {
448            if ($SUL('#sul-city').length > 0)
449                $SUL('#sul-city').html("");
450            if ($SUL('#sul-cityone').length > 0)
451                $SUL('#sul-cityone').html("");
452            $SUL('#city-list-autoone').slideUp("fast");
453        }
454    });
455    $SUL("#txtprefcty").bind('keydown', function (event) {
456        $SUL('#city-list-autoone').slideDown("slow");
457        if (event.keyCode == 27) {
458            $SUL('#sul-cityone').children('li').remove();
459            $SUL('#city-list-autoone').slideUp("fast");
460        }
461
462        if (event.keyCode == 40 || event.keyCode == 38 || event.keyCode == 13) {
463            if ($SUL('#sul-cityone').length > 0 && (event.keyCode == 40 || event.keyCode == 13)) {
464                var i = 0;
465                var j = 0;
466                for (i = 0; i < 10; i++) {
467                    if ($SUL('#autocomplist' + i).hasClass('active')) {
468                        if (event.keyCode == 13) {
469                            $SUL('#autocomplist' + i).children('a').trigger('click');
470                            $SUL('#sul-cityone').children('li').remove();
471                            $SUL('#city-list-autoone').slideUp("fast");
472                        }
473                        j = 1;
474                        $SUL('#autocomplist' + i).removeClass('active');
475                        if ($SUL('#autocomplist' + (parseInt(i) + parseInt(1))).length > 0) {
476                            $SUL('#autocomplist' + (parseInt(i) + parseInt(1))).addClass('active').trigger('hover');
477                            break;
478                        }
479                        else {
480                            $SUL('#autocomplist0').addClass('active').trigger('hover');
481                            break;
482                        }
483                    }
484                }
485                if (j == 0) {
486                    $SUL('#autocomplist0').addClass('active').trigger('hover');
487                }
488            }
489            if ($SUL('#sul-cityone').length > 0 && event.keyCode == 38) {
490                var i = 0;
491                var j = 0;
492                for (i = 0; i < 10; i++) {
493                    if ($SUL('#autocomplist' + i).hasClass('active')) {
494                        j = 1;
495                        $SUL('#autocomplist' + i).removeClass('active');
496                        if ($SUL('#autocomplist' + (parseInt(i) - parseInt(1))).length > 0) {
497                            $SUL('#autocomplist' + (parseInt(i) - parseInt(1))).addClass('active');
498                            break;
499                        }
500                        else {
501                            $SUL('#autocomplist9').addClass('active');
502                            break;
503                        }
504                    }
505                }
506                if (j == 0) {
507                    $SUL('#autocomplist9').addClass('active');
508                }
509            }
510        }
511    });
512    /*autocomp*/
513    /*update location*/
514    $SUL('#gbllocation').find('a.uploc').on("click", function () {
515        var updateprefcity = Sulekha.Common.trim($SUL('#txtprefcty').val());
516        if (updateprefcity != null && updateprefcity != undefined && updateprefcity != "") {
517            if (slocdetail != null && slocdetail != undefined && slocdetail != "") { /*checking for slocdetail*/
518                if ($SUL('#spn_txtprefcty').length > 0) {
519                    $SUL('#spn_txtprefcty').html("");
520                }
521                Sulekha.Common.deleteCookie('sulusrloc');
522                Sulekha.Common.setCookie('sulusrloc', slocdetail, 1826);
523                var selctyurl = $SUL('#selectedcityurl').val();
524                var hdnmeturl = $SUL('#hdnselmetrourl').val();
525                if (window.location.host.toLowerCase() != "techjobs.sulekha.com") {
526                    if (hdnmeturl != "" && hdnmeturl != undefined && hdnmeturl != null) {
527                        document.location.href = gProtocol + window.location.host + '/' + Sulekha.Common.trim(hdnmeturl);
528                    }
529                    else if (selctyurl != "" && selctyurl != undefined && selctyurl != null) {
530                        document.location.href = gProtocol + window.location.host + '/' + Sulekha.Common.trim(selctyurl);
531                    }
532                }
533                else {
534                    window.location.reload(true);
535                }
536            }
537            else {
538                $SUL('#spn_txtprefcty').html("Please select city");
539            }
540        }
541        else {
542            $SUL('#spn_txtprefcty').html("Please select city");
543        }
544    });
545    /*update location*/
546
547}
548
549function searchCityV2(json) {
550    if (json.length > 0) {
551        var html = '';
552        $SUL.each(json, function (index, item) {
553            console.log(ckusrcountry);
554            if (ckusrcountry.toLowerCase() == "uae") {
555                if (item.city != '' && item.city != undefined && item.city != null) {
556                    html += "<li id='autocomplist" + index + "'><a href=\"//www.sulekha.ae/" + item.citystatecodeurl + "\">" + item.city + "</a></li>";
557                }
558            }
559            else if (ckusrcountry.toLowerCase() == "uk") {
560                if (item.city != '' && item.city != undefined) {
561                    if (item.locationlevelid == 3) {
562                        if (item.region2 != '' && item.region2 != undefined) {
563                            cityTxt = item.city + ', ' + item.region2 + ', ' + item.regioncode
564                        }
565                        else {
566                            cityTxt = item.city + ', ' + item.regioncode
567                        }
568                    }
569                    else if (item.locationlevelid == 4) {
570                        if (item.region3 != '' && item.region3 != undefined) {
571                            cityTxt = item.city + ', ' + item.region3 + ', ' + item.regioncode
572                        }
573                        else {
574                            cityTxt = item.city + ', ' + item.regioncode
575                        }
576                    }
577                    else if (item.locationlevelid == 5) {
578                        if (item.region4 != '' && item.region4 != undefined) {
579                            cityTxt = item.city + ', ' + item.region4 + ', ' + item.regioncode
580                        }
581                        else {
582                            cityTxt = item.city + ', ' + item.regioncode
583                        }
584                    }
585                    else {
586                        if (item.region4 != '' && item.region4 != undefined) {
587                            cityTxt = item.city + ', ' + item.region4 + ', ' + item.regioncode
588                        }
589                        else {
590                            cityTxt = item.city + ', ' + item.regioncode
591                        }
592                    }
593                    if (item.citystatecodeurl == "" || item.citystatecodeurl == undefined || item.citystatecodeurl == null) {
594                        item.citystatecodeurl = "";
595                    }
596                    html += "<li id='autocomplist" + index + "'><a href=\"//www.sulekha.co.uk/" + item.citystatecodeurl + "\">" + cityTxt + "</a></li>";
597                }
598            }
599            else if (ckusrcountry.toLowerCase() == "india") {
600                html += "<li id='autocomplist" + index + "'><a href=\"http://www.sulekha.com/" + item.citystatecodeurl + "\">" + item.city + "</a></li>";
601            }
602            else if (ckusrcountry.toLowerCase() == "united states" || ckusrcountry.toLowerCase() == "canada" || ckusrcountry.toLowerCase() == "usa") {
603                //html += "<li id='autocomplist" + index + "'><a href=\"http://us.sulekha.com/" + item.citystatecodeurl + "\">" + item.city + ', ' + item.state + ', ' + item.countrycode + "</a></li>";
604                html += "<li id='autocomplist" + index + "'><a href=\"javascript:void(0);\" onclick='selectCityV2(" + JSON.stringify(item) + ",0)'>" + item.city + ', ' + item.state + ', ' + item.countrycode + "</a></li>";
605            }
606            else {
607                if (item.city != '' && item.city != undefined) {
608                    //cityTxt = item.city;
609                    //html += "<li id='autocomplist" + index + "'><a href=\"javascript:void(0);\" onclick='selectCityV2(" + JSON.stringify(item) + ",0)'>" + cityTxt + "</a></li>";
610                }
611            }
612        });
613        if ($SUL('#sul-cityone').length > 0) {
614            $SUL('#sul-cityone').html(html);
615        }
616        if ($SUL('#sul-city').length > 0) {
617            $SUL('#sul-city').html(html);
618        }
619        $SUL('#city-list-auto').attr('class', 'cityajax show');
620    }
621}
622
623
624
625
626
627
628function selectCityV2(json, istats) {
629    $SUL('#selectedcityurl').val(json.citystatecodeurl);
630    $SUL('#hdnselmetrourl').val(json.metrourl);
631    if ($SUL('#city-list-auto').length > 0)
632        $SUL('#city-list-auto').attr('class', 'cityajax hide');
633    if ($SUL('#city-list-autoone').length > 0)
634        $SUL('#city-list-autoone').slideUp("fast");
635    if ($SUL('#txtSearchCity').length > 0) {
636        $SUL('#txtSearchCity').val(json.city + ', ' + json.state);
637        slocdetail = json.country + '::' + json.countrycode + '::' + json.state + '::' + json.statecode + '::' + json.city + '::' + json.zipcode + '::' + json.latitude + '
637::' + json.longitude + '::1';
638    }
639    if ($SUL('#txtprefcty').length > 0) {
640        $SUL('#txtprefcty').val(json.city + ', ' + json.state);
641        slocdetail = json.country + '::' + json.countrycode + '::' + json.state + '::' + json.statecode + '::' + json.city + '::' + json.zipcode + '::' + json.latitude + '::' + json.longitude + '::1';
642    }
643    if (istats == "1") {
644        if (window.location.host == "techjobs.sulekha.com") {
645            Sulekha.Common.deleteCookie('sulusrloc');
646            Sulekha.Common.setCookie('sulusrloc', slocdetail, 1826);
647            window.location.reload(true);
648        }
649        else {
650            if (json.metrourl != "" && json.metrourl != undefined && json.metrourl != null) {
651                Sulekha.Common.deleteCookie('sulusrloc');
652                Sulekha.Common.setCookie('sulusrloc', slocdetail, 1826);
653                document.location.href = gProtocol + window.location.host + '/' + Sulekha.Common.trim(json.metrourl);
654            }
655            else if (json.citystatecodeurl != "" && json.citystatecodeurl != undefined && json.citystatecodeurl != null) {
656                Sulekha.Common.deleteCookie('sulusrloc');
657                Sulekha.Common.setCookie('sulusrloc', slocdetail, 1826);
658                document.location.href = gProtocol + window.location.host + '/' + Sulekha.Common.trim(json.citystatecodeurl);
659            }
660        }
661    }
662
663}
664
665
666/*city search*/
667ussulcitysearch = {
668    cityparams: {
669        cholder: '',
670        usholder: '',
671        caholder: '',
672        uscaholderwrap: '',
673        divcommonholder: '',
674        customid: '',
675        customhiddenid: '',
676        processpage: 'us.sulekha.com/common/citysearch_sync-call.aspx',
677        groupheadtext1: '',
678        groupheadtext2: '',
679        callback: ''
680    },
681    init: function () {
682        $SUL("#" + ussulcitysearch.cityparams.cholder).bind('keyup', function (event) {
683            if (event.target == undefined)
684                eleID = event.srcElement.id;
685            else
686                eleID = event.target.id;
687            if (eleID == "txtziporcity") {
688                ussulcitysearch.cityparams.customid = '';
689                ussulcitysearch.cityparams.cholder = "txtziporcity";
690                ussulcitysearch.cityparams.uscaholderwrap = 'div_locationmain_result';
691                ussulcitysearch.cityparams.divcommonholder = 'div_paglocationmain_result';
692                ussulcitysearch.cityparams.processpage = 'us.sulekha.com/common/citysearch_sync-call.aspx';
693                ussulcitysearch.cityparams.callback = 'ussulcitysearch.searchUSCanadaCityv2';
694            }
695            //new1
696            if (eleID == "txtcommoncitysearch") {
697                ussulcitysearch.cityparams.customid = '';
698                ussulcitysearch.cityparams.cholder = "txtcommoncitysearch";
699                ussulcitysearch.cityparams.uscaholderwrap = 'div_locationmain_result_v1';
700                ussulcitysearch.cityparams.divcommonholder = 'div_paglocationmain_result_v1';
701                ussulcitysearch.cityparams.processpage = 'us.sulekha.com/common/citysearch_sync-call.aspx';
702                ussulcitysearch.cityparams.callback = 'ussulcitysearch.searchUSCanadaCityv2';
703            }
704            //new1
705
706            if (event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 27 && event.keyCode != 13) {
707                var cityvalue = ""; cityvalue = $SUL("#" + ussulcitysearch.cityparams.cholder).val().trim();
708                var hdnfrmctyurl = ""; var hdnfrmmeturl = "";
709                if ($SUL('#hdnuscanadanewcityurl').length > 0) { hdnfrmctyurl = $SUL('#hdnuscanadanewcityurl').val(); }
710                if ($SUL('#hdnuscanadametrourl').length > 0) { hdnfrmmeturl = $SUL('#hdnuscanadametrourl').val(); }
711                if (cityvalue.length > 1) {
712                    Sulekha.Auth.JSONGetData(gProtocol + ussulcitysearch.cityparams.processpage + "?term=" + cityvalue + "&QuStr=serviceneed&cityurl=" + hdnfrmctyurl + "&metrourl=" + hdnfrmmeturl + "&callback=" + ussulcitysearch.cityparams.callback);
713                    $SUL(".ustxtctyfetching").addClass('hide').removeClass('show');
714                } else {
715                    $SUL(".ustxtfetching").addClass('hide').removeClass('show');
716                    if ($SUL("#" + ussulcitysearch.cityparams.uscaholderwrap).length > 0)
717                        $SUL("#" + ussulcitysearch.cityparams.uscaholderwrap).hide();
718                }
719            }
720            if ($SUL("#" + ussulcitysearch.cityparams.cholder).val() == "") {
721                if ($SUL("#" + ussulcitysearch.cityparams.uscaholderwrap).length > 0)
722                    $SUL("#" + ussulcitysearch.cityparams.uscaholderwrap).hide();
723            }
724        });
725        $SUL("#" + ussulcitysearch.cityparams.cholder).bind('keydown', function (event) {
726            if (event.keyCode == 40 || event.keyCode == 38 || event.keyCode == 13) {
727                if ($SUL('#' + ussulcitysearch.cityparams.divcommonholder + ussulcitysearch.cityparams.customid).length > 0 && (event.keyCode == 40 || event.keyCode == 13)) {
728                    var i = 0; var j = 0;
729                    var ullilengthone = $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').length;
730                    for (i = 0; i < ullilengthone; i++) {
731                        if ($SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(i).hasClass('active')) {
732                            if (event.keyCode == 13) {
733                                //$SUL('#vautocomplist' + i).find('a').trigger('click');
734                                $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('a').eq(i).trigger('click');
735                                $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).hide();
736                            }
737                            j = 1;
738                            $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(i).removeClass('active');
739                            if ($SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(parseInt(i) + parseInt(1)).length > 0) {
740                                $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(parseInt(i) + parseInt(1)).addClass('active').trigger('hover');
741                                break;
742                            } else {
743                                $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq('0').addClass('active').trigger('hover');
744                                break;
745                            }
746                        }
747                    }
748                    if (j == 0) {
749                        $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq('0').addClass('active').trigger('hover');
750                    }
751                }
752                if ($SUL('#' + ussulcitysearch.cityparams.divcommonholder + ussulcitysearch.cityparams.customid).length > 0 && event.keyCode == 38) {
753                    var i = 0; var j = 0;
754                    var ullilengthtwo = $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').length;
755                    for (i = 0; i < ullilengthtwo; i++) {
756                        if ($SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(i).hasClass('active')) {
757                            j = 1; $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(i).removeClass('active');
758                            if ($SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(parseInt(i) - parseInt(1)).length > 0) {
759                                $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(parseInt(i) - parseInt(1)).addClass('active');
760                                break;
761                            } else {
762                                $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(parseInt(ullilengthtwo) - parseInt(1)).addClass('active'); break;
763                            }
764                        }
765                    } if (j == 0) { $SUL('#' + ussulcitysearch.cityparams.uscaholderwrap).find('li').eq(parseInt(ullilengthtwo) - parseInt(1)).addClass('active'); }
766                }
767            }
768        });
769        $SUL("#" + ussulcitysearch.cityparams.cholder).bind('click', function () {
770            this.focus(); this.select();
771            fnhidesearchautocompletelist();
772        });
773    },
774    searchUSCanadaCityv2: function (a) {
775        if (a.length > 0) {
776            var b = "";
777            var isUsa = false, isCanada = false;
778            var uslist = "", canadalist = "";
779            uslist = "<label><b>USA</b></label><ul class=\"result-menu\">";
780            canadalist = "<label><b>Canada</b></label><ul class=\"result-menu\">";
781            $SUL.each(a, function (a, c) {
782                if (c.countrycode.toLowerCase() == "us" || c.countrycode.toLowerCase() == "usa") {
783                    uslist += "<li id='vautocomplist" + a + "'><a href=\"javascript:void(0);\" onclick='ussulcitysearch.selectUSCanadaCityv2(" + JSON.stringify(c) + ")'><i>" + c.city + "</i><b>
783" + c.state + ", " + c.countrycode + "</b></a></li>";
784                    isUsa = true;
785                } else if (c.countrycode.toLowerCase() == "ca" || c.countrycode.toLowerCase() == "canada") {
786                    canadalist += "<li id='vautocomplist" + a + "'><a href=\"javascript:void(0);\" onclick='ussulcitysearch.selectUSCanadaCityv2(" + JSON.stringify(c) + ")'><i>" + c.city + "</i><b>" + c.state + ", " + c.countrycode + "</b></a></li>";
787                    isCanada = true;
788                }
789            });
790            if (isUsa) {
791                uslist += "</ul>";
792            } else {
793
794            }
795            if (isCanada) {
796                canadalist += "</ul>";
797            } else {
798            }
799            $SUL(".ustxtctyfetching").addClass('hide').removeClass('show');
800            if ($SUL("#" + ussulcitysearch.cityparams.uscaholderwrap).length > 0) {
801                $SUL("#" + ussulcitysearch.cityparams.divcommonholder).html(uslist + canadalist);
802                $SUL("#" + ussulcitysearch.cityparams.uscaholderwrap).show();
803            }
804        }
805    },
806    selectUSCanadaCityv2: function (a) {
807        if ($SUL("#hdnuscanadanewcityurl").length > 0) {
808            $SUL("#hdnuscanadanewcityurl").val(a.citystatecodeurl);
809            if ($SUL("#mainhdnlat").length > 0) {
810                $SUL("#mainhdnlat").val(a.latitude);
811            }
812            if ($SUL("#mainhdnlong").length > 0) {
813                $SUL("#mainhdnlong").val(a.longitude);
814            }
815        }
816        if ($SUL("#hdnuscanadametrourl").length > 0) {
817            $SUL("#hdnuscanadametrourl").val(a.metrourl);
818        }
819        $SUL("#" + ussulcitysearch.cityparams.cholder).val(a.city + ", " + a.statecode);
820        $SUL("#" + ussulcitysearch.cityparams.uscaholderwrap).hide();
821    }
822}
823
824$SUL(document).ready(function () {
825    if ($SUL('#txtziporcity').length > 0) {
826        ussulcitysearch.cityparams.cholder = 'txtziporcity';
827        ussulcitysearch.cityparams.usholder = 'usa-city-list1';
828        ussulcitysearch.cityparams.caholder = 'canada-city-list1';
829        ussulcitysearch.cityparams.uscaholderwrap = 'uscanadacity-list-wrap';
830        ussulcitysearch.cityparams.customid = '';
831        ussulcitysearch.init();
832    }
833    if ($SUL('#txtcommoncitysearch').length > 0) {
834        ussulcitysearch.cityparams.cholder = 'txtcommoncitysearch';
835        ussulcitysearch.cityparams.usholder = 'usa-city-list2';
836        ussulcitysearch.cityparams.caholder = 'canada-city-list2';
837        ussulcitysearch.cityparams.uscaholderwrap = 'uscanadacity-list-wrap2';
838        ussulcitysearch.cityparams.customid = '2';
839        ussulcitysearch.init();
840    }
841});
842
843/*city search*/
844
845
846
847
848/*top search integration*/
849
850
851
852
853var searchholder = "";
854var searchoption = "";
855var topsearchmain = "topsearchmain",
856    hdrsearchmain = "hdrsearchmain", pagemainsearch = "txtussearchmain",
857    frompagesearch = "0", dropmainsearch = "drpcmnsearchmain";
858var formquerystring = "";
859//frompagesearch="1" in pagesearch
860
861function fntoppageswaplatlong() {
862    if (frompagesearch == "1") {
863        OAS_lat = $SUL('#mainhdnlat').val();
864        OAS_long = $SUL('#mainhdnlong').val();
865        userlat = $SUL('#mainhdnlat').val();
866        userlong = $SUL('#mainhdnlong').val();
867    }
868    else {
869        OAS_lat = cklat;
870        OAS_long = cklong;
871        userlat = cklat;
872        userlong = cklong;
873    }
874}
875
876cmsulhdrgblsearch =
877{
878    customparam: {
879        pageurl: '',
880        pgtype: '',
881        callback: '',
882        domainpath: '',
883        searchurl: '',
884        groupheadtext2: '',
885        groupheadtext1: '',
886        customid: '',
887        customhiddenid: ''
888    },
889    Init: function () {
890        defval = "Enter the keyword to search";
891        if ($SUL('#txtussearch').length > 0) {
892            Sulekha.Validate.defaultTxt('txtussearch', defval);
893        }
894        if ($SUL('#' + pagemainsearch).length > 0) {
895            Sulekha.Validate.defaultTxt(pagemainsearch, defval);
896        }
897        $SUL('#atopsearch,#atopsearchbtn').on("click", function (event) {
898            var passval = ""; var passdrp = "";
899            var topsearchclk = $SUL(this).attr("id");
900            if (topsearchclk == "atopsearch")
901                passdrp = "drpcmnsearch";
902            else if (topsearchclk == "atopsearchbtn")
903                passdrp = "drpcmnsearchmain";
904
905            var allvalue = $SUL("#" + passdrp + " option:selected").text();
906            if (allvalue.toLowerCase() != "all") {
907                if (topsearchclk == "atopsearch")
908                    passval = "txtussearch";
909                else if (topsearchclk == "atopsearchbtn")
910                    passval = "txtussearchmain";
911                onHeaderTextSearch(passval);
912            }
913            else if (topsearchclk == "atopsearch") {
914                if (topsearchclk == "atopsearch")
915                    passval = "txtussearch";
916                else if (topsearchclk == "atopsearchbtn")
917                    passval = "txtussearchmain";
918                onHeaderTextSearch(passval);
919            }
920            else {
921                var alltermnewreplace = $SUL.trim($SUL('#hdnallnewtermreplace').val());
922                if (alltermnewreplace != null && alltermnewreplace != "" && alltermnewreplace != undefined && alltermnewreplace != 'undefined') {
923                    var searchcityurlnew = $SUL('#hdnuscanadanewcityurl').val();
924                    var searchmetrourlnew = $SUL('#hdnuscanadametrourl').val();
925                    var hdnallsitename = $SUL('#hdnallsitename').val();
926                    var hdnallposition = $SUL('#hdnallposition').val();
927                    var allchkqcityurl = $SUL('div.location-hd').find('a.location').attr("title");
928
929                    if (searchcityurlnew != null && searchcityurlnew != "" && searchcityurlnew != undefined && searchcityurlnew != 'undefined') {
930                        //alltermnewreplace = alltermnewreplace.replace('~newcityurl', searchcityurlnew);
931                        alltermnewreplace = alltermnewreplace.replace('~metrourl', searchmetrourlnew);
932                        var txtussearchvalue = $SUL("#txtussearchmain").val();
933                        //window.location.href = alltermnewreplace;                        
934                        window.location.href = alltermnewreplace + "?q=" + $SUL("#txtussearchmain").val() + "_" + replacespl(txtussearchvalue) + "&c=" + hdnallposition + "_" + replacespl(hdnallsitename) + "_" + replacespl(allchkqcityurl);
935                        $SUL("#divfetching").addClass("show").removeClass("hide");
936                    }
937                }
938                else {
939                    onHeaderTextSearch("txtussearchmain");
940                }
941            }
942        });
943        headersearchvalchange();
944
945        $SUL("#drpcmnsearch,#drpcmnsearchmain").change(function () {
946            if ($SUL('#div_topsearch_result').length > 0)
947                $SUL('#div_topsearch_result').hide();
948            if ($SUL('#div_' + topsearchmain + '_result').length > 0)
949                $SUL('#div_' + topsearchmain + '_result').hide();
950            $SUL('#txtussearch').val(defval);
951            $SUL('#' + pagemainsearch).val(defval);
952            var drpholder = $SUL(this).attr('id');
953            var cvalue = $SUL(this).val();
954            var value = $SUL("#" + drpholder + " option:selected").text();
955            //$SUL('select[name=' + drpholder + '] option[value=' + cvalue + ']').attr('selected', 'selected');
956            $SUL("select[name='" + drpholder + "'] option[value='" + cvalue + "']").attr('selected', 'selected');
957            $SUL(".ustxtfetching").addClass('hide').removeClass('show');
958            if (value.toLowerCase() != "all" && drpholder == "drpcmnsearchmain")
959                $SUL('div.home-search-w').addClass("hsearch2");
960            else
961                $SUL('div.home-search-w').removeClass("hsearch2");
962        });
963
964
965        $SUL("#txtussearch,#txtussearchmain").bind('keyup', function (event) {
966            if (event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 27) {
967                var lservice = "";
968                var ussearchval = "";
969                searchholder = $SUL(this).attr('id');
970                ussearchval = $SUL("#" + searchholder).val().trim();
971                if (searchholder == "txtussearchmain") {
972                    frompagesearch = "1";
973                }
974                else {
975                    frompagesearch = "0";
976                }
977
978                cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_sync-call.aspx';
979                if (Sulekha.Common.isEmptyParam(cmsulhdrgblsearch.customparam.pgtype))
980                    cmsulhdrgblsearch.customparam.pgtype = 'commonsearch';
981                if (searchholder == "txtussearchmain")
982                    var cValue = $SUL('select[name=drpcmnsearchmain]').val();
983                else
984                    var cValue = $SUL('select[name=drpcmnsearch]').val();
985
986                if (cValue == "Events") {
987                    cmsulhdrgblsearch.customparam.callback = 'fncommonsearchsEventHeader';
988                    cmsulhdrgblsearch.customparam.domainpath = "eventssitel.sulekha.com"; // www.sulekhaevents.ca
989                }
990
991                else if (cValue == "DayCare" || cValue == "Day Care") {
992                    lservice = 'day-care';
993                    cmsulhdrgblsearch.customparam.callback = 'fncommonsearchHeader';
994                    /*cmsulhdrgblsearch.customparam.domainpath = "daycare.sulekha.com";
995                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-call.aspx';*/
996                    cmsulhdrgblsearch.customparam.domainpath = window.location.hostname;
997                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-callv4.aspx';
998                }
999                else if (cValue == "Roommates") {
1000                    lservice = 'roommates';
1001                    cmsulhdrgblsearch.customparam.callback = 'fncommonsearchHeader';
1002                    /*cmsulhdrgblsearch.customparam.domainpath = "indianroommates.sulekha.com";
1003                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-call.aspx';*/
1004                    cmsulhdrgblsearch.customparam.domainpath = window.location.hostname;
1005                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-callv4.aspx';
1006                }
1007                else if (cValue == "Rentals") {
1008                    lservice = 'rentals';
1009                    cmsulhdrgblsearch.customparam.callback = 'fncommonsearchHeader';
1010                    /*cmsulhdrgblsearch.customparam.domainpath = "indianroommates.sulekha.com";
1011                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-call.aspx';*/
1012                    cmsulhdrgblsearch.customparam.domainpath = window.location.hostname;
1013                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-callv4.aspx';
1014                }
1015                else if (cValue == "Property") {
1016                    lservice = 'property';
1017                    cmsulhdrgblsearch.customparam.callback = 'fncommonsearchHeader_property';
1018                    cmsulhdrgblsearch.customparam.domainpath = "us.sulekha.com";
1019                    cmsulhdrgblsearch.customparam.pageurl = '/nriproperty/common/headersearch_async-callv2.aspx';
1020                }
1021                else if (cValue == "Jobs") {
1022                    lservice = 'jobs';
1023                    cmsulhdrgblsearch.customparam.callback = 'fncommonsearchsJobsHeader';
1024                    /*cmsulhdrgblsearch.customparam.domainpath = "localjobs.sulekha.com";
1025                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-call.aspx';*/
1026                    cmsulhdrgblsearch.customparam.domainpath = window.location.hostname;
1027                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-callv4.aspx';
1028                }
1029                else if (cValue == "Services") {
1030                    lservice = 'services';
1031                    cmsulhdrgblsearch.customparam.callback = 'fncommonsearchslocalservicesHeader';
1032                    /*cmsulhdrgblsearch.customparam.domainpath = "localservices.sulekha.com";
1033                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-call.aspx';*/
1034                    cmsulhdrgblsearch.customparam.domainpath = window.location.hostname;
1035                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-callv4.aspx';
1036                }
1037                else if (cValue == "LocalBiz" || cValue == "Local Biz") {
1038                    lservice = 'localbiz';
1039                    cmsulhdrgblsearch.customparam.callback = 'fnhdrcommonsearchs';
1040                    /*cmsulhdrgblsearch.customparam.domainpath = "localservices.sulekha.com";
1041                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-call.aspx';*/
1042                    cmsulhdrgblsearch.customparam.domainpath = window.location.hostname;
1043                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-callv4.aspx';
1044                }
1045                else if (cValue == "ITTraining" || cValue == "IT Training") {
1046                    lservice = 'ittraining';
1047                    cmsulhdrgblsearch.customparam.callback = 'fncommonsearchslocalservicesHeader';
1048                    /*cmsulhdrgblsearch.customparam.domainpath = "localservices.sulekha.com";
1049                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-call.aspx';*/
1050                    cmsulhdrgblsearch.customparam.domainpath = window.location.hostname;
1051                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-callv4.aspx';
1052                }
1053                else if (cValue == "Travel") {
1054                    lservice = 'travel';
1055                    cmsulhdrgblsearch.customparam.callback = 'fnhdrcommonsearchstravel';
1056                    /*cmsulhdrgblsearch.customparam.domainpath = "travelindia.sulekha.com";
1057                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_sync_call.aspx';*/
1058                    cmsulhdrgblsearch.customparam.domainpath = window.location.hostname;
1059                    cmsulhdrgblsearch.customparam.pageurl = '/common/headersearch_async-callv4.aspx';
1060                }
1061                else if (cValue == "ALL") {
1062                    cmsulhdrgblsearch.customparam.pageurl = '/common/serviceneed.aspx';
1063                    cmsulhdrgblsearch.customparam.domainpath = "us.sulekha.com";
1064                    cmsulhdrgblsearch.customparam.callback = 'fnallcommonsearchs';
1065                    cmsulhdrgblsearch.customparam.customid = '2';
1066                    cmsulhdrgblsearch.customparam.groupheadtext1 = "";
1067                    cmsulhdrgblsearch.customparam.groupheadtext2 = "";
1068                }
1069                var OAS_lat = userlat; var OAS_long = userlong;
1070                fntoppageswaplatlong();
1071
1072
1073                if (ussearchval.length > 1) {
1074
1075                    var passingcityurl = replacespl($SUL('div.location-hd').find('a.location').attr("title"))
1076                    $SUL(".ustxtfetching").addClass('show').removeClass('hide');
1077                    if (cValue == "Events") {
1078                        Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domainpath + cmsulhdrgblsearch.customparam.pageurl + "?rno=" + Math.random() +
1079                            "&holderid=" + searchholder + "&type=" + cmsulhdrgblsearch.customparam.pgtype + "&searchtxt=" + ussearchval + "&callback=" + cmsulhdrgblsearch.customparam.callback +
1080                            "&lat=" + OAS_lat + "&long=" + OAS_long + "&radius=" + 50 + "&perflat=" + OAS_lat + "&perflong=" + OAS_long + "&meturl=" + meturl + "&cityurl=" + $SUL('#hdngblcityurl').val() + "&passingcityurl=" + passingcityurl + "&sulgobal=" + sulgobal + "&sulcountry=" + sulcountry + "&sultimezone=" + sultimezone);
1081                    }
1082                    else if (cValue == "Roommates" || cValue == "DayCare" || cValue == "Rentals" || cValue == "Day Care" || cValue == "Property") {
1083                        Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domainpath + cmsulhdrgblsearch.customparam.pageurl + "?rno=" + Math.random() +
1084                            "&holderid=" + searchholder + "&type=" + cmsulhdrgblsearch.customparam.pgtype + "&searchtxt=" + ussearchval + "&callback=" + cmsulhdrgblsearch.customparam.callback +
1085                            "&lat=" + userlat + "&long=" + userlong + "&meturl=" + meturl + "&cityurl=" + $SUL('#hdngblcityurl').val() + "&passingcityurl=" + passingcityurl + "&service=" + lservice);
1086                    }
1087                    else if (cValue == "LocalBiz" || cValue == "Local Biz") {
1088                        Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domainpath + cmsulhdrgblsearch.customparam.pageurl + "?rno=" + Math.random() +
1089                            "&holderid=" + searchholder + "&type=metros&searchtxt=" + ussearchval + "&callback=" + cmsulhdrgblsearch.customparam.callback +
1090                            "&hnlat=" + userlat + "&hnlong=" + userlong + "&meturl=" + meturl + "&cityurl=" + $SUL('#hdngblcityurl').val() + "&passingcityurl=" + passingcityurl + "&service=" + lservice);
1091                    }
1092                    else if (cValue == "ITTraining" || cValue == "IT Training") {
1093
1094                        if (frompagesearch != "1")
1095                            var vCity = $SUL('div.location-hd').find('a.location').attr("title");
1096                        else
1097                            var vCity = $SUL('#hdnuscanadanewcity').val();
1098
1099                        vCity = replacespl(vCity);
1100                        Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domain
1100path + cmsulhdrgblsearch.customparam.pageurl + "?term=" + ussearchval + "&callback=" + cmsulhdrgblsearch.customparam.callback + "&city=" + vCity + "&meturl=" + meturl + "&cityurl=" + $SUL('#hdngblcityurl').val() + "&passingcityurl=" + passingcityurl + "&lay=new");
1101                    }
1102                    else if (cValue == "Jobs") {
1103                        Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domainpath + cmsulhdrgblsearch.customparam.pageurl + "?rno=" + Math.random() +
1104                            "&holderid=" + searchholder + "&type=" + cmsulhdrgblsearch.customparam.pgtype + "&searchtxt=" + ussearchval + "&callback=" + cmsulhdrgblsearch.customparam.callback +
1105                            "&lat=" + userlat + "&long=" + userlong + "&meturl=" + meturl + "&cityurl=" + $SUL('#hdngblcityurl').val() + "&passingcityurl=" + passingcityurl + "&service=" + lservice);
1106                    }
1107                    else if (cValue == "Services") {
1108                        Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domainpath + cmsulhdrgblsearch.customparam.pageurl + "?rno=" + Math.random() +
1109                            "&holderid=" + searchholder + "&type=" + cmsulhdrgblsearch.customparam.pgtype + "&searchtxt=" + ussearchval + "&callback=" + cmsulhdrgblsearch.customparam.callback +
1110                            "&lat=" + userlat + "&long=" + userlong + "&meturl=" + meturl + "&cityurl=" + $SUL('#hdngblcityurl').val() + "&passingcityurl=" + passingcityurl + "&service=" + lservice);
1111                    }
1112                    else if (cValue == "Travel") {
1113                        Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domainpath + cmsulhdrgblsearch.customparam.pageurl + "?rno=" + Math.random() +
1114                            "&holderid=" + searchholder + "&type=" + cmsulhdrgblsearch.customparam.pgtype + "&term=" + ussearchval + "&callback=" + cmsulhdrgblsearch.customparam.callback +
1115                            "&lat=" + userlat + "&long=" + userlong + "&meturl=" + meturl + "&cityurl=" + $SUL('#hdngblcityurl').val() + "&passingcityurl=" + passingcityurl + "&service=" + lservice);
1116                    }
1117                    //else if (cValue == "Property") {
1118                    //    var cookiecity = getCookiecityurl();
1119                    //    Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domainpath + cmsulhdrgblsearch.customparam.pageurl + "?rno=" + Math.random() +
1120                    //        "&holderid=" + searchholder + "&type=" + cmsulhdrgblsearch.customparam.pgtype + "&searchtxt=" + ussearchval + "&callback=" + cmsulhdrgblsearch.customparam.callback +
1121                    //        "&lat=" + userlat + "&long=" + userlong + "&meturl=" + meturl + "&cityurl=" + $SUL('#hdngblcityurl').val() +
1122                    //        "&locationtype=&metrourl=" + $SUL('#hdnuscanadametrourl').val() +
1123                    //        "&cookiecity=" + cookiecity + "&passingcityurl=" + passingcityurl + "&service=" + lservice + "&srvtech=" + cValue);
1124                    //}
1125
1126                    else if (cValue == "ALL") {
1127                        var hdnfrmctyurl = ""; var hdnfrmmeturl = "";
1128                        var oldnewallpart = "";
1129                        if (frompagesearch == "1")
1130                            oldnewallpart = "&lay=new";
1131
1132                        if ($SUL("hdngblcityurl").length > 0) {
1133                            if ($SUL('#hdngblcityurl').length > 0) { hdnfrmctyurl = $SUL('#hdngblcityurl').val(); }
1134                        } else {
1135                            if ($SUL('#hdnuscanadanewcityurl').length > 0) { hdnfrmctyurl = $SUL('#hdnuscanadanewcityurl').val(); }
1136                        }
1137
1138                        if ($SUL("#hdnuscanadametrourl").length == 1)
1139                            hdnfrmmeturl = $SUL("#hdnuscanadametrourl").val();
1140
1141                        if (hdnfrmmeturl == "undefined" || hdnfrmmeturl == "")
1142                            hdnfrmmeturl = meturl;
1143
1144                        Sulekha.Auth.JSONGetData(gProtocol + cmsulhdrgblsearch.customparam.domain
1144path + cmsulhdrgblsearch.customparam.pageurl + "?term=" + ussearchval + "&QuStr=serviceneed&cityurl=" + hdnfrmctyurl + "&metrourl=" + hdnfrmmeturl + "&callback=" + cmsulhdrgblsearch.customparam.callback + oldnewallpart);
1145                    }
1146                    else {
1147                        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
1148                    }
1149
1150                } else {
1151                    $SUL(".ustxtfetching").addClass('hide').removeClass('show');
1152                    if ($SUL("#div_topsearch_result").length > 0) {
1153                        $SUL("#div_topsearch_result").hide();
1154                    }
1155                    if ($SUL("#div_" + topsearchmain + "_result").length > 0) {
1156                        $SUL("#div_" + topsearchmain + "_result").hide();
1157                    }
1158
1159                }
1160            }
1161        });
1162        $SUL("#txtussearchmain,#txtussearch").bind('click', function () {
1163            this.focus(); this.select();
1164            fnhidepagelocation();
1165        });
1166        $SUL("#txtussearchmain,#txtussearch").bind('keydown', function (event) {
1167            holder = $SUL(this).attr('id');
1168            if (holder != pagemainsearch) {
1169                hdrsearchmain = "hdrsearch";
1170            }
1171            else {
1172                hdrsearchmain = "hdrsearchmain";
1173            }
1174            if (event.keyCode == 13 && !$SUL("#div_" + hdrsearchmain + "_result:has(li)").length) {
1175                if ($SUL.trim($SUL("#" + holder).val()) != "") {
1176                    $SUL("#div_" + hdrsearchmain + "_result").html("");
1177                    //$SUL("#txtussearchbtn").trigger("click");
1178                }
1179            }
1180            if (event.keyCode == 40 || event.keyCode == 38 || event.keyCode == 13) {
1181                if ($SUL("#div_" + hdrsearchmain + "_result").length > 0 && (event.keyCode == 40 || event.keyCode == 13)) {
1182                    var i = 0;
1183                    var j = 0;
1184                    var hdrsearchlicnt = $SUL("#div_" + hdrsearchmain + "_result").find('li').length;
1185                    for (i = 0; i < hdrsearchlicnt; i++) {
1186                        if ($SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).hasClass('active')) {
1187                            if (event.keyCode == 13) {
1188                                if (holder == pagemainsearch) {
1189                                    var value = $SUL('select[name=drpcmnsearchmain]').val();
1190                                }
1191                                else {
1192                                    var value = $SUL('select[name=drpcmnsearch]').val();
1193                                }
1194                                fntopsearchglobalquerystring("div_" + hdrsearchmain + "_result", '', holder, "1", value, '', '');
1195                                if (value == "ALL") {
1196                                    if (frompagesearch == "1") {
1197                                        $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).find('a').trigger('click');
1198                                    }
1199                                    else {
1200                                        //$SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).find('a').removeAttr("href");
1201                                        $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).find('a').trigger('click');
1202                                        $SUL("#div_" + hdrsearchmain + "_result").remove();
1203                                        if ($SUL("#div_topsearch_result").length > 0) {
1204                                            $SUL("#div_topsearch_result").hide();
1205                                        }
1206                                        $SUL("#divfetching").addClass("show").removeClass("hide");
1207                                    }
1208                                }
1209                                else {
1210
1211                                    //fntopsearchglobalquerystring("div_" + hdrsearchmain + "_result", '', holder, 1, 'test', '', '');
1212                                    var goTo = $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).find('a').attr("href");
1213                                    //$SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).find('a').trigger("click");
1214                                    $SUL("#div_" + hdrsearchmain + "_result").remove();
1215                                    if ($SUL("#div_topsearch_result").length > 0) {
1216                                        $SUL("#div_topsearch_result").hide();
1217                                    }
1218                                    $SUL("#divfetching").addClass("show").removeClass("hide");
1219                                    window.location = goTo;
1220
1221
1222                                }
1223                            }
1224                            j = 1;
1225                            $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).removeClass('active');
1226                            if ($SUL("#div_" + hdrsearchmain + "_result").find('li').eq(parseInt(i) + parseInt(1)).length > 0) {
1227                                $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(parseInt(i) + parseInt(1)).addClass('active').trigger('hover');
1228                                break;
1229                            }
1230                            else {
1231                                $SUL("#div_" + hdrsearchmain + "_result").find('li').eq('0').addClass('active').trigger('hover');
1232                                break;
1233                            }
1234                        }
1235                    }
1236                    if (j == 0) {
1237                        $SUL("#div_" + hdrsearchmain + "_result").find('li').eq('0').addClass('active').trigger('hover');
1238                    }
1239                }
1240                if ($SUL("#div_" + hdrsearchmain + "_result").length > 0 && event.keyCode == 38) {
1241                    var i = 0;
1242                    var j = 0;
1243                    var jhdrsearchlicnt = $SUL("#div_" + hdrsearchmain + "_result").find('li').length;
1244                    for (i = 0; i < jhdrsearchlicnt; i++) {
1245                        if ($SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).hasClass('active')) {
1246                            j = 1;
1247                            $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(i).removeClass('active');
1248                            if ($SUL("#div_" + hdrsearchmain + "_result").find('li').eq(parseInt(i) - parseInt(1)).length > 0) {
1249                                $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(parseInt(i) - parseInt(1)).addClass('active');
1250                                break;
1251                            }
1252                            else {
1253                                $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(parseInt(jhdrsearchlicnt) - parseInt(1)).addClass('active');
1254                                break;
1255                            }
1256                        }
1257                    }
1258                    if (j == 0) {
1259                        $SUL("#div_" + hdrsearchmain + "_result").find('li').eq(parseInt(jhdrsearchlicnt) - parseInt(1)).addClass('active');
1260                    }
1261                }
1262            }
1263        });
1264
1265    }
1266}
1267
1268function fncommonsearchHeader_property(json, cholder) {
1269    if (json.ROW_DS.length > 0 && json != undefined) {
1270        var currentLoc = '';
1271
1272        if (frompagesearch != "1")
1273            var vArea = $SUL('div.location-hd').find('a.location').attr("title").toUpperCase();
1274        else
1275            var vArea = $SUL('#hdnuscanadanewcity').val().toUpperCase();
1276
1277        var isLatlong = false, isLatestlocation = false, issearchTerm = false, isLatest = false;
1278
1279        var v_latlong = "<label><b>Top Property Results (In and Near - " + vArea + ")</b></label><ul>";
1280        var v_latest = "<label><b>Latest Property Results</b></label><ul>";
1281        var v_latloc = "<label><b>Latest Location Property Results</b></label><ul>";
1282        var vSearchterm = "<label><b>Related Search Term</b></label><ul>";
1283        var vSearchHeaderList = "";
1284
1285        cholder = 'hdrsearch';
1286        var topholder = "topsearch";
1287        $SUL.each(json.ROW_DS, function (index, item) {
1288            var sitemtitle = item.title, sitemtitleurl = item.titleurl;
1289            var sNeedtype = "", tagdetails = "", sCaretype = "";
1290            if (sitemtitle.length > 55) {
1291                sitemtitle = sitemtitle.substring(0, 55) + '...';
1292            }
1293
1294
1295
1296            if (item.search == "usproperties_latlong") {
1297                var priceroommates = item.price;
1298                v_latlong += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('https://us.sulekha.com" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b>" + item.adtype + " , " + item.roomtype + " , $" + priceroommates + " in " + item.city + ", " + item.statecode + "</b></a></li>";
1299                isLatlong = true;
1300            }
1301            else if (item.search == "usproperties_latest") {
1302
1303                var priceroommateslatest = item.price;
1304                v_latest += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('https://us.sulekha.com" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b> " + item.adtype + " , " + item.roomtype + " , $" + priceroommateslatest + " in " + item.city + ", " + item.statecode + "</b></a></li>";
1305                isLatest = true;
1306
1307            }
1308            else if (item.search == "usproperties_latest_loc") {
1309
1310                var pricerentalslatest = item.price;
1311                v_latloc += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('https://us.sulekha.com" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b> " + item.adtype + " , " + item.roomtype + " , $" + pricerentalslatest + " in " + item.city + ", " + item.statecode + "</b></a></li>";
1312                isLatestlocation = true;
1313
1314            }
1315            else if (item.search == "search_term") {
1316
1317                var url1 = item.pageurl1;
1318                var url2 = item.pageurl2;
1319
1320                vSearchterm += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('" + url1 + "','" + sitemtitle + "');\"><i>" + sitemtitle + "</i></a></li>";
1321
1322                issearchTerm = true;
1323            }
1324        });
1325
1326
1327
1328        if (issearchTerm) {
1329            vSearchHeaderList = vSearchterm + "</ul>";
1330        }
1331        if (isLatlong) {
1332            vSearchHeaderList += v_latlong + "</ul>";
1333        }
1334        if (isLatestlocation) {
1335            vSearchHeaderList += v_latloc + "</ul>";
1336        }
1337        if (isLatest) {
1338            vSearchHeaderList += v_latest + "</ul>";
1339        }
1340
1341        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
1342        if (frompagesearch == "1") {
1343            cholder = hdrsearchmain;
1344            topholder = topsearchmain;
1345        }
1346
1347        topsearch
1348        if ($SUL("#div_" + cholder + "_result").length > 0)
1349            $SUL("#div_" + cholder + "_result").html(vSearchHeaderList);
1350
1351        if ($SUL("#div_" + topholder + "_result").length > 0)
1352            $SUL("#div_" + topholder + "_result").show();
1353    }
1354}
1355
1356
1357function headersearchvalchange() {
1358    var hostname = window.location.hostname;
1359    var divsearchval = ""; divcontentvalue = "";
1360    if (hostname == "us.sulekha.com" || hostname == "usl.sulekha.com") {
1361        divsearchval = 'ALL';
1362        divcontentvalue = 'ALL';
1363    }
1364    else if (hostname == "www.sulekhaevents.ca" || hostname == "eventssite.sulekha.com") {
1365        divsearchval = 'Events';
1366        divcontentvalue = 'Events';
1367    }
1368    else if (hostname == "indianroommates.sulekha.com") {
1369        divsearchval = 'Roommates';
1370        divcontentvalue = 'Roommates';
1371    }
1372    else if (hostname == "us.classifieds.sulekha.com") {
1373        divsearchval = 'Classifieds';
1374        divcontentvalue = 'Classifieds';
1375    }
1376    else if (hostname == "localjobs.sulekha.com") {
1377        divsearchval = 'Jobs';
1378        divcontentvalue = 'Jobs';
1379    }
1380    else if (hostname == "localservices.sulekha.com" || hostname == "localservicesl.sulekha.com") {
1381
1382        divsearchval = 'Services';
1383        divcontentvalue = 'Services';
1384    }
1385    else if (hostname == "techjobs.sulekha.com") {
1386        divsearchval = 'ITTraining';
1387        divcontentvalue = 'IT Training';
1388    }
1389    else if (hostname == "mycity.sulekha.com") {
1390        divsearchval = 'LocalBiz';
1391        divcontentvalue = 'Local Biz';
1392    }
1393    else if (hostname == "daycare.sulekha.com") {
1394        divsearchval = 'DayCare';
1395        divcontentvalue = 'Day Care';
1396    }
1397    else if (hostname == "travelindia.sulekha.com") {
1398        divsearchval = 'Travel';
1399        divcontentvalue = 'Travel';
1400    }
1401    else {
1402        divsearchval = 'ALL';
1403        divcontentvalue = 'ALL';
1404    }
1405    //rajan
1406    //if ($SUL("#selectedtxt").length > 0)
1407    //    $SUL("#selectedtxt").html(divcontentvalue);
1408
1409    $SUL('select[name=drpcmnsearch] option[value=' + divsearchval + ']').attr('selected', 'selected');
1410
1411    if ($SUL('#drpcmnsearch').length > 0) {
1412        $SUL(document).ready(function () {
1413            try {
1414
1415                var chkdeviOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
1416
1417                if (chkdeviOS) {
1418                    $SUL('select[name=drpcmnsearch] option[value=' + divsearchval + ']').attr('selected', 'selected');
1419                    $SUL('#drpcmnsearch option[value=' + divsearchval + ']').attr('selected', 'selected');
1420                    $SUL('#drpcmnsearch').val(divsearchval);
1421                    $SUL('#drpcmnsearch').val(divsearchval).change();
1422                }
1423
1424            } catch (exws) {
1425                console.log(exws);
1426            }
1427
1428        });
1429    }
1430
1431    $SUL("select[name=drpcmnsearch]").next('span').text(divsearchval);
1432
1433
1434
1435}
1436
1437function fnhdrcommonsearchstravel(a) {
1438    var mapurl = "";
1439    mapurl = "http://travelindia.sulekha.com";
1440    if (a.length > 0) {
1441        var cholder = "hdrsearch";
1442        var topholder = "topsearch";
1443        var isUsa = false;
1444        var uslist = "<label><b>Top Travel Agents</b></label><ul>";
1445        for (var i = 0; i < a[0].ROW_TRAVELAGENT.length; i++) {
1446            if (a[0].ROW_TRAVELAGENT[i].statename != '' && a[0].ROW_TRAVELAGENT[i].statecode != '') {
1447                uslist += "<li id='vautocomplist" + i + "'>
1447<a onclick='fngetjsonagentfortravel(" + JSON.stringify(a[0].ROW_TRAVELAGENT[i].trackurl) + ")'> <i>" + a[0].ROW_TRAVELAGENT[i].AgentName + ', ' + a[0].ROW_TRAVELAGENT[i].statename + ', ' + a[0].ROW_TRAVELAGENT[i].statecode + "</i></a></li>";
1448            }
1449            else {
1450                uslist += "<li id='vautocomplist" + i + "'><a onclick='fngetjsonagentfortravel(" + JSON.stringify(a[0].ROW_TRAVELAGENT[i].trackurl) + ")'> <i>" + a[0].ROW_TRAVELAGENT[i].AgentName + "</i></a></li>";
1451            }
1452            isUsa = true;
1453        }
1454        if (frompagesearch == "1") {
1455            cholder = hdrsearchmain;
1456            topholder = topsearchmain;
1457
1458        }
1459        if (isUsa) {
1460            uslist += "</ul>";
1461            if ($SUL("#div_" + cholder + "_result").length > 0)
1462                $SUL("#div_" + cholder + "_result").html(uslist);
1463        } else {
1464            $SUL("#divus").html('');
1465        }
1466        if ($SUL("#div_" + topholder + "_result").length > 0)
1467            $SUL("#div_" + topholder + "_result").show();
1468        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
1469        //$SUL("#div_" + cholder + "_result").attr("class", "service-need-drop-down  top-search show");
1470    }
1471}
1472function fngetjsonagentfortravel(sjson) {
1473    if ($SUL('#txtussearch').length > 0) {
1474        //$SUL('#txtussearch').val(sjson.AgentName); for forming querystring values
1475        window.location.href = sjson;
1476        $SUL("#divfetching").addClass("show").removeClass("hide");
1477    }
1478
1479}
1480
1481function fncommonsearchsEventHeader(json, cholder) {
1482    if (json.length > 0 && json != undefined) {
1483        var html = '', topholder = "topsearch", hdholder = "hdrsearch";
1484        var isInAndNear = false, isMetro = false, isEvent = false, isFreeEvent = false, isHostedByEvent = false, isArtistEvent = false, isVenueEvent = false, isPastEvent = false;
1485        if (frompagesearch != "1")
1486            var vArea = $SUL('div.location-hd').find('a.location').attr("title").toUpperCase();
1487        else
1488            var vArea = $SUL('#hdnuscanadanewcity').val().toUpperCase();
1489        var vInAndNear = "<label><b>Top Event Results (In and Near - " + vArea + ")</b></label><ul>";
1490        var vMetroLt = "<label><b>Top Location Results</b></label><ul>";
1491        var vEventLt = "<label><b>Top Event Results</b></label><ul>";
1492        var vEventFreet = "<label><b>Top Listing Event Results</b></label><ul>";
1493        var vHostedByEventLt = "<label><b>Top Hosted By Results</b></label><ul>";
1494        var vArtistEventLt = "<label><b>Artist Events and Dates</b></label><ul>";
1495        var vVenueEventLt = "<label><b>Venue Events and Tickets</b></label><ul>";
1496        var vPastEventLt = "<label><b>Your Search</b></label><ul>";  // Recently Concluded Events
1497        var vSearhHeaderList = "";
1498        $SUL.each(json, function (index, item) {
1499            //$SUL('#div_hdrsearch_result').attr('class', 'service-need-drop-down top-search show');
1500            var sitemtitle = item.title;
1501            var vTitle = item.title;
1502            var vMapUrl = item.mapurl;
1503            if (sitemtitle.length > 55)
1504                sitemtitle = sitemtitle.substring(0, 55) + '...';
1505
1506            if (item.search == "latlong") {
1507                vInAndNear += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + item.trackurl + "\" onclick=\"fncommonclick('" + item.trackurl + "');ga('send', 'event', 'headersearch', 'latlong', '" + $SUL("#txtussearch").val() + "');\"><i>" + sitemtitle + "</i><b>" + item.eventdatetime + ", " + item.cityname + "</b></a></li>";
1508                isInAndNear = true;
1509            }
1510            else if (item.search == "metro") {
1511                vMetroLt += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + item.trackurl + "\" onclick=\"fncommonclick('" + item.trackurl + "');ga('send', 'event', 'headersearch', 'metro', '" + $SUL("#txtussearch").val() + "');\"><i>" + sitemtitle + ", " + item.titleurl + ", " + item.cityname + "</i></a></li>";
1512                isMetro = true;
1513            }
1514            else if (item.search == "event") {
1515                vEventLt += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + item.trackurl + "\" onclick=\"fncommonclick('" + item.trackurl + "');ga('send', 'event', 'headersearch', 'event', '" + $SUL("#txtussearch").val() + "');\"><i>" + sitemtitle + "</i><b>" + item.eventdatetime + ", " + item.cityname + "</b></a></li>";
1516                isEvent = true;
1517            } else if (item.search == "freeevent") {
1518                vEventFreet += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + item.trackurl + "\" onclick=\"fncommonclick('" + item.trackurl + "');ga('send', 'event', 'headersearch', 'freeevent', '" + $SUL("#txtussearch").val() + "');\"><i>" + sitemtitle + "</i><b>" + item.eventdatetime + ", " + item.cityname + "</b></a></li>";
1519                isFreeEvent = true;
1520            } else if (item.search == "hostedbyevent") {
1521                vHostedByEventLt += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + item.trackurl + "\" onclick=\"fncommonclick('" + item.trackurl + "');ga('send', 'event', 'headersearch', 'hostedbyevent', '" + $SUL("#txtussearch").val() + "');\"><i>" + item.hostedby + "</i></a></li>";
1522                isHostedByEvent = true;
1523            } else if (item.search == "artist") {
1524                vArtistEventLt += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + item.trackurl + "\" onclick=\"fncommonclick('" + item.trackurl + "');ga('send', 'event', 'headersearch', 'artist', '" + $SUL("#txtussearch").val() + "');\"><i>" + item.title + "</i></a></li>";
1525                isArtistEvent = true;
1526            } else if (item.search == "venue") {
1527                vVenueEventLt += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + item.trackurl + "\" onclick=\"fncommonclick('" + item.trackurl + "');ga('send', 'event', 'headersearch', 'venue', '" + $SUL("#txtussearch").val() + "');\"><i>" + item.title + "</i></a></li>";
1528                isVenueEvent = true;
1529            }
1530            if (item.search == "yoursearch") {
1531                var trackurl = item.trackurl;
1532                try {
1533                    trackurl = trackurl.replace('~newcityurl', citurl);
1534                    trackurl = trackurl.replace('~metrourl', meturl);
1535                } catch (err) { }
1536                vPastEventLt += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + trackurl + "\" onclick=\"fncommonclick('" + trackurl + "');ga('send', 'event', 'headersearch', 'yoursearch', '" + $SUL("#txtussearch").val() + "');\"><i>" + item.title + "</i></a></li>";
1537                isPastEvent = true;
1538            }
1539            //else if (item.search == "past") 
1540            //{
1541            //    vPastEventLt += "<li id='autolist" + index + "'><a style=\"display:block;\" href=\"" + item.trackurl + "\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + item.title + "</i><b>" + item.eventdatetime + ", " + item.cityname + "</b></a></li>";
1542            //    isPastEvent = true;
1543            //}
1544
1545        });
1546
1547        if (isPastEvent) {
1548            vSearhHeaderList = vPastEventLt + "</ul>";
1549        }
1550        if (isInAndNear) {
1551            vSearhHeaderList += vInAndNear + "</ul>";
1552        }
1553        if (isEvent) {
1554            vSearhHeaderList += vEventLt + "</ul>";
1555        }
1556        if (isFreeEvent) {
1557            vSearhHeaderList += vEventFreet + "</ul>";
1558        }
1559        if (isMetro) {
1560            vSearhHeaderList += vMetroLt + "</ul>";
1561        }
1562        if (isHostedByEvent) {
1563            vSearhHeaderList += vHostedByEventLt + "</ul>";
1564        }
1565        if (isArtistEvent) {
1566            vSearhHeaderList += vArtistEventLt + "</ul>";
1567        }
1568        if (isVenueEvent) {
1569            vSearhHeaderList += vVenueEventLt + "</ul>";
1570        }
1571
1572
1573        //$SUL("#" + cholder + "_list").html(html);
1574        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
1575        if (frompagesearch == "1") {
1576            hdholder = hdrsearchmain;
1577            topholder = topsearchmain;
1578        }
1579        if ($SUL("#div_" + hdholder + "_result").length > 0) {
1580            $SUL("#div_" + hdholder + "_result").html(vSearhHeaderList);
1581        }
1582        if ($SUL("#div_" + topholder + "_result").length > 0) {
1583            $SUL("#div_" + topholder + "_result").show();
1584        }
1585    }
1586
1587    scrollToElement($('li.active'));
1588
1589}
1590
1591function scrollToElement(ele) {
1592    $SUL(window).scrollTop(ele.offset().top).scrollLeft(ele.offset().left);
1593}
1594
1595function fncommonsearchsJobsHeader(json, cholder) {
1596    if (json.ROW_DS.length > 0 && json != undefined) {
1597        if (frompagesearch != "1")
1598            var vArea = $SUL('div.location-hd').find('a.location').attr("title").toUpperCase();
1599        else
1600            var vArea = $SUL('#hdnuscanadanewcity').val().toUpperCase();
1601
1602        var isJobs = false, isJobsLatest = false, isOffered = false, isWanted = false, isLatest = false;
1603
1604        var isSkills = false, isRole = false, isfunctionarea = false, isIndustry = false, isemptype = false;
1605        var isWorkauth = false, isCompany = false;
1606
1607        var vJobs_skills = "<label><b>Job by Skills</b></label><ul>";
1608        var vJobs_role = "<label><b>Job by Role</b></label><ul>";
1609        var vJobs_functional = "<label><b>Job by Functional Area</b></label><ul>";
1610        var vJobs_industry = "<label><b>Job by Industry</b></label><ul>";
1611        var vJobs_emptype = "<label><b>Job by Type</b></label><ul>";
1612        var vJobs_work = "<label><b>Job by Work Authorization</b></label><ul>";
1613        var vJobs_company = "<label><b>Job by Company</b></label><ul>";
1614        var vJobs_latlong = "<label><b>Top Jobs Results (In and Near - " + vArea + ")</b></label><ul>";
1615        var vJobs_latest = "<label><b>Latest Jobs Results</b></label><ul>";
1616        var vOffered_latlong = "<label><b>Top Offered Jobs Results In and Near " + vArea + "</b></label><ul>";
1617        var vWanted_latlong = "<label><b>Top Wanted Jobs Results In and Near " + vArea + "</b></label><ul>";
1618        var vSearchHeaderList = "";
1619
1620        var mapurl = "";
1621        var service = "";
1622        if (frompagesearch == "1")
1623            var cValue = $SUL('select[name=' + dropmainsearch + ']').val();
1624        else
1625            var cValue = $SUL('select[name=drpcmnsearch]').val();
1626        if (cValue == "Jobs") {
1627            service = "jobs";
1628            mapurl = "https://localjobs.sulekha.com";
1629        }
1630        cholder = 'hdrsearch';
1631        var topholder = "topsearch";
1632        $SUL.each(json.ROW_DS, function (index, item) {
1633            //$SUL('#div_' + cholder + '_result').attr('class', 'all-ser-com-drop show');
1634            var sitemtitle = item.title, sitemtitleurl = item.titleurl;
1635            var sNeedtype = "", tagdetails = "", sCaretype = "";
1636            if (sitemtitle.length > 55) {
1637                sitemtitle = sitemtitle.substring(0, 55) + '...';
1638            }
1639
1640            if (meturl != undefined && meturl != '' && meturl != null) {
1641                if (item.search == "emptype") {
1642                    vJobs_emptype += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i></a></li>";
1643                    isemptype = true;
1644                }
1645                if (item.search == "skills") {
1646                    vJobs_skills += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i></a></li>";
1647                    isSkills = true;
1648                }
1649                if (item.search == "role") {
1650
1651                    vJobs_role += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i></a></li>";
1652
1653                    isRole = true;
1654                }
1655                if (item.search == "functionalarea") {
1656
1657                    vJobs_functional += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i></a></li>";
1658
1659                    isfunctionarea = true;
1660                }
1661                if (item.search == "industry") {
1662
1663                    vJobs_industry += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i></a></li>";
1664
1665                    isIndustry = true;
1666                }
1667                if (item.search == "workauth") {
1668
1669                    vJobs_work += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i></a></li>";
1670
1671                    isWorkauth = true;
1672                }
1673                if (item.search == "company") {
1674
1675                    vJobs_company += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i></a></li>";
1676
1677                    isCompany = true;
1678                }
1679            }
1680            if (item.search == "localjobs_latlong") {
1681                var pricejobs = item.price1;
1682                if (parseInt(item.price1) == 0 || parseInt(item.price1) == NaN)
1683                    pricejobs = item.price2;
1684                if (item.adtype == "Wanted") {
1685                    vJobs_latlong += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b>" + item.adtype + " , " + item.jobrole + " jobs in " + item.cityname + ", " + item.statecode + "</b></a></li>";
1686                }
1687                else {
1688                    vJobs_latlong += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b>" + item.adtype + " , " + item.jobrole + " jobs in " + item.cityname + ", " + item.statecode + "</b></a></li>";
1689                }
1690                isJobs = true;
1691            }
1692            else if (item.search == "localjobs_latest" && service.toLowerCase() == "jobs") {
1693                var pricejobslatest = item.price1;
1694                if (parseInt(item.price1) == 0 || parseInt(item.price1) == NaN)
1695                    pricejobslatest = item.price2;
1696                if (item.adtype == "Wanted") {
1697                    vJobs_latest += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b> " + item.adtype + " , " + item.jobrole + " jobs in " + item.cityname + ", " + item.statecode + "</b></a></li>";
1698                }
1699                else {
1700                    vJobs_latest += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b> " + item.adtype + " , " + item.jobrole + " jobs in " + item.cityname + ", " + item.statecode + "</b></a></li>";
1701                }
1702                isJobsLatest = true;
1703            }
1704
1705        });
1706
1707
1708        if (service != undefined && service.toLowerCase() == "jobs") {
1709
1710            //if (isemptype || isfunctionarea || isRole || isIndustry || isSkills || isWorkauth || isCompany || isJobs || isJobsLatest) {
1711            //    //vSearchHeaderList = searchsugg;
1712            //}
1713            if (isemptype) {
1714                vSearchHeaderList += vJobs_emptype + "</ul>";
1715            }
1716            if (isfunctionarea) {
1717                vSearchHeaderList += vJobs_functional + "</ul>";
1718            }
1719            if (isRole) {
1720                vSearchHeaderList += vJobs_role + "</ul>";
1721            }
1722            if (isIndustry) {
1723                vSearchHeaderList += vJobs_industry + "</ul>";
1724            }
1725            if (isSkills) {
1726                vSearchHeaderList += vJobs_skills + "</ul>";
1727            }
1728            if (isIndustry) {
1729                vSearchHeaderList += vJobs_industry + "</ul>";
1730            }
1731            if (isWorkauth) {
1732                vSearchHeaderList += vJobs_work + "</ul>";
1733            }
1734            if (isCompany) {
1735                vSearchHeade
1735rList += vJobs_company + "</ul>";
1736            }
1737            if (isJobs) {
1738                vSearchHeaderList += vJobs_latlong + "</ul>";
1739            }
1740            if (isJobsLatest) {
1741                vSearchHeaderList += vJobs_latest + "</ul>";
1742            }
1743        }
1744        if (frompagesearch == "1") {
1745            cholder = hdrsearchmain;
1746            topholder = topsearchmain;
1747
1748        }
1749        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
1750        if ($SUL("#div_" + cholder + "_result").length > 0) {
1751            $SUL("#div_" + cholder + "_result").html(vSearchHeaderList);
1752        }
1753        if ($SUL("#div_" + topholder + "_result").length > 0) {
1754            $SUL("#div_" + topholder + "_result").show();
1755        }
1756
1757    }
1758}
1759
1760onHeaderSearchResult = function (hrefurl) {
1761    window.location.href = hrefurl;
1762    $SUL("#divfetching").addClass("show").removeClass("hide");
1763    $SUL("#div_hdrsearch_result").attr("class", "service-need-drop-down top-search hide");
1764}
1765
1766onHeaderTextSearch = function (holderv) {
1767    if (Sulekha.Common.trim($SUL('#' + holderv).val()) != ""
1768        && Sulekha.Common.trim($SUL('#' + holderv).val()) != defval
1769        && Sulekha.Common.trim($SUL('#' + holderv).val()) != "Enter the keyword to search") {
1770        var searchtext = $SUL("#" + holderv).val();
1771        fnsearchcommon(holderv);
1772    } else {
1773        $SUL("#" + holderv).focus();
1774    }
1775
1776}
1777
1778function fncommonsearchslocalservicesHeader(json, cholder) {
1779    if (json.ROW_DS.length > 0 && json != undefined) {
1780        if (frompagesearch != "1")
1781            var vArea = $SUL('div.location-hd').find('a.location').attr("title").toUpperCase();
1782        else
1783            var vArea = $SUL('#hdnuscanadanewcity').val().toUpperCase();
1784
1785        vArea = vArea.toLowerCase().replace(/\b[a-z]/g, function (vArea) {
1786            return vArea.toUpperCase();
1787        });
1788        var isServicelatlong = false, isServicelatest = false, isServicetop = false, isWanted = false, isLatest = false;
1789        //new
1790        var isServicerelated = false;
1791        var vServices_related = "<label><b>Providers offering the service you need</b></label><ul>";
1792        //new
1793        var vServices_latlong = "<label><b>Top Service Provider in and near " + vArea + "</b></label><ul>";
1794        var vServices_latest = "<label><b>Top Service provider Results in US & Canada</b></label><ul>";
1795        var vServices_top_service = "<label><b>Top Service Results</b></label><ul>";
1796
1797        var vOffered_latlong = "<label><b>Latest Service Provider in and Near " + vArea + "</b></label><ul>";
1798        var vWanted_latlong = "<label><b>Latest Service Provider In and Near " + vArea + "</b></label><ul>";
1799        var vSearchHeaderList = "";
1800
1801        var mapurl = "";
1802        var service = "";
1803        if (frompagesearch == "1")
1804            var cValue = $SUL('select[name=' + dropmainsearch + ']').val();
1805        else
1806            var cValue = $SUL('select[name=drpcmnsearch]').val();
1807        if (cValue == "Services") {
1808            service = "Services";
1809            mapurl = "https://localservices.sulekha.com";
1810        }
1811        cholder = 'hdrsearch';
1812        var topholder = "topsearch";
1813        $SUL.each(json.ROW_DS, function (index, item) {
1814            var sitemtitle = item.title, sitemtitleurl = item.titleurl;
1815            var sitemtags = item.tags;
1816            var sNeedtype = "", tagdetails = "", sCaretype = "";
1817            if (item.title != '' && item.title != null) {
1818                if (sitemtitle.length > 40) {
1819                    sitemtitle = sitemtitle.substring(0, 40) + '...';
1820                }
1821            }
1822            if (item.tags != '' && item.tags != null) {
1823                if (sitemtags.length > 40) {
1824                    sitemtags = sitemtags.substring(0, 40) + '...';
1825                }
1826            }
1827            if (item.search == "services_latlong") {
1828
1829                pricejobs = item.price2;
1830                vServices_latlong += "<li id='autolist" + index + "'><a style=\"display:block;\" href='" + mapurl + "/" + item.titleurl + "_" + item.cityurl + '_' + item.adid + "'><i>" + sitemtitle + "</i><b> in " + item.cityname + ", " + item.statecode + ", Specialised in " + sitemtags + "</b></a></li>";
1831                isServicelatlong = true;
1832            }
1833            else if (item.search == "services_latest" && service.toLowerCase() == "services") {
1834                vServices_latest += "<li id='autolist" + index + "'><a style=\"display:block;\" href='" + mapurl + "/" + item.titleurl + "_" + item.cityurl + '_' + item.adid + "'><i>" + sitemtitle + "</i><b> in " + item.cityname + ", " + item.statecode + ", Specialised in " + sitemtags + "</b></a></li>";
1835                isServicelatest = true;
1836            }
1837            //new
1838            else if (item.search == "services_relatedwords") {
1839                vServices_related += "<li id='autolist" + index + "'><a style=\"display:block;\" href='" + mapurl + "/" + item.titleurl + "_" + item.cityurl + '_' + item.adid + "'><i>" + sitemtitle + "</i><b>in " + item.cityname + ", " + item.statecode + ", Specialised in " + sitemtags + "</b></a></li>";
1840                isServicerelated = true;
1841            }
1842            //new
1843            else {
1844                vServices_top_service += "<li id='autolist" + index + "'><a style=\"display:block;\" href='" + item.pageurl1 + "'><i>" + item.tag + "</i></a></li>";
1845                isServicetop = true;
1846            }
1847
1848        });
1849
1850        if (service != undefined && service.toLowerCase() == "services") {
1851
1852            if (isServicetop) {
1853                vSearchHeaderList = vServices_top_service + "</ul>";
1854            }
1855            //new
1856            if (isServicerelated) {
1857                vSearchHeaderList += vServices_related + "</ul>";
1858            }
1859            //new
1860            if (isServicelatlong) {
1861                vSearchHeaderList += vServices_latlong + "</ul>";
1862            }
1863            if (isServicelatest) {
1864                vSearchHeaderList += vServices_latest + "</ul>";
1865
1866            }
1867        }
1868        if (frompagesearch == "1") {
1869            cholder = hdrsearchmain;
1870            topholder = topsearchmain;
1871
1872        }
1873        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
1874        if ($SUL("#div_" + cholder + "_result").length > 0)
1875            $SUL("#div_" + cholder + "_result").html(vSearchHeaderList);
1876        if ($SUL("#div_" + topholder + "_result").length > 0)
1877            $SUL("#div_" + topholder + "_result").show();
1878    }
1879}
1880
1881function fnallcommonsearchs(a) {
1882    if (a.length > 0) {
1883        var b = "";
1884        var isUsa = false, isCanada = false;
1885        var uslist = "", canadalist = ""; cholder = "hdrsearch"; caholder = "uscandasearch"; topholder = "topsearch";
1886        if (cmsulhdrgblsearch.customparam.groupheadtext1 == "") {
1887            uslist = "<ul>";
1888            canadalist = "<label><b>Event Suggestions</b></label><ul>";
1889        }
1890        else {
1891            uslist = "<div id='divus' class='sea-sug'>Search Suggestions</div><div class=\"label-txt\">" + cmsulhdrgblsearch.customparam.groupheadtext1 + "</div><ul>";
1892            canadalist = "<div id='divcanda' class=\"sea-sug\">Event Suggestions</div><div class=\"label-txt\">" + cmsulhdrgblsearch.customparam.groupheadtext2 + "</div><ul>";
1893        }
1894        $SUL.each(a, function (a, c) {
1895            if (c.countrycode.toLowerCase() == "us" || c.countrycode.toLowerCase() == "usa") {
1896                uslist += "<li id='vautocomplist" + a + "'><a href=\"javascript:void(0);\" onclick='selectALLCityv2(" + JSON.stringify(c) + ")'><b>" + c.city + "</b><i>
1896" + ", " + c.state + ", " + c.countrycode + "</i></a></li>";
1897                isUsa = true;
1898            } else if (c.countrycode.toLowerCase() == "ca" || c.countrycode.toLowerCase() == "canada") {
1899                canadalist += "<li id='vautocomplist" + a + "'><a href=\"javascript:void(0);\" onclick='selectALLCityv2(" + JSON.stringify(c) + ")'><b>" + c.city + "</b><i>" + ", " + c.state + ", " + c.countrycode + "</i></a></li>";
1900                isCanada = true;
1901            }
1902            else if (c.sitename.toLowerCase() != "event") {
1903                uslist += "<li id='vautocomplist" + a + "'><a href=\"javascript:void(0);\" onclick='allsearchserviceneeds(" + a + "," + JSON.stringify(c) + ")'>" + c.label + "</a></li>";
1904                isUsa = true;
1905            }
1906            else if (c.sitename.toLowerCase() == "event") {
1907                canadalist += "<li id='vautocomplist" + a + "'><a href=\"javascript:void(0);\" onclick='allsearchserviceneeds(" + a + "," + JSON.stringify(c) + ")'>" + c.label + "</a></li>";
1908                isCanada = true;
1909                if (frompagesearch == "1")
1910                    isCanada = false;
1911            }
1912        });
1913        if (frompagesearch == "1") {
1914            cholder = hdrsearchmain;
1915            topholder = topsearchmain;
1916
1917        }
1918        $SUL("#div_" + cholder + "_result").html("");
1919        if (isUsa) {
1920            uslist += "</ul>";
1921            $SUL("#div_" + cholder + "_result").append(uslist);
1922        } else {
1923            $SUL("#divus").html('');
1924        }
1925        if (isCanada) {
1926            canadalist += "</ul>";
1927            $SUL("#div_" + cholder + "_result").append(canadalist);
1928        }
1929        else {
1930            $SUL("#divcanda").html('');
1931        }
1932        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
1933        if ($SUL("#div_" + topholder + "_result").length > 0)
1934            $SUL("#div_" + topholder + "_result").show();
1935
1936        //fntopsearchglobalquerystring('div_topsearch_result', 'drpcmnsearch', 'txtussearch', 1, 'allcategorytop', '','');
1937    }
1938}
1939
1940function selectALLCityv2(a) {
1941
1942    var cholder = 'hdrsearch';
1943    if ($SUL("#hdnuscanadanewcityurl").length > 0) {
1944        $SUL("#hdnuscanadanewcityurl").val(a.citystatecodeurl);
1945    }
1946    if ($SUL("#hdnuscanadametrourl").length > 0) {
1947        $SUL("#hdnuscanadametrourl").val(a.metrourl);
1948    }
1949    $SUL("#" + cmsulhdrgblsearch.customparam.customhiddenid).val(a.citystatecodeurl); /*custom hidden id*/
1950    $SUL("#div_" + cholder + "_result").attr("class", "service-need-drop-down  top-search hide");
1951
1952    allsearch();
1953}
1954var selectneedsurl = "";
1955function allsearchserviceneeds(apo, sjson) {
1956    if (sjson != null && sjson != undefined) {
1957
1958        if (frompagesearch == "1") {
1959            if ($SUL('#txtussearchmain').length > 0) {
1960                $SUL('#txtussearchmain').val(sjson.label);
1961            }
1962        }
1963        else {
1964            //if ($SUL('#txtussearch').length > 0)
1965            //$SUL('#txtussearch').val(sjson.label);
1966        }
1967
1968        var eventsorany = sjson.sitename;
1969        if (typeof (locoobject) == undefined || typeof (locoobject) == null) {
1970            var locoobject = "";
1971        }
1972
1973
1974        if (sjson.city != "" && sjson.city != null && sjson.city != undefined && eventsorany == "event") {
1975            //pageurl 1
1976            selectneedsurl = sjson.city;
1977        } else {
1978            if (sjson.metrourl != "" && sjson.metrourl != null && sjson.metrourl != undefined && locoobject == "metro") {
1979                //pageurl 2
1980                selectneedsurl = sjson.metrourl;
1981            }
1982            else if (sjson.city != "" && sjson.city != null && sjson.city != undefined && locoobject == "city") {
1983                //pageurl 1
1984                selectneedsurl = sjson.city;
1985            }
1986            else (sjson.metrourl != null || sjson.city != null)
1987            {
1988                if (sjson.metrourl != null) {
1989                    selectneedsurl = sjson.metrourl;
1990                }
1991                else {
1992                    selectneedsurl = sjson.city;
1993                }
1994            }
1995        }
1996        if (frompagesearch == "1") {
1997            $SUL('#hdnallnewtermreplace').val(selectneedsurl);
1998            $SUL('#hdnallsitename').val(sjson.sitename);
1999            $SUL('#hdnallposition').val(apo);
2000        }
2001        else {
2002            //window.location.href = selectneedsurl;
2003            //fntopsearchglobalquerystring('div_topsearch_result', 'drpcmnsearch', 'txtussearch', 1, sjson.sitename, selectneedsurl, '');            
2004            var allqcityurl = $SUL('div.location-hd').find('a.location').attr("title");
2005            var allgotoloc = selectneedsurl + "?q=" + $SUL("#txtussearch").val() + "_" + replacespl(sjson.label) + "&c=" + apo + "_" + replacespl(sjson.sitename) + "_" + replacespl(allqcityurl);
2006            window.location = allgotoloc;
2007
2008            $SUL("#divfetching").addClass("show").removeClass("hide");
2009        }
2010
2011        if ($SUL('#div_topsearch_result').length > 0)
2012            $SUL('#div_topsearch_result').hide();
2013        if ($SUL('#div_topsearchmain_result').length > 0)
2014            $SUL('#div_topsearchmain_result').hide();
2015
2016    }
2017}
2018
2019function fnsearchcommon(holderv) {
2020    //  var cValue = $SUL("#drpcmnsearch option:selected").text();
2021    if (frompagesearch == "1")
2022        var cValue = $SUL('select[name=' + dropmainsearch + ']').val();
2023    else
2024        var cValue = $SUL('select[name=drpcmnsearch]').val();
2025    var SearchUrl = "";
2026    if (cValue == "Events") {
2027        SearchUrl = "https://www.sulekhaevents.ca/search";
2028    }
2029    else if (cValue == "DayCare" || cValue == "Day Care") {
2030        SearchUrl = "https://daycare.sulekha.com/search";
2031    }
2032    else if (cValue == "Roommates") {
2033        SearchUrl = "https://indianroommates.sulekha.com/search";
2034    }
2035    else if (cValue == "Rentals") {
2036        SearchUrl = "https://indianroommates.sulekha.com/search";
2037    }
2038    else if (cValue == "LocalBiz" || cValue == "Local Biz") {
2039        SearchUrl = "http://mycity.sulekha.com/search";
2040    }
2041    else if (cValue == "Jobs" || cValue == "jobs" || cValue == "job") {
2042        SearchUrl = "https://localjobs.sulekha.com/search";
2043    }
2044    else if (cValue == "ITTraining" || cValue == "IT Training" || cValue == "it training") {
2045
2046        SearchUrl = "https://techjobs.sulekha.com/search";
2047    }
2048    else if (cValue == "Services") {
2049        SearchUrl = "https://localservices.sulekha.com/search?cof=" + $SUL("#cof").val() + "&cx=" + $SUL("#cx").val() + "&q=" + $SUL('#' + holderv).val() + "&sa=Go";
2050    }
2051    else {
2052        SearchUrl = "http://us.sulekha.com/search?cof=" + $SUL("#cof").val() + "&cx=" + $SUL("#cx").val() + "&q=" + $SUL('#' + holderv).val() + "&sa=Go";
2053    }
2054    if (Sulekha.Common.trim($SUL('#' + holderv).val()) != "" && $SUL('#' + holderv).val() != "Enter keywords to search") {
2055        if (SearchUrl != "") {
2056            $SUL("#divfetching").addClass("show").removeClass("hide");
2057
2058            $SUL('<form id="frmsearccmn" name="frmsearccmn" method="post">').appendTo('body');
2059            $SUL('<input type="hidden" id="searchterm" name="searchterm">').val(Sulekha.Common.trim($SUL('#' + holderv).val())).appendTo('#frmsearccmn');
2060            $SUL('<input type="hidden" id="term" name="term">').val(Sulekha.Common.trim($SUL('#' + holderv).val())).appendTo('#frmsearccmn');
2061            $SUL('<input type="hidden" id="termtxt" name="txtussearch">').val(Sulekha.Common.trim($SUL('#' + holderv).val())).appendTo('#frmsearccmn');
2062            $SUL('<input type="hidden" id="hdcustomsearch" name="hdcustomsearch">').val(Sulekha.Common.trim($SUL('#' + holderv).val())).appendTo('#frmsearccmn');
2063            $SUL('<input type="hidden" id="hdsrcval" name="hdsrcval">').val(Sulekha.Common.trim($SUL('#' + holderv).val())).appendTo('#frmsearccmn');
2064            $SUL('<input type="hidden" id="hdilat" name="hdilat">').val(userlat).appendTo('#frmsearccmn');
2065            $SUL('<input type="hidden" id="hdilong" name="hdilong">').val(userlong).appendTo('#frmsearccmn');
2066            $SUL('<input type="hidden" id="hnlat" name="hnlat">').val(userlat).appendTo('#frmsearccmn');
2067            $SUL('<input type="hidden" id="hnlong" name="hnlong">').val(userlong).appendTo('#frmsearccmn');
2068            $SUL('<input type="hidden" id="lat" name="lat">').val(userlat).appendTo('#frmsearccmn');
2069            $SUL('<input type="hidden" id="long" name="long">').val(userlong).appendTo('#frmsearccmn');
2070            $SUL('#frmsearccmn').attr("action", SearchUrl);
2071            $SUL('#frmsearccmn').submit();
2072            SearchUrl = "";
2073            $SUL('#frmsearccmn').remove();
2074        }
2075        else {
2076            $SUL("#divfetching").addClass("show").removeClass("hide");
2077
2078            window.location.href = "/search?cof=" + $SUL("#cof").val() + "&cx=" + $SUL("#cx").val() + "&q=" + $SUL('#txtussearch').val() + "&sa=Go";
2079        }
2080    }
2081}
2082function fnITcommonsearchs(json) {
2083    var result = json[1];
2084    if (json[1] != undefined) {
2085        result = json[1].value;
2086    }
2087    var cholder = 'hdrsearch';
2088    var topholder = "topsearch";
2089    //if ($SUL("#div_hdrsearch_result").length > 0)
2090    //    $SUL("#div_hdrsearch_result").html(result);
2091    //if ($SUL("#div_topsearch_result").length > 0)
2092    //    $SUL("#div_topsearch_result").show();
2093
2094
2095    if (frompagesearch == "1") {
2096        cholder = hdrsearchmain;
2097        topholder = topsearchmain;
2098
2099    }
2100    if ($SUL("#div_" + cholder + "_result").length > 0)
2101        $SUL("#div_" + cholder + "_result").html(result);
2102    if ($SUL("#div_" + topholder + "_result").length > 0)
2103        $SUL("#div_" + topholder + "_result").show();
2104
2105    //$SUL('#div_hdrsearch_result').attr('class', 'service-need-drop-down top-search show');
2106    $SUL(".ustxtfetching").addClass('hide').removeClass('show');
2107    fntopsearchglobalquerystring('div_topsearch_result', 'drpcmnsearch', 'txtussearch', 0, '');
2108    fntopsearchglobalquerystring('div_topsearchmain_result', 'drpcmnsearchmain', 'txtussearchmain', 0, '');
2109}
2110function fncommonsearchHeader(json, cholder) {
2111    if (json.ROW_DS.length > 0 && json != undefined) {
2112        if (frompagesearch != "1")
2113            var vArea = $SUL('div.location-hd').find('a.location').attr("title").toUpperCase();
2114        else
2115            var vArea = $SUL('#hdnuscanadanewcity').val().toUpperCase();
2116
2117        var isRoommates = false, isRentals = false, isRoommatesLatest = false, isRentalsLatest = false, isOffered = false, isWanted = false, isLatest = false;
2118        var vRoommates_latlong = "<label><b>Top Roommates Results (In and Near - " + vArea + ")</b></label><ul>";
2119        var vRentals_latlong = "<label><b>Top Rentals Results (In and Near - " + vArea + ")</b></label><ul>";
2120        var vRoommates_latest = "<label><b>Latest Roommates Results</b></label><ul>";
2121        var vRentals_latest = "<label><b>Latest Rentals Results</b></label><ul>";
2122        var vOffered_latlong = "<label><b>Top Offered Care Results In and Near " + vArea + "</b></label><ul>";
2123        var vWanted_latlong = "<label><b>Top Wanted Care Results In and Near " + vArea + "</b></label><ul>";
2124        var vDaycare_latest = "<label><b>Latest Care Service Results</b></label><ul>";
2125        var vSearchHeaderList = "";
2126
2127        //var service = $SUL("#hostService").val();
2128        //if (service == undefined || service == "") {
2129        //    service = $SUL("#hdService").val();
2130        //}
2131
2132        var mapurl = "";
2133        var service = "";
2134        //   var cValue = $SUL("#drpcmnsearch option:selected").text();
2135        if (frompagesearch == "1")
2136            var cValue = $SUL('select[name=' + dropmainsearch + ']').val();
2137        else
2138            var cValue = $SUL('select[name=drpcmnsearch]').val();
2139        if (cValue == "Day Care" || cValue == "DayCare") {
2140            service = "day-care";
2141            mapurl = "https://daycare.sulekha.com";
2142        } else if (cValue == "Roommates") {
2143            service = "roommates";
2144            mapurl = "https://indianroommates.sulekha.com";
2145        } else if (cValue == "Rentals") {
2146            service = "rentals";
2147            mapurl = "https://indianroommates.sulekha.com";
2148        }
2149        cholder = 'hdrsearch';
2150        var topholder = "topsearch";
2151        $SUL.each(json.ROW_DS, function (index, item) {
2152            var sitemtitle = item.title, sitemtitleurl = item.titleurl;
2153            var sNeedtype = "", tagdetails = "", sCaretype = "";
2154            if (sitemtitle.length > 55) {
2155                sitemtitle = sitemtitle.substring(0, 55) + '...';
2156            }
2157
2158            if (service.toLowerCase() == "day-care") {
2159                sNeedtype = item.supercategoryid;
2160                sCaretype = item.primarycategoryid;
2161
2162                if (parseInt(item.maincategoryid) == 1 || parseInt(item.maincategoryid) == null) {
2163                    sitemtitleurl = "services_" + sitemtitleurl;
2164                }
2165                else if (parseInt(item.maincategoryid) == 2) {
2166                    sitemtitleurl = "center_" + sitemtitleurl;
2167                }
2168                else {
2169                    sitemtitleurl = "wanted_" + sitemtitleurl;
2170                }
2171                if (parseInt(sNeedtype) == 1) {
2172                    sNeedtype = "Care Offered";
2173                }
2174                else if (parseInt(sNeedtype) == 2) {
2175                    sNeedtype = "Care Wanted";
2176                }
2177                if (parseInt(sCaretype) == 3 || parseInt(sCaretype) == 25) {
2178                    sCaretype = "Kids";
2179                }
2180                else if (parseInt(sCaretype) == 4 || parseInt(sCaretype) == 26) {
2181                    sCaretype = "Parents";
2182                }
2183                else if (parseInt(sCaretype) == 5 || parseInt(sCaretype) == 27) {
2184                    sCaretype = "Pets";
2185                }
2186                else if (parseInt(sCaretype) == 6 || parseInt(sCaretype) == 28) {
2187                    sCaretype = "Home";
2188                }
2189
2190                if (sNeedtype != "" && sNeedtype != undefined) {
2191                    tagdetails = sNeedtype + " , " + sCaretype + " , " + item.tertiarycategoryvalue + " in " + item.city + ", " + item.statecode;
2192                }
2193            }
2194
2195            if (item.search == "roommates_latlong") {
2196                var priceroommates = item.price1;
2197                if (parseInt(item.price1) == 0 || parseInt(item.price1) == NaN)
2198                    priceroommates = item.price2;
2199                vRoommates_latlong += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b>" + item.adtype + " , " + item.roomtype + " , $" + priceroommates + " in " + item.cityname + ", " + item.statecode + "</b></a></li>";
2200                isRoommates = true;
2201            }
2202            else if (item.search == "rentals_latlong") {
2203                var pricerentals = item.price1;
2204                if (parseInt(item.price1) == 0 || parseInt(item.price1) == NaN)
2205                    pricerentals = item.price2;
2206                vRentals_latlong += "<li id='autolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b> " + item.adtype + " , " + item.roomtype + " , $" + pricerentals + " in " + item.cityname + ", " + item.statecode + "</b></a></li>";
2207                isRentals = true;
2208            }
2209            else if (item.search == "roommates_latest" && service.toLowerCase() == "roommates") {
2210                var priceroommateslatest = item.price1;
2211                if (parseInt(item.price1) == 0 || parseInt(item.price1) == NaN)
2212                    priceroommateslatest = item.price2;
2213                vRoommates_latest += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b> " + item.adtype + " , " + item.roomtype + " , $" + priceroommateslatest + " in " + item.cityname + ", " + item.statecode + "</b></a></li>";
2214                isRoommatesLatest = true;
2215            }
2216            else if (item.search == "rentals_latest" && service.toLowerCase() == "rentals") {
2217                var pricerentalslatest = item.price1;
2218                if (parseInt(item.price1) == 0 || parseInt(item.price1) == NaN)
2219                    pricerentalslatest = item.price2;
2220                vRentals_latest += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b> " + item.adtype + " , " + item.roomtype + " , $" + pricerentalslatest + " in " + item.cityname + ", " + item.statecode + "</b></a></li>";
2221                isRentalsLatest = true;
2222            }
2223            else if (item.search == "offered_latlong") {
2224                vOffered_latlong += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b>" + tagdetails + "</b></a></li>";
2225                isOffered = true;
2226            }
2227            else if (item.search == "wanted_latlong") {
2228                vWanted_latlong += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b>" + tagdetails + "</b></a></li>";
2229                isWanted = true;
2230            }
2231            else if (item.search == "daycare_latest") {
2232                vDaycare_latest += "<li id='autolist" + index + "'><a style=\"display:block;\"  onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + "</i><b>" + tagdetails + "</b></a></li>";
2233                isLatest = true;
2234            }
2235        });
2236
2237        if (service != undefined && service.toLowerCase() == "rentals") {
2238            if (isRentals) {
2239                vSearchHeaderList = vRentals_latlong + "</ul>";
2240            }
2241            if (isRoommates) {
2242                vSearchHeaderList += vRoommates_latlong + "</ul>";
2243            }
2244            if (isRentalsLatest) {
2245                vSearchHeaderList += vRentals_latest + "</ul>";
2246            }
2247        }
2248        else if (service != undefined && service.toLowerCase() == "roommates") {
2249            if (isRoommates) {
2250                vSearchHeaderList = vRoommates_latlong + "</ul>";
2251            }
2252            if (isRentals) {
2253                vSearchHeaderList += vRentals_latlong + "</ul>";
2254            }
2255            if (isRoommatesLatest) {
2256                vSearchHeaderList += vRoommates_latest + "</ul>";
2257            }
2258        }
2259        else {
2260            if (isOffered) {
2261                vSearchHeaderList = vOffered_latlong + "</ul>";
2262            }
2263            if (isWanted) {
2264                vSearchHeaderList += vWanted_latlong + "</ul>";
2265            }
2266            if (isLatest) {
2267                vSearchHeaderList += vDaycare_latest + "</ul>";
2268            }
2269        }
2270        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
2271        if (frompagesearch == "1") {
2272            cholder = hdrsearchmain;
2273            topholder = topsearchmain;
2274
2275        }
2276        if ($SUL("#div_" + cholder + "_result").length > 0)
2277            $SUL("#div_" + cholder + "_result").html(vSearchHeaderList);
2278        if ($SUL("#div_" + topholder + "_result").length > 0)
2279            $SUL("#div_" + topholder + "_result").show();
2280    }
2281}
2282
2283function fnhdrcommonsearchs(vjsondata) {
2284    if (vjsondata.length > 0 && vjsondata != undefined) {
2285        var html = '';
2286        if (frompagesearch != "1")
2287            var vArea = $SUL('div.location-hd').find('a.location').attr("title").toUpperCase();
2288        else
2289            var vArea = $SUL('#hdnuscanadanewcity').val().toUpperCase();
2290
2291        var isInAndNear = false, isMetro = false, isNearLatLong = false, isprimarydata = false;
2292        var vInAndNear = "<label><b>Top Business Results</b></label><ul>";
2293        var vMetroLt = "<label><b>Top Category Results</b></label><ul>";
2294        var visnearlatlong = "<label><b>Top Business Results (In and Near - " + vArea + ") </b></label><ul>";
2295        var Vprimary = "";
2296        var vSearhHeaderList = "";
2297        var mapurl = "http://mycity.sulekha.com";
2298        searchholder = 'hdrsearch';
2299        var topholder = 'topsearch';
2300        $SUL.each(vjsondata, function (index, item) {
2301            //$SUL('#div_' + searchholder + '_result').attr('class', 'service-need-drop-down top-search show');
2302            var sitemtitle = item.businessname;
2303            var vTitle = item.businessname;
2304            if (sitemtitle.length > 55)
2305                sitemtitle = sitemtitle.substring(0, 55) + '...';
2306
2307            if (item.filter == "latlong") {
2308                if (item.businessname != "" && item.businessname != null && item.businessname != undefined && item.cityurl != "" && item.cityurl != null && item.cityurl != undefined) {
2309                    visnearlatlong += "<li id='searchautolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + ", " + item.city + "</i></a></li>";
2310                    isNearLatLong = true;
2311                }
2312            }
2313            else if (item.filter == "business") {
2314                if (item.businessname != "" && item.businessname != null && item.businessname != undefined && item.cityurl != "" && item.cityurl != null && item.cityurl != undefined) {
2315                    vInAndNear += "<li id='searchautolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + ", " + item.city + "</i></a></li>";
2316                    isInAndNear = true;
2317                }
2318            }
2319            else if (item.filter == "primarytag") {
2320                if (item.businessname != "" && item.businessname != null && item.businessname != undefined && item.cityurl != "" && item.cityurl != null && item.cityurl != undefined) {
2321                    if (Vprimary == "") {
2322                        Vprimary = "<label><b>Top Business Results (" + item.category + ") </b></label><ul>";
2323                    }
2324                    Vprimary += "<li id='searchautolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + sitemtitle + ", " + item.city + "</i></a></li>";
2325                    isprimarydata = true;
2326                }
2327            }
2328            else if (item.filter == "category") {
2329                if (cmsulhdrgblsearch.customparam.pgtype == "cities") {
2330                    var srchcityurl = $SUL('#hdngblcityurl').val();
2331                    if (srchcityurl != "" && srchcityurl != null && srchcityurl != undefined) {
2332                        vMetroLt += "<li id='searchautolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + item.category + "</i></a></li>";
2333                    }
2334                    else {
2335                        vMetroLt += "<li id='searchautolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + item.category + "</i></a></li>";
2336                    }
2337                    isMetro = true;
2338                }
2339                else if (cmsulhdrgblsearch.customparam.pgtype == "metros" || cmsulhdrgblsearch.customparam.pgtype == "commonsearch") {
2340                    vMetroLt += "<li id='searchautolist" + index + "'><a style=\"display:block;\" onclick=\"fncommonclick('" + item.trackurl + "');\"><i>" + item.category + "</i></a></li>";
2341                    isMetro = true;
2342                }
2343            }
2344        });
2345        if (isNearLatLong) {
2346            vSearhHeaderList = visnearlatlong + "</ul>";
2347        }
2348        if (isInAndNear) {
2349            vSearhHeaderList += vInAndNear + "</ul>";
2350        }
2351        if (isMetro) {
2352            vSearhHeaderList += vMetroLt + "</ul>";
2353        }
2354        if (isprimarydata) {
2355            vSearhHeaderList += Vprimary + "</ul>";
2356        }�
2356
2357        $SUL(".ustxtfetching").addClass('hide').removeClass('show');
2358        if (frompagesearch == "1") {
2359            cholder = hdrsearchmain;
2360            topholder = topsearchmain;
2361            searchholder = hdrsearchmain;
2362        }
2363        if ($SUL("#div_" + searchholder + "_result").length > 0)
2364            $SUL("#div_" + searchholder + "_result").html(vSearhHeaderList);
2365        if ($SUL("#div_" + topholder + "_result").length > 0)
2366            $SUL("#div_" + topholder + "_result").show();
2367
2368    }
2369}
2370
2371
2372
2373/*share*/
2374function fnshareafoot() {
2375    $SUL('a.ushare').on('click', function () {
2376        $SUL('#divushare').show();
2377        if ($SUL('#licallback').length > 0) {
2378            fncbkclose();
2379        }
2380        if ($SUL('#lifeedback').length > 0) {
2381            fnfbkclose();
2382        }
2383    });
2384    $SUL('a.ushareclose').on('click', function () {
2385        $SUL('#divushare').hide();
2386    });
2387    $SUL('footer').append("<div id=\"divfetching\" class=\"overlay-load hide\"> <div class=\"overload\"> <p>Just a moment,fetching data </p> <div class=\"fullload\"></div> </div> </div>");
2388}
2389
2390/*share*/
2391
2392/*login part*/
2393var usnewloginurl = "https://myaccount.sulekha.com/network/ussignv2.aspx";
2394function fnnewsignin() {
2395    $SUL('#newsignin').ready(function () {
2396        $SUL('#newsignin').find('div.modal-table').append("<iframe id=\"frMyAccount\" class=\"frame-width absolute\" scrolling=\"no\" src=\"\"></iframe>");
2397    });
2398
2399    $SUL('#ussignin').on('click', function () {
2400        console.log('login');
2401        if (!Sulekha.Auth.isLoggedin()) {
2402            $SUL('#newsignin').show();
2403            $SUL('html').addClass('blur');
2404            //$SUL('html').addClass('overlay-black');
2405            if ($SUL('#frMyAccount').length > 0) {
2406                if ($SUL('#frMyAccount').attr('src') == "")
2407                    $SUL('#frMyAccount').attr("src", "//myaccount.sulekha.com/network/ussignv2.aspx");
2408            }
2409            Sulekha.Auth.CallBack_Success = "fnauthsuccessreload";
2410        }
2411        else {
2412            fnauthsuccessreload();
2413        }
2414    });
2415    if (Sulekha.Auth.isLoggedin()) { fnauthsuccess(); }
2416    $SUL('#newsignin').find('span.clsoeico').on('click', function () {
2417        fnhidelogin();
2418    });
2419}
2420
2421function fnhidelogin() {
2422    $SUL('#newsignin').hide();
2423    $SUL('html').removeClass('blur');
2424    $SUL(document.body).css('overflow', '');
2425}
2426
2427function fnauthsuccessreload() {
2428
2429    window.location.reload(true);
2430
2431}
2432function fnauthsuccess() {
2433    if ($SUL("#newsignin").length > 0) {
2434        $SUL("#newsignin").css("display", "none");
2435        $SUL(document.body).css('overflow', '');
2436    }
2437    Sulekha.CurrentUser.gatherDetail();
2438    if ($SUL('span.login-hd').find('a').length > 0) {
2439        //sulloginlinkv2();
2440        $SUL('span.login-hd').find('a').on("click", function () {
2441            $SUL('#loglinks').addClass("show").removeClass("hide");
2442            $SUL('body').addClass("blurbody");
2443            //$SUL('body').addClass("overlay-black");
2444        });
2445        if ($SUL('#loglinks').length > 0) {
2446            $SUL("#loglinks").find('a.cls').on("click", function () {
2447                $SUL('#loglinks').addClass("hide").removeClass("show");
2448                $SUL('body').removeClass("blurbody");
2449                //$SUL('body').removeClass("overlay-black");
2450            });
2451
2452        }
2453    }
2454}
2455function sulloginlinkv2() {
2456    sulloglink += "<div id=\"loglinks\" class=\"hide\"> <div class=\"afterlogin absolute\"> <div class=\"hmeusrnme\"><span class=\"hmeusrwel\"> Welcome </span>" + Sulekha.CurrentUser.name + " </div> <ul>";
2457    sulloglink += "<li><a title=\"My Profile\" href=\"http://myaccount.sulekha.com/\">My Profile</a></li>";
2458    sulloglink += "<li><a title=\"My Needs\" href=\"http://myaccount.sulekha.com/my-needs\">My Needs</a></li>";
2459    sulloglink += "<li><a title=\"My Tickets\" href=\"https://www.sulekhaevents.ca/track-order\">My Tickets</a></li>";
2460    sulloglink += "<li><a title=\"Tech Jobs\" href=\"https://techjobs.sulekha.com/dashboard\">Tech Jobs</a></li>";
2461    sulloglink += "<li><a title=\"Post An Ad\" href=\"https://us.sulekha.com/postad\">Post An Ad</a></li>";
2462    sulloglink += "</ul> <div class=\"hmelogop\"><a class=\"log\" href=\"//myaccount.sulekha.com/network/signout.aspx\">Logout</a>";
2463    sulloglink += "<a class=\"cls\" href=\"javascript:void()\">Close</a> </div> </div> </div>";
2464    if ($SUL('span.login-hd').find('a').length > 0) {
2465        $SUL('span.login-hd').find('a').after(sulloglink);
2466    }
2467    if ($SUL('#ussignin').length > 0) {
2468        $SUL('#ussignin').find('b').text(Sulekha.CurrentUser.name);
2469    }
2470}
2471
2472document.domain = "sulekhaevents.ca";
2473var newlocationcalback = "searchbymetros";
2474function fnaddactlocclass() {
2475    $SUL("ul.content-2").find('a').on('click', function () {
2476        $SUL("ul.content-2").find('li').each(function (e) {
2477            $SUL(this).removeClass("active");
2478        });
2479        $SUL(this).parent().addClass("active");
2480    });
2481}
2482function fncommoncitibymetrourl(bymetrourl) {
2483    Sulekha.Auth.JSONGetData(gProtocol + "us.sulekha.com/common/objprocess.aspx?type=citilist&term=" + bymetrourl + "&callback=" + newlocationcalback);
2484    if ($SUL('#divctyld').length > 0) {
2485        $SUL('#divctyld').find('ul.content-3').html("<div class=\"loaderhome\"></div>");
2486    }
2487}
2488function searchbymetros(json) {
2489    if (json != "" && json != null && json != undefined && json != 'undefined') {
2490        var html = '';
2491        html += "<p>Cities </p><ul class=\"content-3 relative\">";
2492        $SUL.each(json, function (index, item) {
2493            html += "<li id='locautocomplist" + index + "'><a href=\"javascript:void(0);\" onclick='selectCityV2(" + JSON.stringify(item) + ",1)'>" + item.city + ', ' + item.state + "</a></li>";
2494        });
2495        html += "</ul>";
2496        if ($SUL('#divctyld').length > 0) {
2497            //$SUL('#divctyld').find('ul.content-3').html(html);
2498            $SUL('#divctyld').html(html);
2499            if (typeof (mCustomScrollbar) != undefined && typeof (mCustomScrollbar) != 'undefined') {
2500                $SUL(".content-3").mCustomScrollbar({
2501                    scrollButtons: { enable: true },
2502                    theme: "light-thick",
2503                    scrollbarPosition: "outside"
2504                });
2505            }
2506        }
2507    }
2508}
2509
2510
2511function fillsidemenu() {
2512    $SUL('body').addClass("in-scrolll");
2513    $SUL('nav.navigator').addClass("inline-scroll");
2514
2515    var hostname = window.location.hostname;
2516
2517    if (hostname == "us.sulekha.com") {
2518        liselect = "loc_try";
2519        getnavclass = "loc_try";
2520    }
2521    else if (hostname == "www.sulekhaevents.ca" || hostname == "eventssite.sulekha.com") {
2522        liselect = "eve_try";
2523        getnavclass = "eve_try";
2524    }
2525    else if (hostname == "indianroommates.sulekha.com") {
2526        liselect = "rom_try";
2527        getnavclass = "rom_try";
2528    }
2529    else if (hostname == "us.classifieds.sulekha.com") {
2530        liselect = "cls_try";
2531        getnavclass = "cls_try";
2532    }
2533    else if (hostname == "localjobs.sulekha.com") {
2534        liselect = "job_try";
2535        getnavclass = "job_try";
2536    }
2537    else if (hostname == "localservices.sulekha.com" || hostname == "localservicesl.sulekha.com") {
2538
2539        liselect = "ls_try";
2540        getnavclass = "ls_try";
2541    }
2542    else if (hostname == "techjobs.sulekha.com") {
2543        liselect = "itr_try";
2544        getnavclass = "itr_try";
2545    }
2546    else if (hostname == "mycity.sulekha.com") {
2547        liselect = "localbiz";
2548        getnavclass = "";
2549    }
2550    else if (hostname == "daycare.sulekha.com") {
2551        liselect = "dc_try";
2552        getnavclass = "dc_try";
2553    }
2554    else if (hostname == "travelindia.sulekha.com") {
2555        liselect = "trv_try";
2556        getnavclass = "trv_try";
2557    }
2558    var metrourl = $SUL("#hdnuscanadametrourl").val(), cityurl = $SUL("#hdnuscanadanewcityurl").val(), jobExist = false;
2559    var metro = $SUL("#hdngblmetro").val(), city = $SUL("#hdnuscanadanewcity").val(), statecode = $SUL("#hdngblstate").val();
2560
2561    if ($SUL.trim($SUL('.' + getnavclass).next('ul').html()) == null || $SUL.trim($SUL('.' + getnavclass).next('ul').html()) == "") {
2562        Sulekha.Auth.JSONGetData(gProtocol + "us.sulekha.com/common/megamenu/commonmenuv2.aspx?type=fullmenu&metro=" + metro + "&metrourl=" + metrourl + "&gblcity=" + city + "&gblcityurl=" + cityurl + "&gblstate=" + statecode + "&callback=fillsidemenuSuccess");
2563    }
2564    else {
2565        $SUL('.navigator .ntitle').removeClass('active');
2566        $SUL('ul.navsub').slideUp('slow');
2567        $SUL('.' + getnavclass).addClass('active');
2568        $SUL('.' + getnavclass).next().slideDown('slow').css('overflow', 'auto');
2569    }
2570
2571
2572
2573
2574
2575}
2576
2577function fillsidemenuSuccess(data) {
2578    if (data != "" && data != undefined && data != "undefined" && data != null) {
2579        $SUL("div.loc_try").after(data[0].value);
2580        $SUL("div.eve_try").after(data[1].value);
2581        $SUL("div.rom_try").after(data[2].value);
2582        $SUL("div.ren_try").after(data[3].value);
2583        $SUL("div.itr_try").after(data[4].value);
2584        $SUL("div.ls_try").after(data[5].value);
2585        $SUL("div.dc_try").after(data[6].value);
2586        $SUL("div.job_try").after(data[7].value);
2587        $SUL("div.lb_try").after(data[8].value);
2588        $SUL("div.cls_try").after(data[9].value);
2589        $SUL("div.trv_try").after(data[10].value);
2590        $SUL("div.mov_try").after(data[11].value);
2591        $SUL("div.inv_try").after(data[12].value);
2592        $SUL("div.ipl_try").after(data[13].value);
2593        $SUL("div.lyr_try").after(data[14].value);
2594        $SUL("div.img_try").after(data[15].value);
2595        $SUL("div.prop_try").after(data[17].value);
2596    }
2597
2598    if (getnavclass.toLowerCase() == liselect.toLowerCase()) {
2599        if ($SUL('#divcomnsdemnuol' + getnavclass.toLowerCase()).length > 0 && $SUL('#divcomnsdemnuol' + getnavclass.toLowerCase()).html() != '') {
2600            $SUL('.' + getnavclass).next().html($SUL('#divcomnsdemnuol' + getnavclass.toLowerCase()).html());
2601            $SUL('.' + getnavclass).next().find('.home a').text("Overview");
2602        }
2603    }
2604    $SUL('.' + getnavclass).addClass('active');
2605    $SUL('.' + getnavclass).next().slideDown('slow').css('overflow', 'auto');
2606}
2607
2608function fncommonclick(a) {
2609    if (a != null && a != undefined && a != "undefined" && a != "") {
2610        window.location = a;
2611        $SUL("#divfetching").addClass("show").removeClass("hide");
2612    }
2613}
2614
2615function fntabshowpopularcity() {
2616    $SUL('#popusa').on('click', function () {
2617        $SUL(this).parent().addClass("active");
2618        $SUL('#popind').parent().removeClass("active");
2619        $SUL("div.indcty").slideUp("fast");
2620        $SUL("div.usacty").slideDown("slow");
2621    });
2622    $SUL('#popind').on('click', function () {
2623        $SUL(this).parent().addClass("active");
2624        $SUL('#popusa').parent().removeClass("active");
2625        $SUL("div.indcty").slideDown("fast");
2626        $SUL("div.usacty").slideUp("slow");
2627    });
2628}
2629/*header home scroll*/
2630
2631function fnmnustcky() {
2632
2633    //var hdr = $SUL('#sulmenu');
2634    //var start = $SUL(hdr).next().offset();
2635
2636    //$SUL.event.add(window, "scroll", function () {
2637    //    if ($SUL(window).scrollTop() >= start.top) {
2638    //        if ($SUL("div.botnav").length == 1) {
2639    //            //$SUL('.botnav').addClass("menu-stick");
2640    //        }
2641    //        if ($SUL("#subd").length == 1 && window.location.hostname != 'us.classifieds.sulekha.com') {
2642    //            //$SUL('#subd').addClass("menu-stick");
2643    //        }
2644    //        $SUL('#afillsidemenud').removeClass("hide").addClass("show");
2645    //        //$SUL('.topnav').addClass("menu-stick");
2646    //        $SUL('#ancnhmnumob').removeClass("hide");
2647    //    }
2648    //    else {
2649    //        if ($SUL("div.botnav").length == 1) {
2650    //            //$SUL('.botnav').removeClass('menu-stick');
2651    //        }
2652    //        if ($SUL("#subd").length == 1) {
2653    //            //$SUL('#subd').removeClass("menu-stick");
2654    //        }
2655    //        $SUL('#afillsidemenud').removeClass("show").addClass("hide");
2656    //        //$SUL('.topnav').removeClass("menu-stick");
2657    //        $SUL('#ancnhmnumob').addClass("hide");
2658
2659    //    }
2660    //});
2661}
2662
2663/*header home scroll*/
2664
2665//loginready
2666$SUL(document).ready(function () {
2667    fnnewsignin();
2668    fnlocsetdata();
2669    //fnshowlocationlist();
2670    fndropmenushowhide();
2671    fnmenushowclose();
2672    fnscrollsearchtxtappend();
2673    fnmobileviewsearch();
2674    //fnheadersearchappend();
2675    getaplnk('3');
2676    BackToTop();
2677    fnmainsearchdivappend();
2678    fnfootmenu();
2679    fnshareafoot();
2680    fnmnustcky();
2681
2682});
2683
2684
2685$SUL(document).ready(function () {
2686    $SUL('body').on('click', function (e) {
2687        var eleID = null; var elee = null;
2688        if (e.target == undefined)
2689            eleID = e.srcElement.id;
2690        else
2691            eleID = e.target.id;
2692
2693        if (e.target == undefined)
2694            elee = e.srcElement;
2695        else
2696            elee = e.target;
2697        if (eleID == "clscty" || eleID == "clsctySearch") {
2698            fnhidelocationlist();
2699            try {
2700                fnhidelocationlistSearch();
2701            }
2702            catch (exc) {
2703            }
2704
2705        }
2706        if (!$SUL(e.target).is('div.location-hd,div.location-hd *')) {
2707            fnhidelocationlist();
2708            try {
2709                fnhidelocationlistSearch();
2710            }
2711            catch (exc) {
2712            }
2713        }
2714        if (!$SUL(e.target).is('navigator *,div.hammenu-hd *,div.navinner *')) {
2715            $SUL('html').removeClass("menu-nav");
2716            $SUL('body').removeClass("in-scrolll");
2717            $SUL('nav .navigator').removeClass("inline-scroll");
2718        }
2719        if (!$SUL(e.target).is('span.contact-hd *')) {
2720            $SUL('#loglinks').addClass("hide").removeClass("show");
2721
2722        }
2723        if (!$SUL(e.target).is('#txtmodulesearch, div.tech-suggest-hm *')) {
2724            $SUL("#techcourse").find('div.tech-suggest-hm').hide();
2725        }
2726        if (!$SUL(e.target).is('#divtjsearch *')) {
2727            $SUL('#divtjsearch').hide();
2728        }
2729        if (!$SUL(e.target).is('#txtussearch,#div_topsearch_result *')) {
2730            if ($SUL('#div_topsearch_result').length > 0)
2731                $SUL('#div_topsearch_result').hide();
2732        }
2733        if (!$SUL(e.target).is('#txtussearchmain,#div_topsearchmain_result *')) {
2734            if ($SUL('#div_topsearchmain_result').length > 0)
2735                $SUL('#div_topsearchmain_result').hide();
2736        }
2737        if (!$SUL(e.target).is('#txtziporcity,#div_locationmain_result *')) {
2738            $SUL('#div_locationmain_result').hide();
2739        }
2740        if (!$SUL(e.target).is('#txtcommoncitysearch,#div_locationmain_result_v1 *')) {
2741            $SUL('#div_locationmain_result_v1').hide();
2742        }
2743    });
2744    if ($SUL('#subd').length == 1) {
2745        $SUL('#subd').find('a').on("click", function () {
2746            try {
2747                ga('send', 'event', 'newsubmenu', 'navigation', $SUL(this).attr("href"));
2748            }
2749            catch (exc) {
2750            }
2751        });
2752    }
2753});
2754
2755
2756function fntopsearchglobalquerystring(divholder, dropholder, txtholder, ifdropnotid, setallval, nohref, passloc) {
2757    if ($SUL('#' + divholder).length > 0) {
2758        $SUL('#' + divholder).find('a').unbind('click');
2759        $SUL('#' + divholder).find('a').on('click', function (e) {
2760            var svalue = "";
2761            e.preventDefault();
2762            var gotoloc = "", athref = "", qcityurl = "";
2763            var allvalue = "";
2764            if (ifdropnotid != "1")
2765                allvalue = $SUL("#" + dropholder + " option:selected").text().toLowerCase();
2766            else
2767                allvalue = setallval;
2768            if (passloc != "" && passloc != undefined && passloc != "undefined") {
2769                qcityurl = replacespl(passloc);
2770            }
2771            else {
2772                qcityurl = $SUL('div.location-hd').find('a.location').attr("title");
2773            }
2774
2775            if (allvalue != "all") {
2776                //if (allvalue == "allcategorytop") { nohref = selectneedsurl; }
2777                if (nohref != "" && nohref != undefined && nohref != "undefined") {
2778                    gotoloc = nohref;
2779                    athref = gotoloc;
2780                }
2781                else {
2782                    gotoloc = $SUL(this).attr("href");
2783                    athref = $SUL(this).attr("title");
2784                }
2785
2786                if (athref != null && athref != undefined && athref != "" && athref != "undefined") {
2787
2788                    /*var athreflength = athref.length;
2789                    athref = athref.replace(gProtocol, "");
2790                    var athrefindexval = athref.indexOf("/");
2791                    athrefindexval = athrefindexval + 1;
2792                    athref = athref.substring(athrefindexval, athreflength);*/
2793
2794
2795                    var aposition = $SUL('#' + divholder).find('a').index(this);
2796                    if (aposition != null && aposition != undefined && aposition != 'undefined') {
2797                        aposition = aposition + 1;
2798                    }
2799                    gotoloc = gotoloc + "?q=" + $SUL("#" + txtholder).val() + "_" + replacespl(athref) + "&c=" + aposition + "_" + replacespl(allvalue) + "_" + replacespl(qcityurl);
2800                    window.location = gotoloc;
2801                }
2802            }
2803        });
2804    }
2805}
2806$SUL(document).on('keyup', function (e) {
2807    if (e.keyCode == 27) {
2808        fnhidelocationlist();
2809        fnhidelogin();
2810        if ($SUL('div.hamclose').length == 1) {
2811            $SUL('div.hamclose').find('em').trigger('click');
2812        }
2813    }
2814});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.