PageSourceSearch

https://www.yvonncasellsrealestate.com/res5.0.js?v=1.10

js yvonncasellsrealestate.com collected 2026-10-04 07:21:38 UTC 66,608 bytes, 1,909 lines download raw bytes

1function bindEvents() {
2    console.log('binding events');
3
4
5    console.log('wireup menu');
6    $("#respMenu").aceResponsiveMenu({
7        resizeWidth: '1200', // Set the same in Media query       
8        animationSpeed: 'fast', //slow, medium, fast
9        accoridonExpAll: false //Expands all the accordion menu on click
10    });
11
12    try {
13        bindPluginEvents();
14    } catch (ex) { }
15
16    try {
17        bindPageEvents();
18    } catch (ex) { }
19
20    try {
21        bindDesignEvents();
22    } catch (ex) { }
23
24}
25
26
27// **
28// ** bindDesignEvents
29// ** 
30function bindDesignEvents() {
31    console.log('binding Design Events');
32
33    //Custom Design Events
34    const paragraph = document.querySelector('#disclaimer').firstElementChild.lastElementChild;
35    paragraph.innerHTML = paragraph.innerHTML.replace('Equal Housing Opportunity.', '<br/>');
36    const oldImg = paragraph.querySelector('img');
37    const img = oldImg.cloneNode(true);
38    oldImg.remove()
39    const div = document.createElement('div');
40    div.classList.add('fromJS');
41    div.appendChild(img);
42    const p = document.createElement('p');
43    p.textContent = 'Equal Housing Opportunity.'
44    div.appendChild(p);
45    paragraph.appendChild(div);
46}
47
48function bindPluginEvents() {
49    var dataXmlListings = '';
50
51    $('.qs_submit_form_city').click(function (e) {
52        e.preventDefault();
53        window.location.href = 'idx.aspx?area=' + $('#cityList').val() + '&beds=' + $('#bedrooms').val() + '&baths=' + $('#bathrooms').val() + '&max=' + $('#maxListPrice').val();
54        return false;
55    });
56    $('.qs_submit_form_zip').click(function (e) {
57        e.preventDefault();
58        window.location.href = 'idx.aspx?zip=' + $('#zipList').val() + '&beds=' + $('#bedrooms').val() + '&baths=' + $('#bathrooms').val() + '&max=' + $('#maxListPrice').val();
59        return false;
60    });
61    $('.qs_submit_form').click(function (e) {
62        e.preventDefault();
63        window.location.href = 'idx.aspx?zip=' + $('#qs_zip').val() + '&beds=' + $('#bedrooms').val() + '&baths=' + $('#bathrooms').val() + '&max=' + $('#maxListPrice').val();
64        return false;
65    });
66    $('.qs_submit_zip').click(function (e) {
67        e.preventDefault();
68        window.location.href = 'idx.aspx?zip=' + $('#qs_zip').val();
69        return false;
70    });
71    $('.qs_submit_zip_list').click(function (e) {
72        logConsole('submit zip list');
73        e.preventDefault();
74        window.location.href = 'idx.aspx?zip=' + $('#qs_zip_list').val();
75        return false;
76    });
77    $('.qs_submit_city_list').click(function (e) {
78        e.preventDefault();
79        window.location.href = 'idx.aspx?area=' + $('#qs_city_list').val();
80        return false;
81    });
82
83
84
85    try {
86        loadRotator();
87    }
88    catch (ex) { }
89
90    try {
91        loadListingCarousel();
92    }
93    catch (ex) { }
94
95    try { triggerCarouselTestimonials(); } catch (ex) { logConsole(ex.message); }
96
97    try { triggerTestimonials(); } catch (ex) { }
98
99}
100
101function fetchListings(target, urlXml) {
102
103
104    //$.ajaxSetup({ cache: false });
105
106    logConsole('fetching listings');
107    $.ajax({
108        type: "GET",
109        url: urlXml,
110        dataType: "xml",
111        cache: false,
112        success: function (xml) {
113            /* handle data here */
114            logConsole('success xml');
115            loadListing(xml, target);
116        },
117        error: function () {
118            logConsole('Could not load xml');
119        }
120    });
121    logConsole('done loading listings');
122}
123
124function loadListing(xml, target) {
125
126    var idx = 0;
127
128    var listing;
129    var url;
130    var urlDisplay;
131    var addr;
132    var img;
133
134    var html;
135    $(xml).find('listing').each(function () {
136        //console.log(this);
137        var listing = $(this);
138
139        url = listing.find('url').text();
140        urlDisplay = listing.find('url_display').text();
141        img = listing.find('media').find('property_photos').find('photo [row="1"]').find('url').text();
142
143        html = String.format('<div class="listing_panel" id="listing_panel_{0}">', idx);
144        //html += String.format('<a href="{2}" target="_blank"><img src="{0}" alt="{1}" class="lp_thumb" /></a>', listing.find('preview_thumb').text(), listing.find('details').find('title').text(), listing.find('url').text());
145        html += String.format('<a href="href="/listing/{2}"><img src="{0}" alt="{1}" class="lp_thumb" /></a>', listing.find('preview_publish').text(), listing.find('details').find('title').text(), listing.find('seoname').text());
146        html += String.format('<div class="lp_addr">{0}</div>', listing.find('location').find('street').text());
147        html += String.format('<div class="lp_csz">{0}, {1}  {2}</div>', listing.find('location').find('city').text(), listing.find('location').find('state').text(), listing.find('location').find('zip').text());
148        html += String.format('<div class="lp_beds">{0}</div>', listing.find('details').find('beds').text());
149        html += String.format('<div class="lp_baths">{0}</div>', listing.find('details').find('baths').text());
150        html += String.format('<div class="lp_mls">{0}</div>', listing.find('details').find('mls').text());
151        html += String.format('<div class="lp_price">{0}</div>', listing.find('price').text());
152        html += String.format('<a class="res_button res_button_gray lp_details" href="/listing/{0}">Details &raquo;</a>', listing.find('seoname').text());
153        html += '</div>';
154
155        $(target).append($(html));
156
157        idx++;
158    });
159}
160
161function loadSlider(target, imgs) {
162    logConsole('Loading Slider');
163
164    var arr = imgs.split(',');
165    logConsole('Array Length = ' + arr.length);
166
167    var i;
168    for (i = 0; i < arr.length; i++) {
169        $(target).append('<img src="' + arr[i] + '" />');
170    }
171
172}
173
174function initListingCarousel(blockID, urlXml, numItems, interval) {
175    logConsole('init Listing Carousel');
176    $.ajax({
177        type: "GET",
178        url: urlXml,
179        dataType: "xml",
180        cache: false,
181        success: function (xml) {
182            /* handle data here */
183            logConsole('success xml');
184            internalLoadListingCarousel(xml, blockID, numItems);
185            logConsole('set carousel interval');
186            $('#listing_carousel_' + blockID).carousel({
187                interval: interval
188            });
189
190            /*$('.carousel .carousel-item').each(function(){
191				var minPerSlide = 2;
192				var next = $(this).next();
193				if (!next.length) {
194				next = $(this).siblings(':first');
195				}
196				next.children(':first-child').clone().appendTo($(this));
197				
198				for (var i=0;i<minPerSlide;i++) {
199					next=next.next();
200					if (!next.length) {
201						next = $(this).siblings(':first');
202					}
203					
204					next.children(':first-child').clone().appendTo($(this));
205				  }
206			});*/
207
208        },
209        error: function () {
210            logConsole('Could not load xml');
211        }
212    });
213    logConsole('done triggering carousel');
214
215}
216
217function internalLoadListingCarousel(xml, blockID, numItems) {
218
219    var idx = 0;
220
221    var listing;
222    var url;
223    var urlDisplay;
224    var addr;
225    var img;
226    var altTag = '';
227
228    var html;
229    $(xml).find('listing').each(function () {
230        console.log(' Carousel Item #' + idx);
231
232        var listing = $(this);
233
234        //Adding Indicators & Open item
235        if (idx == 0) {
236            $('#listing_carousel_indicators_' + blockID).append('<li data-target="#listing_carousel_' + blockID + '" data-slide-to="0" class="active"></li>');
237            html = '<div class="item active carousel-item">';
238        }
239        else {
240            $('#listing_carousel_indicators_' + blockID).append('<li data-target="#listing_carousel_' + blockID + '" data-slide-to="' + idx + '"></li>');
241            html = '<div class="item carousel-item">';
242        }
243
244        url = listing.find('url').text();
245        urlDisplay = listing.find('url_display').text();
246        img = listing.find('media').find('property_photos').find('photo [row="1"]').find('url').text();
247
248        html += '<div class="lp_thumb_holder">';
249        altTag = listing.find('details').find('title').text();
250        altTag = altTag.replaceAll('"', '');
251        if (altTag == '') {
252            altTag = 'Property Photo';
253        }
254        html += String.format('<a href="href="/listing/{2}"><img src="{0}" alt="{1}" class="lp_thumb" /></a>', listing.find('preview_publish').text(), altTag, listing.find('seoname').text());
255        html += '</div>';
256        html += String.format('<div class="lp_addr">{0}</div>', listing.find('location').find('street').text());
257        html += String.format('<div class="lp_csz">{0}, {1}  {2}</div>', listing.find('location').find('city').text(), listing.find('location').find('state').text(), listing.find('location').find('zip').text());
258
259        if (checkValidValue(listing.find('details').find('beds').text())) {
260            html += String.format('<div class="lp_beds">{0}</div>', listing.find('details').find('beds').text());
261        }
262        if (checkValidValue(listing.find('details').find('baths').text())) {
263            html += String.format('<div class="lp_baths">{0}</div>', listing.find('details').find('baths').text());
264        }
265
266
267        html += String.format('<div class="lp_mls">{0}</div>', listing.find('details').find('mls').text());
268        if (listing.find('price').text().length > 15) {
269            html += String.format('<div class="lp_price">{0}&hellip;</div>', listing.find('price').text().substring(0, 15));
270        }
271        else {
272            html += String.format('<div class="lp_price">{0}</div>', listing.find('price').text());
273        }
274
275
276        html += String.format('<a class="res_button res_button_gray lp_details" href="/listing/{0}">Details &raquo;</a>', listing.find('seoname').text());
277
278
279        html += '</div>'; //End .item
280
281
282        $('#listing_carousel_wrapper_' + blockID).append($(html));
283
284        idx++;
285    });
286}
287
288function checkValidValue(val) {
289    var rc = false;
290    if (val != '' && val != 'undefined') {
291        rc = true;
292    }
293    return rc
294}
295(function ($) {
296    $.fn.mapmarker = function (options) {
297        var opts = $.extend({}, $.fn.mapmarker.defaults, options);
298
299        return this.each(function () {
300            // Apply plugin functionality to each element
301            var map_element = this;
302            addMapMarker(map_element, opts.zoom, opts.center, opts.markers);
303        });
304    };
305
306    // Set up default values
307    var defaultMarkers = {
308        "markers": []
309    };
310
311    $.fn.mapmarker.defaults = {
312        zoom: 8,
313        center: 'United States',
314        markers: defaultMarkers
315    };
316
317    // Main function code here (ref:google map api v3)
318    function addMapMarker(map_element, zoom, center, markers) {
319        //console.log($.fn.mapmarker.defaults['center']);
320
321        logConsole('In addMapMarker');
322        //Set center of the Map
323        var myOptions = {
324            mapTypeId: 'roadmap'
325        };
326
327        try {
328            var map = new google.maps.Map(map_element, myOptions);
329            var geocoder = new google.maps.Geocoder();
330            var infowindow = null;
331            var baloon_text = "";
332        }
333        catch (ex) {
334            logConsole(ex.toString());
335        }
336
337        //        geocoder.geocode({ 'address': center }, function(results, status) {
338        //            if (status == google.maps.GeocoderStatus.OK) {
339        //                //In this case it creates a marker, but you can get the lat and lng from the location.LatLng
340        //                //map.setCenter(results[0].geometry.location);
341        //            }
342        //            else {
343        //                logConsole("Geocode was not successful for the following reason: " + status);
344        //            }
345        //        });
346
347        var bounds = new google.maps.LatLngBounds();
348
349        //run the marker JSON loop here
350        $.each(markers.markers, function (i, the_marker) {
351            latitude = the_marker.latitude;
352            longitude = the_marker.longitude;
353            icon = the_marker.icon;
354            var baloon_text = the_marker.baloon_text;
355
356            if (latitude != "" && longitude != "") {
357                var marker = new google.maps.Marker({
358                    map: map,
359                    position: new google.maps.LatLng(latitude, longitude),
360                    animation: google.maps.Animation.DROP,
361                    icon: icon
362                });
363
364                // Set up markers with info windows 
365                google.maps.event.addListener(marker, 'click', function () {
366                    // Close all open infowindows
367                    if (infowindow) {
368                        infowindow.close();
369                    }
370
371                    infowindow = new google.maps.InfoWindow({
372                        content: baloon_text
373                    });
374
375                    infowindow.open(map, marker);
376                });
377
378                bounds.extend(new google.maps.LatLng(latitude, longitude));
379            }
380        });
381        logConsole('fitting in bounds');
382        map.fitBounds(bounds);       // auto-zoom
383        map.panToBounds(bounds);     // auto-center
384    }
385
386})(jQuery);
387
388
389function getParameterByName(name, url) {
390    if (!url) url = window.location.href;
391    name = name.replace(/[\[\]]/g, '\\$&');
392    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
393        results = regex.exec(url);
394    if (!results) return null;
395    if (!results[2]) return '';
396    return decodeURIComponent(results[2].replace(/\+/g, ' '));
397}
398
399
400function qsLoadResults() {
401    $('.full_slider').hide();
402    $('.quick_search').hide();
403    $('#qs_results').show();
404    //$('#qs_ihf_frame').width(800);
405    $('#qs_ihf_frame').height(2800);
406
407    // here you can make the height, I delete it first, then I make it again
408
409
410}
411
412function onFrameLoaded() {
413    logConsole('frame loaded');
414
415    //var iFrameID = document.getElementById('qs_ihf_frame');
416    //if(iFrameID) {
417    // here you can make the height, I delete it first, then I make it again
418    //      iFrameID.height = "";
419    //       iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight + "px";
420    // }   
421    //logConsole('Content Window ' + iFrameID.height);
422}
423
424
425function isEmpty(val) {
426    if (val != '' && val != 'undefined') {
427        return false;
428    }
429    else {
430        return true;
431    }
432}
433
434function checkLoadField(className, val) {
435    if (val != '' && val != 'undefined') {
436        return String.format('<div class="{0}">{1}</div>', className, val);
437    }
438}
439
440
441/** Utilities **/
442function logConsole(msg) {
443    try {
444        var d = new Date($.now());
445        var ts = d.getDate() + "-" + (d.getMonth() + 1) + "-" + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
446
447        console.log(ts + '  RES: ' + msg);
448    }
449    catch (ex) { console.log(ex.toString()); }
450}
451
452String.format = function () {
453    var s = arguments[0];
454    for (var i = 0; i < arguments.length - 1; i++) {
455        var reg = new RegExp("\\{" + i + "\\}", "gm");
456        s = s.replace(reg, arguments[i + 1]);
457    }
458    return s;
459}
460
461function bindControls() {
462    logConsole('in bindControls');
463
464    window.addEventListener("message", (event) => {
465        logConsole('message from ' + event.origin);
466        logConsole(' MSG: ' + event.data);
467        // Do we trust the sender of this message?  (might be
468        // different from what we originally opened, for example).
469        if (event.origin == 'https://www.idxhome.com' || event.origin == 'https://idxhome.com' || event.origin == 'https://search.propertiesonline.com') {
470            var h = event.data.replace('height:', '');
471            h = parseInt(h) + 50;
472            logConsole('resetting to ' + h);
473            $('#idxResults').height(h);
474            console.log('smooth scroll to top');
475            window.scrollTo({ top: 0, behavior: 'smooth' });
476        }
477
478        if (event.origin == 'https://player.vimeo.com') {
479            resizeBackgroundVideo(true);
480        }
481
482
483    }, false);
484
485    //Call to resize...  before Vimeo handshakes back.
486    resizeBackgroundVideo(false);
487
488    //logConsole('nav width=' + ('nav').width() + '  Menu=' + ('.ace-responsive-menu').width());
489
490    //if ($('.embed-container-fullscreen').length) {
491    //    try {
492    //        logConsole('preset setting background video height');
493
494    //        logConsole('  Width=' + $('.embed-container-fullscreen').width());
495    //        var h = $('.embed-container-fullscreen').width() * 5 / 16;
496
497    //        $('.embed-container-fullscreen').height(h);
498    //        logConsole('  Height: ' + $('.embed-container-fullscreen').height());
499    //    } catch (ex) { }
500    //}
501
502    //if ($('.embed-container-mobile').is(':visible')) {
503    //    try {
504    //        logConsole('preset setting mobile background video height');
505
506    //        logConsole('  mobile Width=' + $('.embed-container-mobile').width());
507    //        var h = $('.embed-container-mobile').width() * 3 / 5;
508
509    //        $('.embed-container-mobile').height(h);
510    //        logConsole('  mobile Height: ' + $('.embed-container-mobile').height());
511    //    } catch (ex) { }
512    //}
513
514    if ($('.integratedsplash').length) {
515        logConsole('splash w and h');
516        var w = parseInt($('.integratedsplash').width());
517        var h = w * 5 / 16;
518        logConsole('splash ' + h + ' x ' + w);
519        if ($('.integratedsplash_image').length) {
520            var imageUrl = $('.integratedsplash_image').css('background-image').replace('url("', '').replace('")', '');
521            logConsole('img - ' + imageUrl);
522
523            var tmpImg = new Image();
524            tmpImg.src = imageUrl; //or  document.images[i].src;
525            $(tmpImg).one('load', function () {
526                orgWidth = tmpImg.width;
527                orgHeight = tmpImg.height;
528                logConsole(orgWidth + "x" + orgHeight);
529                h = w * orgHeight / orgWidth;
530                logConsole('setting height ' + h);
531                $('.integratedsplash_image').height(h);
532            });
533            logConsole(' h=' + h);
534        }
535        else {
536            $('.embed-container-fullscreen').height(h);
537        }
538        var margin = Math.round((w - 375) / 2);
539        $('.iso_quicksearch').css('margin-left', margin + 'px');
540        $('.iso_quicksearch').show(1000);
541    }
542
543    $("#dialog_sms").dialog({
544        autoOpen: false, modal: true,
545        buttons: {
546            Close: { 
547                text: "Close",
548                'class': 'dialog_close', 
549                click: function() { 
550                    $(this).dialog("close"); 
551                } 
552            },
553            'Send SMS': {
554                text: 'Send SMS',
555                id: 'btnSendSms',
556                click: function () {
557                    if (postSms()) {
558                        logConsole('Success in postSms');
559                        //$(this).dialog("close");
560                    }
561                }
562            }
563        }
564    });
565    $("#open_dialog_sms").click(function (e) {
566        e.preventDefault();
567
568        //Clear in case of previous submit
569        $('#txtSMSFromName').val('');
570        $('#txtSMSFromPhone').val('');
571
572        //Turn on in case its already been used and off.
573        $("#btnSendSms").show();
574        $('#dialog_sms').dialog('open');
575        logConsole('exit Click SMS');
576    });
577
578    $("#dialog_viewing").dialog({
579        autoOpen: false, modal: true, width:400, 
580        buttons: {
581            Close: {
582                text: "Close",
583                'class': 'dialog_close',
584                click: function () {
585                    $(this).dialog("close");
586                }
587            },
588            'Request Viewing': {
589                text: 'Request Viewing',
590                id: 'btnRequestViewing',
591                click: function () {
592                    if (postLeadCapture('viewing', 'success')) {
593                        logConsole('Success in postViewing');
594                        $("#btnRequestViewing").hide();
595                        //$(this).dialog("close");
596                    }
597                }
598            }
599        }
600    });
601
602    //LEAD Capture
603    $(".lc_submit").click(function (e) {
604        e.preventDefault();
605        postLeadCapture($(this).attr('lc-type'), $(this).attr('lc-action'));
606    });
607
608    //Input Masks
609    $('#txtSMSFromPhone').inputmask('(999) 999-9999');
610
611    $('.lc_input_phone').inputmask('(999) 999-9999');
612    $('.lc_input_email').inputmask('email',
613        {
614            onUnMask: function (maskedValue, unmaskedValue) {
615                return unmaskedValue;
616            }
617        }
618    );
619
620    //DatePicker
621    $(".lc_input_date").datepicker();
622
623
624    /*
625    try {
626        $('#qstypeahead').typeahead({
627            minLength: 1,
628            highlight: true
629        },
630        {
631            name: 'qstypeaheadsource',
632            source: substringMatcher(qstypeaheadsource)
633        });
634    } catch (ex) { }
635    */
636    try{
637        $('.js-typeahead').typeahead({
638            order: 'asc',
639            minLength: 0,
640            debug: true,
641            source: {
642                groupName: {
643                    // Array of Objects / Strings
644                    data: qstypeaheadsource
645                }
646            },
647            callback: {
648                onInit: function () { logConsole('init js-typeahead'); },
649                onClick: function (node, a, item, event) {
650                    logConsole('js-typeahead onClick ' + item.display);
651                    $('#typeahead__selected').val(item.display);
652                },
653                onSearch: function (node, query) {
654                    logConsole('js-typeahead onSearch ');
655                },
656                onCancel: function (node, query) {
657                    $('#typeahead__selected').val('');
658                },
659
660                onSubmit: function (node, form, item, event) {
661                    event.preventDefault();
662
663                    logConsole('submit js-typeahead');
664                    logConsole(node);
665                    logConsole(form);
666                    logConsole(item);
667                    logConsole(event);
668 
669                    //var encode = encodeURIComponent($('#qstypeahead').typeahead('val'));
670                    //logConsole(' ENCODE = ' + encode);
671                    //window.location.href = 'idx.aspx?search=' + encode;
672                }
673            }
674        });
675
676        $('#typeahead__submit').click(function (e) {
677            logConsole('typeahead submit');
678            e.preventDefault();
679            
680            var encode = encodeURIComponent($('#typeahead__selected').val());
681
682            logConsole(' ENCODE = ' + encode);
683            window.location.href = 'idx.aspx?search=' + encode;
684            return false;
685        });
686
687        $('#typeahead__submit__ihf10').click(function (e) {
688            logConsole('typeahead submit ifh10');
689            e.preventDefault();
690            var encode = encodeURIComponent($('#typeahead__selected').val());
691
692            window.location.href = '/ihf/search/?search=' + encode;
693            return false;
694        });
695
696
697    } catch (ex) { }
698
699
700
701    try {
702        if ($('.integratedsplash').length) {
703            var w = parseInt($('.integratedsplash').width());
704            logConsole('width of splash = ' + w);
705            var margin = Math.round((w - 375) / 2);
706            logConsole('margin = ' + margin);
707
708            $('.iso_quicksearch').css('margin-left', margin + 'px');
709            $('.typeahead__container').css('margin-left', margin + 'px');
710            $('.gaac_container').css('margin-left', margin + 'px');
711
712            $('#gaac_submit').click(function (e) {
713                logConsole('gaac submit');
714                e.preventDefault();
715                submitGaac();
716                return false;
717            });
718
719            logConsole('call to bind gaac');
720            bindGoogleAddressAutocomplete('#gaac_search_location');
721        }
722    }
723    catch (ex) {
724        logConsole('splash EX: ' + ex.message);
725    }
726
727
728
729    logConsole('done bindControls');
730
731
732    $('#qs_submit_form').click(function (e) {
733        e.preventDefault();
734
735        var encode = encodeURIComponent($('#qstypeahead').typeahead('val'));
736
737        logConsole(' ENCODE = ' + encode);
738        window.location.href = 'idx.aspx?search=' + encode;
739
740        return false;
741    });
742
743    $('.w3_slider_expand').click(function () {
744        logConsole('Expanding on ' + slideIndex);
745        //showW3PhotoSwipe(slideIndex);
746        showW3PhotoSwipe(slideIndex - 1);
747    });
748
749    $('.calcfields').change(function (e) {
750        calcFields();
751    });
752
753
754
755}
756
757function bindLeadCapture() {
758}
759
760var flagValidateForm;
761function validateFieldText(id) {
762    if ($(id).val() == '') {
763        $(id).addClass('ui-state-error ui-corner-all');
764        $(id).change(function (e) {
765            if ($(this).val() != '') {
766                $(this).removeClass('ui-state-error ui-corner-all');
767            }
768        });
769        flagValidateForm = false;
770    }
771}
772
773function validateFieldPhone(id) {
774    if ($(id).val() == '' || cleanPhone($(id).val()) == '') {
775        $(id).addClass('ui-state-error ui-corner-all');
776        $(id).change(function (e) {
777            if ($(this).val() != '' && cleanPhone($(id).val()) != '') {
778                $(this).removeClass('ui-state-error ui-corner-all');
779            }
780        });
781        flagValidateForm = false;
782    }
783}
784
785function cleanPhone(ph) {
786    var clean = ph.replace("(", "").replace(")", "").replace("-", "").replace("_", "").replace("+1", "").replace(" ", "");
787    var phoneno = /^\d{10}$/;
788    if (clean.match(phoneno)) {
789        return clean;
790    }
791    else {
792        return '';
793    }
794}
795
796function validateFieldEmail(id) {
797    if ($(id).val() == '') {
798        logConsole('Empty Email');
799    }
800
801    if (cleanEmail($(id).val()) == '' || !internalValidateEmail($(id).val())) {
802        $(id).addClass('ui-state-error ui-corner-all');
803        $(id).change(function (e) {
804            if (cleanEmail($(id).val()) != '' && internalValidateEmail($(id).val())) {
805                $(this).removeClass('ui-state-error ui-corner-all');
806            }
807        });
808        flagValidateForm = false;
809    }
810}
811
812function internalValidateEmail(em) {
813    em = em.replace('@_._','');
814
815    var mailformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
816    if (em.match(mailformat)) {
817        return true;
818    }
819    else {
820        logConsole('invald email ' + em);
821        return false;
822    }
823}
824
825function cleanEmail(em) {
826    var clean = em.replace("@", "").replace(".", "").replace("_", "").replace(" ", "");
827    return clean;
828}
829
830function validateFieldDate(id) {
831    logConsole('Validate Date ' +id + ' - ' + $(id).val());
832    if ($(id).val() == '') {
833        $(id).addClass('ui-state-error ui-corner-all');
834        $(id).change(function (e) {
835            if ($(this).val() != '') {
836                $(this).removeClass('ui-state-error ui-corner-all');
837            }
838        });
839        flagValidateForm = false;
840    }
841}
842
843function bindCaptcha() {
844    grecaptcha.ready(function () {
845        grecaptcha.execute(grecaptcha_key, { action: 'form' }).then(function (token) {
846            $('#hiddenFormToken').val(token);
847        });
848    });
849
850}
851
852function postSms() {
853
854    flagValidateForm = true;
855
856    validateFieldText('#txtSMSFromName');
857    validateFieldPhone('#txtSMSFromPhone');
858    validateFieldText('#txtSMSMessage');
859
860    if (flagValidateForm) {
861        logConsole('posting to handler');
862 
863        $('#sms_feedback').show();
864        $('#sms_feedback_text').html('Processing Request.');
865        $('#sms_feedback_image').attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/processing.gif');
866
867        $.post({
868            url:"/forms/handler.ashx",
869            data:{
870                action: 'sms',
871                transaction: $('#hiddenFormTransaction').val(),
872                token: $('#hiddenFormToken').val(),
873                name: $('#txtSMSFromName').val(),
874                phone: cleanPhone($('#txtSMSFromPhone').val()),
875                message: $('#txtSMSMessage').val(),
876                listingid: $('#hiddenListingID').val(),
877                ref: window.location.href
878            },
879            complete: function (data, status) {
880                logConsole('Data: ' + data.responseText + ' Status: ' + status);
881                if (status == 'success') {
882                    $('#sms_feedback_text').html('Your request has been sent.');
883                    $('#sms_feedback_image').attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/check.png');                    
884                    $("#btnSendSms").hide();
885                }
886                else {
887                    $('#sms_feedback_text').html('Unable to process request.');
888                    $('#sms_feedback_image').attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/no_check.png');
889                }
890
891                $('#hiddenFormTransaction').val(data.responseText.split('|')[2]);
892                bindCaptcha();
893
894            }
895        });
896    }
897
898    return flagValidateForm;
899}
900
901    function postLeadCaptureXXX(lcType, lcAction) {
902        logConsole('Submitting LC - ' + lcType);
903        flagValidateForm = true;
904
905        //Validate Common Fields
906        validateFieldText('#txtlcfromname' + lcType);
907        validateFieldEmail('#txtlcfromemail' + lcType);
908        validateFieldPhone('#txtlcfromphone' + lcType);
909
910        var lcName = $('#txtlcfromname' + lcType).val();
911        var lcPhone = cleanPhone($('#txtlcfromphone' + lcType).val());
912        var lcEmail = $('#txtlcfromemail' + lcType).val();
913        var lcMessage = $('#txtlcmessage' + lcType).val();
914    
915        var lcViewingDate = $('#txtlcviewingdate' + lcType).val();
916
917        switch (lcType) {
918            case 'contact':
919                validateFieldText('#txtlcmessage' + lcType);
920                break;
921            default:
922                //nothing
923        }
924
925
926
927        if (flagValidateForm) {
928            logConsole('posting to handler');
929
930            var feedbackText = '#lc_feedback_' + lcType + ' .lc_feedback_text';
931            var feedbackImage = '#lc_feedback_' + lcType + ' .lc_feedback_image';
932            $('#lc_feedback_' + lcType).show();
933            $(feedbackText).html('Processing Request.');
934            $(feedbackImage).attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/processing.gif');
935
936            $.post({
937                url: "/forms/handler.ashx",
938                data: {
939                    action: lcType,
940                    transaction: $('#hiddenFormTransaction').val(),
941                    token: $('#hiddenFormToken').val(),
942                    name: lcName,
943                    email: lcEmail,
944                    phone: lcPhone,
945                    message: lcMessage,
946                    listingid: $('#hiddenListingID').val(),
947                    ref: window.location.href,
948                    viewing: lcViewingDate
949                },
950                complete: function (data, status) {
951                    logConsole('Data: ' + data.responseText + ' Status: ' + status);
952                    if (status == 'success') {
953
954                        $(feedbackText).html('Your request has been sent.');
955                        $(feedbackImage).attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/check.png');
956
957                        $('#txtlcfromname' + lcType).val('');
958                        $('#txtlcfromphone' + lcType).val('');
959                        $('#txtlcfromemail' + lcType).val('');
960                        $('#txtlcmessage' + lcType).val('');
961
962
963                        if (lcAction != 'success' && lcAction != '') {
964                            setTimeout(function () { location.href = lcAction }, 3000);
965                        }
966                    }
967                    else {
968                        $(feedbackText).html('Unable to process request. ' + data.responseText.split('|')[1] + '.');
969                        $(feedbackImage).attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/no_check.png');
970                    }
971                    $('#hiddenFormTransaction').val(data.responseText.split('|')[2]);
972                    bindCaptcha();
973                }
974            });
975        }
976
977
978    }
979
980
981function postLeadCapture(lcType, lcAction) {
982        
983    logConsole('Submitting LC - ' + lcType);
984    flagValidateForm = true;
985
986    //Validate Common Fields
987    validateFieldText('#txtlcfromname' + lcType);
988
989    if ($('#cbolcpreference' + lcType).val() == 'email') {
990        validateFieldEmail('#txtlcfromemail' + lcType);
991    }
992    else {
993        validateFieldPhone('#txtlcfromphone' + lcType);
994    }
995
996    switch (lcType) {
997        case 'contact':
998            validateFieldText('#txtlcmessage' + lcType);
999            break;
1000        case 'viewing':
1001            validateFieldDate('#txtlcdate' + lcType);
1002            break;
1003        default:
1004            //nothing
1005    }
1006
1007    if (flagValidateForm) {
1008        logConsole('posting to handler');
1009
1010        let params = [];
1011        //Common
1012        params.push({ "action": lcType });
1013        params.push({ "transaction": $('#hiddenFormTransaction').val() });
1014        params.push({ "token": $('#hiddenFormToken').val() });
1015        params.push({ "listingid": $('#hiddenListingID').val() });
1016        params.push({ "ref": window.location.href });
1017        //User Entered
1018        params.push({ "name": $('#txtlcfromname' + lcType).val() });
1019        params.push({ "email": $('#txtlcfromemail' + lcType).val() });
1020        params.push({ "phone": cleanPhone($('#txtlcfromphone' + lcType).val()) });
1021        params.push({ "preference": $('#cbolcpreference' + lcType).val() });
1022        params.push({ "message": $('#txtlcmessage' + lcType).val() });
1023        switch (lcType) {
1024            case 'viewing':
1025                params.push({ "viewing": $('#txtlcdate' + lcType).val() });
1026                params.push({ "viewingtime": $('#cbolctime' + lcType).val() });
1027                params.push({ "propertyaddress": $('#txtlcpropertyaddress' + lcType).val() });
1028                break;
1029
1030            case 'cma':
1031                params.push({ "address": $('#txtlcaddress' + lcType).val() });
1032                params.push({ "beds": $('#txtlcbeds' + lcType).val() });
1033                params.push({ "baths": $('#txtlcbaths' + lcType).val() });
1034                params.push({ "built": $('#txtlcbuilt' + lcType).val() });
1035                params.push({ "livingspace": $('#txtlclivingspace' + lcType).val() });
1036                params.push({ "lotsize": $('#txtlclotsize' + lcType).val() });
1037                params.push({ "upgrades": $('#txtlcupgrades' + lcType).val() });
1038                break;
1039
1040            case 'reports':
1041                if ($('#chklcbuyers' + lcType).prop('checked')) { params.push({ "buyers": "true" }); }
1042                if ($('#chklcsellers' + lcType).prop('checked')) { params.push({ "sellers": "true" }); }
1043                if ($('#chklctechtrends' + lcType).prop('checked')) { params.push({ "techtrends": "true" }); }
1044                break;
1045
1046            case 'listingupdates':
1047                params.push({ "propertytype": $('#cbolcpropertytype' + lcType).val() });
1048                params.push({ "beds": $('#txtlcbeds' + lcType).val() });
1049                params.push({ "baths": $('#txtlcbaths' + lcType).val() });
1050                params.push({ "amenities": $('#txtlcamenities' + lcType).val() });
1051                params.push({ "neighborhoods": $('#txtlcneighborhoods' + lcType).val() });
1052                break;
1053
1054            default:
1055                //nothing
1056        }
1057        logConsole('Params Count => ' + params.length);
1058
1059        
1060
1061        var feedbackText = '#lc_feedback_' + lcType + ' .lc_feedback_text';
1062        var feedbackImage = '#lc_feedback_' + lcType + ' .lc_feedback_image';
1063        $('#lc_feedback_' + lcType).show();
1064        $(feedbackText).html('Processing Request.');
1065        $(feedbackImage).attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/processing.gif');
1066
1067        $("html, body").animate({ scrollTop: $(feedbackImage).offset().top }, 1000);
1068
1069        $.post({
1070            url: "/forms/handler.ashx",
1071            data: { params },
1072            complete: function (data, status) {
1073                logConsole('Data: ' + data.responseText + ' Status: ' + status);
1074                if (status == 'success') {
1075
1076                    $(feedbackText).html('Your request has been sent.');
1077                    $(feedbackImage).attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/check.png');
1078
1079                    $('#txtlcfromname' + lcType).val('');
1080                    $('#txtlcfromphone' + lcType).val('');
1081                    $('#txtlcfromemail' + lcType).val('');
1082                    $('#txtlcmessage' + lcType).val('');
1083
1084
1085                    if (lcAction != 'success' && lcAction != '') {
1086                        setTimeout(function () { location.href = lcAction }, 3000);
1087                    }
1088                }
1089                else {
1090                    $(feedbackText).html('Unable to process request. ' + data.responseText.split('|')[1] + '.');
1091                    $(feedbackImage).attr('src', 'https://s3-us-west-1.amazonaws.com/realestatesites.com/stock/icons/no_check.png');
1092                }
1093                $('#hiddenFormTransaction').val(data.responseText.split('|')[2]);
1094                bindCaptcha();
1095            }
1096        });
1097    }
1098
1099
1100}
1101
1102
1103var substringMatcher = function (strs) {
1104    return function findMatches(q, cb) {
1105        var matches, substringRegex;
1106
1107        matches = [];
1108
1109        substrRegex = new RegExp(q, 'i');
1110
1111        $.each(strs, function (i, str) {
1112            if (substrRegex.test(str)) {
1113                matches.push(str);
1114            }
1115        });
1116
1117        cb(matches);
1118    };
1119};
1120
1121
1122
1123
1124function bindSlickListings(target, urlXml, settingNumSlides, blockId) {
1125    logConsole('binding to Slick #' + blockId);
1126    $.ajax({
1127        type: "GET",
1128        url: urlXml,
1129        dataType: "xml",
1130        cache: false,
1131        success: function (xml) {
1132            /* handle data here */
1133            logConsole('success xml');
1134            //loadSlickListings(xml, target);
1135            if (loadSlickListings(xml, target) > 0) {
1136                logConsole('Binding ' + target + ' to slick');
1137                logConsole(' this ' + $(target).width());
1138
1139                //NOTE: this code still needs to be tweaked
1140                var numSlides;
1141                if (settingNumSlides > 0) { numSlides = settingNumSlides; }
1142                else if ($(target).width() <= 500) { numSlides = 1; }
1143                else if ($(target).width() <= 850) { numSlides = 2; }
1144                else if ($(target).width() <= 1200) { numSlides = 3; }
1145                else { numSlides = 4; }
1146
1147                $('#slick_listing_controls_' + blockId).show();
1148
1149                $(target).slick({
1150                    dots: false,
1151                    infinite: true,
1152                    speed: 300,
1153                    slidesToShow: numSlides,
1154                    slidesToScroll: 1,
1155                    prevArrow: '#slc_prev_' + blockId,
1156                    nextArrow: '#slc_next_' + blockId,
1157                });
1158
1159                
1160            }
1161            else {
1162                $(target).hide();
1163                
1164                //WARNING, If other content is in this block, then it will get hidden
1165                $('#block_' + blockId).hide();
1166            }
1167
1168        },
1169        error: function () {
1170            logConsole('Could not load xml');
1171        }
1172    });
1173    logConsole('done loading listings');
1174
1175}
1176
1177
1178function loadSlickListings(xml, target) {
1179
1180    var idx = 0;
1181
1182    var listing;
1183    var url;
1184    var urlDisplay;
1185    var addr;
1186    var img;
1187    var altTag = '';
1188
1189    var html;
1190    $(xml).find('listing').each(function () {
1191        var listing = $(this);
1192
1193        url = listing.find('url').text();
1194        urlDisplay = listing.find('url_display').text();
1195        img = listing.find('media').find('property_photos').find('photo [row="1"]').find('url').text();
1196
1197        html = String.format('<div class="slg_item" id="slg_item_{0}">', idx);
1198        html += '<div class="slgi_thumbholder">';
1199
1200        altTag = listing.find('details').find('title').text();
1201        altTag = altTag.replaceAll('"', '');
1202        if (altTag == '') {
1203            altTag = 'Property Photo';
1204        }
1205
1206        if (listing.find('preview_publish').text() == '') {
1207            html += String.format('<a href="/listing/{1}"><img src="https://s3.us-west-1.amazonaws.com/core.propertiesonline.com/graphics/generic/no_photo_500.jpg" alt="{0}" class="slgi_thumb" /></a>', altTag, listing.find('seoname').text());
1208        }
1209        else {
1210            html += String.format('<a href="/listing/{2}"><img src="{0}" alt="{1}" class="slgi_thumb" /></a>', listing.find('preview_publish').text(), altTag, listing.find('seoname').text());
1211        }
1212        
1213        html += '</div>';
1214        html += '<div class="slgi_facts">';
1215
1216        if (listing.find('location').find('showaddress').text() == 'yes') {
1217            var addr = String.format('{0}<br />{1}, {2}  {3}', listing.find('location').find('street').text(), listing.find('location').find('city').text(), listing.find('location').find('state').text(), listing.find('location').find('zip').text());
1218            html += String.format('<div class="slgi_addr">{0}</div>', addr);
1219        } else {
1220            html += String.format('<div class="slgi_addr">{0}<br />&nbsp;</div>', listing.find('location').find('city').text());
1221        }
1222
1223
1224        if (checkXmlValue(listing.find('details').find('beds').text())) {
1225            html += String.format('<div class="slgi_beds"><span class="slgi_label res_accent">Beds:</span>{0}</div>', listing.find('details').find('beds').text());
1226        }
1227        if (checkXmlValue(listing.find('details').find('baths').text())) {
1228            html += String.format('<div class="slgi_baths"><span class="slgi_label res_accent">Baths:</span>{0}</div>', listing.find('details').find('baths').text());
1229        }
1230        if (checkXmlValue(listing.find('price').text())) {
1231            html += String.format('<div class="slgi_price">{0}</div>', listing.find('price').text());
1232        }
1233        html += '</div>';
1234
1235        html += String.format('<a class="res_button res_button_gray slgi_details" href="/listing/{0}">Details &raquo;</a>', listing.find('seoname').text());
1236        html += '</div>';
1237
1238        $(target).append($(html));
1239
1240        idx++;
1241    });
1242
1243    logConsole('loaded ' + idx + ' listings');
1244    return idx;
1245}
1246
1247
1248
1249function bindSlickTestimonials(target, urlXml, blockId) {
1250    logConsole('binding to Slick');
1251    $.ajax({
1252        type: "GET",
1253        url: urlXml,
1254        dataType: "xml",
1255        cache: false,
1256        success: function (xml) {
1257            loadSlickTestimonials(xml, target, blockId);            
1258            try {
1259                logConsole('Binding ' + target + ' to slickTestimonials');
1260                $(target).slick({
1261                    dots: false,
1262                    infinite: true,
1263                    speed: 300,
1264                    slidesToShow: 1,
1265                    slidesToScroll: 1,
1266                    prevArrow: '#slt_prev_' + blockId,
1267                    nextArrow: '#slt_next_' + blockId,
1268                });
1269            }
1270            catch (ex) {
1271                logConsole('Failed to bind Slick Testimonials. ' + ex.message);
1272                $(target).hide();
1273                $('#slick_testimonials_controls_' + blockId).hide();
1274            }
1275        },
1276        error: function (XMLHttpRequest, textStatus, errorThrown) {
1277            //logConsole('Could not load xml. ' + errorThrown);
1278            $(target).hide();
1279            $('#slick_testimonials_controls_' + blockId).hide();
1280        }
1281    });
1282    logConsole('done binding to slick testimonials');
1283}
1284
1285function loadSlickTestimonials(xml, target, blockId) {
1286
1287    var idx = 0;
1288    var $testimonial;
1289    var html;
1290    var cssExtra = 'horizontal';
1291    var altTag = '';
1292
1293    logConsole('targeting width=' + $(target).width());
1294    if ($(target).width() <= 500) {
1295        cssExtra = 'stacked';
1296    }
1297
1298    $(xml).find('testimonial').each(function () {
1299        $testimonial = $(this);
1300        html = String.format('<div class="st_item sti_{1}" id="st_item_{0}">', idx, cssExtra);
1301
1302        html += '<div class="testmonial_image">';
1303        if (!isEmpty($testimonial.find('media').text())) {
1304            altTag = $testimonial.find('caption').text();
1305            if (altTag == '') {
1306                altTag = 'Testimonial ' + idx;
1307            }
1308            html += String.format('<a href="/testimonials.aspx#t{2}"><img src="{0}" alt="{1}" class="testimonial_media" /></a>', $testimonial.find('media').text(), altTag, $testimonial.attr('idx'));
1309        }
1310        html += '</div>';
1311        html += '<div class="testmonial_details">';
1312        html += String.format('<h3 class="testimonial_title">{0}</h3>', $testimonial.find('title').text());
1313        if ($testimonial.find('body').text().length > 250) {
1314            html += String.format('<div class="testimonial_text"><a href="/testimonials.aspx#t{1}">{0}</a></div>', $testimonial.find('body').text().substring(0, 250) + ' ...', $testimonial.attr('idx'));
1315        } 
1316        else {
1317            html += String.format('<div class="testimonial_text"><a href="/testimonials.aspx#t{1}">{0}</a></div>', $testimonial.find('body').text(), $testimonial.attr('idx'));
1318        }
1319        html += String.format('<div class="testimonial_source">{0}</div>', $testimonial.find('source').text());
1320        html += '</div>';
1321
1322        html += '</div>';
1323        $(target).append($(html));
1324        idx++;
1325    });
1326
1327    if (idx <= 0) {
1328        logConsole('No Testimonials');
1329        $(target).hide();
1330        $('#slick_testimonials_controls_' + blockId).hide();
1331    }
1332}
1333
1334
1335
1336function checkXmlValue(val) {
1337    if (val != '' && val != 'undefined' && val != '0') {
1338        return true;
1339    }
1340    else {
1341        return false;
1342    }
1343}
1344
1345
1346
1347
1348/** W3 Functions **/
1349var slideIndex = 1;
1350var tokenTimeout;
1351var w3PhotoswipeItems = [];
1352function startW3Slider(blockID, interval, aspectW, aspectH) {
1353    logConsole('W3Slider - Start #' + blockID + ' - ' + aspectW + ':' + aspectH);
1354
1355    //CALC The Sizes...
1356    var h = Math.round($('#w3_slider_' + blockID).width() * aspectH / aspectW);
1357    
1358    logConsole('W3Slider - Height=' + h);
1359    $('#w3_slider_' + blockID).height(h);
1360
1361    window['sliderInterval' + blockID] = interval;
1362    w3SlideFocus(blockID, slideIndex);
1363
1364    loadW3Photoswipe(blockID);
1365}
1366
1367//function startW3SliderV1(blockID, interval, aspectW, aspectH) {
1368//    logConsole('W3Slider - Start #' + blockID + ' - ' + aspectW + ':' + aspectH);
1369
1370//    //DONT need click now that we have expand
1371//    //$('#w3_slider_' + blockID + ' img').click(function () {
1372//    //    logConsole('click slider item');
1373//    //    var idx = $(this).attr('id').replace('w3_slide_' + blockID + '_', '');
1374//    //    idx = idx - 1;
1375//    //    var pswpElement = document.querySelectorAll('.pswp')[0];
1376
1377//    //    // define options (if needed)
1378//    //    var options = {
1379//    //        index: idx
1380//    //    };
1381
1382//    //    // Initializes and opens PhotoSwipe
1383//    //    var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, w3PhotoswipeItems, options);
1384//    //    gallery.init();
1385//    //});
1386
1387//    window['sliderInterval' + blockID] = interval;
1388//    w3SlideFocus(blockID, slideIndex);
1389
1390//    loadW3Photoswipe(blockID);
1391//}
1392
1393function w3SlideAdvance(blockID, n) {
1394    slideIndex += n;
1395    w3SlideFocus(blockID);
1396}
1397
1398function w3SlideAdvanceTo(blockID, n) {
1399    slideIndex = n;
1400    w3SlideFocus(blockID);
1401}
1402
1403function w3SlideFocus(blockID) {
1404    logConsole('w3Sliding on ' + blockID + ' idx ' + slideIndex);
1405
1406    if (tokenTimeout) {
1407        clearTimeout(tokenTimeout);
1408    }
1409
1410    var i;
1411    var x = document.getElementsByClassName("w3_slide_" + blockID);
1412    var dots = document.getElementsByClassName("w3_dots_" + blockID);
1413
1414    //RESET SlideIndex, if applicable
1415    try {
1416        if (slideIndex > x.length) { slideIndex = 1; }
1417        if (slideIndex < 1) { slideIndex = x.length; }
1418    }
1419    catch (ex) { logConsole('failed slide check' + ex.message); }
1420
1421    logConsole(' slide to => ' + slideIndex);
1422
1423    try {
1424        if ($('.w3_slide_active_' + blockID).length) {
1425            logConsole('hiding');
1426            $('.w3_slide_active_' + blockID).fadeOut(800);
1427            $('.w3_slide_active_' + blockID).removeClass('w3_slide_active_' + blockID);
1428            
1429        } else { logConsole('nothing to hide'); }
1430
1431        try {
1432            for (i = 0; i < dots.length; i++) {
1433                dots[i].className = dots[i].className.replace('w3-dot-resaccent', 'w3-gray');
1434            }
1435            dots[slideIndex - 1].className = dots[slideIndex - 1].className.replace('w3-gray', 'w3-dot-resaccent');
1436            x[slideIndex - 1].className += ' w3_slide_active_' + blockID;
1437        }
1438        catch (ex) { logConsole('failed ' + ex.message); }
1439
1440        $('.w3_slide_active_' + blockID).delay(800).fadeIn(800);
1441
1442        logConsole('W3 Resetting Timeout');
1443        slideIndex += 1;
1444        tokenTimeout = setTimeout(function () { w3SlideFocus(blockID); }, window['sliderInterval' + blockID]);
1445
1446    }
1447    catch (ex) {
1448        logConsole('ex ' + ex.message)
1449    }
1450
1451    
1452    
1453}
1454
1455
1456function loadW3Photoswipe(blockID) {
1457    logConsole('in loadW3Photoswipe');
1458    var item;
1459    var items = $('#w3_photostream_' + blockID).html().split('|'); 
1460    for (i = 0; i < items.length; i++) {
1461        item = {
1462            src: items[i].split(',')[0],
1463            title: items[i].split(',')[1],
1464            h: 2000,
1465            w: 3000
1466        };
1467        w3PhotoswipeItems.push(item);
1468    }
1469    logConsole('set prefetch');
1470    setTimeout(function () { prefetchDimensions(); });
1471}
1472
1473function showW3PhotoSwipe(idx) {
1474    logConsole('in showPhotoSwipe');
1475    idx = idx - 1;
1476    var pswpElement = document.querySelectorAll('.pswp')[0];
1477
1478    // define options (if needed)
1479    var options = {
1480        index: idx
1481    };
1482
1483    // Initializes and opens PhotoSwipe
1484    var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, w3PhotoswipeItems, options);
1485    gallery.init();
1486}
1487
1488//Loops through array, and prefetches all dimensions
1489function prefetchDimensions() {
1490    logConsole('in prefetch');
1491    for (var i = 0; i < w3PhotoswipeItems.length; i++) {
1492        var obj = w3PhotoswipeItems[i];
1493        prefetchDimension(obj);
1494    }
1495}
1496
1497//Fetches Dimensions of obj.src, and refreshes the obj.h & obj.w
1498function prefetchDimension(obj) {
1499    var img = new Image();
1500    img.addEventListener("load", function () {       
1501        if (obj.h == '2000') {
1502            obj.h = this.naturalHeight;
1503        }
1504        if (obj.w == '3000') {
1505            obj.w = this.naturalWidth;
1506        }
1507        //logConsole('fetched ' + obj.src + ' ' + this.naturalWidth + ' x ' + this.naturalHeight + ' VS ' + obj.w + ' x ' + obj.h);
1508    });
1509    img.src = obj.src;
1510}
1511
1512
1513
1514//CAROUSEL TESTIMONIALS
1515function initCarouselTestimonials(blockID, urlXml, numSlides, interval) {
1516    logConsole('init Carousel Testimonials');
1517    $.ajax({
1518        type: "GET",
1519        url: urlXml,
1520        dataType: "xml",
1521        cache: false,
1522        success: function (xml) {
1523            /* handle data here */
1524            logConsole('success xml testimonials');
1525            loadCarouselTestimonials(xml, blockID);
1526            logConsole('set carousel interval testimonials');
1527            $('#carousel_testimonials_' + blockID).carousel({
1528                interval: interval
1529            });
1530        },
1531        error: function () {
1532            logConsole('Could not load xml');
1533        }
1534    });
1535    logConsole('done triggering carousel testimonials');
1536}
1537
1538function loadCarouselTestimonials(xml, blockID) {
1539
1540    var idx = 0;
1541
1542    var $testimonial;
1543
1544    var html;
1545    $(xml).find('testimonial').each(function () {
1546        console.log(' Testimonial Carousel Item #' + idx);
1547        
1548        var wrapperWidth=$('#carousel_wrapper_testimonials_' + blockID).width();
1549        console.log(' TC Width ' + wrapperWidth);
1550
1551        try {
1552            $testimonial = $(this);
1553
1554            //Adding Indicators & Open item
1555            if (idx == 0) {
1556                $('#carousel_indicators_testimonials_' + blockID).append('<li data-target="#carousel_testimonials_' + blockID + '" data-slide-to="0" class="active"></li>');
1557                html = '<div class="item active carousel-item slide-testimonial">';
1558            }
1559            else {
1560                $('#carousel_indicators_testimonials_' + blockID).append('<li data-target="#carousel_testimonials_' + blockID + '" data-slide-to="' + idx + '"></li>');
1561                html = '<div class="item carousel-item slide-testimonial">';
1562            }
1563
1564            html += '<div class="carousel_item_testimonial">';
1565            html += '<div class="testmonial_image">';
1566            if (!isEmpty($testimonial.find('media').text())) {
1567                html += String.format('<img src="{0}" alt="{1}" class="testimonial_media" />', $testimonial.find('media').text(), $testimonial.find('caption').text());
1568            }
1569            html += '</div>';
1570            html += '<div class="testmonial_details">';
1571            html += String.format('<h3 class="testimonial_title">{0}</h3>', $testimonial.find('title').text());
1572            html += String.format('<p class="testimonial_text">{0}</p>', $testimonial.find('body').text());
1573            html += String.format('<p class="testimonial_source">{0}</p>', $testimonial.find('source').text());
1574            html += '</div>';
1575
1576            $('#carousel_wrapper_testimonials_' + blockID).append(html);
1577
1578            idx++;
1579
1580        }
1581        catch (ex) {
1582            logConsole('ex in carousel ' + ex.message)
1583        }
1584    });
1585}
1586
1587function resizeBackgroundVideo(hideLoading) {
1588    logConsole('setting background video height');
1589
1590    if ($('.embed-container-fullscreen').is(':visible')) {
1591        logConsole('Fullscreen Width=' + $('.embed-container-fullscreen').width());
1592        var h = $('.embed-container-fullscreen').width() * 5 / 16;
1593        $('.embed-container-fullscreen').height(h);
1594        logConsole(' Height: ' + $('.embed-container-fullscreen').height());
1595    }
1596
1597    if ($('.embed-container-mobile-desktop').is(':visible')) {
1598        logConsole('Mobile Width (DK) =' + $('.embed-container-mobile-desktop').width());
1599        var h = $('.embed-container-mobile-desktop').width() * 5 / 16;
1600        $('.embed-container-mobile-desktop').height(h);
1601        logConsole(' Mobile Height: ' + $('.embed-container-mobile-desktop').height());
1602    }
1603
1604    if ($('.embed-container-mobile').is(':visible')) {
1605        logConsole('Mobile Width=' + $('.embed-container-mobile').width());
1606        var h = $('.embed-container-mobile').width() * 3 / 5;
1607        $('.embed-container-mobile').height(h);
1608        logConsole(' Mobile Height: ' + $('.embed-container-mobile').height());
1609    }
1610
1611    if (hideLoading) {
1612        $('.mobile_alt_loading').hide();
1613    }
1614
1615}
1616
1617function initMasonryGallery(target) {
1618    logConsole('init MasonryGallery');
1619    $(target).imagesLoaded(function () {
1620        logConsole('images loaded MasonryGallery');
1621        $(target).masonry({
1622            itemSelector: '.grid-item',
1623            columnWidth: '.grid-item-sizer',
1624            percentPosition: true
1625        });
1626    });
1627
1628}
1629
1630// BEGIN calcFields
1631function calcFields() {
1632    logConsole('in calc');
1633    var L, P, n, c, dp;
1634
1635    L = parseInt($(".calc_price").val().replace("$", "").replace(/,/g, ''));
1636    n = parseInt($(".calc_terms").val()) * 12;
1637    c = parseFloat($(".calc_rate").val().replace("%", "").replaceAll(" ", "")) / 1200;
1638    dp = 1 - parseFloat($(".calc_downpay").val().replace("%", "").replaceAll(" ", "")) / 100;
1639
1640    logConsole('calc L=' + L + ' n=' + n + ' c=' + c + ' dp=' + dp);
1641
1642    L = L * dp;
1643    P = (L * (c * Math.pow(1 + c, n))) / (Math.pow(1 + c, n) - 1);
1644
1645    if (!isNaN(P)) {
1646        //$(".calc_payment").html('$ ' + P.toFixed(2));
1647        $(".calc_payment").html('$' + Math.floor(P) + ' / Month');
1648    }
1649    else {
1650        $(".calc_payment").html('');
1651    }
1652}
1653// END calcFields
1654
1655
1656
1657function hlv1loaded() {
1658    logConsole('in hlv1loaded');
1659
1660    try {
1661
1662        var heightLogo = parseInt($('.hlv1_image').height());
1663        var heightDetails = $('.header_details_v1').height();
1664
1665        logConsole('Logo (' + heightLogo + ') vs Details (' + heightDetails + ')');
1666        if (heightLogo == heightDetails) {
1667            logConsole('same size');
1668        }
1669        else if (heightLogo > heightDetails) {
1670            logConsole('Logo is taller');
1671            var margintop = heightLogo - heightDetails - 1;  //Offset by one
1672            margintop = Math.round(margintop / 2);
1673            logConsole(' Details needs a top margin of ' + margintop);
1674            $('.header_details_v1').css('margin-top', margintop + 'px');
1675        }
1676        else{
1677            logConsole('Details are taller');
1678            var margintop = heightDetails - heightLogo - 1; //Offset by one
1679            margintop = Math.round(margintop / 2);
1680            logConsole(' Logo needs a top margin of ' + margintop);
1681
1682            $('.hlv1_image').css('margin-top', margintop + 'px');
1683        }
1684
1685    } catch (ex) {
1686        logConsole('EX: ' + ex.message);
1687    }
1688
1689}
1690
1691function hlv2loaded() {
1692    logConsole('in hlv2loaded');
1693
1694    try {
1695
1696        var heightLogo = parseInt($('.hlv2_image').height());
1697
1698        logConsole('Logo = ' + heightLogo );
1699        if (heightLogo < 50) {
1700            logConsole('adding logo margin');
1701            var margintop = Math.round((50 - heightLogo) / 2);
1702            $('.hlv2_image').css('margin-top', margintop + 'px');
1703        }
1704        logConsole('adding padding');
1705        //Add padding in js, css doesn't have knowledge that menu is different for V2
1706        $('#respMenu').css('padding-top', 20 + 'px');
1707        logConsole('done adding padding');
1708    } catch (ex) {
1709        logConsole('EX: ' + ex.message);
1710    }
1711
1712}
1713
1714function hlv3loaded() {
1715    logConsole('in hlv4loaded');
1716
1717    try {
1718
1719        var heightLogo = parseInt($('.hlv3_image').height());
1720
1721        logConsole('Logo = ' + heightLogo);
1722        if (heightLogo < 80) {
1723            logConsole('adding logo margin');
1724            var margintop = Math.round((80 - heightLogo) / 2);
1725            $('.hlv3_image').css('margin-top', margintop + 'px');
1726        }
1727    } catch (ex) {
1728        logConsole('EX: ' + ex.message);
1729    }
1730
1731}
1732
1733
1734
1735function initTestimonials(target, urlXml) {
1736    //$.ajaxSetup({ cache: false });
1737    logConsole('fetching testimonials');
1738    $.ajax({
1739        type: "GET",
1740        url: urlXml,
1741        dataType: "xml",
1742        cache: false,
1743        success: function (xml) {
1744            logConsole('success xml');
1745            loadTestimonials(xml, target);
1746
1747            if ($(location).attr('hash').length > 0) {
1748                logConsole('scrolling to ' + $(location).attr('hash'));
1749                $("html, body").animate({ scrollTop: $($(location).attr('hash')).offset().top }, 1000);
1750            }
1751            else { logConsole('not scrolling'); }
1752
1753        },
1754        error: function () {
1755            logConsole('Could not load xml');
1756        }
1757    });
1758    logConsole('done initTestimonials');
1759}
1760
1761function loadTestimonials(xml, target) {
1762    var idx = 0;
1763    var $testimonial;
1764    var html;
1765    $(xml).find('testimonial').each(function () {
1766        $testimonial = $(this);
1767
1768        html = String.format('<div class="testimonial" id="t{0}">', $testimonial.attr('idx'));
1769        html += '<div class="testmonial_image">';
1770        if (!isEmpty($testimonial.find('media').text())) {
1771            html += String.format('<img src="{0}" alt="{1}" />', $testimonial.find('media').text(), $testimonial.find('caption').text());
1772        }
1773        html += '</div>';
1774        html += '<div class="testmonial_details">';
1775        html += String.format('<h3 class="testimonial_title">{0}</h3>', $testimonial.find('title').text());
1776        html += String.format('<p class="testimonial_text">{0}</p>', $testimonial.find('body').text());
1777        html += String.format('<p class="testimonial_source">{0}</p>', $testimonial.find('source').text());
1778        html += '</div>';
1779        html += '</div>';
1780
1781        $(target).append($(html));
1782
1783        idx++;
1784    });
1785}
1786
1787//function bgSize(url, cb) {
1788//    logConsole('in bgsize');
1789//    $('<img />')
1790//        .load(function () { logConsole('in bgsize load');  })
1791//        .attr('src', url);
1792//}
1793
1794function bindGoogleAddressAutocomplete(field) {
1795    var options = {};
1796    var autocomplete = new google.maps.places.Autocomplete(document.getElementById('gaac_search_location'), options);
1797
1798    if ($(field).length)
1799    {
1800        logConsole('binding gaac autocomplete');
1801        var MlsNumberTest = '';
1802        var searchLocation = $(field).val();
1803        var MlsNumberTest = searchLocation.startsWith
1804
1805
1806        if (MlsNumberTest == true) {
1807            var MlsNumber = searchLocation.slice(1);
1808            $('#gaac_area').val('');
1809            $('#gaac_city').val('');
1810            $('#gaac_state').val('');
1811            $('#gaac_zip').val('');
1812            $('#gaac_mls').val('MlsNumber');
1813            $('#gaac_lat').val('');
1814            $('#gaac_lng').val('');
1815
1816        } else {
1817
1818
1819
1820            google.maps.event.addListener(autocomplete, 'place_changed', function (e) {
1821                var place = autocomplete.getPlace();
1822                if (!place.geometry) {
1823                    return;
1824                }
1825
1826                var address = '';
1827                var zip_code = '';
1828                var city = '';
1829                var state = '';
1830
1831                if (place.address_components) {
1832                    address = [
1833						(place.address_components[0] && place.address_components[0].short_name || ''),
1834						(place.address_components[1] && place.address_components[1].short_name || ''),
1835						(place.address_components[2] && place.address_components[2].short_name || '')
1836                    ].join(' ');
1837
1838                    for (var i = 0; i < place.address_components.length; i++) {
1839                        for (var j = 0; j < place.address_components[i].types.length; j++) {
1840
1841                            if (place.address_components[i].types[j] == "postal_code") {
1842                                zip_code = place.address_components[i].long_name;
1843                                //$('#postal_code').val(zip_code);
1844                            }
1845
1846                            if (place.address_components[i].types[j] == "locality") {
1847                                city = place.address_components[i].long_name;
1848                                //$('#city').val(city);
1849                            }
1850
1851                            if (place.address_components[i].types[j] == "administrative_area_level_1") {
1852                                state = place.address_components[i].short_name;
1853                                //$('#state').val(state);
1854                            }
1855
1856                        }
1857                    }
1858                }
1859
1860                logConsole('lat/lng=' + place.geometry.location.lat() + ' ' + place.geometry.location.lng());
1861                logConsole('csz=' + city + ' ' + state + ' ' + zip_code);
1862                $('#gaac_area').val(address);
1863                $('#gaac_city').val(city);
1864                $('#gaac_state').val(state);
1865                $('#gaac_zip').val(zip_code);
1866                $('#gaac_mls').val('');
1867                $('#gaac_lat').val(place.geometry.location.lat());
1868                $('#gaac_lng').val(place.geometry.location.lng());
1869
1870            });
1871
1872        }
1873
1874    }
1875
1876
1877    $(field).keypress(function (e) {
1878        if (e.which == 13) {
1879            google.maps.event.trigger(autocomplete, 'place_changed');
1880            logConsole('in keypress 13');
1881            submitGaac();
1882            return false;
1883        } else {
1884            $('#gaac_area').val('');
1885            $('#gaac_city').val('');
1886            $('#gaac_state').val('');
1887            $('#gaac_zip').val('');
1888            $('#gaac_mls').val('');
1889            $('#gaac_lat').val('');
1890            $('#gaac_lng').val('');
1891        }
1892    });
1893
1894
1895}
1896
1897/*
1898Submits the GoogleAddressAutoComplete
1899Routine can be called from Submit button or KeyPress(13) in input
1900*/
1901function submitGaac() {
1902    logConsole('submitting gaac');
1903
1904    var encode = encodeURIComponent($('#gaac_area').val());
1905
1906    logConsole(' ENCODE = ' + encode);
1907    window.location.href = 'idx.aspx?sidx=3&a=' + encodeURIComponent($('#gaac_area').val()) + '&c=' + encodeURIComponent($('#gaac_city').val()) + '&s=' + encodeURIComponent($('#gaac_state').val()) + '&z=' + encodeURIComponent($('#gaac_zip').val()) + '&m=' + encodeURIComponent($('#gaac_mls').val()) + '&lat=' + encodeURIComponent($('#gaac_lat').val()) + '&lng=' + encodeURIComponent($('#gaac_lng').val());
1908
1909}

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.