PageSourceSearch

https://redwingsafety.com/library/js/RWSC/common.js

js redwingsafety.com collected 2026-09-29 12:28:51 UTC 35,016 bytes, 1,019 lines download raw bytes

1/* main js file */
2
3//changed ppk script, get calculated styles, must me called before mods to get orig vals
4function getStyle(el, styleProp) {
5    var x;
6    if (typeof el === 'object') {
7        x = el;
8    } else {
9        x = document.getElementById(el);
10    }
11    var y;
12    if (x.currentStyle) {
13        y = x.currentStyle[styleProp];
14    }
15    else if (window.getComputedStyle) {
16        y = document.defaultView.getComputedStyle(x, null).getPropertyValue(styleProp);
17    }
18    return y;
19}
20
21var scaleObj;
22var scaleHeight;
23var imgRatio;
24var currheight;
25
26function setScale() {
27    if (document.getElementById('secContent') !== null) {
28        scaleObj.attr('style', 'height: auto !important; width: 100%;');
29
30        var extra = $("#branding").height() - document.getElementById('branding').offsetHeight;
31        scaleHeight = document.getElementById('secContent').offsetTop - (document.getElementById('branding').offsetHeight + document.getElementById('branding').offsetTop) + extra;
32
33        if (scaleObj) {
34            if (scaleObj.height() <= scaleHeight) {
35                scaleObj.attr('style', 'height:' + scaleHeight + 'px !important; width: ' + scaleHeight * imgRatio + 'px');
36
37                currheight = document.documentElement.clientHeight;
38                return true;
39            } else {
40                scaleObj.attr('style', 'height: auto !important; width: 100%;');
41            }
42        }
43    }
44}
45
46function init() {
47    /* get aspectratio for scale */
48    imgRatio = 1256 / 475;
49    scaleObj = $('.background');
50    if (document.getElementById('secContent') !== null) {
51        scaleHeight = document.getElementById('secContent').offsetTop - document.getElementById('branding').offsetHeight + document.getElementById('branding').offsetTop;
52        setScale();
53    }
54    setLinks();
55    addRemoveFilterButtons();
56}
57
58function popUp(url) {
59    var newwindow = window.open(url, 'extWin', 'height=600,width=1024,scrollbars=1,resizable=1,menubar=1,status=1,toolbar=1,location=1,personalbar=1');
60    if (newwindow.focus) {
61        newwindow.focus();
62    }
63    return false;
64}
65
66function addRemoveFilterButtons() {
67    var checkedFilterCheckboxes = $('#sidebarFilters input[checked]'),
68        crumbs = $('.crumbs'),
69        filter = [],
70        filterString = '';
71
72    if (checkedFilterCheckboxes.length > 0) {
73
74        checkedFilterCheckboxes.each(function createLabels() {
75            filter.push([$(this).attr('id'), $(this).data('name')]);
76        });
77
78        filter.forEach(function (item, index) {
79
80            if (item[1] !== undefined) {
81                filterString = filterString + item[1] + '<label for="' + item[0] + '">x</label>';
82
83                if (index < checkedFilterCheckboxes.length - 1) {
84                    filterString = filterString + ', ';
85                }
86            }
87        });
88        crumbs.append('<li>' + filterString + '</li>');
89    }
90}
91
92function setLinks() {
93    var anchors = document.getElementsByTagName('a');
94    for (var i = 0; i < anchors.length; i++) {
95        var h = anchors[i].getAttribute('href');
96        var r = anchors[i].getAttribute("rel");
97        if (h !== null && r !== null) {
98            if (r.match('external')) {
99                //popup script
100                anchors[i].onclick = function () {
101                    return popUp(this.getAttribute("href"));
102                };
103                anchors[i].setAttribute("title", anchors[i].getAttribute("title") + " - " + anchors[i]);
104            }
105        }
106    }
107}
108var panelHeight;
109function expand(panel) {
110    panelHeight = $(panel).height();
111    $(panel + ' .hide').fadeOut('fast');
112    $(panel).animate({ width: "510px", right: "0" }, 600, function () {
113        $(panel).animate({ height: "208px" }, 600, function () {
114            $(panel + ' .collapsed').css('visibility', 'visible');
115            $(panel + ' .collapsed').css('height', 'auto');
116        });
117    });
118
119    return false;
120}
121
122function collapse(panel) {
123
124    $(panel + ' .collapsed').css('visibility', 'hidden');
125    $(panel).animate({ height: panelHeight }, 600, function () {
126        $(panel).animate({ width: "242px" }, 600, function () {
127            $(panel + ' .hide').fadeIn('fast');
128        });
129    });
130    return false;
131}
132
133function expandDist() {
134}
135
136function collapseDist() {
137}
138
139function toggleStates(hide, show) {
140    $('#' + hide).hide('slow');
141    $('#' + show).show('slow');
142    return false;
143}
144
145function getKeyCode(e) {
146    return window.event ? e.keyCode : e.which;
147}
148
149function onHitKey(e, keyCode, elementOrId) {
150    if (getKeyCode(e) === keyCode) {
151        var type = typeof elementOrId;
152
153        var element = type.toLowerCase() === "object" ? elementOrId : document.getElementById(elementOrId);
154
155        if (element.click !== null) {
156            element.click();
157        }
158        else if (element.onclick !== null) {
159            element.onclick();
160        }
161        else if (element.href !== null && element.href.match('javascript:')) {
162            eval(unescape(element.href.replace('javascript:', '')));
163        }
164
165        return false;
166    }
167    else {
168        return true;
169    }
170}
171
172function getScrollingPosition() {
173    //used to eliminate browser inconsistancies
174    var position = [0, 0];
175
176    if (typeof window.pageYOffset !== 'undefined') {
177        position = [
178            window.pageXOffset,
179            window.pageYOffset
180        ];
181    }
182
183    else if (typeof document.documentElement.scrollTop
184        !== 'undefined' && document.documentElement.scrollTop > 0) {
185        position = [
186            document.documentElement.scrollLeft,
187            document.documentElement.scrollTop
188        ];
189    }
190
191    else if (typeof document.body.scrollTop !== 'undefined') {
192        position = [
193            document.body.scrollLeft,
194            document.body.scrollTop
195        ];
196    }
197
198    return position;
199}
200
201function toggleMe(hide, show) {
202    $('#' + hide).hide();
203    $('#' + show).show();
204    return false;
205}
206
207var modalPopup = new function modalPopupObj() {
208    var _this = this;
209
210    this.openPopup = function (popupElem) {
211
212        $('#' + popupElem).css('display', 'block');
213        $('select').css('visibility', 'hidden');
214        if ($('#' + popupElem).parents('.sideBar').length > 0) {
215            $('#' + popupElem).remove().appendTo('body');
216        }
217        $('#' + popupElem).after('<div id="#' + popupElem + 'Curtain" class="blackout" style="display: block;">&nbsp;</div>');
218        if (typeof changeClasses === 'function') {
219            changeClasses();
220        }
221        initPrint();
222    };
223
224    this.closePopup = function () {
225        $('select').css('visibility', 'visible');
226        $('.blackout').remove();
227    };
228};
229
230function setupQuickview() {
231    $('.quickLookItem .imageLink').on("click", function (e) {
232        quickView(this, $(this).find('input[name="quickViewURL"]').val());
233        return false;
234    });
235}
236
237function quickView(clickObj, url) {
238    modalPopup.openPopup('quickView');
239    $('#quickView').load(url, {}, function () {
240        var curX = clickObj.parentNode.offsetLeft;
241        var curY = clickObj.parentNode.offsetTop + clickObj.parentNode.offsetHeight;
242        var parentWidth = clickObj.parentNode.parentNode.parentNode.offsetWidth;
243
244        var w = $(window).width();
245        var h = $(window).height();
246        var s = $(document).scrollTop();
247        var tw;
248        var th;
249        $('#divQuickLook').css('display', 'block');
250        $('#divQuickLook').css('position', 'absolute');
251        tw = $('#divQuickLook').outerWidth();
252        th = $('#divQuickLook').outerHeight();
253
254        $('#divQuickLook').css({ 'top': (h - th) / 2 + s - $('.products').offset().top, 'left': (w - tw) / 2 - $('.products').offset().left });
255
256    });
257}
258
259function closeQuickView() {
260    modalPopup.closePopup();
261    $('#divQuickLook').css('display', 'none');
262    return false;
263}
264
265function createCookie(name, value, days) {
266    var expires;
267    if (days) {
268        var date = new Date();
269        date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
270        expires = "; expires=" + date.toGMTString();
271    }
272    else expires = "";
273    document.cookie = name + "=" + value + expires + "; path=/";
274}
275
276function readCookie(name) {
277    var nameEQ = name + "=";
278    var ca = document.cookie.split(';');
279    for (var i = 0; i < ca.length; i++) {
280        var c = ca[i];
281        while (c.charAt(0) === ' ') c = c.substring(1, c.length);
282        if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
283    }
284    return null;
285}
286
287function eraseCookie(name) {
288    createCookie(name, "", -1);
289}
290
291
292var savedLists = new function savedListsObj() {
293    var _this = this;
294    this.productID = '';
295    this.userID = '';
296    this.siteID = '';
297    this.newListCount = 0;
298    this.listCount = 0;
299
300    this.init = function () {
301        _this.siteID = $('#txtCurrentListSiteID').attr('value');
302        _this.userID = readCookie('__REDWING_MEMBERSHIP_ID');
303    };
304
305    this.addProduct = function () {
306        _this.listCount = $('#savePopUpForm .lists input:checked').length;
307
308        function checkNewLists() {
309        }
310        var checkedboxes = $('#savePopUpForm .lists input:checked');
311        for (var i = 0; i < _this.listCount; i++) {
312
313            $.post('/data/membership.asmx/quickAdd', { memberId: _this.userID, productId: _this.productID, listName: $(checkedboxes[i]).attr('value') }, function (xml) {
314                if (i >= _this.listCount) {
315                    _this.complete(xml);
316                }
317            });
318        }
319
320        if (_this.newListCount > 0) {
321
322            $('#savePopUpForm .newLists input').each(function (i) {
323                if ($(this).prev().is(':checked')) {
324                    $.post('/data/membership.asmx/quickAdd', { memberId: _this.userID, productId: _this.productID, listName: $(this).attr('value') }, function (xml) {
325                        if (i >= _this.newListCount) {
326
327                            $('#savePopUpForm .contain .newLists').empty();
328                            if (!$('.yourSavedLists').is(':visible')) {
329                                $('.yourSavedLists').css('display', 'block');
330                            }
331                            _this.newListCount = 0;
332                            _this.complete(xml);
333                        }
334                    });
335                }
336            });
337        }
338    };
339
340    this.complete = function (xml) {
341        //$('#savePopUpForm .msg').empty();
342        $('error message', xml).each(function (i) {
343            //$('#savePopUpForm .msg').append($(this).text());
344            $('#savePopUpForm .msg').append('An error has occurred. Please try again later.');
345        });
346        $('success message', xml).each(function (i) {
347            //$('#savePopUpForm .msg').append($(this).text());
348            _this.flyoverClose();
349            if ($('.yourSavedLists').is(':visible')) {
350                savedLists.toggleSidePanel();
351            }
352        });
353    };
354
355    this.checkNewList = function (newList) {
356        $(newList).prev().attr("checked", "checked");
357    };
358    // onclick="savedLists.checkNewList(this);"
359    this.createList = function () {
360        $('#savePopUpForm .contain .newLists').append('<p><input type="checkbox" id="newlist' + _this.newListCount + 'active" name="" value="" /><input type="text" maxlength="40" id="newlist' + _this.newListCount + '" name="newlist' + _this.newListCount + '" onclick="savedLists.checkNewList(this);" /></p>');
361        _this.newListCount++;
362    };
363
364    this.get = function (success, callback) {
365        var completeFunc = callback;
366        var successFunc = success;
367        $.ajax({
368            type: 'POST',
369            url: '/data/membership.asmx/getSavedListsByUserId',
370            data: { memId: _this.userID, productId: _this.productID },
371            complete: function (xml, success) { completeFunc(xml, success); },
372            success: function (xml, success) { successFunc(xml, success); },
373            error: function (XMLHttpRequest, textStatus, errorThrown) {
374                //curtain.css('display', 'none');
375            }
376        });
377    };
378
379    this.flyoverOpen = function (clickObj, productID) {
380        _this.productID = productID;
381        modalPopup.openPopup('savedListsFlyover');
382        /*var curtain = $('#quickViewBlackout');
383        curtain.css('display', 'block');*/
384        if ($('.yourSavedLists .collapsed').is(':visible')) {
385            _this.toggleSidePanel();
386        }
387
388        positionFlyover = function () {
389            var curX = $(clickObj).position().left;
390            var curY = $(clickObj).position().top;
391            var parentWidth = $(clickObj).offsetParent().width();
392            var d = $('#savedListsFlyover');
393            d.css('display', 'block');
394            d.css('position', 'absolute');
395            d.css('left', curX + 'px');
396            d.css('right', 'auto');
397            if (curX + $(d).width() > parentWidth) {
398                d.css('left', 'auto');
399                d.css('right', '0');
400            }
401
402            var scrollT = getScrollingPosition()[1];
403
404            var t = curY - Math.floor($(d).height() / 2);
405            var parentObj = $(clickObj).offsetParent();
406
407            if ($('.content').offset()) {
408                var curTop = scrollT - $('.content').offset().top;
409                if (curY - Math.floor($(d).height() / 2) < curTop) {
410                    t = curTop;
411                } else if (t + d.height() + 25 > curTop + document.documentElement.clientHeight) {
412                    var temp = curY - (d.height() - 15);
413                    if (temp > 0) {
414                        t = temp;
415                    }
416                }
417            }
418            d.css('top', t + 'px');
419        };
420
421        complete = function (xml, success) {
422
423            positionFlyover();
424        };
425
426        success = function (xml, success) {
427            $('#savePopUpForm .col1').empty();
428            $('#savePopUpForm .col2').empty();
429            $('list', xml).each(function (i) {
430                var listItem = '';
431                var checked = false;
432                var col = '';
433                if (i % 2 === 0) {
434                    col = 'col1';
435                } else {
436                    col = 'col2';
437                }
438                if ($(this).find('productinlist').text() === 'True') {
439                    checked = 'checked="checked" ';
440                } else {
441                    checked = '';
442                }
443                listItem = '<p class="singleOption"><label for="chk' + i + '">' + $(this).find('name').text() + '</label><input type="checkbox" class="chkListItem" id="chk' + i + '" name="chk' + i + '" value="' + $(this).find('name').text() + '" ' + checked + '/></p>';
444                $('#savePopUpForm .contain .' + col).append(listItem);
445            });
446        };
447
448        if (_this.userID !== '') {
449            _this.get(success, complete);
450        } else {
451            positionFlyover();
452        }
453
454        return false;
455    };
456
457    this.flyoverClose = function () {
458        modalPopup.closePopup();
459        var d = $('#savedListsFlyover');
460        d.css('display', 'none');
461    };
462
463    this.toggleSidePanel = function () {
464        if (!$('#yourSavedListsCollapsed').is(':visible')) {
465            complete = function (xml, success) {
466                $('#yourSavedListsCollapsed').slideDown('fast', function () { $('#savedListBtn').text('x'); });
467            };
468            success = function (xml, success) {
469                $('#yourSavedListsCollapsed .lists').empty();
470                $('#yourSavedListsCollapsed .lists').append('<ul></ul>');
471                var listUrl = '';
472                if (document.URL.search(/intl/) !== -1) {
473                    listUrl = '/intl/mylists/savedlist-';
474                } else {
475                    listUrl = '/mylists/savedlist-';
476                }
477                var listCount = 0;
478                $('list', xml).each(function (i) {
479                    $('#yourSavedListsCollapsed .lists ul').append('<li><a href="' + listUrl + $(this).find('siteid').text() + '">' + $(this).find('name').text() + '</a></li>');
480                    listCount++;
481                });
482                $('#yourSavedListsCollapsed .lists').css('display', 'block');
483                if (listCount === 1) {
484                    $('.oneListMsg').show();
485                } else {
486                    $('.oneListMsg').css('display', 'none');
487                }
488            };
489            _this.get(success, complete);
490        } else {
491            $('#yourSavedListsCollapsed').slideUp('fast', function () { $('#savedListBtn').text('v'); });
492        }
493    };
494
495    this.emailFlyoverOpen = function (clickObj) {
496        $('.emailList :text, .emailList textarea').attr('value', '');
497        modalPopup.openPopup('emailFlyover');
498        $('.emailList').css('top', $(clickObj).offset().top);
499        $('.emailList').css('left', $(clickObj).offset().left);
500        $('.emailList').show();
501    };
502
503    this.emailFlyoverClose = function () {
504        modalPopup.closePopup();
505        $('.emailList').hide();
506    };
507
508    this.toggleRenameList = function () {
509        if (!$('h3 .edit').is(':visible')) {
510            $('h3 .text').hide();
511            $('h3 .edit').show();
512            $('h3 .edit input').css('display', 'block');
513            $('h3 .edit input').bind('keypress', function (e) {
514                onHitKey(e, '13', $('h3 .edit .btn'));
515            });
516        } else {
517
518            $('h3 .text').show();
519            $('h3 .edit').hide();
520        }
521    };
522
523    this.renameListSave = function () {
524        var newName = $('#txtListRename').attr('value');
525        $.ajax({
526            type: 'POST',
527            url: '/data/membership.asmx/changeListName',
528            data: { memberId: _this.userID, siteId: _this.siteID, newListName: newName },
529            complete: function (xml, success) { _this.toggleRenameList(); },
530            success: function (xml, success) { $('h3 .text').get(0).innerHTML = newName; },
531            error: function (XMLHttpRequest, textStatus, errorThrown) {
532
533            }
534        });
535    };
536
537    this.emailList = function () {
538        var emailBody = $('#txtMessage').attr('value');
539        $.ajax({
540            type: 'POST',
541            url: '/data/membership.asmx/sendEmailList',
542            data: { toAddress: $('#txtRecptEmail').attr('value'), shortName: $('#txtShortName').attr('value'), savedUrl: $('#txtUrl').attr('value'), customMsg: emailBody, userName: $('#txtUserName').attr('value'), listName: $('#txtListName').attr('value') },
543            complete: function (xml, success) { },
544            success: function (xml, success) {
545                $('error message', xml).each(function (i) {
546                    if ($(this).text().toLowerCase().indexOf('address') !== -1) {
547                        $('#toAddressErr').show();
548                    }
549                });
550                $('success message', xml).each(function (i) {
551                    _this.emailFlyoverClose();
552                });
553            },
554            error: function (XMLHttpRequest, textStatus, errorThrown) {
555
556            }
557        });
558    };
559};
560
561var compareFootwear;
562var compareGarment;
563function setupCompare() {
564    compareFootwear = new compareClass('__REDWING_COMPARISON_PRODUCTS', 'product');
565    compareFootwear.init();
566
567    compareGarment = new compareClass('__REDWING_COMPARISON_GARMENT', 'garment');
568    compareGarment.init();
569}
570
571function clearCompare() {
572    compareGarment.clear();
573    compareFootwear.clear();
574
575}
576
577function compareClass(cookieName, group) {
578    var _this = this;
579    this._cookieVal = '';
580    this._productCount = 0;
581    this._searhstr = /\/intl/;
582    this._cookieCompareType = '';
583    this._currentCompareCookie = cookieName;
584    this._group = group + 'Type';
585    this._chkcompare = '.' + group + 'Type .chkcompare';
586
587    //USe cookie for diffrent sites
588    if (document.location.href.search(_this._searhstr) > 0) {
589        _this._currentCompareCookie += "_INTL";
590    }
591    else {
592        _this._currentCompareCookie += "_US";
593    }
594
595    this.init = function () {
596        if (readCookie(_this._currentCompareCookie) !== null) {
597            _this._cookieVal = readCookie(_this._currentCompareCookie);
598            _this._productCount = _this._cookieVal.split(',').length;
599        }
600
601        /* check at least two items are being compared */
602        $('.' + _this._group + ' a.compare').on("click", function (e) {
603            if (_this._productCount < 2) {
604                modalPopup.openPopup('compareTooFew');
605                var curX = $(this).position().left;
606                var curY = $(this).position().top;
607                var parentWidth = $(this).offsetParent().width();
608                var d = $('.compareTooFew');
609                d.css('position', 'absolute');
610                d.css('left', curX + 'px');
611                d.css('right', 'auto');
612                if (curX + $(d).width() > parentWidth) {
613                    d.css('left', 'auto');
614                    d.css('right', '0');
615                }
616                var t = curY - $(d).height();
617                d.css('top', t + 'px');
618                $('.compareTooFew').show("slow", function () {
619                    _this.setupButtons();
620                });
621                return false;
622            }
623            return;
624        });
625
626        //on click for checkbox compare
627        $(_this._chkcompare).on("click", function (e) {
628            //increase productCount if checked
629
630            if ($(this).attr('checked') === 'checked' || $(this).attr('checked') === true || $(this).is(':checked')) {
631                ++_this._productCount;
632                _this.buildCompareLink($(this));
633            } else {
634                //decrease product count if unchecked
635                --_this._productCount;
636                _this.removeCompareLink($(this));
637
638            }
639            //if productCount is greater than 4 show warning
640            if (_this._productCount > 4) {
641                $(this).removeAttr('checked');
642                _this.removeCompareLink($(this));
643                --_this._productCount;
644                modalPopup.openPopup('compareFootwearWarning');
645                var curX = $(this).position().left;
646                var curY = $(this).position().top;
647                var parentWidth = $(this).offsetParent().width();
648                var d = $('.compareFootwearWarning');
649                $('.compareFootwearWarning').show("slow", function () {
650                    _this.setupButtons();
651                });
652            } else {
653                //else toggle product on
654                _this.toggleProduct($(this).attr('checked'), $(this).attr('value'));
655            }
656        });
657        // check all compare boxes that have a cookie value
658        var currCompItems = '';
659        $(_this._chkcompare).each(function (i) {
660            var chkcompareVal = $(this);
661            if (_this._cookieVal.indexOf(chkcompareVal.attr('value')) !== -1) {
662                chkcompareVal.attr('checked', 'checked');
663
664            }
665
666        });
667
668        // building each compare link
669        $('.' + _this._group + ' a.compare').each(function (i) {
670            var compItems = $(this).attr('href') + _this._cookieVal.split(',');
671            $(this).attr('href', compItems);
672        });
673        return;
674    };
675
676    this.buildCompareLink = function (check) {
677        var compItems = $('.' + _this._group + ' a.compare').attr('href') + "," + check.val();
678        compItems = compItems.replace("/,", '/');
679        $('.' + _this._group + ' a.compare').attr('href', compItems);
680    };
681
682    this.removeCompareLink = function (check) {
683        var compItems = $('.' + _this._group + ' a.compare').attr('href');
684
685        compItems = compItems.replace(check.val(), '');
686        compItems = compItems.replace(",,", ",");
687        compItems = compItems.replace(/,$/g, '');
688        compItems = compItems.replace("/,", '/');
689
690        $('.' + _this._group + ' a.compare').attr('href', compItems);
691    };
692
693    this.setupButtons = function () {
694        //close btns
695        var closeBtn = '.msgPanel .closeBtn';
696        $(closeBtn).on("click", function (e) {
697            _this.closeWarning();
698            return false;
699        });
700        //compare btns
701        var compareBtn = '.msgPanel .compareBtn';
702        $(compareBtn).on("click", function (e) {
703            _this.compare();
704            return true;
705        });
706
707        //clear all btns
708        var clearAllBtn = '.msgPanel .clearAllBtn';
709        $(clearAllBtn).on("click", function (e) {
710            _this.clear();
711            _this.closeWarning();
712            return false;
713        });
714    };
715
716    this.clear = function () {
717        _this._productCount = 0;
718        $(_this._chkcompare + ':checked').each(function (i) {
719            _this.removeCompareLink($(this));
720        });
721        $(_this._chkcompare + ':checked').removeAttr('checked');
722        _this._cookieVal = '';
723        eraseCookie(_this._currentCompareCookie);
724    };
725
726    this.toggleProduct = function (checked, prod_id) {
727        if (_this._cookieVal.indexOf(prod_id) === -1) {
728            _this._cookieVal += ',' + prod_id;
729        } else {
730            var cookieArr = _this._cookieVal.split(',');
731            var newArr = $.grep(cookieArr, function (n) {
732                return n !== prod_id;
733            });
734
735            _this._cookieVal = newArr.join(',');
736        }
737        _this.compare();
738    };
739
740    this.compare = function () {
741        if (_this._cookieVal.indexOf(',') === 0) {
742            _this._cookieVal = _this._cookieVal.substr(1);
743        }
744        eraseCookie(_this._currentCompareCookie);
745        createCookie(_this._currentCompareCookie, _this._cookieVal);
746    };
747
748    this.closeWarning = function () {
749        modalPopup.closePopup();
750        $('.msgPanel').hide();
751    };
752
753}
754
755var activeTab = 'features';
756function switchTab(clickObj) {
757    var a = activeTab + 'Tab';
758    if (clickObj.attr('id') !== a) {
759        clickObj.addClass("active");
760        var oe = $('#' + a);
761        var ox = $('#' + activeTab + 'Content');
762        ox.css('display', 'none');
763        oe.removeClass('active');
764        activeTab = clickObj.attr('id').replace(/Tab/, '');
765
766        var x = $('#' + activeTab + 'Content');
767        x.css('display', 'block');
768    }
769    return false;
770}
771
772function printScreen() {
773    window.print();
774
775    return false;
776}
777
778function setActiveSearchResult(clickObj) {
779    $(clickObj).parents('li').addClass('active');
780    if (document.getElementById('directions').style.display === "block") {
781        $('#directions').css('display', 'none');
782        $('#directions_map').css('display', 'none');
783        $('#ctl00_ContentPlaceHolder1_ctlGoogleMap').css('display', 'block');
784    }
785}
786
787function clearActiveSearchResult() {
788    $('.searchResults li').removeClass('active');
789}
790
791var fittingChart = new function fittingChart() {
792    var _this = this;
793    this._xml = null;
794    this._chartID = "";
795
796    this.init = function () {
797        $('.fittingchartBtn').on("click", function (e) {
798            _this._chartID = $(this).attr('data-value');
799            _this.get(function () { }, _this.complete);
800            return false;
801        });
802    };
803
804    this.showFittingChart = function (xml, success) {
805    };
806
807    this.complete = function (xml, success) {
808        //request complete
809        if (success === 'success') {
810            _this._xml = xml.responseXML;
811
812            var curChart;
813            $("fittingchart", _this._xml).each(function () {
814                if ($(this).attr('chartid') === _this._chartID) {
815                    curChart = $(this);
816                }
817            });
818            $('#branding,.garment').addClass('fittingChartPrint');
819
820            var retHtml = '<div id="fittingchart" class="popover fitguide" style="display: block;"><div class="header"><a href="#" class="btn closeBtn">x</a><span class="btnHead">Close Fitting Chart</span><a href="#" class="btn inactive printPageBtn">Print This Page</a>';
821            retHtml += '</div><div class="content">';
822
823            if ($(curChart).find('chart imagesrc_alt').text() !== "") {
824                var test = $("#ContentPlaceHolder1_gender")[0].value;
825                if ($("#ContentPlaceHolder1_gender")[0].value === "Men's") {
826                    retHtml += '<div class="measurementInfo men visible"><img src="' + $(curChart).find('measurementinfo imagesrc').text() + '" alt="' + $(curChart).find('measurementinfo alt').text() + '" width="166" height="341" /></div>';
827                    retHtml += '<div class="fittingChart">' + $(curChart).find('description').text();
828                    retHtml += '<img class="men visible" src="' + $(curChart).find('chart imagesrc').text() + '" alt="' + $(curChart).find('chart alt').text() + '" />';
829                    retHtml += '</div></div>';
830                }
831                else {
832                    retHtml += '<div class="measurementInfo women visible"><img src="' + $(curChart).find('measurementinfo imagesrc_alt').text() + '" alt="' + $(curChart).find('measurementinfo alt').text() + '" width="166" height="341" /></div>';
833                    retHtml += '<div class="fittingChart">' + $(curChart).find('description').text();
834                    retHtml += '<img class="women visible" src="' + $(curChart).find('chart imagesrc_alt').text() + '" alt="' + $(curChart).find('chart alt').text() + '" />';
835                    retHtml += '</div></div>';
836                }
837            }
838
839            $('#bodyMain').append(retHtml);
840            modalPopup.openPopup('fittingchart');
841
842            $('.closeBtn').on("click", function (e) {
843                $('#branding,.garment').removeClass('fittingChartPrint');
844                modalPopup.closePopup('fittingchart');
845                $('.fitguide').css('display', 'none');
846                $('#fittingchart').remove();
847                return false;
848            });
849
850        }
851    };
852
853    this.get = function (success, callback) {
854        var completeFunc = callback;
855        var successFunc = success;
856        $.ajax({
857            type: 'GET',
858            url: '/assets/xml/fittingcharts.xml',
859            data: {},
860            dataType: "xml",
861            complete: function (xml, success) { completeFunc(xml, success); },
862            success: function (xml, success) { successFunc(xml, success); },
863            error: function (XMLHttpRequest, textStatus, errorThrown) {
864
865            }
866        });
867    };
868};
869
870$(fittingChart.init);
871
872/* tech info popover */
873var techinfo = new techInfoPopover();
874
875function techInfoPopover() {
876    this._techID = "";
877    this.init = function () {
878        $('.techInfoBtn').on("click", function (e) {
879            modalPopup.openPopup('techInfoPopover');
880            $('.techinfo').css('display', 'block');
881            var ww = $(window).width();
882            var wh = $(window).height();
883            var mw = $('.techinfo').width();
884            var mh = $('.techinfo').height();
885            $('.techinfo').css({ "top": $(document).scrollTop() + wh / 2 - mh / 2, "left": ww / 2 - mw / 2 });
886            $('.closeBtn').on("click", function (e) {
887                modalPopup.closePopup('techInfoPopover');
888                $('.techinfo').css('display', 'none');
889                return false;
890            });
891
892            return false;
893        });
894    };
895}
896$(techinfo.init);
897
898/* printing */
899function initPrint() {
900    $('.printPageBtn').on("click", function (e) {
901        printScreen();
902        return false;
903    });
904}
905
906$(initPrint);
907$(init);
908//$(window).load(setScale);
909$(window).on("load", setScale);
910//$(window).resize(setScale);
911$(window).on("resize", setScale);
912$(setupCompare);
913$(setupQuickview);
914$(savedLists.init);
915
916// JQZOOM  loading on document ready for safari to work
917var options = {
918    showPreload: true,
919    title: false,
920    zoomWidth: 450,
921    zoomHeight: 520,
922    xOffset: 115,
923    yOffset: 0,
924    position: "right" //and MORE OPTIONS
925};
926
927$(function () {
928    if (typeof $.fn.jqzoom === 'function') {
929
930        $('.zoom').jqzoom(options);
931    }
932});
933
934//modals
935function openModal(key) {
936    var target;
937    switch (key) {
938        case 'share':
939            target = $('#emailModal');
940            break;
941        case 'compare':
942            target = $('#compareModal');
943            break;
944        case 'comparefew':
945            target = $('#compareModalFew');
946            break;
947        default:
948            target = $('');
949            break;
950    }
951
952    if (target !== '') {
953        showScreen();
954        target.css('opacity', '0').show();
955        target.stop(true).animate({ opacity: 1 }, 400);
956    }
957}
958function openStoreModal(key, storeId) {
959    var target;
960    switch (key) {
961        case 'share':
962            target = $('#emailModal');
963            break;
964        case 'compare':
965            target = $('#compareModal');
966            break;
967        case 'comparefew':
968            target = $('#compareModalFew');
969            break;
970        default:
971            target = $('');
972            break;
973    }
974
975    if (target !== '') {
976        showScreen();
977        target.find(".storeid").val(storeId);
978        target.css('opacity', '0').show();
979        target.stop(true).animate({ opacity: 1 }, 400);
980    }
981}
982
983function centerModals() {
984    var w = $(window).width();
985    var h = $(window).height();
986    var s = $(document).scrollTop();
987    var tw;
988    var th;
989
990    if ($('.modal.positioned:visible').length > 0) {
991        hideScreen();
992        closeModals();
993    }
994    else {
995        $('.modal').not('.positioned').each(function () {
996            tw = $(this).outerWidth();
997            th = $(this).outerHeight();
998
999            $(this).css({ 'top': (h - th) / 2 + s, 'left': (w - tw) / 2 });
1000        });
1001
1002        $('#screen').height($(document).height());
1003    }
1004}
1005
1006function showScreen() {
1007    centerModals();
1008    $('#screen').css('opacity', '0').show();
1009    $('#screen').stop(true).animate({ opacity: 0.75 }, 400);
1010}
1011
1012function hideScreen() {
1013    $('#screen').stop(true).animate({ opacity: 0 }, 400, function () { $(this).hide(); });
1014}
1015
1016function closeModals() {
1017    $('.modal').stop(true).animate({ opacity: 0 }, 400, function () { $(this).hide(); });
1018    hideScreen();
1019}

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.