PageSourceSearch

https://www.hartfordfunds.com/etc.clientlibs/thf/clientlibs/hf-ext….ACSHASH3d8bd39bee732d266d370569e3a52dc8.js

js hartfordfunds.com collected 2026-09-24 17:20:01 UTC 251,653 bytes, 6,292 lines download raw bytes

1/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
2 * Licensed under the MIT License (LICENSE.txt).
3 *
4 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
5 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
6 * Thanks to: Seamus Leahy for adding deltaX and deltaY
7 *
8 * Version: 3.0.6
9 * 
10 * Requires: 1.2.2+
11 */
12
13(function($) {
14
15var types = ['DOMMouseScroll', 'mousewheel'];
16
17if ($.event.fixHooks) {
18    for ( var i=types.length; i; ) {
19        $.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
20    }
21}
22
23$.event.special.mousewheel = {
24    setup: function() {
25        if ( this.addEventListener ) {
26            for ( var i=types.length; i; ) {
27                this.addEventListener( types[--i], handler, false );
28            }
29        } else {
30            this.onmousewheel = handler;
31        }
32    },
33    
34    teardown: function() {
35        if ( this.removeEventListener ) {
36            for ( var i=types.length; i; ) {
37                this.removeEventListener( types[--i], handler, false );
38            }
39        } else {
40            this.onmousewheel = null;
41        }
42    }
43};
44
45$.fn.extend({
46    mousewheel: function(fn) {
47        return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
48    },
49    
50    unmousewheel: function(fn) {
51        return this.unbind("mousewheel", fn);
52    }
53});
54
55
56function handler(event) {
57    var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
58    event = $.event.fix(orgEvent);
59    event.type = "mousewheel";
60    
61    // Old school scrollwheel delta
62    if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
63    if ( orgEvent.detail     ) { delta = -orgEvent.detail/3; }
64    
65    // New school multidimensional scroll (touchpads) deltas
66    deltaY = delta;
67    
68    // Gecko
69    if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
70        deltaY = 0;
71        deltaX = -1*delta;
72    }
73    
74    // Webkit
75    if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
76    if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
77    
78    // Add event and delta to the front of the arguments
79    args.unshift(event, delta, deltaX, deltaY);
80    
81    return ($.event.dispatch || $.event.handle).apply(this, args);
82}
83
84})(jQuery);
85
86/*!
87 * jQuery Popup Overlay
88 *
89 * @version 1.6.0
90 * @requires jQuery v1.7.1+
91 * @link http://vast-eng.github.com/jquery-popup-overlay/
92 */
93(function ($) {
94
95    var $window = $(window);
96    var options = {};
97    var zindexvalues = [];
98    var lastclicked = [];
99    var onevisible = false;
100    var oneormorevisible = false;
101    var scrollbarwidth;
102    var focushandler = null;
103    var blurhandler = null;
104    var escapehandler = null;
105    var bodymarginright = null;
106    var opensuffix = '_open';
107    var closesuffix = '_close';
108    var focusedelementbeforepopup = null;
109
110    var methods = {
111
112        _init: function (el) {
113            var $el = $(el);
114            var options = $el.data('popupoptions');
115            lastclicked[el.id] = false;
116            zindexvalues[el.id] = 0;
117
118            if (!$el.data('popup-initialized')) {
119                $el.attr('data-popup-initialized', 'true');
120                methods._initonce(el);
121            }
122
123            if (options.autoopen) {
124                setTimeout(function() {
125                    methods.show(el, 0);
126                }, 0);
127            }
128        },
129
130        _initonce: function (el) {
131            var $body = $('body');
132            var $wrapper;
133            var options = $el.data('popupoptions');
134            bodymarginright = parseInt($body.css('margin-right'), 10);
135
136            if (options.type == 'tooltip') {
137                options.background = false;
138                options.scrolllock = false;
139            }
140
141            if (options.scrolllock) {
142                // Calculate the browser's scrollbar width dynamically
143                var parent;
144                var child;
145                if (typeof scrollbarwidth === 'undefined') {
146                    parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body');
147                    child = parent.children();
148                    scrollbarwidth = child.innerWidth() - child.height(99).innerWidth();
149                    parent.remove();
150                }
151            }
152
153            if (!$el.attr('id')) {
154                $el.attr('id', 'j-popup-' + parseInt(Math.random() * 100000000));
155            }
156
157            $el.addClass('popup_content');
158
159            $body.prepend(el);
160
161            $el.wrap('<div id="' + el.id + '_wrapper" class="popup_wrapper" />');
162
163            $wrapper = $('#' + el.id + '_wrapper');
164
165            $wrapper.css({
166                opacity: 0,
167                visibility: 'hidden',
168                position: 'absolute',
169                overflow: 'auto'
170            });
171
172            $el.css({
173                opacity: 0,
174                visibility: 'hidden',
175                display: 'inline-block'
176            });
177
178            if (options.setzindex && !options.autozindex) {
179                $wrapper.css('z-index', '2001');
180            }
181
182            if (!options.outline) {
183                $el.css('outline', 'none');
184            }
185
186            if (options.transition) {
187                $el.css('transition', options.transition);
188                $wrapper.css('transition', options.transition);
189            }
190
191            // Hide popup content from screen readers initially
192            $(el).attr('aria-hidden', true);
193
194            if ((options.background) && (!$('#' + el.id + '_background').length)) {
195
196                var popupbackground = '<div id="' + el.id + '_background" class="popup_background"></div>';
197
198                $body.prepend(popupbackground);
199
200                var $background = $('#' + el.id + '_background');
201
202                $background.css({
203                    opacity: 0,
204                    visibility: 'hidden',
205                    backgroundColor: options.color,
206                    position: 'fixed',
207                    top: 0,
208                    right: 0,
209                    bottom: 0,
210                    left: 0
211                });
212
213                if (options.setzindex && !options.autozindex) {
214                    $background.css('z-index', '2000');
215                }
216
217                if (options.transition) {
218                    $background.css('transition', options.transition);
219                }
220            }
221
222            if (options.type == 'overlay') {
223                $el.css({
224                    textAlign: 'left',
225                    position: 'relative',
226                    verticalAlign: 'middle'
227                });
228
229                $wrapper.css({
230                    position: 'fixed',
231                    top: 0,
232                    right: 0,
233                    left: 0,
234                    bottom: 0,
235                    textAlign: 'center'
236                });
237
238                // CSS vertical align helper
239                $wrapper.append('<div class="popup_align" />');
240
241                $('.popup_align').css({
242                    display: 'inline-block',
243                    verticalAlign: 'middle',
244                    height: '100%'
245                });
246            }
247
248            // Add WAI ARIA role to announce dialog to screen readers
249            $el.attr('role', 'dialog');
250
251            var openelement =  (options.openelement) ? options.openelement : ('.' + el.id + opensuffix);
252
253            $(openelement).each(function (i, item) {
254                $(item).attr('data-popup-ordinal', i);
255
256                if (!$(item).attr('id')) {
257                    $(item).attr('id', 'open_' + parseInt((Math.random() * 100000000), 10));
258                }
259            });
260
261            // Set aria-labelledby (if aria-label or aria-labelledby is not set in html)
262            if (!($el.attr('aria-labelledby') || $el.attr('aria-label'))) {
263                $el.attr('aria-labelledby', $(openelement).attr('id'));
264            }
265
266            $(document).on('click', openelement, function (e) {
267                if (!($el.data('popup-visible'))) {
268                    var ord = $(this).data('popup-ordinal');
269
270                    // Show element when clicked on `open` link.
271                    // setTimeout is to allow `close` method to finish (for issues with multiple tooltips)
272                    setTimeout(function() {
273                        methods.show(el, ord);
274                    }, 0);
275
276                    e.preventDefault();
277                }
278            });
279
280            // Handler: `close` element
281            var closeelement = (options.closeelement) ? options.closeelement : ('.' + el.id + closesuffix);
282            $(document).on('click', closeelement, function (e) {
283                methods.hide(el);
284                e.preventDefault();
285            });
286
287            if (options.detach) {
288                $el.hide().detach();
289            } else {
290                $wrapper.hide();
291            }
292        },
293
294        /**
295         * Show method
296         *
297         * @param {object} el - popup instance DOM node
298         * @param {number} ordinal - order number of an `open` element
299         */
300        show: function (el, ordinal) {
301            var $el = $(el);
302
303            if ($el.data('popup-visible')) return;
304
305            // Initialize if not initialized. Required for: $('#popup').popup('show')
306            if (!$el.data('popup-initialized')) {
307                methods._init(el);
308            }
309            $el.attr('data-popup-initialized', 'true');
310
311            var $body = $('body');
312            var options = $el.data('popupoptions');
313            var $wrapper = $('#' + el.id + '_wrapper');
314            var $background = $('#' + el.id + '_background');
315
316            // `beforeopen` callback event
317            callback(el, ordinal, options.beforeopen);
318
319            // Remember last clicked place
320            lastclicked[el.id] = ordinal;
321
322            if (options.detach) {
323                $wrapper.prepend(el);
324                $el.show();
325            } else {
326                $wrapper.show();
327            }
328
329            setTimeout(function() {
330                $wrapper.css({
331                    visibility: 'visible',
332                    opacity: 1
333                });
334
335                $('html').addClass('popup_visible').addClass('popup_visible_' + el.id);
336                $el.addClass('popup_content_visible');
337            }, 20);
338
339
340            $el.css({
341                'visibility': 'visible',
342                'opacity': 1
343            });
344
345            // Disable background layer scrolling when popup is opened
346            if (options.scrolllock) {
347                $body.css('overflow', 'hidden');
348                if ($body.height() > $window.height()) {
349                    $body.css('margin-right', bodymarginright + scrollbarwidth);
350                }
351            }
352
353            setTimeout(function () {
354                // Set event handlers
355                if(!onevisible) {
356                    if (options.keepfocus) {
357                        $(document).on('focusin', focushandler)
358                    };
359
360                    if (options.blur) {
361                        $(document).on('click', blurhandler);
362                    }
363
364                    if (options.escape) {
365                        $(document).on('keydown', escapehandler);
366                    }
367                }
368
369                // Set plugin state
370                if (!onevisible) {
371                    onevisible = true;
372                } else {
373                    oneormorevisible = true;
374                }
375            }, 0);
376
377            $el.data('popup-visible', true);
378
379            // Position popup
380            methods.reposition(el, ordinal);
381
382            // Show background
383            if (options.background) {
384                $background.css({
385                    'visibility': 'visible',
386                    'opacity': options.opacity
387                });
388
389                // Fix IE8 issue with background not appearing
390                setTimeout(function() {
391                    $background.css({
392                        'opacity': options.opacity
393                    });
394                }, 0);
395            }
396
397            // Remember which element had focus before opening a popup
398            focusedelementbeforepopup = document.activeElement;
399
400            // Handler: Keep focus inside dialog box
401            if (options.keepfocus) {
402
403                // Make holder div focusable
404                $el.attr('tabindex', -1);
405
406                // Focus popup or user specified element.
407                // Initial timeout of 50ms is set to give some time to popup to show after clicking on
408                // `open` element, and after animation is complete to prevent background scrolling.
409                setTimeout(function() {
410                    if (options.focuselement) {
411                        $(options.focuselement).focus();
412                    } else {
413                        $el.focus();
414                    }
415                }, options.focusdelay);
416
417                // Handler for keyboard focus
418                focushandler = function(event) {
419                    var dialog = document.getElementById(el.id);
420                    if (!dialog.contains(event.target)) {
421                        event.stopPropagation();
422                        dialog.focus();
423                    }
424                };
425            }
426
427            // Calculating maximum z-index
428            if (options.autozindex) {
429
430                var elements = document.getElementsByTagName('*');
431                var len = elements.length;
432                var maxzindex = 0;
433
434                for(var i=0; i<len; i++){
435
436                    var elementzindex = $(elements[i]).css('z-index');
437
438                    if(elementzindex !== 'auto'){
439
440                      elementzindex = parseInt(elementzindex);
441
442                      if(maxzindex < elementzindex){
443                        maxzindex = elementzindex;
444                      }
445                    }
446                }
447
448                zindexvalues[el.id] = maxzindex;
449
450                // Add z-index to the wrapper
451                if (zindexvalues[el.id] > 0) {
452                    $wrapper.css({
453                        zIndex: (zindexvalues[el.id] + 2)
454                    });
455                }
456
457                // Add z-index to the background
458                if (options.background) {
459                    if (zindexvalues[el.id] > 0) {
460                        $('#' + el.id + '_background').css({
461                            zIndex: (zindexvalues[el.id] + 1)
462                        });
463                    }
464                }
465            }
466
467            // Handler: Hide popup if clicked outside of it
468            if (options.blur) {
469                blurhandler = function (e) {
470                    if (!$(e.target).parents().andSelf().is('#' + el.id)) {
471                        //methods.hide(el);
472                    }
473                };
474            }
475
476            // Handler: Close popup on ESC key
477            if (options.escape) {
478                escapehandler = function (e) {
479                    if (e.keyCode == 27 && $el.data('popup-visible')) {
480                        //methods.hide(el);
481                    }
482                };
483            }
484
485            // Hide main content from screen readers
486            $(options.pagecontainer).attr('aria-hidden', true);
487
488            // Reveal popup content to screen readers
489            $el.attr('aria-hidden', false);
490
491            $wrapper.one('transitionend', function() {
492                callback(el, ordinal, options.opentransitionend);
493            });
494
495            callback(el, ordinal, options.onopen);
496        },
497
498        /**
499         * Hide method
500         *
501         * @param {object} el - popup instance DOM node
502         */
503        hide: function (el) {
504
505            var $body = $('body');
506            var $el = $(el);
507            var options = $el.data('popupoptions');
508            var $wrapper = $('#' + el.id + '_wrapper');
509            var $background = $('#' + el.id + '_background');
510
511            $el.data('popup-visible', false);
512
513            if (oneormorevisible) {
514                $('html').removeClass('popup_visible_' + el.id);
515                oneormorevisible = false;
516            } else {
517                $('html').removeClass('popup_visible').removeClass('popup_visible_' + el.id);
518                onevisible = false;
519            }
520
521            $el.removeClass('popup_content_visible');
522
523            // Re-enable scrolling of background layer
524            if (options.scrolllock) {
525                setTimeout(function() {
526                    $body.css({
527                        overflow: 'visible',
528                        'margin-right': bodymarginright
529                    });
530                }, 10); // 10ms added for CSS transition in Firefox which doesn't like overflow:auto
531            }
532
533            // Unbind blur handler
534            if (options.blur) {
535                $(document).off('click', blurhandler);
536            }
537
538            if (options.keepfocus) {
539
540                // Unbind focus handler
541                $(document).off('focusin', focushandler);
542
543                // Focus back on saved element
544                setTimeout(function() {
545                    if ($(focusedelementbeforepopup).is(':visible')) {
546                        focusedelementbeforepopup.focus();
547                    }
548                }, 0);
549            }
550
551            // Unbind ESC key handler
552            if (options.escape) {
553                $(document).off('keydown', escapehandler);
554            }
555
556            // Hide popup
557            $wrapper.css({
558                'visibility': 'hidden',
559                'opacity': 0
560            });
561            $el.css({
562                'visibility': 'hidden',
563                'opacity': 0
564            });
565
566            // Hide background
567            if (options.background) {
568                $background.css({
569                    'visibility': 'hidden',
570                    'opacity': 0
571                });
572            }
573
574            // After closing CSS transition is over... (if transition is set and supported)
575            $el.one('transitionend', function(e) {
576
577                if (!($el.data('popup-visible'))) {
578                    if (options.detach) {
579                        $el.hide().detach();
580                    } else {
581                        $wrapper.hide();
582                    }
583                }
584
585                if (!options.notransitiondetach) {
586                    callback(el, lastclicked[el.id], options.closetransitionend);
587                }
588            });
589
590            if (options.notransitiondetach) {
591                if (options.detach) {
592                    $el.hide().detach();
593                } else {
594                    $wrapper.hide();
595                }
596            }
597
598            // Reveal main content to screen readers
599            $(options.pagecontainer).attr('aria-hidden', false);
600
601            // Hide popup content from screen readers
602            $el.attr('aria-hidden', true);
603
604            // `onclose` callback event
605            callback(el, lastclicked[el.id], options.onclose);
606        },
607
608        /**
609         * Toggle method
610         *
611         * @param {object} el - popup instance DOM node
612         * @param {number} ordinal - order number of an `open` element
613         */
614        toggle: function (el, ordinal) {
615            if ($el.data('popup-visible')) {
616                methods.hide(el);
617            } else {
618                setTimeout(function() {
619                    methods.show(el, ordinal);
620                }, 0);
621            }
622        },
623
624        /**
625         * Reposition method
626         *
627         * @param {object} el - popup instance DOM node
628         * @param {number} ordinal - order number of an `open` element
629         */
630        reposition: function (el, ordinal) {
631            var $el = $(el);
632            var options = $el.data('popupoptions');
633            var $wrapper = $('#' + el.id + '_wrapper');
634            var $background = $('#' + el.id + '_background');
635
636            ordinal = ordinal || 0;
637
638            // Tooltip type
639            if (options.type == 'tooltip') {
640                $wrapper.css({
641                    'position': 'absolute'
642                });
643                var openelement =  (options.openelement) ? options.openelement : ('.' + el.id + opensuffix);
644                var $elementclicked = $(openelement + '[data-popup-ordinal="' + ordinal + '"]');
645                var linkOffset = $elementclicked.offset();
646
647                // Horizontal position for tooltip
648                if (options.horizontal == 'right') {
649                    $wrapper.css('left', linkOffset.left + $elementclicked.outerWidth() + options.offsetleft);
650                } else if (options.horizontal == 'leftedge') {
651                    $wrapper.css('left', linkOffset.left + $elementclicked.outerWidth() - $elementclicked.outerWidth() +  options.offsetleft);
652                } else if (options.horizontal == 'left') {
653                    $wrapper.css('right', $(window).width() - linkOffset.left  - options.offsetleft);
654                } else if (options.horizontal == 'rightedge') {
655                    $wrapper.css('right', $(window).width()  - linkOffset.left - $elementclicked.outerWidth() - options.offsetleft);
656                } else {
657                    $wrapper.css('left', linkOffset.left + ($elementclicked.outerWidth() / 2) - ($el.outerWidth() / 2) - parseFloat($el.css('marginLeft')) + options.offsetleft);
658                }
659
660                // Vertical position for tooltip
661                if (options.vertical == 'bottom') {
662                    $wrapper.css('top', linkOffset.top + $elementclicked.outerHeight() + options.offsettop);
663                } else if (options.vertical == 'bottomedge') {
664                    $wrapper.css('top', linkOffset.top + $elementclicked.outerHeight() - $el.outerHeight() + options.offsettop);
665                }
665 else if (options.vertical == 'top') {
666                    $wrapper.css('bottom', $(window).height() - linkOffset.top - options.offsettop);
667                } else if (options.vertical == 'topedge') {
668                    $wrapper.css('bottom', $(window).height() - linkOffset.top - $el.outerHeight() - options.offsettop);
669                } else {
670                    $wrapper.css('top', linkOffset.top + ($elementclicked.outerHeight() / 2) - ($el.outerHeight() / 2) - parseFloat($el.css('marginTop')) + options.offsettop);
671                }
672
673            // Overlay type
674            } else if (options.type == 'overlay') {
675
676                // Horizontal position for overlay
677                if (options.horizontal) {
678                    $wrapper.css('text-align', options.horizontal);
679                } else {
680                    $wrapper.css('text-align', 'center');
681                }
682
683                // Vertical position for overlay
684                if (options.vertical) {
685                    $el.css('vertical-align', options.vertical);
686                } else {
687                    $el.css('vertical-align', 'middle');
688                }
689            }
690        }
691
692    };
693
694    /**
695     * Callback event calls
696     *
697     * @param {object} el - popup instance DOM node
698     * @param {number} ordinal - order number of an `open` element
699     * @param {function} func - callback function
700     */
701    var callback = function (el, ordinal, func) {
702        var openelement =  (options.openelement) ? options.openelement : ('.' + el.id + opensuffix);
703        var elementclicked = $(openelement + '[data-popup-ordinal="' + ordinal + '"]');
704        if (typeof func == 'function') {
705            func(elementclicked);
706        }
707    };
708
709    /**
710     * Plugin API
711     */
712    $.fn.popup = function (customoptions) {
713        return this.each(function () {
714
715            $el = $(this);
716
717            if (typeof customoptions === 'object') {  // e.g. $('#popup').popup({'color':'blue'})
718                var opt = $.extend({}, $.fn.popup.defaults, customoptions);
719                $el.data('popupoptions', opt);
720                options = $el.data('popupoptions');
721
722                methods._init(this);
723
724            } else if (typeof customoptions === 'string') { // e.g. $('#popup').popup('hide')
725                if (!($el.data('popupoptions'))) {
726                    $el.data('popupoptions', $.fn.popup.defaults);
727                    options = $el.data('popupoptions');
728                }
729
730                methods[customoptions].call(this, this);
731
732            } else { // e.g. $('#popup').popup()
733                if (!($el.data('popupoptions'))) {
734                    $el.data('popupoptions', $.fn.popup.defaults);
735                    options = $el.data('popupoptions');
736                }
737
738                methods._init(this);
739
740            }
741
742        });
743    };
744
745    $.fn.popup.defaults = {
746        type: 'overlay',
747        autoopen: false,
748        background: true,
749        color: 'black',
750        opacity: '0.5',
751        horizontal: 'center',
752        vertical: 'middle',
753        offsettop: 0,
754        offsetleft: 0,
755        escape: true,
756        blur: true,
757        setzindex: true,
758        autozindex: false,
759        scrolllock: false,
760        keepfocus: true,
761        focuselement: null,
762        focusdelay: 50,
763        outline: false,
764        pagecontainer: null,
765        detach: false,
766        openelement: null,
767        closeelement: null,
768        transition: null,
769        notransitiondetach: false,
770        beforeopen: function(){},
771        onclose: function(){},
772        onopen: function(){},
773        opentransitionend: function(){},
774        closetransitionend: function(){}
775    };
776
777})(jQuery);
778(function($){ 
779     $.fn.extend({  
780         tabify: function() {
781			function getHref(el){
782				hash = $(el).find('a').attr('href');
783				if(hash)
784					return hash.substring(0,hash.length-4);
785				else
786					return false;
787				}
788		 	function setActive(el){
789				$(el).addClass('current');
790				if(getHref(el))
791					$(getHref(el)).show();
792				else
793					return false;
794				$(el).siblings('li').each(function(){
795					$(this).removeClass('current');
796					$(getHref(this)).hide();
797				});
798			}
799			return this.each(function() {
800				var self = this;
801				
802				$(this).find('li>a').each(function(){
803					$(this).attr('href',$(this).attr('href') + '-tab');
804				});
805				
806				function handleHash(){
807					  if(location.hash){
808                        var locationHash="";
809                        var hashVal=location.hash;
810                        if(hashVal.indexOf('?')!=-1){
811                              locationHash=hashVal.split('?')[0];
812                        }else{
813                            locationHash=location.hash;
814                        }
815						setActive($(self).find('a[href="' + locationHash + '"]').parent());
816                    }
817				}
818				if(location.hash)
819					handleHash();
820				setInterval(handleHash,100);
821				$(this).find('li').each(function(){
822					if($(this).hasClass('current'))
823						$(getHref(this)).show();
824					else
825						$(getHref(this)).hide();
826				});
827            }); 
828        } 
829    }); 
830})(jQuery);
831/*
832 * SimpleModal OSX Style Modal Dialog
833 * http://www.ericmmartin.com/projects/simplemodal/
834 * http://code.google.com/p/simplemodal/
835 *
836 * Copyright (c) 2010 Eric Martin - http://ericmmartin.com
837 *
838 * Licensed under the MIT license:
839 *  http://www.opensource.org/licenses/mit-license.php
840 *
841 * Revision: $Id: osx.js 238 2010-03-11 05:56:57Z emartin24 $
842 */
843 
844function osxOverlay() {
845    // Capture click event on anchor
846    var links = document.getElementsByTagName('a');
847    var isIE = false;
848    if (navigator.userAgent.search("MSIE") >= 0){
849        isIE = true;
850    }
851    for (i = 0; i < links.length; i++){
852        if(links[i] != undefined || links[i] != null){
853            if(isIE ){
854                links[i].attachEvent("onclick",linkClick); 
855               
856            }
857            else{
858                 links[i].addEventListener('click', linkClick, false); 
859				}
860       }  
861	}
862  
863    var openoverlay=true;    
864    var OSX = {
865        container: null,
866        sacertification: function() {
867            jQuery.ajax({
868                url: '/content/thf/en/profile-pages/salesassistantcertification.html',
869                type: 'GET',
870                data: '',
871                contentType: "text/html; charset=utf-8",
872                dataType: 'html',
873                async: true,
874                cache: false,
875                error: function() {
876                	console.log("Error loading Sales Assistant certification page screen.");
877                },
878                success: function(data) {
879                	$(document).scrollTop(0);                    
880                    $("#osx-container").css({'width' : '400px'});
881                    var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
882                    $("#osx-container").css('left', passdLeft);
883                    $("#osx-modal-data").html(/<body[\s\S]*?>([\s\S]*?)<\/body>/.exec(data)[1]);                    
884                }
885            });
886            $('body').find(".loadingOverlay").remove();
887        },
888        registration: function() {
889            $('#osx-container').removeClass('passwordHintOverlay');
890            $("#osx-modal-data").removeClass("passwordHintdata");
891            if(isURLSecure()) {
892                jQuery.ajax({
893                    url: '/content/thf/en/profile-pages/register.html',
894                    type: 'GET',
895                    data: '',
896                    contentType: "text/html; charset=utf-8",
897                    dataType: 'html',
898                    async: true,
899                    cache: false,
900                    error: function() {
901                    	console.log("Error loading register page screen.");
902                    },
903                    success: function(data) {   
904                        $(document).scrollTop(0);                    
905                        $('#osx-container').removeClass('passwordHintOverlay');
906                        $("#osx-modal-data").removeClass("passwordHintdata");
907                        $("#osx-container").css({'width' : '750px'});
908                        var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
909                        $("#osx-container").css('left', passdLeft);
910                        $("#osx-modal-data").html(/<body[\s\S]*?>([\s\S]*?)<\/body>/.exec(data)[1]);
911                        setTimeout(function(){
912                            $("#osx-container").css({'width' : '437px'});
913                            var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
914                            $("#osx-container").css('left', passdLeft);
915                        }, 300);
916                    }
917                });
918                $('body').find(".loadingOverlay").remove();
919            } else {
920                //redirect the page with HTTPS and show the overlay
921                openoverlay = false;
922                targetURL = thf.utils.secureUrl.url + location.pathname + window.location.search + "#registration";
923                window.location.href = targetURL;
924            }
925        },
926        resetPassword: function() {
927            // Bootstrap 4.5.0 - OSX modal already migrated to Bootstrap
928            // This function loads reset password form into existing Bootstrap modal            
929            // Remove old SimpleModal styling
930            $('#osx-container').removeClass('passwordHintOverlay');
931            $("#osx-modal-data").removeClass("passwordHintdata");            
932            jQuery.ajax({
933                url: '/content/thf/en/profile-pages/resetpassword.html',
934                type: 'GET',
935                data: '',
936                contentType: "text/html; charset=utf-8",
937                dataType: 'html',
938                async: true,
939                cache: false,
940                error: function() {
941                	console.log("Error loading reset password.");
942                },
943                success: function(data) {
944                    $(document).scrollTop(0);
945                    // Bootstrap 4.5.0 - Modal width and positioning handled by CSS
946                    // Removed manual positioning: $("#osx-container").css({'width' : '400px'});
947                    // Removed manual left calculation: var passdLeft = ...                    
948                    // Load form HTML into modal body
949                    $("#osx-modal-data").html(/<body[\s\S]*?>([\s\S]*?)<\/body>/.exec(data)[1]);                    
950                    // Bootstrap handles form width via CSS
951                    // Removed: $("input#resetpasswordform_emailAddressProfile").css({'width' : '82%'});                    
952                    if(navigator.userAgent.indexOf('iPad') !== -1) {
953                        $("#osx-modal-data").css('display','block');
954                    }                    
955                    // Bootstrap handles close button styling
956                    // Keep close button visible for Bootstrap
957                    $("#osx-container .close").css('display','block');                    
958                    // Show Bootstrap modal if not already visible
959                    if ($('#osx-modal-content').length) {
960                        // Bootstrap 4.5.0 Modal - jQuery Plugin Method
961                        try {
962                            $('#osx-modal-content').modal({
963                                backdrop: 'static',
964                                keyboard: false,
965                                focus: true,
966                                show: true
967                            });
968                        } catch (err) {
969                            console.error('Error initializing Bootstrap Modal via jQuery:', err);
970                            $('#osx-modal-content').show();  // Fallback
971                        }
972                    }
973                }
974            });
975            $('body').find(".loadingOverlay").remove();
976        },
977        preresetPassword: function() {			
978            // Bootstrap 4.5.0 - Pre-registration reset password
979            $('#osx-container').removeClass('passwordHintOverlay');
980            $("#osx-modal-data").removeClass("passwordHintdata");            
981            var prereg=true;
982            jQuery.ajax({
983                url: '/content/thf/en/profile-pages/resetpassword.html?prereg='+prereg,
984                type: 'GET',
985                data: '',
986                contentType: "text/html; charset=utf-8",
987                dataType: 'html',
988                async: true,
989                cache: false,
990                error: function() {
991                	console.log("Error loading reset password.");
992                },
993                success: function(data) {
994                    $(document).scrollTop(0);
995                    // Bootstrap 4.5.0 - Removed manual sizing and positioning
996                    // $("#osx-container").css({'width' : '400px'});
997                    // var passdLeft = ...                    
998                    $("#osx-modal-data").html(/<body[\s\S]*?>([\s\S]*?)<\/body>/.exec(data)[1]);                    
999                    // Removed manual width: $("input#resetpasswordform_emailAddressProfile").css({'width' : '82%'});                    
1000                    if(navigator.userAgent.indexOf('iPad') !== -1) {
1001                        $("#osx-modal-data").css('display','block');
1002                    }                    
1003                    $("#osx-container .close").css('display','block');                    
1004                    // Show Bootstrap modal if not already visible
1005                    if ($('#osx-modal-content').length) {
1006                        // Bootstrap 4.5.0 Modal - jQuery Plugin Method
1007                        try {
1008                            $('#osx-modal-content').modal({
1009                                backdrop: 'static',
1010                                keyboard: false,
1011                                focus: true,
1012                                show: true
1013                            });
1014                        } catch (err) {
1015                            console.error('Error initializing Bootstrap Modal via jQuery:', err);
1016                            $('#osx-modal-content').show();  // Fallback
1017                        }
1018                    }
1019                }
1020            });
1021            $('body').find(".loadingOverlay").remove();
1022        },
1023        passwordHint: function(u) {
1024            var ajaxSuccessResult;
1025            if(u==''){
1026                ajaxSuccessResult= 'blank';
1027            }else{
1028                    jQuery.ajax({
1029                        url: '/content/thf/en/profile-pages/login.passwordhint.html?username='+u,
1030                        type: 'GET',
1031                        data: '',
1032                        contentType: "text/html; charset=utf-8",
1033                        dataType: 'html',
1034                        async: true,
1035                        cache: false,
1036                        error: function() {
1037                        	console.log("Error loading password hint screen.");
1038                        },
1039                        success: function(data) {
1040                            var hint =$(data).find('#pwd-hint-valid').html();
1041                            if(hint!=null){
1042                                ajaxSuccessResult= 'valid';
1043                                $("#osx-modal-data").addClass("passwordHintdata");
1044                                $(".login.section").hide();
1045                                $(".new.section").hide();
1046                                $('.rightRegistration').hide();
1047                                $("#osx-container").css({'width' : '500px', 'left': '50%', 'margin-left': '-200px' });
1048                                $("#osx-modal-data").html(data);
1049                                if($('.passwdDesp').length) {
1050                                    $(".osx.hintReset").click(function (e) {
1051                                        if( $(this).parent('div').hasClass('registration') === true || 
1052                                            $(this).parent('div').hasClass('rightRegistration') === true || 
1053                                            $(this).parent('li').hasClass('register') === true) {
1054                                            OSX.registration();
1055                                            OSX.thfLightbox(e,this);
1056                                        } else if ($(this).parent('li').hasClass('resetPassword') === true) {
1057                                            OSX.resetPassword();
1058                                            OSX.thfLightbox(e,this);
1059                                        } else if ($(this).parent('li').hasClass('passwordHint') === true) {
1060                                            var u = $("#pwdhint_username").val();
1061                                            OSX.passwordHint(u);
1062                                        }
1063                                    });
1064                                }
1065                                if(navigator.userAgent.indexOf('iPad') !== -1) {
1066                                    $("#osx-modal-data").css('display','block');
1067                                }
1068                            }
1069                            else{
1070                                ajaxSuccessResult= 'invalid';
1071                            }
1072                            $('#login-Overlay').bind("submit",function(){
1073                                 if($("#login-Overlay").valid()){
1074                                    loginuserOverlay();
1075                                 }   
1076                                  return false;
1077                            });
1078                        }
1079                    });
1080            }
1081            $('body').find(".loadingOverlay").remove();
1082            return ajaxSuccessResult;
1083        },
1084        loginOverlay: function() {
1085            if(isURLSecure()) {
1086                jQuery.ajax({
1087                    url: thf.utils.secureUrl.url + '/content/thf/en/profile-pages/login.loginoverlay.html',
1088                    type: 'GET',
1089                    data: '',
1090                    cache: false,
1091                    contentType: "text/html; charset=utf-8",
1092                    dataType: 'html',
1093                    async: true,
1094                    cache:false,
1095                    error: function() {
1096                    	console.log("Error loading login page screen.");
1097                    },
1098                    success: function(data) {
1099                        $(document).scrollTop(0);                    
1100                        $('#osx-container').removeClass('passwordHintOverlay');
1101                        $("#osx-modal-data").removeClass("passwordHintdata");
1102                        $("#osx-container").css({'width' : '750px'});
1103                        var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
1104                        $("#osx-container").css('left', passdLeft);
1105                        $("#osx-modal-data").html(/<body[\s\S]*?>([\s\S]*?)<\/body>/.exec(data)[1]);                        
1106                        $(".osx").click(function (e) {
1107                            if($(this).parent('div').parent('div').hasClass('rightRegistration') === true) {
1108                                OSX.registration();
1109                                OSX.thfLightbox(e,this);
1110                            } else if ($(this).parent('li').hasClass('resetPassOver') === true) {
1111                                OSX.resetPassword();
1112                                OSX.thfLightbox(e,this);
1113                            } else if ($(this).parent('li').hasClass('passwordHintOver') === true) {
1114                                var u = $("#overlay_username").val();
1115                                clearLoginError('login-error-overlay');
1116                                var result =OSX.passwordHint(u);
1117                                if(result=='blank'){
1118                                    showErrorOverlay(errorJsonLogin["VLD_LOGIN_INFO"]);
1119                                }else if (result=='invalid'){
1120                                    showErrorOverlay(errorJsonLogin["VLD_LOGIN"]);
1121                                }                                
1122                            }
1123                        });
1124                        $("#osx-modal-data form[name='loginForm']").validate({
1125                            errorLabelContainer: $("#osx-modal-data form[name='loginForm'] .scfValidationSummary")
1126                        });
1127                        if(navigator.userAgent.indexOf('iPad') !== -1) {
1128                            $("#osx-modal-data").css('display','block');
1129                        }
1130                        $(".loginFailedModal .osx").unbind("click");
1131                        $(".loginFailedModal .osx").click(function (e) {
1132                            $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1133                            OSX.loginFailed();
1134                            OSX.thfLightbox(e,this);
1135                            
1136                        });
1137                        $('#login-Overlay').bind("submit",function(){
1138                        	if($("#login-Overlay").valid()){
1139                        		loginuserOverlay();
1140                         	}   
1141                        	return false;
1142                        });
1143                        setTimeout(function(){
1144                            $("#osx-container").css({'width' : '750px'});
1145                            var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
1146                            $("#osx-container").css('left', passdLeft);
1147                        }, 300);
1148                    }
1149                });
1150                $('body').find(".loadingOverlay").remove();
1151            } else {
1152                //redirect the page with HTTPS and show the overlay
1153                openoverlay = false;
1154                targetURL = thf.utils.secureUrl.url + location.pathname + window.location.search + "#showloginoverlay";
1155                window.location.href = targetURL;
1156            }
1157        },
1158		
1159		thfLightbox: function (e, thisObj) {
1160            var contentHeight = $(thisObj).parents("div").find(".osxContent").height();
1161            var windowHeight = $(window).height();
1162            topX = 20;
1163            e.preventDefault();
1164            if(openoverlay) {
1165                // Bootstrap 4.5.0 Modal - jQuery Plugin Method
1166                try {
1167                    $('#osx-modal-content').modal({
1168                        backdrop: 'static',
1169                        keyboard: false,
1170                        focus: true,
1171                        show: true
1172                    });
1173                } catch (err) {
1174                    console.error('Error initializing Bootstrap Modal via jQuery:', err);
1175                    $('#osx-modal-content').show();  // Fallback
1176                }
1177            }
1178            $('body').find(".loadingOverlay").remove();
1179        },
1180        seminarAndCollege: function () {
1181            
1182        },
1183        loginFailed: function () {
1184            $('#osx-container').removeClass('passwordHintOverlay');
1185            $("#osx-modal-data").removeClass("passwordHintdata");
1186            jQuery.ajax({
1187                url: '/content/thf/en/profile-pages/login.loginfailed.html',
1188                type: 'GET',
1189                data: '',
1190                contentType: "text/html; charset=utf-8",
1191                dataType: 'html',
1192                async: true,
1193                cache: false,
1194                error: function() {
1195                	console.log("Error loading Login.");
1196                },
1197                success: function(data){
1198                	$("#osx-modal-data").html(/<body[\s\S]*?>([\s\S]*?)<\/body>/.exec(data)[1]);   
1199                	osxOverlay();
1200                    if(navigator.userAgent.indexOf('iPad') !== -1) {
1201                        $("#osx-modal-data").css('display','block');
1202                    }
1203                }
1204            });
1205            $('body').find(".loadingOverlay").remove();
1206        },
1207        seminar: function (thisObj) {
1208            var parentDiv = $(thisObj).parents('div.subDetails'),
1209                            divid = $(parentDiv).parents('div.seminarsDetails').attr('id'),
1210                            appendHTMLData = $(thisObj).parents(".subDetails").find(".seminarButtonTop").html(),
1211                            myUrl = $(thisObj).attr("href");
1212            jQuery.ajax({
1213                url: myUrl,
1214                type: 'GET',
1215                data: '',
1216                contentType: "text/html; charset=utf-8",
1217                dataType: 'html',
1218                async: true,
1219                cache: false,
1220                error: function() {
1221                	console.log("Error loading seminar.");
1222                },
1223                success: function(data) {
1224                    $("#osx-modal-data").html(data).append(appendHTMLData);
1225                    $("#osx-modal-data .loginOverlay span").click(function() {
1226                        showLoginOverlay();
1227                        osxOverlay();
1228                     });
1229                    if(navigator.userAgent.indexOf('iPad') !== -1) {
1230                        $("#osx-modal-data").css('display','block');
1231                    }
1232                    $("#osx-modal-data .seminarButton").click(function(e) {
1233                        var contentText = $("#" + divid + " .osxContent").html();
1234                        $("#osx-modal-data").html(contentText);
1235                        $("#osx-modal-data .close").click(function(e) {
1236                            $("#osx-container .close").eq(0).trigger("click");
1237                        });
1238                    });
1239                }
1240            });
1241            $('body').find(".loadingOverlay").remove();
1242        },
1243        roleSelectionOverlay: function() {
1244            jQuery.ajax({
1245            	url: '/content/thf/en/profile-pages/login.roleselection.html',
1246                type: 'GET',
1247                data: '',
1248                cache: false,
1249                contentType: "text/html; charset=utf-8",
1250                dataType: 'html',
1251                async: true,
1252                cache:false,
1253                error: function() {
1254                	console.log("Error loading login page screen.");
1255            	},
1256                success: function(data) {
1257                	$(document).scrollTop(0);                    
1258                	$("#osx-container").css({'width' : '615px'});
1259                	var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
1260                	$("#osx-container").css('left', passdLeft);
1261                	$("#osx-modal-data").html(/<body[\s\S]*?>([\s\S]*?)<\/body>/.exec(data)[1]); 
1262
1263					$(".osx").click(function (e) {
1264                        if($(this).parent('div').hasClass('rightRegistration') === true) {
1265                            OSX.registration();
1266                            OSX.thfLightbox(e,this);
1267                        } else if ($(this).parent('li').hasClass('resetPassOver') === true) {
1268                            OSX.resetPassword();
1269                            OSX.thfLightbox(e,this);
1270                        } else if ($(this).parent('li').hasClass('passwordHintOver') === true) {
1271                            var u = $("#overlay_username").val();
1272                            clearLoginError('login-error-overlay');
1273                            var result =OSX.passwordHint(u);
1274                            if(result=='blank'){
1275                                showErrorOverlay(errorJsonLogin["VLD_LOGIN_INFO"]);
1276                            }else if (result=='invalid'){
1277                                showErrorOverlay(errorJsonLogin["VLD_LOGIN"]);
1278                            }
1279
1280                        }
1281                    });
1282                    $("#osx-modal-data form[name='loginForm']").validate({
1283                        errorLabelContainer: $("#osx-modal-data form[name='loginForm'] .scfValidationSummary")
1284                    });
1285
1286                    if(navigator.userAgent.indexOf('iPad') !== -1) {
1287                        $("#osx-modal-data").css('display','block');
1288                    }
1289
1290                    $('#login-Overlay').bind("submit",function(){
1291                        if($("#login-Overlay").valid()){
1292                            loginuserOverlay();
1293                        }   
1294                        return false;
1295                    });
1296
1297                	setTimeout(function(){
1298                    	$("#osx-container").css({'width' : '615px'});
1299                    	var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
1300                    	$("#osx-container").css('left', passdLeft);
1301                	}, 300);
1302            	}
1303        	});
1304            $('body').find(".loadingOverlay").remove();
1305        },
1306        overlayContainer: function(thisObj){
1307            var myUrl = $(thisObj).attr("href");
1308            var pageWidth = 780;
1309            var marginLeft = 0;
1310            var windowHeight = $(window).height();
1311            var windowWidth = $(window).width();
1312            var path = myUrl;
1313            var i = myUrl.indexOf(".");
1314            if (i != -1) {
1315            	path = myUrl.substring(0, i);
1316            }
1317            $.getJSON(path + '/jcr:content.json', function(data) {
1318                pageWidth  = data["pagewidth"];
1319            });
1320			jQuery.ajax({
1321                url: myUrl,
1322                type: 'GET',
1323                data: '',
1324                contentType: "text/html; charset=utf-8",
1325                dataType: 'html',
1326                async: true,
1327                cache: false,
1328                error: function() {
1329                	console.log("Error loading modal.");
1330                },
1331                success: function(data) {
1332                  $(document).scrollTop(0);
1333                  if(pageWidth==null){
1334                      pageWidth = 780;
1335                  }
1336                  var left = (windowWidth-pageWidth)/2;
1337
1338                  var maxHeight= windowHeight - 130;
1339
1340                  $("#osx-container").css({'width' : pageWidth + 'px'});
1341
1342                  var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
1343                  $("#osx-container").css('left', passdLeft);
1344                  // This following statement is added to get the only data of body + 1.5.
1345                  $("#osx-modal-data").html(/<body[\s\S]*?>([\s\S]*?)<\/body>/.exec(data)[1]);
1346                  $("#osx-modal-data").find('.contentContainer').css({'max-height':maxHeight + 'px', overflow:'auto'});   
1347                  // This method is called for modal story + 1.5.   
1348
1349                  OSX.modalObjClick();
1350                  if ($(".slides").length > 1) {
1351                    hartFord.homeCarousel();
1352                  }
1353                  if ($('#osx-modal-data .contentContainer .midnav-inner-tab').length) {
1354                    hartFord.tabify();
1355                  }     
1356                  
1357                  if($("#osx-modal-data form[name='preSubscription']").length){
1358                      $("div.leftHalfSub .form-input-wrapper, div.rightHalfSub .form-input-wrapper").css({"width": "446px"});
1359                      $("div.leftHalfSub .form-input-wrapper input[type=text], div.rightHalfSub .form-input-wrapper input[type=text]").css({"width": "423px"});
1360                      $("#osx-modal-data .contentContainer").css({'max-height':'', overflow:''});   
1361                      $("#osx-container").css({'width' : '450px', 'left': '50%', 'margin-left': '-225px' });                                                                                          
1362                      showRecaptcha();
1363             }
1364             
1365             if ($("#osx-modal-data form[name='preRegistration']").length) {
1366                 $("#osx-modal-data .contentContainer").css({'max-height':'', overflow:''});  
1367                 $("div.leftHalfReg .form-input-wrapper, div.rightHalfReg .form-input-wrapper").css({"width": "310px"});
1368                 $("div.leftHalfReg .form-input-wrapper input[type=text], div.rightHalfReg .form-input-wrapper input[type=text]").css({"width": "287px"});
1369                 $("#osx-container").css({'width' : '314px', 'left': '50%', 'margin-left': '-157px' });   
1370                 thf.preregisterAction.validateRegister();
1371                 thf.preregisterAction.clickNext(role);
1372                 thf.preregisterAction.clickSubmit();
1373                 thf.preregisterAction.saveSubmit();
1374             } 
1375             
1376                //The following reinitiates the login/reset password.   
1377                if($('a#login, button#login').length){
1378                    $('a#login, button#login').click(function(e){
1379                        $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1380                        OSX.loginOverlay();                
1381                    });                  
1382                } 
1383                
1384                if($('#resetmypassword').length){
1385                    $('#resetmypassword').click(function(e){
1386                        $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1387                        OSX.preresetPassword();                 
1388                    });                  
1389                } 
1390                  
1391                }
1392            });
1393            $('body').find(".loadingOverlay").remove();  
1394        },
1395        modalObjClick: function(){
1396        var targetModalLink= $('ul.topnavLinks li').find('a.osx.overlayContainer.parentLink');
1397        targetModalLink.removeClass('parentLink');          
1398        $(".osx.overlayContainer").click(function (e) {
1399                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1400                OSX.overlayContainer(this);
1401                var contentHeight = 500;
1402                var windowHeight = $(window).height();
1403                topX = 20;
1404                e.preventDefault();
1405                if(openoverlay) {
1406                    // Bootstrap 4.5.0 Modal - jQuery Plugin Method
1407                    try {
1408                        $('#osx-modal-content').modal({
1409                            backdrop: 'static',
1410                            keyboard: false,
1411                            focus: true,
1412                            show: true
1413                        });
1414                    } catch (err) {
1415                        console.error('Error initializing Bootstrap Modal via jQuery:', err);
1416                        $('#osx-modal-content').show();  // Fallback
1417                    }
1418            }
1419            $('body').find(".loadingOverlay").remove();
1420            });
1421        },
1422        subscriptionObjLink: function(){
1423            $(".subscriptionOverlay").click(function (e) {
1424				e.preventDefault();
1425				if ($('#loggedInStatus').val() === 'NotLoggedIn') {
1426					var targetModalLink= $('ul.topnavLinks li').find('a.osx.overlayContainer.parentLink');
1427					targetModalLink.removeClass('parentLink');          
1428                    $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1429                    OSX.overlayContainer(this);
1430                    var contentHeight = 500;
1431                    var windowHeight = $(window).height();
1432                    topX = 20;
1433                    e.preventDefault();
1434                    if(openoverlay) {
1435						// Bootstrap 4.5.0 Modal - jQuery Plugin Method
1436						try {
1437							$('#osx-modal-content').modal({
1438								backdrop: 'static',
1439								keyboard: false,
1440								focus: true,
1441								show: true
1442							});
1443						} catch (err) {
1444							console.error('Error initializing Bootstrap Modal via jQuery:', err);
1445							$('#osx-modal-content').show();  // Fallback
1446						}
1447                    }
1448                    $('body').find(".loadingOverlay").remove();
1449                } else {
1450                    window.location = "/profile-pages/insight-subscriptions.html";
1451                }
1452            });
1453        },
1454        init: function () {
1455        	$(".loginRegister .osx").unbind("click");
1456            $(".loginRegister .osx").click(function (e) {
1457                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1458                if($(this).parent('div').hasClass('registration') === true) {
1459                    OSX.registration();
1460                    OSX.thfLightbox(e,this);
1461                }
1462                else if($(this).parent('li').hasClass('resetPassword') === true) {
1463                    OSX.resetPassword();
1464                    OSX.thfLightbox(e,this);
1465                }
1466                else if($(this).parent('li').hasClass('passwordHint') === true) {
1467                    var result;
1468                    var u = $("#login_username").val();
1469                    clearLoginError('login-error');
1470                    result = OSX.passwordHint(u);
1471                    if(result=='valid'){
1472                        OSX.thfLightbox(e,this);
1473                    }
1474                    else if(result=='blank'){
1475                        showError(errorJsonLogin["VLD_LOGIN_INFO"]);
1476                        return result;
1477                    }else if (result=='invalid'){
1478                        showError(errorJsonLogin["VLD_LOGIN"]);
1479                        return result;
1480                    }
1481                }
1482            });
1483            
1484            //The following reset password click method
1485            $("a.osx.resetPassword.hide").unbind("click");
1486            $('a.osx.resetPassword.hide').click(function(e){
1487                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1488                OSX.resetPassword(); 
1489                OSX.thfLightbox(e,this);                               
1490            });
1491            
1492            // This method is called for modal story + 1.5.
1493            OSX.modalObjClick();
1494            
1495            // This method is called for subscription overlay.
1496            OSX.subscriptionObjLink();
1497            
1498            $(".loginOverlay.osx").unbind("click");
1499            $(".loginOverlay.osx").click(function (e) {
1500                if($('#loggedInStatus').val() === 'NotLoggedIn') {
1501                    $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1502                    OSX.loginOverlay();
1503                    OSX.thfLightbox(e,this);
1504                    setTimeout(function(){
1505                        var ua = window.navigator.userAgent;
1506                        var msie = ua.indexOf("MSIE ");
1507                        if (msie > 0) {
1508                        } else {
1509                            $("#overlay_username").prop('type', 'email');
1510                        }                        
1511                        $("#overlay_username").focus();
1512                    },1000);
1513                }
1514            });
1515            
1516            $(".registrationOverlay.osx").unbind("click");
1517            $(".registrationOverlay.osx").click(function (e) {
1518                if($('#loggedInStatus').val() === 'NotLoggedIn') {
1519                    $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1520                    OSX.registration();
1521                    OSX.thfLightbox(e,this);
1522                }
1523            });
1524            
1525            $(".roleSelection.osx").unbind("click");
1526            $(".roleSelection.osx").click(function (e) {
1527                if($('#loggedInStatus').val() === 'NotLoggedIn') {
1528                    $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1529                    OSX.roleSelectionOverlay();
1530                    OSX.thfLightbox(e,this);
1531                }
1532            });
1533            
1534            $("#sacertificate-modal").unbind("click");
1535            $("#sacertificate-modal").click(function (e) {
1536                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1537                OSX.sacertification();
1538                OSX.thfLightbox(e,this);               
1539            });
1540            
1541            $(".osx.parentLink, .osx.seminarButton").unbind("click");
1542            $(".osx.parentLink, .osx.seminarButton").click(function (e) {
1543                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1544                var contentText = $(this).closest("div").find(".osxContent").html();
1545                
1546            $("#osx-modal-data").html(contentText);
1547            hartFord.selectBox();
1548            if(navigator.userAgent.indexOf('iPad') !== -1) {
1549                $("#osx-modal-data").css('display','block');
1550            }
1551            
1552            $("#osx-modal-data .seminarButton").unbind("click");
1553            $("#osx-modal-data .seminarButton").click(function(e) {
1554                var contentText = $("#" + divid + " .osxContent").html();
1555                $("#osx-modal-data").html(contentText);
1556                $("#osx-modal-data .close").click(function(e) {
1557                    $("#osx-container .close").eq(0).trigger("click");
1558                });
1559            });
1560            $("#osx-modal-data .close").click(function(e) {
1561                $("#osx-container .close").eq(0).trigger("click");
1562            });
1563            $('body').find(".loadingOverlay").remove();
1564                OSX.thfLightbox(e,this);
1565            });
1566            
1567            $(".loginFailedModal .osx").unbind("click");
1568            $(".loginFailedModal .osx").click(function (e) {
1569                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1570                OSX.loginFailed();
1571                OSX.thfLightbox(e,this);
1572                
1573            });
1574            $(".seminarGettingStarted .osx").click(function (e) {
1575                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1576                OSX.seminar(this);
1577                OSX.thfLightbox(e,this);
1578            });
1579            //The following click method is added for 51_Duplicate Email Address Error story + 1.5   
1580            $("label.error a.osx.resetPassword").unbind("click");
1581            $('label.error a.osx.resetPassword').click(function(e){
1582                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1583                OSX.resetPassword();                
1584            });
1585            
1586            //The following click method is added for wave 2.0   
1587            $("label.error a.osx.loginOverlay").unbind("click");
1588            $('label.error a.osx.loginOverlay').click(function(e){
1589                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1590                OSX.loginOverlay();
1591                OSX.thfLightbox(e,this);              
1592            });  
1593            
1594            $("a.osx.lockoutreset").unbind("click");
1595            $('a.osx.lockoutreset').click(function(e){
1596                $('body').append('<div class="loadingOverlay"><img src="/conf/thf/images/loading.png" alt="loading" /></div>');
1597                OSX.resetPassword();                
1598            });
1599            
1600            },
1601        open: function (d) {            
1602            // Guard clause: Check if d is valid and has the required container property
1603            // (This handles Bootstrap event where d might be an event object without container)
1604            if (!d || typeof d !== 'object' || !d.container) {
1605                console.warn('OSX.open() called with invalid event data. Using Bootstrap modal directly.');
1606                // Don't try to access d.container - just return early
1607                return;
1608            }
1609            
1610            $('.framePopup').hide();
1611            if( $("#osx-modal-data").hasClass('passwordHintdata') === true) {
1612                $('.passwordHintdata').parents('#osx-container').addClass('passwordHintOverlay');
1613                var passdLeft = (($(window).width()) - ($('.passwordHintOverlay').width()))/2;
1614                $('.passwordHintOverlay').css("left",passdLeft);
1615            }
1616            if( $("#osx-modal-data form").attr("id") === "registerForm") {
1617                //$("#osx-container").css("position","absolute");
1618            }
1619            if ($("form[name='loginForm']").length > 0) {
1620                $("#osx-modal-data form[name='loginForm']").validate({
1621                    errorLabelContainer: $("#osx-modal-data form[name='loginForm'] .scfValidationSummary")
1622                });
1623            }
1624            var self = this;
1625            self.container = d.container[0];
1626            $("#osx-modal-content", self.container).show();
1627            d.overlay.fadeIn('slow', function () {
1628            $("#osx-modal-data", self.container).show();
1629                d.container.slideDown('fast', function () {
1630                    setTimeout(function () {
1631                        var h = $("#osx-modal-data", self.container).height();
1632                       d.container.animate(
1633                            {
1634                            height: h
1635                            },
1636                            200,
1637                            function () {
1638                                $("div.close", self.container).show();          
1639                            }
1640                        );
1641                    }, 300);
1642                });
1643            });
1644        },
1645        close: function (d) {        
1646        	$('#osx-container').removeClass('passwordHintOverlay');
1647        	$("#osx-modal-data").removeClass("passwordHintdata");
1648        	var userRole = getCookie('userRole');
1649        	if( $(d.data[0]).has('.roleSelectionOverlay').length > 0 && !(userRole != undefined && userRole.length > 0)){
1650        		document.cookie = "userRole=financial-advisors; path=/";
1651        	}
1652            //s.pageName=old;
1653            var self = this;
1654            self.close();
1655            $("#osx-overlay").hide();           
1656        }
1657    };
1658    
1659    // Bootstrap Modal Close Button Handler
1660    $(document).on('click', '#osx-modal-content .close', function(e) {
1661        e.preventDefault();
1662        // Bootstrap 4.5.0 Modal - jQuery Plugin Method
1663        try {
1664            $('#osx-modal-content').modal('hide');
1665        } catch (err) {
1666            console.error('Error closing Bootstrap Modal via jQuery:', err);
1667            $('#osx-modal-content').hide();  // Fallback
1668        }
1669    });
1670
1671    OSX.init();    
1672}
1673
1674function linkClick(e) {
1675    if((e.target || e.srcElement).href != undefined) { 
1676        if((e.target.href.indexOf("javascript:void(0)") !== -1 || 
1677             e.srcElement.href.indexOf("javascript:void(0)") !== -1)){
1678        }else{
1679			document.cookie='linkDoc'+"="+(e.target || e.srcElement).href+";path=/" ;
1680        }
1681    } else if ((e.target.parentElement || e.srcElement.parentElement).href != undefined) {
1682        if((e.srcElement.parentElement.href.indexOf("mailto") !== -1 || e.target.parentElement.href.indexOf("mailto") !== -1 || 
1683            e.target.parentElement.href.indexOf("javascript:void(0)") !== -1 || e.srcElement.parentElement.href.indexOf("javascript:void(0)") !== -1 )){
1684        }
1685        else{ 
1686			document.cookie='linkDoc'+"="+(e.target.parentElement  || e.srcElement.parentElement).href+";path=/" ;
1687        }
1688    }
1689    else if ((e.target.parentElement.parentElement.parentElement || e.srcElement.parentElement.parentElement.parentElement).href != undefined) {
1690        document.cookie='linkDoc'+"="+(e.target.parentElement.parentElement.parentElement  || e.srcElement.parentElement.parentElement.parentElement).href+";path=/" ;
1691    }
1692}
1693
1694$(document).ready(function() {
1695    osxOverlay();
1696    showLoginOverlay();
1697    $('.litPag li a, .serachLinks li a').live("click",function() {
1698        osxOverlay();
1699    });    
1700});
1701/**
1702 * jQuery Validation Plugin 1.9.0
1703 *
1704 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
1705 * http://docs.jquery.com/Plugins/Validation
1706 *
1707 * Copyright (c) 2006 - 2011 Jörn Zaefferer
1708 *
1709 * Dual licensed under the MIT and GPL licenses:
1710 *   http://www.opensource.org/licenses/mit-license.php
1711 *   http://www.gnu.org/licenses/gpl.html
1712 */
1713
1714(function($) {
1715
1716$.extend($.fn, {
1717	// http://docs.jquery.com/Plugins/Validation/validate
1718	validate: function( options ) {
1719
1720		// if nothing is selected, return nothing; can't chain anyway
1721		if (!this.length) {
1722			options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
1723			return;
1724		}
1725
1726		// check if a validator for this form was already created
1727		var validator = $.data(this[0], 'validator');
1728		if ( validator ) {
1729			return validator;
1730		}
1731
1732		// Add novalidate tag if HTML5.
1733		this.attr('novalidate', 'novalidate');
1734
1735		validator = new $.validator( options, this[0] );
1736		$.data(this[0], 'validator', validator);
1737
1738		if ( validator.settings.onsubmit ) {
1739
1740			var inputsAndButtons = this.find("input, button");
1741
1742			// allow suppresing validation by adding a cancel class to the submit button
1743			inputsAndButtons.filter(".cancel").click(function () {
1744				validator.cancelSubmit = true;
1745			});
1746
1747			// when a submitHandler is used, capture the submitting button
1748			if (validator.settings.submitHandler) {
1749				inputsAndButtons.filter(":submit").click(function () {
1750					validator.submitButton = this;
1751				});
1752			}
1753
1754			// validate the form on submit
1755			this.submit( function( event ) {
1756				if ( validator.settings.debug )
1757					// prevent form submit to be able to see console output
1758					event.preventDefault();
1759
1760				function handle() {
1761					if ( validator.settings.submitHandler ) {
1762						if (validator.submitButton) {
1763							// insert a hidden input as a replacement for the missing submit button
1764							var hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
1765						}
1766						validator.settings.submitHandler.call( validator, validator.currentForm );
1767						if (validator.submitButton) {
1768							// and clean up afterwards; thanks to no-block-scope, hidden can be referenced
1769							hidden.remove();
1770						}
1771						return false;
1772					}
1773					return true;
1774				}
1775
1776				// prevent submit for invalid forms or custom submit handlers
1777				if ( validator.cancelSubmit ) {
1778					validator.cancelSubmit = false;
1779					return handle();
1780				}
1781				if ( validator.form() ) {
1782					if ( validator.pendingRequest ) {
1783						validator.formSubmitted = true;
1784						return false;
1785					}
1786					return handle();
1787				} else {
1788					validator.focusInvalid();
1789					return false;
1790				}
1791			});
1792		}
1793
1794		return validator;
1795	},
1796	// http://docs.jquery.com/Plugins/Validation/valid
1797	valid: function() {
1798        if ( $(this[0]).is('form')) {
1799            return this.validate().form();
1800        } else {
1801            var valid = true;
1802            var validator = $(this[0].form).validate();
1803            this.each(function() {
1804				valid &= validator.element(this);
1805            });
1806            return valid;
1807        }
1808    },
1809	// attributes: space seperated list of attributes to retrieve and remove
1810	removeAttrs: function(attributes) {
1811		var result = {},
1812			$element = this;
1813		$.each(attributes.split(/\s/), function(index, value) {
1814			result[value] = $element.attr(value);
1815			$element.removeAttr(value);
1816		});
1817		return result;
1818	},
1819	// http://docs.jquery.com/Plugins/Validation/rules
1820	rules: function(command, argument) {
1821		var element = this[0];
1822
1823		if (command) {
1824			var settings = $.data(element.form, 'validator').settings;
1825			var staticRules = settings.rules;
1826			var existingRules = $.validator.staticRules(element);
1827			switch(command) {
1828			case "add":
1829				$.extend(existingRules, $.validator.normalizeRule(argument));
1830				staticRules[element.name] = existingRules;
1831				if (argument.messages)
1832					settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
1833				break;
1834			case "remove":
1835				if (!argument) {
1836					delete staticRules[element.name];
1837					return existingRules;
1838				}
1839				var filtered = {};
1840				$.each(argument.split(/\s/), function(index, method) {
1841					filtered[method] = existingRules[method];
1842					delete existingRules[method];
1843				});
1844				return filtered;
1845			}
1846		}
1847
1848		var data = $.validator.normalizeRules(
1849		$.extend(
1850			{},
1851			$.validator.dataAttributeRules(element),
1852			$.validator.classRules(element),
1853			$.validator.attributeRules(element),
1854			$.validator.staticRules(element)
1855		), element);
1856
1857		// make sure required is at front
1858		if (data.required) {
1859			var param = data.required;
1860			delete data.required;
1861			data = $.extend({required: param}, data);
1862		}
1863
1864		return data;
1865	}
1866});
1867
1868// Custom selectors
1869$.extend($.expr[":"], {
1870	// http://docs.jquery.com/Plugins/Validation/blank
1871	blank: function(a) {return !$.trim("" + a.value);},
1872	// http://docs.jquery.com/Plugins/Validation/filled
1873	filled: function(a) {return !!$.trim("" + a.value);},
1874	// http://docs.jquery.com/Plugins/Validation/unchecked
1875	unchecked: function(a) {return !a.checked;}
1876});
1877
1878// constructor for validator
1879$.validator = function( options, form ) {
1880	this.settings = $.extend( true, {}, $.validator.defaults, options );
1881	this.currentForm = form;
1882	this.init();
1883};
1884
1885$.validator.format = function(source, params) {
1886	if ( arguments.length == 1 )
1887		return function() {
1888			var args = $.makeArray(arguments);
1889			args.unshift(source);
1890			return $.validator.format.apply( this, args );
1891		};
1892	if ( arguments.length > 2 && params.constructor != Array  ) {
1893		params = $.makeArray(arguments).slice(1);
1894	}
1895	if ( params.constructor != Array ) {
1896		params = [ params ];
1897	}
1898	$.each(params, function(i, n) {
1899		source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
1900	});
1901	return source;
1902};
1903
1904$.extend($.validator, {
1905
1906	defaults: {
1907		messages: {},
1908		groups: {},
1909		rules: {},
1910		errorClass: "error",
1911		validClass: "valid",
1912		errorElement: "label",
1913		focusInvalid: true,
1914		errorContainer: $( [] ),
1915		errorLabelContainer: $( [] ),
1916		onsubmit: true,
1917		ignore: ":hidden",
1918		ignoreTitle: false,
1919		onfocusin: function(element, event) {
1920			this.lastActive = element;
1921
1922			// hide error label and remove error class on focus if enabled
1923			if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
1924				this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.val
1924idClass );
1925				this.addWrapper(this.errorsFor(element)).hide();
1926			}
1927		},
1928		onfocusout: function(element, event) {
1929			if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
1930				this.element(element);
1931			}
1932		},
1933		onkeyup: function(element, event) {
1934			if ( element.name in this.submitted || element == this.lastElement ) {
1935				this.element(element);
1936			}
1937		},
1938		onclick: function(element, event) {
1939			// click on selects, radiobuttons and checkboxes
1940			if ( element.name in this.submitted )
1941				this.element(element);
1942			// or option elements, check parent select in that case
1943			else if (element.parentNode.name in this.submitted)
1944				this.element(element.parentNode);
1945		},
1946		highlight: function(element, errorClass, validClass) {
1947			if (element.type === 'radio') {
1948				this.findByName(element.name).addClass(errorClass).removeClass(validClass);
1949			} 
1950//			if (element.type === 'checkbox') {
1951//				this.findByName(element.name).addClass(errorClass).removeClass(validClass);
1952//				$(element).parents('.form-checkbox-wrapper').addClass(errorClass).removeClass(validClass);
1953//				$(element).parents('.form-checkbox-wrapper').siblings('span').addClass(errorClass).removeClass(validClass);				
1954//				$(element).parents('.form-checkbox-wrapper').siblings('label').addClass(errorClass).removeClass(validClass);					
1955//			}
1956			else {
1957				$(element).addClass(errorClass).removeClass(validClass);
1958				$(element).parents('.form-input-wrapper').addClass(errorClass).removeClass(validClass);
1959				$(element).parents('.form-input-wrapper').siblings('label').addClass(errorClass).removeClass(validClass);		
1960			}
1961		},
1962		unhighlight: function(element, errorClass, validClass) {
1963			if (element.type === 'radio') {
1964				this.findByName(element.name).removeClass(errorClass).addClass(validClass);
1965			}
1966//			if (element.type === 'checkbox') {
1967//				this.findByName(element.name).removeClass(errorClass).addClass(validClass);
1968//				$(element).parents('.form-checkbox-wrapper').removeClass(errorClass).addClass(validClass);
1969//				$(element).parents('.form-checkbox-wrapper').siblings('span').removeClass(errorClass).removeClass(validClass);	
1970//				$(element).parents('.form-checkbox-wrapper').siblings('label').removeClass(errorClass).addClass(validClass);					
1971//			} 
1972			 else {
1973				$(element).removeClass(errorClass).addClass(validClass);
1974				$(element).parents('.form-input-wrapper').removeClass(errorClass).addClass(validClass);
1975				$(element).parents('.form-input-wrapper').siblings('label').removeClass(errorClass).addClass(validClass);	
1976			}
1977		}
1978	},
1979
1980	// http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
1981	setDefaults: function(settings) {
1982		$.extend( $.validator.defaults, settings );
1983	},
1984
1985	messages: {
1986		required: "This field is required.",
1987		remote: "Please fix this field.",
1988		email: "Please enter a valid email address.",
1989		url: "Please enter a valid URL.",
1990		date: "Please enter a valid date.",
1991		dateISO: "Please enter a valid date (ISO).",
1992		number: "Please enter a valid number.",
1993		digits: "Please enter only digits.",
1994		creditcard: "Please enter a valid credit card number.",
1995		equalTo: "Please enter the same value again.",
1996		accept: "Please enter a value with a valid extension.",
1997		maxlength: $.validator.format("Please enter no more than {0} characters."),
1998		minlength: $.validator.format("Please enter at least {0} characters."),
1999		rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
2000		range: $.validator.format("Please enter a value between {0} and {1}."),
2001		max: $.validator.format("Please enter a value less than or equal to {0}."),
2002		min: $.validator.format("Please enter a value greater than or equal to {0}.")
2003	},
2004
2005	autoCreateRanges: false,
2006
2007	prototype: {
2008
2009		init: function() {
2010			this.labelContainer = $(this.settings.errorLabelContainer);
2011			this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
2012			this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
2013			this.submitted = {};
2014			this.valueCache = {};
2015			this.pendingRequest = 0;
2016			this.pending = {};
2017			this.invalid = {};
2018			this.reset();
2019
2020			var groups = (this.groups = {});
2021			$.each(this.settings.groups, function(key, value) {
2022				$.each(value.split(/\s/), function(index, name) {
2023					groups[name] = key;
2024				});
2025			});
2026			var rules = this.settings.rules;
2027			$.each(rules, function(key, value) {
2028				rules[key] = $.validator.normalizeRule(value);
2029			});
2030
2031			function delegate(event) {
2032				var validator = $.data(this[0].form, "validator"),
2033					eventType = "on" + event.type.replace(/^validate/, "");
2034				validator.settings[eventType] && validator.settings[eventType].call(validator, this[0], event);
2035			}
2036			$(this.currentForm)
2037			       .validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, " +
2038						"[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
2039						"[type='email'], [type='datetime'], [type='date'], [type='month'], " +
2040						"[type='week'], [type='time'], [type='datetime-local'], " +
2041						"[type='range'], [type='color'] ",
2042						"focusin focusout keyup", delegate)
2043				.validateDelegate("[type='radio'], [type='checkbox'], select, option", "click", delegate);
2044
2045			if (this.settings.invalidHandler)
2046				$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
2047		},
2048
2049		// http://docs.jquery.com/Plugins/Validation/Validator/form
2050		form: function() {
2051			this.checkForm();
2052			$.extend(this.submitted, this.errorMap);
2053			this.invalid = $.extend({}, this.errorMap);
2054			if (!this.valid())
2055				$(this.currentForm).triggerHandler("invalid-form", [this]);
2056			this.showErrors();
2057			return this.valid();
2058		},
2059
2060		checkForm: function() {
2061			this.prepareForm();
2062			for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
2063				this.check( elements[i] );
2064			}
2065			return this.valid();
2066		},
2067
2068		// http://docs.jquery.com/Plugins/Validation/Validator/element
2069		element: function( element ) {
2070			element = this.validationTargetFor( this.clean( element ) );
2071			this.lastElement = element;
2072			this.prepareElement( element );
2073			this.currentElements = $(element);
2074			var result = this.check( element );
2075			if ( result ) {
2076				delete this.invalid[element.name];
2077			} else {
2078				this.invalid[element.name] = true;
2079			}
2080			if ( !this.numberOfInvalids() ) {
2081				// Hide error containers on last error
2082				this.toHide = this.toHide.add( this.containers );
2083			}
2084			this.showErrors();
2085			return result;
2086		},
2087
2088		// http://docs.jquery.com/Plugins/Validation/Validator/showErrors
2089		showErrors: function(errors) {
2090			if(errors) {
2091				// add items to error list and map
2092				$.extend( this.errorMap, errors );
2093				this.errorList = [];
2094				for ( var name in errors ) {
2095					this.errorList.push({
2096						message: errors[name],
2097						element: this.findByName(name)[0]
2098					});
2099				}
2100				// remove items from success list
2101				this.successList = $.grep( this.successList, function(element) {
2102					return !(element.name in errors);
2103				});
2104			}
2105			this.settings.showErrors
2106				? this.settings.showErrors.call( this, this.errorMap, this.errorList )
2107				: this.defaultShowErrors();
2108		},
2109
2110		// http://docs.jquery.com/Plugins/Validation/Validator/resetForm
2111		resetForm: function() {
2112			if ( $.fn.resetForm )
2113				$( this.currentForm ).resetForm();
2114			this.submitted = {};
2115			this.lastElement = null;
2116			this.prepareForm();
2117			this.hideErrors();
2118			this.elements().removeClass( this.settings.errorClass );
2119		},
2120
2121		numberOfInvalids: function() {
2122			return this.objectLength(this.invalid);
2123		},
2124
2125		objectLength: function( obj ) {
2126			var count = 0;
2127			for ( var i in obj )
2128				count++;
2129			return count;
2130		},
2131
2132		hideErrors: function() {
2133			this.addWrapper( this.toHide ).hide();
2134		},
2135
2136		valid: function() {
2137			return this.size() == 0;
2138		},
2139
2140		size: function() {
2141			return this.errorList.length;
2142		},
2143
2144		focusInvalid: function() {
2145			if( this.settings.focusInvalid ) {
2146				try {
2147					$(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
2148					.filter(":visible")
2149					.focus()
2150					// manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
2151					.trigger("focusin");
2152				} catch(e) {
2153					// ignore IE throwing errors when focusing hidden elements
2154				}
2155			}
2156		},
2157
2158		findLastActive: function() {
2159			var lastActive = this.lastActive;
2160			return lastActive && $.grep(this.errorList, function(n) {
2161				return n.element.name == lastActive.name;
2162			}).length == 1 && lastActive;
2163		},
2164
2165		elements: function() {
2166			var validator = this,
2167				rulesCache = {};
2168
2169			// select all valid inputs inside the form (no submit or reset buttons)
2170			return $(this.currentForm)
2171			.find("input, select, textarea")
2172			.not(":submit, :reset, :image, [disabled]")
2173			.not( this.settings.ignore )
2174			.filter(function() {
2175				!this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
2176
2177				// select only the first element for each name, and only those with rules specified
2178				if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
2179					return false;
2180
2181				rulesCache[this.name] = true;
2182				return true;
2183			});
2184		},
2185
2186		clean: function( selector ) {
2187			return $( selector )[0];
2188		},
2189
2190		errors: function() {
2191			return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
2192		},
2193
2194		reset: function() {
2195			this.successList = [];
2196			this.errorList = [];
2197			this.errorMap = {};
2198			this.toShow = $([]);
2199			this.toHide = $([]);
2200			this.currentElements = $([]);
2201		},
2202
2203		prepareForm: function() {
2204			this.reset();
2205			this.toHide = this.errors().add( this.containers );
2206		},
2207
2208		prepareElement: function( element ) {
2209			this.reset();
2210			this.toHide = this.errorsFor(element);
2211		},
2212
2213		check: function( element ) {
2214			element = this.validationTargetFor( this.clean( element ) );
2215
2216			var rules = $(element).rules();
2217			var dependencyMismatch = false;
2218			for (var method in rules ) {
2219				var rule = { method: method, parameters: rules[method] };
2220				try {
2221					var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters );
2222
2223					// if a method indicates that the field is optional and therefore valid,
2224					// don't mark it as valid when there are no other rules
2225					if ( result == "dependency-mismatch" ) {
2226						dependencyMismatch = true;
2227						continue;
2228					}
2229					dependencyMismatch = false;
2230
2231					if ( result == "pending" ) {
2232						this.toHide = this.toHide.not( this.errorsFor(element) );
2233						return;
2234					}
2235
2236					if( !result ) {
2237						this.formatAndAdd( element, rule );
2238						return false;
2239					}
2240				} catch(e) {
2241					this.settings.debug && window.console && console.log("exception occured when checking element " + element.id
2242						 + ", check the '" + rule.method + "' method", e);
2243					throw e;
2244				}
2245			}
2246			if (dependencyMismatch)
2247				return;
2248			if ( this.objectLength(rules) )
2249				this.successList.push(element);
2250			return true;
2251		},
2252
2253		// return the custom message for the given element and validation method
2254		// specified in the element's "data-msg-*" attributes
2255		customMetaMessage: function(element, method) {
2256			var $element = $(element);
2257			var message = $element.data("msg" + method.charAt(0).toUpperCase() + method.slice(1));
2258			if (message === undefined) {
2259				message = $element.data("msg");
2260			}
2261			return message;
2262		},
2263
2264		// return the custom message for the given element name and validation method
2265		customMessage: function( name, method ) {
2266			var m = this.settings.messages[name];
2267			return m && (m.constructor == String
2268				? m
2269				: m[method]);
2270		},
2271
2272		// return the first defined argument, allowing empty strings
2273		findDefined: function() {
2274			for(var i = 0; i < arguments.length; i++) {
2275				if (arguments[i] !== undefined)
2276					return arguments[i];
2277			}
2278			return undefined;
2279		},
2280
2281		defaultMessage: function( element, method) {
2282			return this.findDefined(
2283				this.customMessage( element.name, method ),
2284				this.customMetaMessage( element, method ),
2285				// title is never undefined, so handle empty string as undefined
2286				!this.settings.ignoreTitle && element.title || undefined,
2287				$.validator.messages[method],
2288				"<strong>Warning: No message defined for " + element.name + "</strong>"
2289			);
2290		},
2291
2292		formatAndAdd: function( element, rule ) {
2293			var message = this.defaultMessage( element, rule.method ),
2294				theregex = /\$?\{(\d+)\}/g;
2295			if ( typeof message == "function" ) {
2296				message = message.call(this, rule.parameters, element);
2297			} else if (theregex.test(message)) {
2298				message = jQuery.format(message.replace(theregex, '{$1}'), rule.parameters);
2299			}
2300			this.errorList.push({
2301				message: message,
2302				element: element
2303			});
2304
2305			this.errorMap[element.name] = message;
2306			this.submitted[element.name] = message;
2307		},
2308
2309		addWrapper: function(toToggle) {
2310			if ( this.settings.wrapper )
2311				toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
2312			return toToggle;
2313		},
2314
2315		defaultShowErrors: function() {
2316			for ( var i = 0; this.errorList[i]; i++ ) {
2317				var error = this.errorList[i];
2318				this.settings.highlight && this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.val
2318idClass );
2319				this.showLabel( error.element, error.message );
2320			}
2321			if( this.errorList.length ) {
2322				this.toShow = this.toShow.add( this.containers );
2323			}
2324			if (this.settings.success) {
2325				for ( var i = 0; this.successList[i]; i++ ) {
2326					this.showLabel( this.successList[i] );
2327				}
2328			}
2329			if (this.settings.unhighlight) {
2330				for ( var i = 0, elements = this.validElements(); elements[i]; i++ ) {
2331					this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
2332				}
2333			}
2334			this.toHide = this.toHide.not( this.toShow );
2335			this.hideErrors();
2336			this.addWrapper( this.toShow ).show();
2337		},
2338
2339		validElements: function() {
2340			return this.currentElements.not(this.invalidElements());
2341		},
2342
2343		invalidElements: function() {
2344			return $(this.errorList).map(function() {
2345				return this.element;
2346			});
2347		},
2348
2349		showLabel: function(element, message) {
2350			var label = this.errorsFor( element );
2351			if ( label.length ) {
2352				// refresh error/success class
2353				label.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
2354
2355				// check if we have a generated label, replace the message then
2356				label.attr("generated") && label.html(message);
2357			} else {
2358				// create label
2359				label = $("<" + this.settings.errorElement + "/>")
2360					.attr({"for":  this.idOrName(element), generated: true})
2361					.addClass(this.settings.errorClass)
2362					.html(message || "");
2363				if ( this.settings.wrapper ) {
2364					// make sure the element is visible, even in IE
2365					// actually showing the wrapped element is handled elsewhere
2366					label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
2367				}
2368				if ( !this.labelContainer.append(label).length )
2369					this.settings.errorPlacement
2370						? this.settings.errorPlacement(label, $(element) )
2371						: label.insertAfter(element);
2372			}
2373			if ( !message && this.settings.success ) {
2374				label.text("");
2375				typeof this.settings.success == "string"
2376					? label.addClass( this.settings.success )
2377					: this.settings.success( label );
2378			}
2379			this.toShow = this.toShow.add(label);
2380		},
2381
2382		errorsFor: function(element) {
2383			var name = this.idOrName(element);
2384    		return this.errors().filter(function() {
2385				return $(this).attr('for') == name;
2386			});
2387		},
2388
2389		idOrName: function(element) {
2390			return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
2391		},
2392
2393		validationTargetFor: function(element) {
2394			// if radio/checkbox, validate first element in group instead
2395			if (this.checkable(element)) {
2396				element = this.findByName( element.name ).not(this.settings.ignore)[0];
2397			}
2398			return element;
2399		},
2400
2401		checkable: function( element ) {
2402			return /radio|checkbox/i.test(element.type);
2403		},
2404
2405		findByName: function( name ) {
2406			// select by name and filter by form for performance over form.find("[name=...]")
2407			var form = this.currentForm;
2408			return $(document.getElementsByName(name)).map(function(index, element) {
2409				return element.form == form && element.name == name && element  || null;
2410			});
2411		},
2412
2413		getLength: function(value, element) {
2414			switch( element.nodeName.toLowerCase() ) {
2415			case 'select':
2416				return $("option:selected", element).length;
2417			case 'input':
2418				if( this.checkable( element) )
2419					return this.findByName(element.name).filter(':checked').length;
2420			}
2421			return value.length;
2422		},
2423
2424		depend: function(param, element) {
2425			return this.dependTypes[typeof param]
2426				? this.dependTypes[typeof param](param, element)
2427				: true;
2428		},
2429
2430		dependTypes: {
2431			"boolean": function(param, element) {
2432				return param;
2433			},
2434			"string": function(param, element) {
2435				return !!$(param, element.form).length;
2436			},
2437			"function": function(param, element) {
2438				return param(element);
2439			}
2440		},
2441
2442		optional: function(element) {
2443			return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch";
2444		},
2445
2446		startRequest: function(element) {
2447			if (!this.pending[element.name]) {
2448				this.pendingRequest++;
2449				this.pending[element.name] = true;
2450			}
2451		},
2452
2453		stopRequest: function(element, valid) {
2454			this.pendingRequest--;
2455			// sometimes synchronization fails, make sure pendingRequest is never < 0
2456			if (this.pendingRequest < 0)
2457				this.pendingRequest = 0;
2458			delete this.pending[element.name];
2459			if ( valid && this.pendingRequest == 0 && this.formSubmitted && this.form() ) {
2460				$(this.currentForm).submit();
2461				this.formSubmitted = false;
2462			} else if (!valid && this.pendingRequest == 0 && this.formSubmitted) {
2463				$(this.currentForm).triggerHandler("invalid-form", [this]);
2464				this.formSubmitted = false;
2465			}
2466		},
2467
2468		previousValue: function(element) {
2469			return $.data(element, "previousValue") || $.data(element, "previousValue", {
2470				old: null,
2471				valid: true,
2472				message: this.defaultMessage( element, "remote" )
2473			});
2474		}
2475
2476	},
2477
2478	classRuleSettings: {
2479		required: {required: true},
2480		email: {email: true},
2481		url: {url: true},
2482		date: {date: true},
2483		dateISO: {dateISO: true},
2484		dateDE: {dateDE: true},
2485		number: {number: true},
2486		numberDE: {numberDE: true},
2487		digits: {digits: true},
2488		creditcard: {creditcard: true}
2489	},
2490
2491	addClassRules: function(className, rules) {
2492		className.constructor == String ?
2493			this.classRuleSettings[className] = rules :
2494			$.extend(this.classRuleSettings, className);
2495	},
2496
2497	classRules: function(element) {
2498		var rules = {};
2499		var classes = $(element).attr('class');
2500		classes && $.each(classes.split(' '), function() {
2501			if (this in $.validator.classRuleSettings) {
2502				$.extend(rules, $.validator.classRuleSettings[this]);
2503			}
2504		});
2505		return rules;
2506	},
2507
2508	attributeRules: function(element) {
2509		var rules = {};
2510		var $element = $(element);
2511
2512		for (var method in $.validator.methods) {
2513			var value;
2514			// If .prop exists (jQuery >= 1.6), use it to get true/false for required
2515			if (method === 'required' && typeof $.fn.prop === 'function') {
2516				value = $element.prop(method);
2517			} else {
2518				value = $element.attr(method);
2519			}
2520			if (value) {
2521				rules[method] = value;
2522			} else if ($element[0].getAttribute("type") === method) {
2523				rules[method] = true;
2524			}
2525		}
2526
2527		// maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
2528		if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
2529			delete rules.maxlength;
2530		}
2531
2532		return rules;
2533	},
2534
2535	dataAttributeRules: function(element) {
2536		var rules = {};
2537		var $element = $(element);
2538
2539		$.each($element.data(), function(key, value) {
2540			var match = /^rule(.+)/.exec(key);
2541			if (!match) {
2542				return;
2543			}
2544			var method = match[1].charAt(0).toLowerCase() + match[1].slice(1);
2545			if (value === "true") {
2546				value = true;
2547			} else if (value === "false") {
2548				value = false;
2549			} else if (value !== "" && value !== null && !isNaN(value)) {
2550				value = Number(value);
2551			}
2552			rules[method] = value;
2553		});
2554
2555		return rules;
2556	},
2557
2558	staticRules: function(element) {
2559		var rules = {};
2560		var validator = $.data(element.form, 'validator');
2561		if (validator.settings.rules) {
2562			rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
2563		}
2564		return rules;
2565	},
2566
2567	normalizeRules: function(rules, element) {
2568		// handle dependency check
2569		$.each(rules, function(prop, val) {
2570			// ignore rule when param is explicitly false, eg. required:false
2571			if (val === false) {
2572				delete rules[prop];
2573				return;
2574			}
2575			if (val.param || val.depends) {
2576				var keepRule = true;
2577				switch (typeof val.depends) {
2578					case "string":
2579						keepRule = !!$(val.depends, element.form).length;
2580						break;
2581					case "function":
2582						keepRule = val.depends.call(element, element);
2583						break;
2584				}
2585				if (keepRule) {
2586					rules[prop] = val.param !== undefined ? val.param : true;
2587				} else {
2588					delete rules[prop];
2589				}
2590			}
2591		});
2592
2593		// evaluate parameters
2594		$.each(rules, function(rule, parameter) {
2595			rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
2596		});
2597
2598		// clean number parameters
2599		$.each(['minlength', 'maxlength', 'min', 'max'], function() {
2600			if (rules[this]) {
2601				rules[this] = Number(rules[this]);
2602			}
2603		});
2604		$.each(['rangelength', 'range'], function() {
2605			if (rules[this]) {
2606				rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
2607			}
2608		});
2609
2610		if ($.validator.autoCreateRanges) {
2611			// auto-create ranges
2612			if (rules.min && rules.max) {
2613				rules.range = [rules.min, rules.max];
2614				delete rules.min;
2615				delete rules.max;
2616			}
2617			if (rules.minlength && rules.maxlength) {
2618				rules.rangelength = [rules.minlength, rules.maxlength];
2619				delete rules.minlength;
2620				delete rules.maxlength;
2621			}
2622		}
2623
2624		// To support custom messages in metadata ignore rule methods titled "messages"
2625		if (rules.messages) {
2626			delete rules.messages;
2627		}
2628
2629		return rules;
2630	},
2631
2632	// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
2633	normalizeRule: function(data) {
2634		if( typeof data == "string" ) {
2635			var transformed = {};
2636			$.each(data.split(/\s/), function() {
2637				transformed[this] = true;
2638			});
2639			data = transformed;
2640		}
2641		return data;
2642	},
2643
2644	// http://docs.jquery.com/Plugins/Validation/Validator/addMethod
2645	addMethod: function(name, method, message) {
2646		$.validator.methods[name] = method;
2647		$.validator.messages[name] = message != undefined ? message : $.validator.messages[name];
2648		if (method.length < 3) {
2649			$.validator.addClassRules(name, $.validator.normalizeRule(name));
2650		}
2651	},
2652
2653	methods: {
2654
2655		// http://docs.jquery.com/Plugins/Validation/Methods/required
2656		required: function(value, element, param) {
2657			// check if dependency is met
2658			if ( !this.depend(param, element) )
2659				return "dependency-mismatch";
2660			switch( element.nodeName.toLowerCase() ) {
2661			case 'select':
2662				// could be an array for select-multiple or a string, both are fine this way
2663				var val = $(element).val();
2664				return val && val.length > 0;
2665			case 'input':
2666				if ( this.checkable(element) )
2667					return this.getLength(value, element) > 0;
2668			default:
2669				return $.trim(value).length > 0;
2670			}
2671		},
2672
2673		// http://docs.jquery.com/Plugins/Validation/Methods/remote
2674		remote: function(value, element, param) {
2675			if ( this.optional(element) )
2676				return "dependency-mismatch";
2677
2678			var previous = this.previousValue(element);
2679			if (!this.settings.messages[element.name] )
2680				this.settings.messages[element.name] = {};
2681			previous.originalMessage = this.settings.messages[element.name].remote;
2682			this.settings.messages[element.name].remote = previous.message;
2683
2684			param = typeof param == "string" && {url:param} || param;
2685
2686			if ( this.pending[element.name] ) {
2687				return "pending";
2688			}
2689			if ( previous.old === value ) {
2690				return previous.valid;
2691			}
2692
2693			previous.old = value;
2694			var validator = this;
2695			this.startRequest(element);
2696			var data = {};
2697			data[element.name] = value;
2698			$.ajax($.extend(true, {
2699				url: param,
2700				mode: "abort",
2701				port: "validate" + element.name,
2702				dataType: "json",
2703				data: data,
2704				success: function(response) {
2705					validator.settings.messages[element.name].remote = previous.originalMessage;
2706					var valid = response === true;
2707					if ( valid ) {
2708						var submitted = validator.formSubmitted;
2709						validator.prepareElement(element);
2710						validator.formSubmitted = submitted;
2711						validator.successList.push(element);
2712						validator.showErrors();
2713					} else {
2714						var errors = {};
2715						var message = response || validator.defaultMessage( element, "remote" );
2716						errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
2717						validator.showErrors(errors);
2718					}
2719					previous.valid = valid;
2720					validator.stopRequest(element, valid);
2721				}
2722			}, param));
2723			return "pending";
2724		},
2725
2726		// http://docs.jquery.com/Plugins/Validation/Methods/minlength
2727		minlength: function(value, element, param) {
2728			return this.optional(element) || this.getLength($.trim(value), element) >= param;
2729		},
2730
2731		// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
2732		maxlength: function(value, element, param) {
2733			return this.optional(element) || this.getLength($.trim(value), element) <= param;
2734		},
2735
2736		// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
2737		rangelength: function(value, element, param) {
2738			var length = this.getLength($.trim(value), element);
2739			return this.optional(element) || ( length >= param[0] && length <= param[1] );
2740		},
2741
2742		// http://docs.jquery.com/Plugins/Validation/Methods/min
2743		min: function( value, element, param ) {
2744			return this.optional(element) || value >= param;
2745		},
2746
2747		// http://docs.jquery.com/Plugins/Validation/Methods/max
2748		max: function( value, element, param ) {
2749			return this.optional(element) || value <= param;
2750		},
2751
2752		// http://docs.jquery.com/Plugins/Validation/Methods/range
2753		range: function( value, element, param ) {
2754			return this.optional(element) || ( value >= param[0] && value <= param[1] );
2755		},
2756
2757		// http://docs.jquery.com/Plugins/Validation/Methods/email
2758		email: function(value, element) {
2759			// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
2760			return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value);
2761		},
2762
2763		// http://docs.jquery.com/Plugins/Validation/Methods/url
2764		url: function(value, element) {
2765			// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
2766			return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
2767		},
2768
2769		// http://docs.jquery.com/Plugins/Validation/Methods/date
2770		date: function(value, element) {
2771			return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
2772		},
2773
2774		// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
2775		dateISO: function(value, element) {
2776			return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
2777		},
2778
2779		// http://docs.jquery.com/Plugins/Validation/Methods/number
2780		number: function(value, element) {
2781			return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
2782		},
2783
2784		// http://docs.jquery.com/Plugins/Validation/Methods/digits
2785		digits: function(value, element) {
2786			return this.optional(element) || /^\d+$/.test(value);
2787		},
2788
2789		// http://docs.jquery.com/Plugins/Validation/Methods/creditcard
2790		// based on http://en.wikipedia.org/wiki/Luhn
2791		creditcard: function(value, element) {
2792			if ( this.optional(element) )
2793				return "dependency-mismatch";
2794			// accept only spaces, digits and dashes
2795			if (/[^0-9 -]+/.test(value))
2796				return false;
2797			var nCheck = 0,
2798				nDigit = 0,
2799				bEven = false;
2800
2801			value = value.replace(/\D/g, "");
2802
2803			for (var n = value.length - 1; n >= 0; n--) {
2804				var cDigit = value.charAt(n);
2805				var nDigit = parseInt(cDigit, 10);
2806				if (bEven) {
2807					if ((nDigit *= 2) > 9)
2808						nDigit -= 9;
2809				}
2810				nCheck += nDigit;
2811				bEven = !bEven;
2812			}
2813
2814			return (nCheck % 10) == 0;
2815		},
2816
2817		// http://docs.jquery.com/Plugins/Validation/Methods/accept
2818		accept: function(value, element, param) {
2819			param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
2820			return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
2821		},
2822
2823		// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
2824		equalTo: function(value, element, param) {
2825			// bind to the blur event of the target in order to revalidate whenever the target field is updated
2826			// TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
2827			var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
2828				$(element).valid();
2829			});
2830			return value == target.val();
2831		}
2832
2833	}
2834
2835});
2836
2837// deprecated, use $.validator.format instead
2838$.format = $.validator.format;
2839
2840})(jQuery);
2841
2842// ajax mode: abort
2843// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
2844// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
2845;(function($) {
2846	var pendingRequests = {};
2847	// Use a prefilter if available (1.5+)
2848	if ( $.ajaxPrefilter ) {
2849		$.ajaxPrefilter(function(settings, _, xhr) {
2850			var port = settings.port;
2851			if (settings.mode == "abort") {
2852				if ( pendingRequests[port] ) {
2853					pendingRequests[port].abort();
2854				}
2855				pendingRequests[port] = xhr;
2856			}
2857		});
2858	} else {
2859		// Proxy ajax
2860		var ajax = $.ajax;
2861		$.ajax = function(settings) {
2862			var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
2863				port = ( "port" in settings ? settings : $.ajaxSettings ).port;
2864			if (mode == "abort") {
2865				if ( pendingRequests[port] ) {
2866					pendingRequests[port].abort();
2867				}
2868				return (pendingRequests[port] = ajax.apply(this, arguments));
2869			}
2870			return ajax.apply(this, arguments);
2871		};
2872	}
2873})(jQuery);
2874
2875// provides cross-browser focusin and focusout events
2876// IE has native support, in other browsers, use event caputuring (neither bubbles)
2877
2878// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
2879// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
2880;(function($) {
2881	// only implement if not provided by jQuery core (since 1.4)
2882	// TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
2883	if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
2884		$.each({
2885			focus: 'focusin',
2886			blur: 'focusout'
2887		}, function( original, fix ){
2888			$.event.special[fix] = {
2889				setup:function() {
2890					this.addEventListener( original, handler, true );
2891				},
2892				teardown:function() {
2893					this.removeEventListener( original, handler, true );
2894				},
2895				handler: function(e) {
2896					arguments[0] = $.event.fix(e);
2897					arguments[0].type = fix;
2898					return $.event.handle.apply(this, arguments);
2899				}
2900			};
2901			function handler(e) {
2902				e = $.event.fix(e);
2903				e.type = fix;
2904				return $.event.handle.call(this, e);
2905			}
2906		});
2907	};
2908	$.extend($.fn, {
2909		validateDelegate: function(delegate, type, handler) {
2910			return this.bind(type, function(event) {
2911				var target = $(event.target);
2912				if (target.is(delegate)) {
2913					return handler.apply(target, arguments);
2914				}
2915			});
2916		}
2917	});
2918})(jQuery);
2919
2920/*!
2921* jQuery UI Touch Punch 0.2.3
2922*
2923* Copyright 2011–2014, Dave Furfero
2924* Dual licensed under the MIT or GPL Version 2 licenses.
2925*
2926* Depends:
2927*  jquery.ui.widget.js
2928*  jquery.ui.mouse.js
2929*/
2930!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);
2931 
2932/*
2933 * Function to show the loginOverlay when clicked on the lock icon.
2934 * 
2935 */
2936function showLoginOverlay() {
2937    //alert('showLoginOverlay');
2938    if ($(".frameBox .framePopup").css('display','block')){
2939          $(".frameBox .framePopup").css('display','none');
2940    }
2941
2942    var hash = window.location.hash.substring(1);
2943
2944    var cookieValue = thf.utils.getCookieValue('user');
2945
2946    if (hash === "showloginoverlay") {
2947        $(document).ready(function() { 
2948            setTimeout(function(){
2949                var numberoflinks = $(".loginOverlay.osx").length;
2950                if(numberoflinks > 0) {
2951                    if (cookieValue == null || cookieValue == '' || cookieValue.indexOf("uid:=0")>= 0) {
2952                        var abc = $(".loginOverlay.osx").eq(0);
2953                        $(abc).trigger('click');
2954                        $('.midnav-inner-tab li.current a').trigger('click');  
2955                    }          
2956                }
2957            },1000);
2958        });
2959    }
2960    var saCookieValue = thf.utils.getCookieValue('showSACertificate');
2961    if (saCookieValue === "true") {
2962        if(!$('.salesAssistantCertificate #saDisagree').length) {
2963            if (cookieValue != null && cookieValue != '' && cookieValue.indexOf("uid:=0") < 0 && cookieValue.indexOf("saCertificate:=null") >= 0) {                   
2964                var abc = $("#sacertificate-modal").eq(0);
2965                $(abc).trigger('click');
2966            }
2967        }
2968    }
2969}
2970
2971
2972/*
2973 * Function to fetch query parameter.
2974 * */
2975function getQuery(key){
2976    var temp = location.search.match(new RegExp(key + "=(.*?)($|\&)", "i"));
2977    if(!temp) return;
2978    return temp[1];
2979}
2980
2981/*
2982 * Function to check if the current request secure or not.
2983 * */
2984function isURLSecure() {
2985    var requestedURL = location.protocol + "//" + location.host;
2986    //alert('secure url value'+requestedURL);
2987    //alert('secre url configured'+thf.utils.secureUrl.url);
2988    if(requestedURL === thf.utils.secureUrl.url) {
2989        return true;
2990    }else {
2991        return false;
2992    }
2993}
2994
2995/*
2996 * Function to show the login overlay from utility navigation.
2997 * */
2998function showLoginFrame() {
2999    //alert('inside showLoginFrame');
3000    if(isURLSecure()) {
3001        thf.loginFrameHover();
3002        if (window.location.hash) {
3003            // Puts hash in variable, and removes the # character
3004            var hash = window.location.hash.substring(1);
3005            if (hash === "showlogin") {
3006                //$('.utility-nav .frameBox .framePopup').slideDown(300);
3007                $('.midnav-inner-tab li.current a').trigger('click');
3008                $('.utility-nav .frameBox .framePopup').slideDown(300);
3009                if(document.forms['loginFrame'] != undefined && document.forms['loginFrame'].j_username != undefined){ 
3010                	document.forms['loginFrame'].j_username.focus();                
3011             	}                               
3012            }
3013        }
3014    }
3015}
3016
3017/*
3018 * Function to close the login overlay from utility navigation.
3019 * */
3020function closeLoginFrame() {
3021    $('.framePopup').slideUp(300);    
3022}
3023
3024/*
3025* Function to show the login overlay from utility navigation.
3026* */
3027var thf = window.thf || {};
3028(function(window, document, $, thf) {
3029    thf.loginFrameHover = function() {
3030        $('.loginFrameHover').click(function() {
3031            $('.framePopup').slideDown(300);
3032            $(this).css('color', '#008cbd');
3033            $( "#login_username" ).focus();
3034        });
3035    };
3036}(window, document, jQuery, thf));
3037
3038
3039
3040$(document).ready(function() {
3041
3042    var cookieVal = thf.utils.getCookieValue('user');
3043
3044   // alert('user coookie'+cookieVal);
3045
3046  //  console.log('user coookie'+cookieVal);
3047
3048
3049   var shibd = $('#shib').val();
3050
3051    var rtype=getQuery('rtype');
3052
3053    //extensionredirect=extensionredirect.replace("rtype=", "");
3054
3055              var domainRegex = /\b(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}\b/;
3056
3057    if (cookieVal != null && cookieVal != '' && cookieVal.indexOf("uid:=0")< 0) {
3058        if (rtype != "" && rtype != null && rtype != undefined)
3059
3060            { 
3061                rtype=rtype.replace("#showloginoverlay", "");
3062                rtype=rtype.replace(domainRegex,window.location.hostname);
3063                window.location = thf.utils.secureUrl.url + rtype; 
3064            }
3065    }
3066    else if( rtype != "" && rtype != null && rtype != undefined && shibd !=null &&  shibd !=undefined && shibd !=null){
3067         rtype=rtype.replace("showloginWindow", "");
3068         rtype=rtype.replace(domainRegex,window.location.hostname);
3069         window.location = thf.utils.secureUrl.url + rtype;
3070    }
3071
3072
3073});
3074
3075/**
3076 * jQuery Plugin to obtain touch gestures from iPhone, iPod Touch and iPad, should also work with Android mobile phones (not tested yet!)
3077 * Common usage: wipe images (left and right to show the previous or next image)
3078 * 
3079 * @author Andreas Waltl, netCU Internetagentur (http://www.netcu.de)
3080 * @version 1.1.1 (9th December 2010) - fix bug (older IE's had problems)
3081 * @version 1.1 (1st September 2010) - support wipe up and wipe down
3082 * @version 1.0 (15th July 2010)
3083 */
3084(function($) { 
3085   $.fn.touchwipe = function(settings) {
3086     var config = {
3087    		min_move_x: 20,
3088    		min_move_y: 20,
3089 			wipeLeft: function() { },
3090 			wipeRight: function() { },
3091 			wipeUp: function() { },
3092 			wipeDown: function() { },
3093			preventDefaultEvents: true
3094	 };
3095     
3096     if (settings) $.extend(config, settings);
3097 
3098     this.each(function() {
3099    	 var startX;
3100    	 var startY;
3101		 var isMoving = false;
3102
3103    	 function cancelTouch() {
3104    		 this.removeEventListener('touchmove', onTouchMove);
3105    		 startX = null;
3106    		 isMoving = false;
3107    	 }	
3108    	 
3109    	 function onTouchMove(e) {
3110    		 if(config.preventDefaultEvents) {
3111    			 e.preventDefault();
3112    		 }
3113    		 if(isMoving) {
3114	    		 var x = e.touches[0].pageX;
3115	    		 var y = e.touches[0].pageY;
3116	    		 var dx = startX - x;
3117	    		 var dy = startY - y;
3118	    		 if(Math.abs(dx) >= config.min_move_x) {
3119	    			cancelTouch();
3120	    			if(dx > 0) {
3121	    				config.wipeLeft();
3122	    			}
3123	    			else {
3124	    				config.wipeRight();
3125	    			}
3126	    		 }
3127	    		 else if(Math.abs(dy) >= config.min_move_y) {
3128		    			cancelTouch();
3129		    			if(dy > 0) {
3130		    				config.wipeDown();
3131		    			}
3132		    			else {
3133		    				config.wipeUp();
3134		    			}
3135		    		 }
3136    		 }
3137    	 }
3138    	 
3139    	 function onTouchStart(e)
3140    	 {
3141    		 if (e.touches.length == 1) {
3142    			 startX = e.touches[0].pageX;
3143    			 startY = e.touches[0].pageY;
3144    			 isMoving = true;
3145    			 this.addEventListener('touchmove', onTouchMove, false);
3146    		 }
3147    	 }    	 
3148    	 if ('ontouchstart' in document.documentElement) {
3149    		 this.addEventListener('touchstart', onTouchStart, false);
3150    	 }
3151     });
3152 
3153     return this;
3154   };
3155 
3156 })(jQuery);
3157
3158jQuery.validator.addMethod("regexPassword", function(value, element) {
3159    var regexpr = /^(?!.*(.)\1{2})(?=.*\d)(?=.*[a-zA-Z])(?!.*(#|`)).{8,12}$/;
3160    var regex = new RegExp(regexpr);
3161    //alert(regex.test(value));
3162    var regexTest = regex.test(value);
3163    return regexTest;
3164});
3165
3166jQuery.validator.addMethod("containsAtLeastOneDigit", function (value) { 
3167            return (/[0-9]/).test(value); 
3168        },"Password must contain at least one digit.");  
3169 
3170jQuery.validator.addMethod("containsAtLeastOneLetter", function (value) { 
3171            return (/[a-zA-Z]/).test(value); 
3172         }, "Password must contain at least one letter.");
3173
3174jQuery.validator.addMethod("isZipCodeCart", function(value, element) {
3175    return value.match(new RegExp(/(^\d{5}
3175$)|(^\d{5}-\d{4}$)/));
3176}, "Please enter correct Zip Code");  
3177
3178
3179jQuery.validator.addMethod("validateSequence", function(value, element) {
3180    var qwerty = "qwertyuiopasdfghjklzxcvbnm";
3181    var taberr = [];
3182    var liberr = [];
3183    taberr = [false, false];
3184    var pw = value;
3185
3186    var lpw = pw.length;
3187    var IAdjac = false;
3188    var ISeq = false;
3189    var pw1 = pw.replace(/(\W)|([\d])/g, "");
3190    var lpw1 = pw1.length;
3191    //var NbCharOk = 0;
3192    var c, c0, c1, c2, c3, cc, diffseq;
3193    var iqw = 0;
3194    var old_iqw = 0;
3195    for (var i = 0; i < lpw; i++) {
3196        c = pw.charAt(i);
3197        c0 = c.charCodeAt(0);
3198        if (c.match(/^[0-9]|[A-Z]$/i)) {
3199            //NbCharOk++;
3200            if (i < (lpw - 1)) {
3201                // adjacent characters ?
3202                c1 = pw.charCodeAt(i + 1);
3203                if (c0 == c1) IAdjac = true;
3204                if (i < (lpw - 3)) {
3205                    c2 = pw.charCodeAt(i + 2);
3206                    c3 = pw.charCodeAt(i + 3);
3207                    diffseq = c1 - c0;
3208                    if (Math.abs(diffseq) == 1) {
3209                        if (((c2 - c1) == diffseq) && ((c3 - c2) == diffseq)) ISeq = true;
3210                    }
3211                }
3212            }
3213            if (lpw1 > 3) {
3214                // qwerty sequence ?
3215                if (c.match(/^[A-Z]$/i)) {
3216                    cc = c.toLowerCase();
3217                    iqw = qwerty.indexOf(cc, old_iqw);
3218                    if (iqw < old_iqw) IQwerty = false;
3219                    old_iqw = iqw;
3220                }
3221            }
3222        }
3223    }
3224    taberr[0] = IAdjac;
3225    taberr[1] = ISeq;
3226    var msg = "";
3227    for (var j = 0; j < taberr.length; j++) {
3228        if (taberr[j]) {
3229            msg += liberr[j] + "\n";
3230        }
3231    }
3232    if (!msg.length) {
3233        //////alert("Password valid");
3234        return true;
3235    }
3236    else {
3237        //////alert("Password invalid");
3238        return false;
3239    }
3240
3241}
3242
3243);
3244jQuery.validator.addMethod("isZipCodePRO", function(value, element) {
3245	 var zipLength = $('#profileForm_zipCode').val().length ;
3246	if($('#profileForm_zipCode').val().length>0){
3247   return value.match(new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/));
3248	}
3249	else {
3250	 return true ;
3251	}
3252 });  
3253
3254jQuery.validator.addMethod("notEqualToReg", function(value, element, param) {
3255    var notEqual = true;
3256    value = $.trim(value);
3257    for (i = 0; i < param.length; i++) {
3258        if (value.toLowerCase() == $.trim($(param[i]).val()).toLowerCase()) {
3259            notEqual = false;
3260        }
3261    }
3262    return this.optional(element) || notEqual;
3263}, "Please enter a different value.");
3264
3265jQuery.validator.addMethod("nameValidation", function(value, element) {
3266    return this.optional(element) || /^[a-zA-Z'-]+$/.test(value);
3267}); 
3268
3269jQuery.validator.addMethod("validName", function(value, element) {
3270	return this.optional(element) || /^(\D)+$/.test(value);
3271}, "Please fill correct value for Name. Numbers not allowed.");   
3272
3273//Wave2.0- Name validation which should not accept characters [, and  "]
3274jQuery.validator.addMethod("checkName", function(value, element) {
3275    return this.optional(element) || /^[^,"]+$/.test(value);
3276}, "Please fill correct value for Name. Numbers not allowed."); 
3277
3278jQuery.validator.addMethod("verifyEmail", function(value, element, param) {
3279    var emailEqual = false;
3280    value = $.trim(value);
3281    for (i = 0; i < param.length; i++) {
3282        if (value.toLowerCase() == $.trim($(param[i]).val()).toLowerCase()) {
3283            emailEqual = true;
3284        }
3285    }
3286    return this.optional(element) || emailEqual;
3287}, "Please enter a different value.");
3288
3289jQuery.validator.addMethod("subroleVal", function() {
3290/*$("#CheckboxGroup1_2").on("click",function(){
3291     //alert("indi selected");
3292     return true;
3293     });
3294     var clickStatus =    thf.registerAction.checkIfBothSelectedNext();
3295     //alert("Click status: " + clickStatus);                
3296     //alert("Validate Subrole called");
3297     
3298     if(clickStatus){*/
3299    if ($("#subrole").val() == "default") {
3300        //alert("in if");
3301        //$("#osx-modal-data form[name='registerForm'] .scfValidationSummaryRegister").append('<label id="subrolelabel" for="subrole" generated="true" class="" ><strong>Enter a sub role</strong></label>');
3302        return false;
3303    }
3304    else {
3305        //alert("in else");
3306        //$("#osx-modal-data form[name='registerForm'] .scfValidationSummaryRegister label#subrolelabel").css('display','none');
3307        return true;
3308    }
3309/*}else{
3310     //alert("Only one role selected");
3311     return true;
3312     }*/
3313
3314}
3315
3316);
3317
3318jQuery.validator.addMethod("selectState", function() {
3319	    if (($('#profileForm_addressLn1').val() != '' || $('#profileForm_addressLn2').val() != '' || $('#profileForm_city').val() != '' || $('#profileForm_zipCode').val() != '') && $("#profileForm_state").val() == "Select State" ) {
3320	        return false;
3321	    }
3322	    else {
3323	        return true;
3324	    }
3325});
3326
3327
3328//alert("Error JSON Obj: " + errorJson["REG_FN_BL"]);
3329//alert("Role: " + role);
3330jQuery.validator.addMethod("specialChar", function(value, element) {
3331    return this.optional(element) || /([0-9a-zA-Z\s\-\`])$/.test(value);
3332}, "Please Fill Correct Value in Field.");
3333
3334
3335jQuery.validator.addMethod("isZipCode", function(value, element) {
3336    return value.match(new RegExp(/(^\d{5}
3336$)|(^\d{5}-\d{4}$)/));
3337});
3338
3339jQuery.validator.addMethod("valueNotEquals", function(value, element, arg) {
3340    return arg != value;
3341}, "Please Select a State");
3342
3343jQuery.validator.addMethod("roleVal", function() {
3344    var fields = $("input[name='roles']").serializeArray();
3345    if (fields.length == 0) {
3346        return false;
3347    } else {
3348        return true;
3349    }
3350});
3351
3352jQuery.validator.addMethod("checkbox_1", function(value, element) {
3353    if(($("input[name='CheckboxGroup1']:checked").length > 0)){
3354        return true;
3355    } else {
3356        return false;
3357    }
3358});
3359
3360jQuery.validator.addMethod("noSpace", function(value, element) { 
3361  return value.indexOf(" ") < 0 && value != ""; 
3362}, "No space please and don't leave it empty");
3363
3364jQuery.validator.addMethod("numberNot", function(value, element) {
3365    return value.match(new RegExp(/.*?(\d)[^\d]*/));
3366});
3367
3368jQuery.validator.addMethod("cityProfile", function() {
3369    var fields = $("input[name='roles']").serializeArray();  
3370    if ($('#roles_financial').attr('checked')&& $('#profileForm_branchIdProfile').val().length==0) {
3371        return false;
3372    } else {
3373        return true;
3374    }
3375});
3376//This method truncates the white space from the first position.
3377jQuery.validator.addMethod("checkFirstChar", function(key, txt){
3378    if(key == 32 && txt.value.length<=0)
3379    {
3380        return false;
3381    }
3382    else if(txt.value.length>0)
3383    {
3384        if(txt.value.charCodeAt(0) == 32)
3385        {
3386            txt.value=txt.value.substring(1,txt.value.length);
3387            return true;
3388        }
3389    }
3390    return true;
3391}, "Spaces should not be placed in the first place.");
3392
3393jQuery.validator.addMethod("containsSSN", function(value, element) {
3394    if(value.match(new RegExp(/\d{3}-\d{2}-\d{4}$|\d{3}-\d{2}-\d{4}[^0-9]|^\d{9}$|[^0-9]\d{9}$|[^0-9]\d{9}[^0-9]|^\d{9}[^0-9]/gi))){
3395        return false;
3396    } else {
3397        return true;
3398    }
3399});
3400
3401//Not allow number and space.
3402$.validator.addMethod("checkNumberNSpace",function(value,element){
3403	return this.optional(element) || /^\S[0-9]+$/i.test(value);  
3404},"Spaces and numbers should not be be allowed.");
3405
3406//Not allow space.
3407$.validator.addMethod("checkNoSpace",function(value,element){
3408    return this.optional(element) || (/^\S+$/i).test(value);  
3409},"Space is not be be allowed.");
3410
3411jQuery.validator.addMethod("checkComp", function(value,element) {
3412	
3413    var flag = false;
3414    	var val = $( element ).val();
3415    	$(".companyNameCrd1 .ui-autocomplete li").each(function() {
3416        	var a = $(this).find("a").text();
3417        	if(a==val) {
3418        		flag=true;
3419        		return false;
3420        	}
3421        })
3422    return flag;
3423});
3424
3425jQuery.validator.addMethod("checkComp2", function(value,element) {
3426	
3427    var flag = false;
3428    	var val = $( element ).val();
3429    	$(".companyNameCrd2 .ui-autocomplete li").each(function() {
3430        	var a = $(this).find("a").text();
3431        	if(a==val) {
3432        		flag=true;
3433        		return false;
3434        	}
3435        })
3436    return flag;
3437});
3438
3439$.validator.addMethod("captcha", function(value, element) {
3440        var result = true;
3441        if (value.length < 1) {
3442            $.validator.messages.captcha = " ";
3443            $('p.captchaDesc').addClass("error");
3444            return false;
3445        } 
3446        $('p.captchaDesc').removeClass("error");
3447        return result;
3448    },
3449    "captcha invalid"
3450);
3451
3452$.validator.addMethod("captcha1", function validateSubscribe(resultData){
3453                        var data = [
3454                                      {
3455                                         "result":"SUCCESS",
3456                                         "message":"Success"
3457                                      },
3458                                      {
3459                                         "result":"FAILURE_CAPTCHA",
3460                                         "message":"Failure captcha"
3461                                      },
3462                                      {
3463                                         "result":"FAILURE_USER_ALREADY_REGISTERED",
3464                                         "message":"Failure user already registered"
3465                                      },
3466                                      {
3467                                         "result":"FAILURE_INTERNAL_PROCESSING",
3468                                         "message":"Failure internal processing"
3469                                      }
3470                                    ];
3471                        
3472                        function validateSubscribe(resultData){
3473                            if(resultData=='SUCCESS'){
3474                                  //  $('section#regCompleteNew').css("display","none");
3475                                  //  $('section#subSuccess').css("display","block");                               
3476                                    return true;   
3477                            }else if(resultData=='FAILURE_CAPTCHA'){
3478                               $.validator.messages.captcha1 = "FAILURE CAPTCHA";                                
3479                               return false;                                                                                     
3480                            }else if(resultData=='FAILURE_USER_ALREADY_REGISTERED'){
3481                               $.validator.messages.captcha1 = "FAILURE USER ALREADY REGISTERED";                                                        
3482                               return false;                                       
3483                            }else if(resultData=='FAILURE_INTERNAL_PROCESSING'){
3484                               $.validator.messages.captcha1 = "FAILURE INTERNAL PROCESSING";                 
3485                               return false;                                       
3486                            }
3487                        }  
3488                        validateSubscribe('FAILURE_CAPTCHA');    
3489                        },"captcha invalid"
3490);
3491
3492function injectTrim(handler) {
3493  return function (element, event) {
3494    if (element.tagName === "TEXTAREA" || (element.tagName === "INPUT" && element.type !== "password")) {
3495      element.value = $.trim(element.value);
3496    }
3497    return handler.call(this, element, event);
3498  };
3499}
3500
3501
3502function updateCheckboxValueInCookie(checkPath){
3503  	var subscriptionValue = getCookieVar("subscribeEmailCookie");
3504    if(document.getElementById("checkbox"+checkPath)!=null)
3505    { 
3506		if(subscriptionValue.indexOf(checkPath) != -1){
3507            var replaceStr = checkPath + ",";
3508            subscriptionValue = subscriptionValue.replace(replaceStr,"");   
3509            subscriptionValue = subscriptionValue.replace(checkPath,"");
3510        } else if(subscriptionValue != "''" && subscriptionValue != '""'){
3511        	subscriptionValue = subscriptionValue+','+checkPath;
3512        } else{
3513        	subscriptionValue = checkPath;  
3514        }
3515    }
3516    document.cookie="subscribeEmailCookie="+subscriptionValue+";path=/";  
3517  	var newsubscriptionValue = getCookieVar("subscribeEmailCookie");
3518}
3519
3520function updateSelectAllCheckboxValueInCookie(checkPath){
3521  var subscriptionValue = getCookieVar("subscribeEmailCookie");
3522  if(document.getElementById("checkbox"+checkPath)!=null && !document.getElementById("checkbox"+checkPath).checked)
3523    { 
3524        if(subscriptionValue != ''){
3525            subscriptionValue = subscriptionValue.replace(checkPath, '');   
3526        }
3527    }else{
3528        if(document.getElementById("checkbox"+checkPath)!=null && !document.getElementById("checkbox"+checkPath).disabled){
3529            if((subscriptionValue =="''")||(subscriptionValue =='""') ){
3530            subscriptionValue = checkPath;
3531            }else if(subscriptionValue!=''){
3532            subscriptionValue = subscriptionValue+','+checkPath;
3533            }
3534            else{
3535            subscriptionValue = checkPath;  
3536            }
3537        }
3538    }
3539  document.cookie="subscribeEmailCookie="+subscriptionValue+";path=/" ;
3540  var newsubscriptionValue = getCookieVar("subscribeEmailCookie");
3541}
3542function selectCookieCheckboxes(){
3543    var subscriptionValue = getCookieVar("subscribeEmailCookie");
3544    if(subscriptionValue != ''){
3545        var selectionarray = subscriptionValue.split(',');        
3546        $('table.emailAlert input[type=checkbox]').each(function (){
3547            var _this = $(this);
3548            verifyCheckboxFromCookie(_this, selectionarray);
3549        });
3550   }
3551}
3552function verifyCheckboxFromCookie(checkbox, valuearray){    
3553    var checkId = $(checkbox).attr('id');
3554    $.each( valuearray, function(index, value) { 
3555        value = 'checkbox'+ value;
3556        if(value === checkId){
3557            $(checkbox).prop('checked', true);
3558        }
3559    });
3560}
3561
3562
3563function getCookie(c_name)
3564{
3565var i,x,y,ARRcookies=document.cookie.split(";");
3566for (i=0;i<ARRcookies.length;i++)
3567{
3568  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
3569  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
3570  x=x.replace(/^\s+|\s+$/g,"");
3571  if (x==c_name)
3572    {
3573    return unescape(y);
3574    }
3575  }
3576}
3577
3578function dropDownEmailSubscriptionSearch(){
3579    /* dropdown functionality */  
3580    $(".dropdownSearch dt a").click(function() {
3581        var dropID = $(this).closest("dl").attr("id");
3582        $("#"+dropID+" dd ul").slideToggle(200);
3583    });
3584    
3585    $(".dropdownSearch dd ul li a").click(function() {
3586        var dropID = $(this).closest("dl").attr("id");
3587        var text = $(this).html();
3588        var selVal = $(this).find(".dropdown_value").html();
3589        $("#"+dropID+" dt a").html(text);
3590        $("#"+dropID+" dd ul").hide();
3591        // INSERT FUNCTION HERE getSelectedValue("partner_dropdown"));
3592    });
3593    
3594    $("dl[class!=dropdownSearch]").click(function() {
3595        $(".dropdownSearch dd ul").hide();
3596    }); 
3597    
3598    $(document).bind('click', function(e) {
3599        var $clicked = $(e.target);
3600        if (! $clicked.parents().hasClass("dropdownSearch"))
3601            $(".dropdownSearch dd ul").hide();
3602    });
3603    
3604    /* Selection functionality */   
3605    var dropDownList = $("#fundAlert dd ul li a");
3606    var hoverList = $("nav.leftPanel ul.filterList li a");
3607    //var currentNode = $("#currentNode").val();
3608    var searchKeyword = $("#searchKeyword").val();
3609    var searchedType = $("#searchedType").val();
3610    var fundname = $("#fundname").val();
3611    var filters = $("#filters").val();
3612    var subscriptionname = $("#subscriptionname").val();
3613    var subscriptionnameForEmail = $("#subscriptionnameForEmail").val();
3614    $("#fundAlert dd ul li a").click(function(){
3615        var fundnametagId = $(this).attr('rel');        
3616        makeAjaxCallForSubscription(searchKeyword, searchedType, filters, fundnametagId, subscriptionname,subscriptionnameForEmail);
3617    });
3618 }
3619
3620
3621 
3622 //**************************************************************
3623 function getCookieVar(cookieName){
3624        var cookievalue =checkCookie(cookieName);
3625        if(cookievalue == ''){
3626        	if(cookieName != 'user') {
3627        		document.cookie=cookieName+"='';path=/";
3628        	}
3629            return '';
3630        }else{
3631            return cookievalue;
3632        }
3633}
3634function addPrintDataToCookie(obj,path){   
3635		var inputvalue=$(obj).val();
3636        if($.isNumeric(inputvalue)){
3637            var cookieName="subscribePrintCookie";
3638            var subscriptionValue = getCookieVar(cookieName);
3639            var delimeter="::";
3640            var valueArray= new Array();
3641            var finalString='';
3642            if(subscriptionValue.length != "2"){
3643                valueArray =jQuery.trim(subscriptionValue).split(delimeter);         
3644                //to remoce earlier entered entry
3645                valueArray = checkValueInArray(valueArray,path);
3646                if(valueArray == "'"){
3647                    valueArray= new Array();
3648                }
3649            }
3650            if(Number(inputvalue)> 0){
3651                valueArray.push(path+"||"+inputvalue);
3652                finalString=prepareStringFromArray(valueArray,delimeter);
3653            }
3654            document.cookie=cookieName+"="+finalString+";path=/";
3655        }
3656}
3657
3658function prepareStringFromArray(valuearray,delimeter){
3659        var stringValue='';
3660        $.each( valuearray, function(index, value) { 
3661            if(value != ''){
3662                if(stringValue == ''){                  
3663                     stringValue=value;
3664                }else{
3665                     stringValue=stringValue+delimeter+value;
3666                }
3667            } 
3668        });
3669        return stringValue;
3670}
3671function checkValueInArray(valueArray,path){
3672        var newArray = new Array();
3673        $.each( valueArray, function(index, value) { 
3674            //f1#12
3675            if(value != ''){
3676                var valueObject=jQuery.trim(value).split("||");
3677                if(valueObject[0] != path){
3678                    newArray.push(value);
3679                }
3680            }
3681        });
3682        return newArray;
3683}
3684function updateInputFromCookie(){
3685        selectCookieCheckboxes();
3686        var delimeter="::";
3687        var cookieValue=getCookieVar('subscribePrintCookie');
3688        if(cookieValue != ''){
3689            var valueArray= jQuery.trim(cookieValue).split(delimeter);
3690            $.each( valueArray, function(index, value) { 
3691                var valueObjectArray=jQuery.trim(value).split("||");
3692                verifyQuantityFromCookie(valueObjectArray[0], valueObjectArray[1]);
3693            });                 
3694       }    
3695}
3696function verifyQuantityFromCookie(id, value){
3697        $('table.emailAlert input[type=text]').each(function (){
3698             var obj =$(this);
3699             if(obj.attr("id") === id){
3700                 obj.attr("value",value);              
3701             }
3702        });
3703}
3704
3705function checkCookie(cookieName)
3706{
3707    var i,name,y,ARRcookies=document.cookie.split(";");
3708    for (i=0;i<ARRcookies.length;i++)
3709    {
3710      name=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
3711      value=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
3712      name=name.replace(/^\s+|\s+$/g,"");
3713      if (name == cookieName)
3714        {   
3715         return unescape(value);
3716        }
3717    }   
3718    return '';
3719}
3720
3721
3722
3723function dropDownSubscriptionSearch(resourcepath){
3724        /* dropdown functionality */  
3725        $(".dropdownSearch dt a").click(function() {
3726            var dropID = $(this).closest("dl").attr("id");
3727            $("#"+dropID+" dd ul").slideToggle(200);
3728        });
3729        
3730        $(".dropdownSearch dd ul li a").click(function() {
3731            var dropID = $(this).closest("dl").attr("id");
3732            var text = $(this).html();
3733            var selVal = $(this).find(".dropdown_value").html();
3734            $("#"+dropID+" dt a").html(text);
3735            $("#"+dropID+" dd ul").hide();
3736            // INSERT FUNCTION HERE getSelectedValue("partner_dropdown"));
3737        });
3738        
3739        $("dl[class!=dropdownSearch]").click(function() {
3740            $(".dropdownSearch dd ul").hide();
3741        }); 
3742        
3743        $(document).bind('click', function(e) {
3744            var $clicked = $(e.target);
3745            if (! $clicked.parents().hasClass("dropdownSearch"))
3746                $(".dropdownSearch dd ul").hide();
3747        });
3748
3749        /* Selection functionality */   
3750        var dropDownList = $("#fundAlert dd ul li a");
3751        var hoverList = $("nav.leftPanel ul.filterList li a");
3752        var searchKeyword = $("#searchKeyword").val();
3753        var searchedType = $("#searchedType").val();
3754        var fundname = $("#fundname").val();
3755        var filters = $("#filters").val();
3756        var itemsPerPage = $("#thf-itemsPage").val();
3757        var subscriptionname = $("#subscriptionname").val();
3758        var subscriptionnameForEmail = $("#subscriptionnameForEmail").val();
3759        $("#fundAlert dd ul li a").click(function(){
3760            var fundnametagId = $(this).attr('rel');
3761            filters = "";
3762            makeAjaxCallForSubscription(resourcepath, searchKeyword, searchedType, filters, fundnametagId, subscriptionname,subscriptionnameForEmail,itemsPerPage);
3763        });
3764}
3765    
3766function makeAjaxCallForSubscription(resourcepath, keyword,searchType,filtertagid,fundnametagId,subscriptionname,subscriptionnameForEmail, itemsPerPage) {
3767        var url = "";
3768    	if(filtertagid == 'thf:resources/literature/fund-document')
3769        {
3770          itemsPerPage =25;
3771         
3772        }        
3773              url = resourcepath+'.searchsubscribedocumentajax.html?keyword='+keyword+'&searchType='+searchType+'&filters='+filtertagid+'&fundname='+fundnametagId+'&subscriptionname='+subscriptionname+'&subscriptionnameForEmail='+subscriptionnameForEmail + '&itemsperpage=' + itemsPerPage;
3774              jQuery.ajax({
3775            url: url,
3776            type: 'GET',    
3777            data: '',
3778            dataType: 'html',
3779            async: true,
3780            cache: false,   
3781            error: function() {
3782            	console.log("Error loading subscription list.");   
3783            },
3784            success: function(data)
3785            {  
3786                var printC = getCookie("subscribePrintCookie");
3787                var emailC = getCookie("subscribeEmailCookie");
3788                
3789                var eCookieTrimedValue = emailC.substring(0,2);
3790                var pCookieTrimedValue = printC.substring(0,2);
3791                if((eCookieTrimedValue != '""' && eCookieTrimedValue != "''") || (pCookieTrimedValue != '""' && pCookieTrimedValue != "''")){
3792                    $(document).trigger("subscriptionUpdateEvent");
3793                }
3794                
3795                if($("div#printSubscriptionAlert").length){ 
3796                    var exdate=new Date();
3797                    document.cookie ='subscribePrintCookie="";path=/;expires='+exdate.getDate();
3798                    document.cookie ='subscribeEmailCookie="";path=/;expires='+exdate.getDate();    
3799                    
3800                    }
3801            //  alert(data);
3802                
3803                $("#thf-subscription").html(data);  
3804                
3805    //          if($('#updateMySubscriptionButton')){
3806        //          $('#updateMySubscriptionButton').click(updateMySubscriptionAttachment);
3807            //  }
3808                hartFord.printSubscriptionAlert(resourcepath);
3809                hartFord.emailSelectAll();
3810                
3811                $('.printMySubscription table.emailAlert tbody tr td input[type=text]').blur(function() {
3812                var enterValue = $(this).val();
3813                var hiddenVal = $(this).siblings('input[type=hidden]').val();
3814                if(Number(enterValue) > Number(hiddenVal)){
3815                 $(this).css("border","solid 1px red");
3816                 $('.printMySubscription table.emailAlert tbody tr td input[type=text]').not(this).attr("disabled",true);
3817                 
3818                   $("a#updateMySubscriptionButton").addClass("disable");       
3819                  return true;
3820                } else {
3821                  $(this).css("border","");  
3822                  $('.printMySubscription table.emailAlert tbody tr td input[type=text]').not(this).attr("disabled",fal
3822se);
3823                  
3824                  $("a#updateMySubscriptionButton").removeClass("disable");
3825                  $(".printUpdate button").css('cursor', 'pointer');
3826                  return false;
3827                }
3828              });
3829              $('.printMySubscription table.emailAlert .EmailSub .form-select-wrapper, .printMySubscription td input[type=text]').click(function(){                  
3830                  $("a#updateMySubscriptionButton").removeClass("disable");
3831                  $(".printUpdate button").css('cursor', 'pointer');
3832              })
3833              $("#subscriptionAlert td input[type=text]").click(function(){
3834               $(".alertList").find("#subscriptionButton").removeClass("disable")
3835             });
3836
3837              if ($('.emailAlert .errorTabData').is( ":visible" ))
3838                {   
3839                   if($('.emailAlert .errorTabData').text('You currently have no subscriptions. '))
3840                   $('.dataTables_info').text('Showing 0-0 of 0');
3841                }
3842               setTimeout(function(){applyDropDownStyle(),0}); 
3843            }
3844        });
3845}
3846function makeAjaxCallForUpdateMySubscription(resourcepath, itemsPerPage) {
3847    var url = "";
3848          url = resourcepath+'.searchsubscribedocumentajax.html?itemsperpage=' + itemsPerPage;
3849          if ($('.filterList .current a').attr('rel') != undefined){
3850              url = url + "&filters="+$('.filterList .current a').attr('rel');}
3851          jQuery.ajax({
3852        url: url,
3853        type: 'GET',    
3854        data: '',
3855        dataType: 'html',
3856        async: true,
3857        cache: false,   
3858        error: function() {
3859        	console.log("Error loading subscription list.");   
3860        },
3861        success: function(data)
3862        {  
3863            //alert('success')
3864            
3865            if($("div#printSubscriptionAlert").length){ 
3866                var exdate=new Date();
3867                document.cookie ='subscribePrintCookie="";path=/;expires='+exdate.getDate();
3868                document.cookie ='subscribeEmailCookie="";path=/;expires='+exdate.getDate();    
3869                }
3870            $("#thf-subscription").html(data);
3871    //      if($('#updateMySubscriptionButton')){
3872//              $('#updateMySubscriptionButton').click(updateMySubscriptionAttachment);
3873            //}
3874            hartFord.printSubscriptionAlert(resourcepath);      
3875            hartFord.emailSelectAll(); 
3876            setTimeout(function(){applyDropDownStyle(),300}); 
3877        }
3878    });
3879}
3880     
3881 
3882  function applyDropDownStyle(){
3883     if ($('.emailAlert .errorTabData').is( ":visible" ))
3884    {   
3885       
3886       if($('.emailAlert .errorTabData').text('You currently have no subscriptions. '))
3887       $('.dataTables_info').text('Showing 0-0 of 0');
3888    }
3889    $('.top .form-select-wrapper').css('width','60px'); 
3890    $('.top .form-select-wrapper').css('margin-left','15px');
3891    $('.top .form-select-wrapper').css('margin-top','-5px');
3892    $('.bottom .form-select-wrapper').css('width','60px');
3893    $('.bottom .form-select-wrapper').css('margin-left','15px');
3894    $('.bottom .form-select-wrapper').css('margin-top','-5px');
3895    $('.top .form-select-wrapper span').css('width','20px'); 
3896    $('.bottom .form-select-wrapper span').css('width','20px');
3897    $('.top .form-select-wrapper ul').css('width','60px');
3898    $('.bottom .form-select-wrapper ul').css('width','60px');
3899 }
3900
3901
3902
3903//changepassword form validation
3904function validatePasswordForReset() {
3905	$.validator.addMethod("password_same", function(value, element) {
3906		if (thf.changePassword === 'changepassword') {
3907			return $('#changepasswordform_profilePassword3').val() != $('#changepasswordform_profilePasswordcurrent').val();
3908		} else {
3909			return true;
3910		}
3911	}, "* password should not match");
3912
3913	$.validator.addMethod("password_userid_same", function(value, element) {
3914		var validationemail = thf.checkemail;
3915		return $('#changepasswordform_profilePassword3').val() != validationemail;
3916	}, "* password should not match");
3917
3918	//Form validator
3919	var validator = $(".formCustom form[name='changepasswordform']").validate({
3920		rules: {
3921			profilePasswordcurrent: {
3922				required: true,
3923				checkNoSpace:true,                        
3924				containsAtLeastOneDigit: true,
3925				containsAtLeastOneLetter: true,				
3926				minlength: 8
3927			},
3928			profilePassword3: {
3929				required: true,
3930				checkNoSpace:true,                        
3931				containsAtLeastOneDigit: true,
3932				containsAtLeastOneLetter: true,				
3933				minlength: 8,
3934				password_same: true,
3935				password_userid_same: true
3936			},
3937			profilePassword4: {
3938				required: true,
3939				minlength: 8,
3940				equalTo: "#changepasswordform_profilePassword3"
3941			}
3942		},
3943		messages: {
3944			profilePasswordcurrent: {
3945				required: "Please enter a password.",
3946				checkNoSpace: "Password should not allow space character.",                        
3947				containsAtLeastOneDigit: "Password must contain at least one digit.",
3948				containsAtLeastOneLetter: "Password must contain at least one letter.",						
3949				minlength: "Password must be a minimum of 8 characters length."
3950			},
3951			profilePassword3: {
3952				required: "Please enter a password.",
3953                checkNoSpace: "Password should not allow space character.",                        
3954                containsAtLeastOneDigit: "Password must contain at least one digit.",
3955                containsAtLeastOneLetter: "Password must contain at least one letter.",						
3956				minlength: "Passwords must be a minimum of 8 characters length.",
3957				password_same: "New password can not be equal to current password.",
3958				password_userid_same: "User id and password can not be same!"
3959			},
3960			profilePassword4: {
3961				required: "Please confirm your Password.",
3962				minlength: "Passwords must be a minimum of 8 characters length.",
3963				equalTo: "The Passwords you entered do not match."
3964			}
3965		},
3966		// the errorPlacement has to take the table layout into account
3967		errorLabelContainer: $(".formCustom form[name='changepasswordform'] .scfValidationSummary"),
3968		success: function(label) {
3969			label.css("display", "none");
3970		}
3971	});
3972}
3973 
3974function showMessage(showMessage) {
3975	if (null !== showMessage && showMessage.length > 0) {
3976		$('#successMessage').show();
3977		$('#successMessage #success').append(showMessage);		
3978		// Bootstrap 4.5.0 Modal - jQuery Plugin Method
3979		if ($('#successMessage-modal').length) {
3980			try {
3981				$('#successMessage-modal').modal({
3982					backdrop: 'static',
3983					keyboard: false,
3984					focus: true,
3985					show: true
3986				});			
3987				$('#successMessage-modal .closeMe, .close').off('click').on('click', function() {
3988					try {
3989						$('#successMessage-modal').modal('hide');
3990					} catch (err) {
3991						$('#successMessage-modal').hide();
3992					}
3993					return false;
3994				});
3995			} catch (err) {
3996				console.error('Error initializing Bootstrap Modal:', err);
3997				$('#successMessage-modal').show();
3998			}
3999		}
4000	} else {
4001		$('#successMessage').hide();
4002	}
4003}
4004 
4005function showfailure(showMessage) {
4006	if (showMessage !== null && showMessage.length > 0) {
4007		$('#faliure').html(showMessage);
4008	} else {
4009		$('#failure').hide();
4010	}
4011}
4012
4013function redirect(redirect,currentRole){
4014	 window.location = redirect+'.'+currentRole+'.html';   
4015	}
4016$(document).ready(function() {
4017    var usrLoginStatus = $('#loggedInStatus').val();
4018	$('a.lockedContent').each(function( index ) {
4019		if (usrLoginStatus == "NotLoggedIn") {
4020			// user is not logged-in
4021			$(this).addClass("loginOverlay osx");
4022			
4023			if($(this).find(".button").hasClass("button")) {
4024				$(this).find(".button").append("<span class='whitelock'></span>");
4025			} else {
4026				$(this).append("<span class='lock'></span>");
4027			}
4028		}
4029	});
4030}); 
4031var timerRef;
4032// 'xmlhttp' request object, do not access directly, use getXmlHttp instead
4033var errorJsonLogin = new Array();
4034
4035function getXmlHttp() {
4036    if (window.XMLHttpRequest) {
4037        return new XMLHttpRequest();
4038    } else {
4039        if (window.ActiveXObject) {
4040            try {
4041                return new ActiveXObject('Msxml2.XMLHTTP');
4042            } catch (ex) {
4043                try {
4044                    return new ActiveXObject('Microsoft.XMLHTTP');
4045                } catch (ex) {
4046                }
4047            }
4048        }
4049    }
4050    return null;
4051}
4052
4053function getResultCode(xmlhttp) {
4054    if (xmlhttp.status === 200) {
4055        return 0;
4056    }
4057    if (xmlhttp.status === 403) {
4058        var accountLocked = xmlhttp.getResponseHeader("accountLock");
4059        if (accountLocked) {
4060            return 2;
4061        }
4062        return 1;
4063    }
4064    return 1;
4065}
4066
4067function sendRequest(path, user, pass, callback) {
4068    var xmlhttp = getXmlHttp();
4069    if (!xmlhttp) {
4070        callback(1);
4071        return;
4072    }
4073    if (xmlhttp.readyState < 4) {
4074        try {
4075            xmlhttp.abort();
4076        } catch (e) {
4077        }
4078    }
4079    // send the authentication request
4080    var params = "j_validate=true";
4081    params += "&j_username=" + encodeURIComponent(user);
4082    params += "&j_password=" + encodeURIComponent(pass);
4083    params += "&_charset_=utf8";
4084    params += "&sling:authRequestLogin=1";
4085    xmlhttp.onreadystatechange = function() {
4086        if (xmlhttp.readyState === 4) {
4087            callback(getResultCode(xmlhttp));
4088        }
4089    };
4090    xmlhttp.open('POST', "/j_security_check", true);
4091    xmlhttp.setRequestHeader("Content-type",
4092            "application/x-www-form-urlencoded");
4093    xmlhttp.send(params);
4094}
4095
4096function safeDecode(value) {
4097    try {
4098        return decodeURIComponent(value);
4099    } catch (e) {
4100        return value;
4101    }
4102}
4103
4104function showError(msg) {
4105    
4106    try {
4107        var loginError = document.getElementById("login-error");
4108        loginError.innerHTML = msg;
4109        loginError.className = loginError.className + ' errorDisplay';
4110    } catch (e) {
4111    }
4112}
4113
4114function showErrorOverlay(msg) {
4115    try {
4116        var loginError = document.getElementById("login-error-overlay");
4117        loginError.innerHTML = msg;
4118        loginError.className = loginError.className + ' errorDisplay';
4119    } catch (e) {
4120    }
4121}
4122
4123function getCookieValue(cookieName) {
4124	var cookievalue = checkCookieValue(cookieName);
4125	if (cookievalue == '') {
4126		return '';
4127	} else {
4128		return cookievalue;
4129	}
4130}
4131
4132function checkCookieValue(cookieName) {
4133	var i, name, y, ARRcookies = document.cookie.split(";");
4134	for (i = 0; i < ARRcookies.length; i++) {
4135		name = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
4136		value = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
4137		name = name.replace(/^\s+|\s+$/g, "");
4138		if (name == cookieName) {
4139            return safeDecode(value);
4140		}
4141	}
4142	return '';
4143}
4144
4145function loginuser(failedLoginMessage) {
4146   
4147    document.cookie = 'Status_SF'+ '=;expires=Thu, 01 Jan 1970 00:00:01 UTC;';
4148    document.cookie = 'Info_SF'+ '=;expires=Thu, 01 Jan 1970 00:00:01 UTC;';
4149    clearLoginError('login-error');
4150    var path = document.forms['login'].action;
4151    var user = document.forms['login'].j_username.value;
4152    var pass = document.forms['login'].j_password.value;
4153    var resource = document.forms['login'].resource.value;
4154    // if no user is given, avoid login request
4155    if (!user || !pass) {
4156
4157        showError(errorJsonLogin["LGN_UP_DNM"]);
4158
4159        return false;
4160    }
4161    // send user/id password to check and persist
4162    sendRequest(path, user, pass, function(resultCode) {
4163        if (resultCode == 0) {
4164            //customLinks('thf_en:HeaderNav|', 'Login_login'); Commenting for Sitecatalyst code clean up
4165            $("form#login button").attr("disabled", "disabled");
4166            $("form#login-Overlay button").addClass("disabled");
4167            $("form#login").bind("keypress", function(e) {
4168                if (e.keyCode == 13)
4169                    return false;
4170            });
4171            handleCookie();
4172            redirectPostLogin();
4173        } else if (resultCode == 1) {
4174          //  customLinks('thf_en:HeaderNav|', 'Login_login'); Commenting for Sitecatalyst code clean up
4175            
4176            showError(errorJsonLogin["LGN_UP_DNM"]);
4177            getErrorsLogin();
4178        } else if (resultCode == 2) {
4179            //Wave 1.5. | Change start | Track login failed overlay modal
4180          //  customLinks('thf_en:HeaderNav|', 'Login_login'); Commenting for Sitecatalyst code clean up
4181            
4182            getErrorCodesAndTrackLoginFailureModal();
4183            //Wave 1.5. | Change end | Track login failed overlay modal
4184            $(".loginFailedModal .osx").trigger('click');
4185        }
4186    });
4187    return false;
4188}
4189
4190function loginuserreg(userName, password, currentPage, actionPath) {
4191    var path = actionPath;
4192    var user = userName;
4193    var pass = password;
4194    var resource = currentPage;
4195
4196    // if no user is given, avoid login request
4197    if (!user) {
4198        return false;
4199    }
4200
4201    // send user/id password to check and persist
4202    sendRequest(path, user, pass, function(resultCode) {
4203        if (resultCode == 0) {
4204            var u = resource;
4205            if (window.location.hash && u.indexOf('#') < 0) {
4206                u = u + window.location.hash;
4207            }
4208            handleCookie();
4209        } else if (resultCode == 1) {
4210
4211            showError(errorJsonLogin["LGN_UP_DNM"]);
4212
4213            getErrorsLogin();
4214        } else if (resultCode == 2) {
4215            //Wave 1.5. | Change start | Track login failed overlay modal
4216          //  customLinks('thf_en:HeaderNav|', 'Login_login'); Commenting for Sitecatalyst code clean up
4217            
4218            getErrorCodesAndTrackLoginFailureModal();
4219            //Wave 1.5. | Change end | Track login failed overlay modal
4220            $(".loginFailedModal .osx").trigger('click');
4221        }
4222    });
4223    return false;
4224}
4225
4226function loginuserOverlay(failedLoginMessage) {
4227    // to clear previous login errors
4228    clearLoginError('login-error-overlay');
4229    var path = document.forms['login-Overlay'].action;
4230    var user = document.forms['login-Overlay'].j_username.value;
4231    var pass = document.forms['login-Overlay'].j_password.value;
4232    // if no user is given, avoid login request
4233    if (!user || !pass) {
4234
4235        showErrorOverlay(errorJsonLogin["LGN_UP_DNM"]);
4236        return false;
4237    }
4238    // send user/id password to check and persist
4239    sendRequest(path, user, pass, function(resultCode) {
4240        if (resultCode == 0) {
4241            $("form#login-Overlay button").attr("disabled", "disabled");
4242            $("form#login-Overlay button").addClass("disabled");
4243            $("form#login-Overlay").bind("keypress", function(e) {
4244                if (e.keyCode == 13)
4245                    return false;
4246            });
4247            handleCookie();
4248            redirectPostLogin();
4249        } else if (resultCode == 1) {
4250            
4251            showErrorOverlay(errorJsonLogin["LGN_UP_DNM"]);
4252            getErrorsLogin();
4253        } else if (resultCode == 2) {
4254            //Wave 1.5. | Change start | Track login failed overlay modal
4255           // customLinks('thf_en:HeaderNav|', 'Login_login'); Commenting for Sitecatalyst code clean up
4256            
4257            getErrorCodesAndTrackLoginFailureModal();
4258            //Wave 1.5. | Change end | Track login failed overlay modal
4259            $(".loginFailedModal .osx").trigger('click');
4260         }
4261    });
4262    return false;
4263}
4264
4265function getErrorCodesAndTrackLogin(errorList) {
4266    var errorKeys = "";
4267    for ( var i = 0; i < errorList.length; i++) {
4268        for ( var key in errorJsonLogin) {
4269            if (errorJsonLogin.hasOwnProperty(key)) {
4270                if (errorJsonLogin[key] == errorList[i]) {
4271                    if (errorKeys == "") {
4272                        errorKeys = errorKeys + key;
4273                    } else {
4274                        errorKeys = errorKeys + "|" + key;
4275                    }
4276                }
4277            }
4278        }
4279    }
4280
4281
4282   // s.t();
4283}
4284
4285function getErrorsLogin() {
4286    var errorList = new Array();
4287    $("#login-error").each(function() {
4288        if ($(this).text() != " ") {
4289            errorList.push($(this).text());
4290        }
4291    });
4292    $("#login-error-overlay").each(function() {
4293        if ($(this).text() != " ") {
4294            errorList.push($(this).text());
4295        }
4296    });
4297    getErrorCodesAndTrackLogin(errorList);
4298}
4299
4300function setErrorJsonLogin(jsonarray) {
4301    for ( var i = 0; i < jsonarray["messages"].length; i++) {
4302        var jsonObj = jsonarray["messages"][i];
4303        for ( var key in jsonObj) {
4304            var value = "";
4305            if (jsonObj.hasOwnProperty(key)) {
4306                value = jsonObj[key];
4307                errorJsonLogin[key] = value;
4308            }
4309        }
4310    }
4311}
4312
4313function handleCookie() {
4314    var cookieVal = getCookieValue('sc');
4315    if (cookieVal == null || cookieVal == '' || cookieVal == 'login=false') {
4316        //eraseCookie('sc', -1); Commented for SiteCatalyst code cleanup
4317        //createCookie('sc', 'login=true', 0); Commented for SiteCatalyst code cleanup
4318    } else if (cookieVal.indexOf('open=true') >= 0
4319            && cookieVal.indexOf('login=true') < 0) {
4320        //eraseCookie('sc', -1); Commented for SiteCatalyst code cleanup
4321        //createCookie('sc', 'open=true,login=true', 0); Commented for SiteCatalyst code cleanup
4322    }
4323}
4324
4325function clearSessionCookies() {
4326    document.cookie = 'thfcc'+ '=;expires=Thu, 01 Jan 1970 00:00:01 UTC;';
4327    document.cookie = 'Advisor_infoFrom_SF'+ '=;expires=Thu, 01 Jan 1970 00:00:01 UTC;';
4328    document.cookie = 'Status_SF'+ '=;expires=Thu, 01 Jan 1970 00:00:01 UTC;';
4329    document.cookie = 'Info_SF'+ '=;expires=Thu, 01 Jan 1970 00:00:01 UTC;';
4330    document.cookie = 'Queried_Sf'+ '=;expires=Thu, 01 Jan 1970 00:00:01 UTC;';
4331}
4332
4333function getCsrfToken() {
4334    if (window.Granite && Granite.csrf && Granite.csrf.token) {
4335        return Granite.csrf.token;
4336    }
4337    var csrfMeta = document.querySelector('meta[name="csrf-token"]');
4338    if (csrfMeta) {
4339        return csrfMeta.getAttribute('content');
4340    }
4341    return '';
4342}
4343
4344function logoutRequest(onComplete) {
4345    var uri = thf.utils.secureUrl.url
4346            + "/bin/thf/servlets/AjaxServlet?command=logoutuser";
4347    var csrfToken = getCsrfToken();
4348    var headers = {};
4349    if (csrfToken) {
4350        headers['CSRF-Token'] = csrfToken;
4351    }
4352    jQuery.ajax({
4353        url : uri,
4354        type : 'POST',
4355        data : { command: 'logoutuser' },
4356        contentType : "text/html; charset=utf-8",
4357        dataType : 'html',
4358        headers : headers,
4359        cache : false,
4360        error : function() { 
4361            clearSessionCookies();
4362            onComplete();
4363        },
4364        success : function(data) {
4365            clearSessionCookies();
4366            onComplete();
4367        }
4368    });
4369}
4370
4371function logoutUser() {
4372    logoutRequest(function() {
4373        redirectPostLogout();
4374    });
4375    return false;
4376}
4377
4378function logoutUserSession() {
4379    logoutRequest(function() {
4380    });
4381    return false;
4382}
4383
4384function logoutUserForChangePassword(redirect,currentRole) {
4385    logoutRequest(function() {
4386        targetURL = thf.utils.secureUrl.url + redirect+'.html'+'#showloginoverlay';
4387        window.location.href = targetURL;
4388    });
4389    return false;
4390}
4391
4392$(document).ready(function() {
4393    var errorJsonLoginParam = $.getJSON('/content/thf/en/messages.login.html', function(data) {
4394        setErrorJsonLogin(data);
4395    });
4396});
4397
4398function checkCookie(cookieName)
4399{
4400    var i,name,y,ARRcookies=document.cookie.split(";");
4401    for (i=0;i<ARRcookies.length;i++)
4402    {
4403      name=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
4404      value=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
4405      name=name.replace(/^\s+|\s+$/g,"");
4406      if (name == cookieName)
4407        {   
4408                 return safeDecode(value);
4409        }
4410    }   
4411    return '';
4412}
4413
4414function getCookieVar(cookieName){
4415	var cookievalue =checkCookie(cookieName);
4416    if(cookievalue == ''){
4417    	if(cookieName != 'user') {
4418        	document.cookie=cookieName+"='';path=/";
4419        }
4420        return '';
4421    } else {
4422        return cookievalue;
4423    }
4424}
4425
4426/*
4427 * reloads the same URL on the secure domain.
4428 */
4429 function redirectPostLogin() {
4430
4431	if(window.location.href.indexOf('funds.html') != -1 || window.location.href.indexOf('etfs.html') != -1){
4432		document.cookie = "linkDoc=" + window.location.href + "; expires; path=/"
4433	}
4434
4435    var linkDocCookie = getCookieVar('linkDoc');
4436
4437    var extensionredirect = window.location.href;
4438
4439    extensionredirect = extensionredirect.split('?')[1];
4440
4441    targetURL = thf.utils.secureUrl.url + location.pathname
4442            + window.location.search;
4443    
4444    
4445    if (extensionredirect != 'undefined' && extensionredirect != undefined && extensionredirect != null) {
4446
4447        if (extensionredirect.indexOf("profile-pages") !== -1 || extensionredirect.indexOf("cart-pages") !== -1 || extensionredirect.indexOf("auth") !== -1) {
4448
4449            extensionredirect = extensionredirect.replace("rtype=", "");
4450
4451            extensionredirect = extensionredirect.replace("#showloginWindow", "");
4452            
4453            extensionredirect = extensionredirect.replace("/showloginWindow", "");
4454
4455            if (extensionredirect.indexOf("auth") !== -1  && extensionredirect.indexOf("auth-pages") == -1) {
4456
4457                extensionredirect = extensionredirect.replace(".html", "");
4458
4459            }
4460
4461            targetURL = thf.utils.secureUrl.url + extensionredirect;
4462        }
4463    }
4464    if (targetURL.indexOf('sessionTimeout=true') != -1) {
4465        window.location.href = '/home.html';
4466    } else {
4467        if ((extensionredirect != 'undefined' && extensionredirect != undefined && extensionredirect != null) && (extensionredirect.indexOf("profile-pages") !== -1 || extensionredirect.indexOf("cart-pages") !== -1 || extensionredirect.indexOf("auth") !== -1 || extensionredirect.indexOf("segmentation") !== -1)) {
4468            window.location.href = targetURL;
4469        }
4470        else {
4471            Cookies.remove('linkDoc', { path: '/' });
4472            var hostname = window.location.host;
4473            var protocol = window.location.protocol;
4474            
4475            protocol = protocol + "//" + hostname;
4476            if (linkDocCookie != 'undefined' && linkDocCookie != undefined && linkDocCookie != null && linkDocCookie != '')
4477            {
4478                if (linkDocCookie.indexOf(protocol) !== -1) {
4479                    linkDocCookie = linkDocCookie.replace("#showlogin", "");
4480                    if ((linkDocCookie.indexOf('.pptx') !== -1) || (linkDocCookie.indexOf('.docx') !== -1) || (linkDocCookie.indexOf('.doc') !== -1) || (linkDocCookie.indexOf('.pdf') !== -1) || (linkDocCookie.indexOf('.xls') !== -1)) {
4481                        window.location.reload();
4482                       if((linkDocCookie.indexOf('/docs/auth/') !== -1) || (linkDocCookie.indexOf('auth-pages') !== -1)){
4483                        window.open(linkDocCookie);
4484                        }
4485                    } else {
4486                        //linkDocCookie = linkDocCookie.replace("#", "");
4487                        //linkDocCookie = linkDocCookie.split("#",1);
4488                        if( targetURL.indexOf("searchResult.html")!== -1 ){
4489                        	window.location.href = targetURL;
4490                            window.location.replace(linkDocCookie);
4491                            window.location.reload();
4492                        } else if(window.location.href.indexOf("funds.html") !== -1 || window.location.href.indexOf("etfs.html") !== -1) {
4493                        	document.cookie = "linkDoc=" + window.location.href + "; expires; path=/"
4494                        	//linkDocCookie = getCookieVar('linkDoc');
4495                        	//window.location.replace(linkDocCookie);
4496                        	window.location.reload();
4497                        }
4498                        else{
4499                        	window.location.replace(linkDocCookie);
4500                        	if (linkDocCookie.indexOf("#") !== -1) {
4501                        		window.location.reload();
4502                        	}
4503                        }
4504                    }
4505                } else if(linkDocCookie.indexOf(protocol) == -1) {
4506                    window.location.reload();
4507                    //window.open(linkDocCookie);
4508                } else if (linkDocCookie.indexOf("http") !== -1) {
4509                    linkDocCookie = linkDocCookie.replace("http", "https");
4510
4511                    if ((linkDocCookie.indexOf('.pptx') !== -1) || (linkDocCookie.indexOf('.docx') !== -1) || (linkDocCookie.indexOf('.doc') !== -1) || (linkDocCookie.indexOf('.pdf') !== -1) || (linkDocCookie.indexOf('.xls') !== -1)) {
4512    
4513                        window.location.reload();
4514                        //window.open(linkDocCookie);
4515                    } else {
4516                    
4517                        window.location.replace(linkDocCookie);
4518                    }
4519    
4520                } else {
4521                    linkDocCookie = protocol + linkDocCookie;
4522                    linkDocCookie = linkDocCookie.replace("#showlogin", "");
4523    
4524                    if ((linkDocCookie.indexOf('.pptx') !== -1) || (linkDocCookie.indexOf('.docx') !== -1) || (linkDocCookie.indexOf('.doc') !== -1) || (linkDocCookie.indexOf('.pdf') !== -1) || (linkDocCookie.indexOf('.xls') !== -1)) {
4525    
4526                        window.location.reload();
4527                        //window.open(linkDocCookie);
4528                    }  else {
4529             
4530                        window.location.replace(linkDocCookie);
4531                    }
4532    
4533                }           
4534            
4535            }
4536            else
4537            {
4538                window.location.reload();
4539            }
4540        }
4541    }
4542}
4543
4544function deleteCookie(name)
4545{
4546    var d = new Date();
4547    var cookieval=getCookieVar(name);
4548    document.cookie = name + "=" + cookieval + ";expires=" + d.toGMTString() + ";" + ";";
4549}    
4550/*
4551 * reloads the same URL on the non secure domain.
4552 */
4553function redirectPostLogout() {
4554     targetURL = thf.utils.baseUrl.url + location.pathname
4555            + window.location.search;
4556    if(timerRef) {
4557        clearTimeout(timerRef);
4558    }
4559     
4560        if(targetURL.indexOf("profile-pages") !== -1 || targetURL.indexOf("cart-pages") !== -1 || targetURL.indexOf("auth") !== -1) { 
4561            targetURL = thf.utils.baseUrl.url + '/home.html'; 
4562      window.location.href = targetURL;
4563          }  else {
4564          window.location.href = targetURL;
4565          }  
4566}
4567//Wave 1.5. | Change start | Track login failed overlay modal
4568function getErrorCodesAndTrackLoginFailureModal() {
4569    var errorList = new Array();
4570    $("#login-error").each(function() {
4571        if ($(this).text() != " ") {
4572            errorList.push($(this).text());
4573        }
4574    });
4575    $("#login-error-overlay").each(function() {
4576        if ($(this).text() != " ") {
4577            errorList.push($(this).text());
4578        }
4579    });
4580    var errorKeys = "";
4581    for ( var i = 0; i < errorList.length; i++) {
4582        for ( var key in errorJsonLogin) {
4583            if (errorJsonLogin.hasOwnProperty(key)) {
4584                if (errorJsonLogin[key] == errorList[i]) {
4585                    if (errorKeys == "") {
4586                        errorKeys = errorKeys + key;
4587                    } else {
4588                        errorKeys = errorKeys + "|" + key;
4589                    }
4590                }
4591            }
4592        }
4593    }
4594
4595    var errArr = errorKeys.split('|');
4596
4597   // s.t();
4598}
4599
4600
4601//Wave 1.5. | Change end | Track login failed overlay modal
4602/*
4603 * clears errors for the given element id
4604 */
4605function clearLoginError(elementId){
4606
4607    $.fn.hasAttr = function(name) {  
4608   return this.attr(name) !== undefined;
4609};
4610
4611    var loginError = document.getElementById(elementId);
4612        if(!$('#login-error-overlay').hasAttr('ejuser')){
4613
4614            if(loginError){
4615         loginError.innerHTML = '';
4616            }
4617
4618
4619    $(loginError).removeClass('errorDisplay');
4620    $(loginError).css({"display": "none"});
4621
4622         $("#overlay_password").removeAttr("disabled");
4623         $("#login.proceedBtn").removeAttr("disabled");
4624         $("#login.proceedBtn").removeClass("disabled");
4625         $("#login.proceedBtn.readmorebigLogin").removeAttr("style");
4626         $("#login-error-overlay").removeAttr("ejuser");
4627}
4628
4629}
4630
4631function checkLen(val){
4632
4633   if(val.length == 0){
4634    clearLoginError('login-error');
4635
4636       clearLoginError('login-error-overlay');
4637
4638        $("#overlay_password").removeAttr("disabled");
4639
4640
4641         $("#login.proceedBtn").removeAttr("disabled");
4642         $("#login.proceedBtn").removeClass("disabled");
4643
4644
4645        $("#login.proceedBtn.readmorebigLogin").removeAttr("style");
4646
4647        $("#login-error-overlay").removeAttr("ejuser");
4648        $("#defaultChecked").removeAttr("disabled");
4649
4650       $("#ejalert").empty();
4651
4652       $("#login-error-overlay").removeClass("errorDisplay");
4653
4654
4655
4656   }
4657    if(val.length>0 && val.length<=100){
4658
4659   /* var emailRGEX = /^[A-Za-z0-9._%+-][email protected]$/;
4660
4661      var ejFlag=emailRGEX.test(val);
4662
4663        if(ejFlag){
4664
4665
4666
4667         $("#login-error-overlay").attr("ejuser","ejuser");
4668
4669              $("#overlay_password").val("");
4670
4671         $("#overlay_password").attr("disabled", "disabled");
4672
4673            $(".checkbox").addClass("disableChckBx");
4674
4675         $("#defaultChecked").attr("disabled", "disabled");
4676
4677             $(".readmorebigLogin").css("background","#e9ecef");
4678
4679             $(".readmorebigLogin").css("color", "#fff");
4680
4681             $(".readmorebigLogin").css("border","#e9ecef");
4682
4683             $("#login.proceedBtn.readmorebigLogin").attr("disabled", "disabled");
4684
4685
4686
4687            showErrorOverlay('<span id="ejalert"> Attention Edward Jones Representatives: to access this website, you must <a href="#">login via JonesLink</a>.</span>');
4688
4689
4690
4691
4692        }else{
4693
4694            $("#overlay_password").removeAttr("disabled");
4695
4696         $("#defaultChecked").removeAttr("disabled");
4697
4698             $(".checkbox").removeClass("disableChckBx");
4699
4700         $("#login.proceedBtn").removeAttr("disabled");
4701         $("#login.proceedBtn").removeClass("disabled");
4702
4703
4704          $("#login.proceedBtn.readmorebigLogin").removeAttr("style");
4705
4706              $("#login-error-overlay").removeAttr("ejuser");
4707
4708              //$("#login-error-overlay").removeClass('errorDisplay');
4709
4710             //$("#login-error-overlay").css("display","none");
4711
4712             $("#ejalert").empty();
4713
4714        }*/
4715
4716    }
4717
4718    if(val.length>100){
4719        showErrorOverlay('Please enter username below 100 characters');
4720    }
4721
4722
4723}
4724
4725function change_check_box(){
4726
4727 $(".checkbox").addClass("addborder");
4728
4729}
4730
4731var thf = window.thf || {};
4732(function(window, document, $, thf) {
4733	thf.modalWindow = {
4734		// callback function		
4735		modalOnShow: function(dialog){
4736			    var s = this; // refers to the simplemodal object
4737				$('.link', dialog.data[0]).click(function () { // use the modal data context
4738				  var id = '#' + this.id + '-modal'; // dynamically determine the modal content id based on the link id
4739				  s.close(); // close the current dialog
4740			
4741				  setTimeout(function () { // wait for 6/10ths of a second, then open the next dialog
4742					$(id).modal({
4743					  overlayClose: true,
4744					  onShow: modalOnShow,
4745					  onOpen: modalOpen,
4746					  onClose: modalClose
4747					});
4748				  }, 600);
4749			
4750				  return false;
4751				});
4752			},
4753		// callback function	
4754		  modalOpen: function(dialog){
4755			dialog.overlay.fadeIn(200, function () {
4756			  dialog.data.hide();
4757			  dialog.container.fadeIn(100, function () {
4758				dialog.data.fadeIn(100);
4759			  });
4760			});
4761		  },
4762		  // callback function
4763		  modalClose: function(dialog){
4764			dialog.data.fadeOut(100, function () {
4765			  dialog.container.fadeOut(100, function () {
4766				dialog.overlay.fadeOut(200, function () {
4767				  $.modal.close();
4768				});
4769			  });
4770			});
4771		  } 		  
4772	}
4773}(window, document, jQuery, thf));	
4774
4775
4776//Select fill
4777var thf = window.thf || {};
4778var role="";
4779var emailExistsError = "";
4780var action = "";
4781var resourceStr = "";
4782
4783Array.prototype.contains = function(obj) {
4784    var i = this.length;
4785    while (i--) {
4786        if (this[i] == obj) {
4787            return true;
4788        }
4789    }
4790    return false;
4791};
4792
4793var errorCodes = [];
4794
4795(function(window, document, $, thf) {
4796    var errorJson = [];
4797    thf.registerAction = {
4798        // this method is called to populate role checkbox on click event
4799        fillselect: function () {
4800            FinancialAdvisorData('financial-advisors');
4801            function FinancialAdvisorData(duration) {
4802                $.getJSON('/bin/thf/servlets/tagvalues.role.json', function(data) {
4803                    $.each(data[duration], function(index, dataItem) {
4804                        var dataLength = $(".selectList .form-select-wrapper ul li").length + index;
4805                        $("input#CheckboxGroup1_0").click(function () {
4806                            if($(this).prop('checked')) {
4807                                thf.registerAction.hideAll();
4808                                if ($("div.crd1 .form-input-wrapper").hasClass("disable")) {
4809                                    $("div.crd1 .form-input-wrapper").removeClass("disable");
4810                                    $("span.linkNote a").removeClass("disableLink").css({"cursor": "link"});
4811                                    $("div.crd1 label").removeClass("disableLink");
4812                                    $("input#registerForm_crd1").removeClass("disableTextBox");
4813                                    $("input#registerForm_crd1").removeAttr("disabled");
4814                                }
4815                                $('#crdInfo, .crd, .noCrdLink').show();
4816                                $(".selectList .form-select-wrapper ul li").remove('.financialAdvisor');
4817                                $(".selectList select option").remove('.financialAdvisor');
4818                            }else {
4819                                $(".selectList .form-select-wrapper ul").append($('<li class="financialAdvisor"><a href="#" index="'+dataLength+'">'+ dataItem.optionType +'</a></li>'));
4820                                $(".selectList select").append($('<option class="financialAdvisor" value="'+dataItem.optionType+'">'+ dataItem.optionType +'</option>'));
4821                            }
4822                        });
4823                    });
4824                });
4825            }
4826            InstitutionalInvestorData('institutional-investors');
4827            function InstitutionalInvestorData(duration) {
4828                $.getJSON('/bin/thf/servlets/tagvalues.role.json', function(data) {
4829                    $.each(data[duration], function(index, dataItem) {
4830                        $("input#CheckboxGroup1_1").click(function () {
4831                            if($(this).prop('checked')) {
4832                                $(".selectList .form-select-wrapper ul li").remove('.institutionalInvestor');
4833                                $(".selectList select option").remove('.institutionalInvestor');
4834                            } else {
4835                                $(".selectList .form-select-wrapper ul").append($('<li class="institutionalInvestor"><a href="#">
4835'+ dataItem.optionType +'</a></li>'));
4836                                $(".selectList select").append($('<option class="institutionalInvestor" value="'+dataItem.optionType+'">'+ dataItem.optionType +'</option>'));
4837                            }
4838                        });
4839                    });
4840                });
4841            }
4842        },
4843        showNextButton: function() {
4844            $("#CheckboxGroup1_1").on("click",function() {
4845                thf.registerAction.hideAll();
4846                $("#actionButtons .registerBtn").toggle();
4847                $("#actionButtons .nextBtn").toggle();
4848                $(".selectList").show();
4849                var bothDeselected = false;
4850                if($('#CheckboxGroup1_1').attr('checked') && $('#CheckboxGroup1_0').attr('checked')) {
4851                    $('#crdInfo').show();
4852                    $('.crd').show();
4853                    $('.noCrdLink').show();
4854                    $("div.crd1 .form-input-wrapper").removeClass("disable");
4855                    $("span.linkNote a").removeClass("disableLink").css({"cursor": "link"});
4856                    $("div.crd1 label").removeClass("disableLink");
4857                    $("input#registerForm_crd1").removeClass("disableTextBox");
4858                    $("input#registerForm_crd1").removeAttr("disabled");
4859                }else if(!$('#CheckboxGroup1_1').attr('checked') && !$('#CheckboxGroup1_0').attr('checked')) {
4860                    thf.registerAction.realignCompany();
4861                    $('#companyDetails').hide();
4862                    $('#branchId').hide();
4863                    $('.companyNameOrBranch').hide();
4864                }else if(!$('#CheckboxGroup1_1').attr('checked') && $('#CheckboxGroup1_0').attr('checked')) {
4865                    $('#crdInfo').show();
4866                }else if($('#CheckboxGroup1_1').attr('checked') && !$('#CheckboxGroup1_0').attr('checked')) {
4867                    $('#crdInfo').show();
4868                    bothDeselected = true;
4869                }
4870                if(!bothDeselected){
4871                    thf.registerAction.checkIfBothClicked();
4872                }
4873            });
4874        },
4875        hideAll: function () {
4876            $('#companyDetails').hide();
4877            $('#registerForm_crd1').val('');
4878            $('#crdInfo').hide();
4879            $("#utilField").hide();
4880        },
4881        setRole: function (roleParam) {
4882            role = roleParam;
4883        },
4884        setAction: function (actionString, resourceString) {
4885            action = actionString;
4886            resourceStr = resourceString;
4887        },
4888        setErrorJson: function (jsonarray) {
4889            for(var i = 0; i < jsonarray["messages"].length; i++) {
4890                var jsonObj = jsonarray["messages"][i]; 
4891                for(var key in jsonObj) {
4892                    var value = "";
4893                    if(jsonObj.hasOwnProperty(key)) {
4894                        value = jsonObj[key];
4895                        errorJson[key] = value;
4896                    }
4897                }
4898            }
4899        },
4900        realignCompany: function() {
4901            var companyNameHTML = $("#companyName").html();
4902            $("#utilField").html(companyNameHTML);
4903            $('#crdInfo').hide();
4904            $("#utilField").show();
4905            thf.registerAction.companyNameCrd();
4906        },
4907        /*Check if both the checkboxes are selected*/
4908        checkIfBothClicked: function () {
4909            if(!$('#CheckboxGroup1_1').attr('checked') && $('#CheckboxGroup1_0').attr('checked') || $('#CheckboxGroup1_1').attr('checked') && !$('#CheckboxGroup1_0').attr('checked')) {
4910                $('.crd, #crdInfo,.noCrdLink,#companyDetails,#companyName').show();
4911                $('#branchId, .companyNameOrBranch').hide();
4912                if ($("div.crd1 .form-input-wrapper").hasClass("disable")) {
4913                    $("div.crd1 .form-input-wrapper").removeClass("disable");
4914                    $("span.linkNote a").removeClass("disableLink").css({"cursor": "link"});
4915                    $("div.crd1 label").removeClass("disableLink");
4916                    $("input#registerForm_crd1").removeClass("disableTextBox");
4917                    $("input#registerForm_crd1").removeAttr("disabled");
4918                }
4919                return true;
4920            }
4921        },
4922        /*Check if both the checkboxes are selected*/
4923        checkIfBothSelectedNext: function () {
4924            if($('#CheckboxGroup1_1').attr('checked') && $('#CheckboxGroup1_0').attr('checked')) {
4925                return true;
4926            }
4927        },
4928        /*executed when Financial Adv is clicked*/
4929        deselectFa: function () {
4930            $("#CheckboxGroup1_0").on("click",function() {
4931                thf.registerAction.hideAll();
4932                $(".selectList").show();
4933                $('#crdInfo').show();
4934                var bothDeselected = false;
4935                if($('#CheckboxGroup1_1').attr('checked') && $('#CheckboxGroup1_0').attr('checked')) {
4936                    thf.registerAction.realignCompany();
4937                    $('.companyNameOrBranch').hide();
4938                    $('#companyDetails').hide();
4939                    $('#branchId').hide();
4940                }else if(!$('#CheckboxGroup1_1').attr('checked') && !$('#CheckboxGroup1_0').attr('checked')) {
4941                    $("input#registerForm_crd1").val('');
4942                    $('#crdInfo').show();
4943                    $('.crd').show();
4944                    $('.noCrdLink').show();
4945                    $("div.crd1 .form-input-wrapper").removeClass("disable");
4946                    $("span.linkNote a").removeClass("disableLink").css({"cursor": "link"});
4947                    $("div.crd1 label").removeClass("disableLink");
4948                    $("input#registerForm_crd1").removeClass("disableTextBox");
4949                    $("input#registerForm_crd1").removeAttr("disabled");
4950                }else if(!$('#CheckboxGroup1_1').attr('checked') && $('#CheckboxGroup1_0').attr('checked')) {
4951                    $('#crdInfo').show();
4952                    $('.companyNameOrBranch').show();
4953                }else if(!$('#CheckboxGroup1_1').attr('checked') && $('#CheckboxGroup1_0').attr('checked')) {
4954                    bothDeselected = true;
4955                    $('#crdInfo').hide();
4956                }
4957                if(!bothDeselected) {
4958                    thf.registerAction.checkIfBothClicked();
4959                }
4960            });
4961        },
4962        companyNameCrd: function () {
4963            $("#registerForm_companyName").autocomplete({
4964                source: function(request, response) {
4965                    var filterString = request.term.charAt(0);
4966                    var url = '/bin/thf/servlets/tagvalues.' + filterString + '.company.json'; 
4967                    $.getJSON(url, function(data) {
4968                        var qLowerCase = request.term.toLowerCase();
4969                        var qLowerCaseRegEx = "^" + qLowerCase;
4970                        var maxcount = 5;
4971                        var counter = 0;
4972                        data.companyList = data.companyList.sort();
4973                        response($.map(data.companyList, function(item) {
4974                            var companyNameLowerCase = item.companyName.toLowerCase();
4975                            if(companyNameLowerCase.match(qLowerCaseRegEx)) {
4976                                counter++;
4977                                if(counter <= maxcount) {
4978                                    return item;
4979                                }
4980                            }
4981                        }));
4982                    });
4983                },
4984                minLength: 1,
4985                appendTo: "div.companyName1",
4986                select: function(event, ui) {
4987                    $('#registerForm_companyName').val(ui.item.companyName);
4988                    return false;
4989                },
4990                change : function(event,ui) {
4991                    if(!ui.item) {
4992                        $(this).val("");
4993                        $('#registerForm_companyName').valid();
4994                    }
4995                }
4996            }).data("ui-autocomplete")._renderItem = function(ul, item) {
4997                return $( "<li></li>" ).data("ui-autocomplete-item", item).append( $("<a>"+item.companyName+"</a>").html(item.companyName)).appendTo('ul.ui-autocomplete');
4998            };            
4999        },
5000        companyNameCrd1: function () {
5001            $("#registerForm_companyName1").autocomplete({
5002                source: function(request, response) {
5003                    var filterString = request.term.charAt(0);
5004                    var url = '/bin/thf/servlets/tagvalues.' + filterString + '.company.json';
5005                    $.getJSON(url, function(data) {
5006                        var qLowerCase = request.term.toLowerCase();
5007                        var qLowerCaseRegEx = "^" + qLowerCase;
5008                        var maxcount = 5;
5009                        var counter = 0;
5010                        response($.map(data.companyList, function(item) {
5011                            var companyNameLowerCase = item.companyName.toLowerCase();
5012                            if(companyNameLowerCase.match(qLowerCaseRegEx)) {
5013                                counter++;
5014                                if(counter <= maxcount) {
5015                                    return item;
5016                                }
5017                            }
5018                        }));
5019                    });
5020                },
5021                minLength: 1,
5022                appendTo: "div.companyName2",
5023                select: function(event, ui) {
5024                    $('#registerForm_companyName1').val(ui.item.companyName);
5025                    return false;
5026                },
5027                change : function(event,ui) {
5028                    if(!ui.item) {
5029                        $(this).val("");
5030                        $('#registerForm_companyName1').valid();
5031                    }
5032                }
5033            }).data("ui-autocomplete")._renderItem = function(ul, item) {
5034                return $( "<li></li>" ).data("ui-autocomplete-item", item).append( $("<a>"+item.companyName+"</a>").html(item.companyName)).appendTo('ul.ui-autocomplete');
5035            };
5036        },
5037        companyNameCrd2: function () {
5038            $("#registerForm_companyName2").autocomplete({
5039                source: function(request, response) {
5040                    var filterString = request.term.charAt(0);
5041                    var url = '/bin/thf/servlets/tagvalues.' + filterString + '.company.json';
5042                    $.getJSON(url, function(data) {
5043                        var qLowerCase = request.term.toLowerCase();
5044                        var qLowerCaseRegEx = "^" + qLowerCase;
5045                        var maxcount = 5;
5046                        var counter = 0;
5047                        response($.map(data.companyList, function(item) {
5048                            var companyNameLowerCase = item.companyName.toLowerCase();
5049                            if(companyNameLowerCase.match(qLowerCaseRegEx)) {
5050                                counter++;
5051                                if(counter <= maxcount) {
5052                                    return item;
5053                                }
5054                            }
5055                        }));
5056                    });
5057                },
5058                minLength: 1,
5059                appendTo: "div.companyName3",
5060                select: function(event, ui) {
5061                    $('#registerForm_companyName2').val(ui.item.companyName);
5062                    $(".selectList1 select").html("<option value=''>SELECT CITY</option>");
5063                    $(".selectList1 select").attr('disabled', 'disabled');
5064                    $(".showCityLoading").show();
5065                    var companyName = ui.item.companyName;
5066                    var cName = companyName.replace("&", "replacetext"); 
5067                    var url = '/bin/thf/servlets/tagvalues.'+ cName +'.city.json?city=' + cName	;          
5068                    $.getJSON(url, function(data) {
5069                        $.each(data['cityList'], function(index, dataItem) {
5070                            var city = dataItem.cityName;
5071                            var cityName = city.toUpperCase();
5072                            $(".selectList1 select").append($('<option value="'+cityName +'">'+ cityName +'</option>'));                                           
5073                        });   
5074                        setTimeout( function(){
5075                            $(".selectList1 select").removeAttr('disabled');                 
5076                            $(".showCityLoading").hide();}, 1000);                   
5077                    }).fail(function( jqxhr, textStatus, error ) {
5078                        $(".showCityLoading").hide();
5079                    });    
5080                    return false;
5081                },
5082                change : function(event,ui) {
5083                    if(!ui.item) {
5084                        $(this).val("");
5085                        $(".selectList1 select").html("<option value=''>SELECT CITY</option>");
5086                        $(".selectList1 select").attr('disabled', 'disabled');
5087                        $('#registerForm_companyName2').valid();
5088                    } 
5089                }
5090            }).data("ui-autocomplete")._renderItem = function(ul, item) {
5091                return $( "<li></li>" ).data("ui-autocomplete-item", item).append( $("<a>"+item.companyName+"</a>").html(item.companyName)).appendTo('ul.ui-autocomplete');
5092            };
5093        },
5094        companyNameCrd3: function () {
5095            $("#registerForm_companyName3").autocomplete({
5096                source: function(request, response) {
5097                    var filterString = request.term.charAt(0);
5098                    var url = '/bin/thf/servlets/tagvalues.' + filterString + '.company.json';
5099                    $.getJSON(url, function(data) {
5100                        var qLowerCase = request.term.toLowerCase();
5101                        var qLowerCaseRegEx = "^" + qLowerCase;
5102                        var maxcount = 5;
5103                        var counter = 0;
5104                        response($.map(data.companyList, function(item) {
5105                            var companyNameLowerCase = item.companyName.toLowerCase();
5106                            if(companyNameLowerCase.match(qLowerCaseRegEx)) {
5107                                counter++;
5108                                if(counter <= maxcount) {
5109                                    return item;
5110                                }
5111                            }
5112                        }));
5113                    });
5114                },
5115                minLength: 1,
5116                appendTo: "div.companyName4",
5117                select: function(event, ui) {
5118                    $('#registerForm_companyName3').val(ui.item.companyName);
5119                    $(".selectList2 select").html("<option value=''>SELECT CITY</option>");
5120                    $(".selectList2 select").attr('disabled', 'disabled');
5121                    $(".showCityLoading1").show();
5122                    var companyName = ui.item.companyName;
5123                    var cName = companyName.replace("&", "replacetext"); 
5124                    var url = '/bin/thf/servlets/tagvalues.'+ cName +'.city.json?city=' + cName	;           
5125                    $.getJSON(url, function(data) {                        
5126                        $.each(data['cityList'], function(index, dataItem) {
5127                            var city = dataItem.cityName;
5128                            var cityName = city.toUpperCase();
5129                            $(".selectList2 select").append($('<option value="'+cityName+'">'+ cityName +'</option>'));                                      
5130                        });
5131                        setTimeout( function(){
5132                            $(".selectList2 select").removeAttr('disabled');                 
5133                            $(".showCityLoading1").hide();}, 1000);                
5134                    }).fail(function( jqxhr, textStatus, error ) {
5135                        $(".showCityLoading1").hide();
5136                    });
5137                    return false;
5138                },
5139                change : function(event,ui) {
5140                    if(!ui.item) {
5141                        $(this).val("");
5142                        $(".selectList2 select").html("<option value=''>SELECT CITY</option>");
5143                        $(".selectList2 select").attr('disabled', 'disabled');
5144                        $('#registerForm_companyName3').valid();
5145                    }
5146                }
5147            }).data("ui-autocomplete")._renderItem = function(ul, item) {
5148                return $( "<li></li>" ).data("ui-autocomplete-item", item).append( $("<a>"+item.companyName+"</a>").html(item.companyName)).appendTo('ul.ui-autocomplete');
5149            };
5150        },
5151        crdDetail: function () {
5152            if($('#CheckboxGroup1_1').attr('checked')){
5153                $("fieldset#companyDetails").css({"display": "block"});
5154            }
5155            else{
5156            $("fieldset#companyDetails").css({"display": "none"});
5157            }
5158            $("div.crd1 .form-input-wrapper").removeClass("disable");
5159            $("div.crd1 label").removeClass("disableLink");
5160            $("span.linkNote a").click(function(e) {
5161                e.preventDefault();
5162                $(this).addClass("disableLink");
5163                $("div.crd1 label").addClass("disableLink").css({"cursor": "text"});
5164                $("fieldset#companyDetails,#branchId, .companyNameOrBranch").css({"display": "block"});
5165                $("div.crd1 .form-input-wrapper").addClass("disable");
5166                if($("#registerForm_crd1").parents("div.form-input-wrapper").hasClass("error")){
5167                    $("#registerForm_crd1").parents("div.form-input-wrapper").removeClass("error");
5168                    $("#registerForm_crd1").parents("div.form-input-wrapper").siblings("label").removeClass("error");                  
5169                }
5170                $("div.branchDetail .form-input-wrapper").css({"width": "300px"});
5171                $("input#registerForm_crd1").addClass("disableTextBox").attr("disabled", "disabled");
5172                $("input#registerForm_crd1").val('');
5173            });
5174        },
5175        changeSubRole: function() {
5176            $("#subrole").change(function() {
5177                var clickStatus = thf.registerAction.checkIfBothSelectedNext();
5178                if(clickStatus) {
5179                    thf.registerAction.validateSubrole();
5180                }
5181            });
5182        },
5183        validateSubrole: function() {
5184            var clickStatus = thf.registerAction.checkIfBothSelectedNext();
5185            if(clickStatus) {
5186                if($("#subrole").val() === "default") {
5187                    $("#osx-modal-data form[name='registerForm'] .scfValidationSummaryRegister").append('<label id="subrolelabel" for="subrole" generated="true" class="" ><strong>Enter a sub role</strong></label>');
5188                    return false;
5189                } else {
5190                    $("#osx-modal-data form[name='registerForm'] .scfValidationSummaryRegister label#subrolelabel").css('display','none');
5191                    return true;
5192                }
5193            }
5194        },
5195        // Copy-paste disable
5196        disableCopy: function () {
5197            $('#registerForm_emailAddress, #registerForm_conEmailAddress').bind('copy paste', function(e) {
5198                e.preventDefault();
5199            });
5200        },
5201        changeDropdownValue: function(){
5202            $('#subrole').change(function(){
5203                if($('#subrole').val() == 'Sales Assistant'){
5204                    $("#registerForm_crd1").parents("div.form-input-wrapper").removeClass("error");
5205                    $("#registerForm_crd1").parents("div.form-input-wrapper").siblings("label").removeClass("error");
5206                }else{
5207                    $("#registerForm_crd1").parents("div.form-input-wrapper").addClass("error");
5208                    $("#registerForm_crd1").parents("div.form-input-wrapper").siblings("label").addClass("error");
5209                }
5210            });
5211
5212        },
5213       validateRegisterInitiationModal: function () {
5214            //Form validator
5215            var validator = $("form[name='registerForm']").validate({
5216                onfocusout: injectTrim($.validator.defaults.onfocusout),
5217                rules: {
5218                    emailAddress: {
5219                        required: true,
5220                        email: true,
5221                        maxlength: 60,
5222
5223                    },                  
5224                    subRole: {
5225                        required: true
5226                    },
5227                    "firstName": {
5228                        required: true,
5229                        validName:true,
5230                        checkName:true,                             
5231                        maxlength: 20,
5232
5233                    },
5234                    firstName1: {
5235                        required: true,
5236                        validName:true,
5237                        checkName:true,                             
5238                        maxlength: 20,
5239
5240                    },
5241                    firstName2: {
5242                        required: true,
5243                        validName:true,
5244                        checkName:true,                             
5245                        maxlength: 20,
5246
5247                    },
5248                    firstName3: {
5249                        required: true,
5250                        validName:true,
5251                        checkName:true,                             
5252                        maxlength: 20,
5253
5254                    },
5255                    lastName: {
5256                        required: true,
5257                        validName:true,
5258                        checkName:true,                             
5259                        maxlength: 30,
5260
5261                    },
5262                    lastName1: {
5263                        required: true,
5264                        validName:true,
5265                        checkName:true,                             
5266                        maxlength: 30,
5267
5268                    },
5269                    lastName2: {
5270                        required: true,
5271                        validName:true,
5272                        checkName:true,                             
5273                        maxlength: 30,
5274
5275                    },
5276                    lastName3: {
5277                        required: true,
5278                        validName:true,
5279                        checkName:true,                             
5280                        maxlength: 30,
5281
5282                    },
5283                    crd1: {
5284                        required: true
5285                    },
5286                    crd2: {
5287                        required: {
5288                            depends: function(element) {
5289                                return ($('#registerForm_companyName3').val() === '');
5290                            }
5291                        }
5292                    },
5293                    companyName: {
5294                        required: true,
5295                        notEqualToReg: ['#registerForm_emailAddress'],
5296                        maxlength:80
5297                    },
5298                    companyName1: {
5299                        required: true,
5300                        notEqualToReg: ['#registerForm_emailAddress'],
5301                        maxlength:80
5302                    },
5303                    companyName2: {
5304                        required: true,
5305                        notEqualToReg: ['#registerForm_emailAddress'],
5306                        maxlength:80
5307                    },
5308                    companyName3: {
5309                        required: {
5310                            depends: function(element) {
5311                                return ($('#registerForm_crd2').val() === '');
5312                            }
5313                        },
5314                        notEqualToReg: ['#registerForm_emailAddress'],
5315                        maxlength:80
5316                    },
5317                    city1: {
5318                        required: true,
5319                        maxlength:30
5320                    },
5321                    city2: {
5322                        required: {
5323                            depends: function(element) {
5324                                return ($('#registerForm_crd2').val() === '');
5325                            }
5326                        },
5327                        maxlength:30
5328                    },
5329                    password: {
5330                        required: true,
5331                        checkNoSpace:true,                        
5332                        containsAtLeastOneDigit: true,
5333                        containsAtLeastOneLetter: true,
5334                        notEqualToReg: ['#registerForm_emailAddress'],
5335                        minlength:8                     
5336                    },
5337                    password1: {
5338                        required: true,
5339                        checkNoSpace:true,                        
5340                        containsAtLeastOneDigit: true,
5341                        containsAtLeastOneLetter: true,
5342                        notEqualToReg: ['#registerForm_emailAddress'],
5343                        minlength:8                     
5344                    },
5345                    password2: {
5346                        required: true,
5347                        checkNoSpace:true,                        
5348                        containsAtLeastOneDigit: true,
5349                        containsAtLeastOneLetter: true,
5350                        notEqualToReg: ['#registerForm_emailAddress'],
5351                        minlength:8                     
5352                    },
5353                    confirmPassword: {
5354                        required: true,
5355                        equalTo: "#registerForm_password"
5356                    },
5357                    confirmPassword1: {
5358                        required: true,
5359                        equalTo: "#registerForm_password1"
5360                    },
5361                    confirmPassword2: {
5362                        required: true,
5363                        equalTo: "#registerForm_password2"
5364                    }
5365                },
5366               messages: {                 
5367                    emailAddress: {
5368                        required: "Please enter your Email Address.",
5369                        email: "Please enter a valid Email Address.",
5370                        maxlength: "Email address should not exceed 60 characters.",
5371                        notEqualToReg: "Please enter a different email address."
5372                    },                  
5373                    subRole: {
5374                        required: "Please select a Sub Role."                   
5375                    },
5376                   "firstName": {
5377                        required: "Please enter your First Name.",
5378                        validName: "Numeric values and the characters , and \" cannot be used in this field.",
5379                        checkName: "Numeric values and the characters , and \" cannot be used in this field.",                         
5380                        maxlength: "First name should not exceed 20 character length!",
5381                        notEqualToReg: "First name should not be equal to email address."
5382                    },
5383                    firstName1: {
5384                        required: "Please enter your First Name.",
5385                        validName: "Numeric values and the characters , and \" cannot be used in this field.",
5386                        checkName: "Numeric values and the characters , and \" cannot be used in this field.",                         
5387                        maxlength: "First name should not exceed 20 character length!",
5388                        notEqualToReg: "First name should not be equal to email address."
5389                    },
5390                    firstName2: {
5391                        required: "Please enter your First Name.",
5392                        validName: "Numeric values and the characters , and \" cannot be used in this field.",
5393                        checkName: "Numeric values and the characters , and \" cannot be used in this field.",                         
5394                        maxlength: "First name should not exceed 20 character length!",
5395                        notEqualToReg: "First name should not be equal to email address."
5396                    },
5397                    firstName3: {
5398                        required: "Please enter your First Name.",
5399                        validName: "Numeric values and the characters , and \" cannot be used in this field.",
5400                        checkName: "Numeric values and the characters , and \" cannot be used in this field.",                         
5401                        maxlength: "First name should not exceed 20 character length!",
5402                        notEqualToReg: "First name should not be equal to email address."
5403                    },
5404                    lastName: {
5405                        required: "Please enter your Last Name.",
5406                        validName: "Numeric values and the characters , and \" cannot be used in this field.",
5407                        checkName: "Numeric values and the characters , and \" cannot be used in this field.",                         
5408                        maxlength: "Last name should not exceed 30 character length!",
5409                        notEqualToReg: "Last name should not be equal to email address."
5410                    },
5411                    lastName1: {
5412                        required: "Please enter your Last Name.",
5413                        validName: "Numeric values and the characters , and \" cannot be used in this field.",
5414                        checkName: "Numeric values and the characters , and \" cannot be used in this field.",                         
5415                        maxlength: "Last name should not exceed 30 character length!",
5416                        notEqualToReg: "Last name should not be equal to email address."
5417                    },
5418                    lastName2: {
5419                        required: "Please enter your Last Name.",
5420                        validName: "Numeric values and the characters , and \" cannot be used in this field.",
5421                        checkName: "Numeric values and the characters , and \" cannot be used in this field.",                         
5422                        maxlength: "Last name should not exceed 30 character length!",
5423                        notEqualToReg: "Last name should not be equal to email address."
5424                    },
5425                    lastName3: {
5426                        required: "Please enter your Last Name.",
5427                        validName: "Numeric values and the characters , and \" cannot be used in this field.",
5428                        checkName: "Numeric values and the characters , and \" cannot be used in this field.",                         
5429                        maxlength:  "Last name should not exceed 30 character length!",
5430                        notEqualToReg: "Last name should not be equal to email address."
5431                    },
5432                    crd1: {
5433                        required: "Please enter your CRD #."
5434                    },
5435                    crd2: {
5436                        required: "Please enter your CRD #."
5437                    },
5438                    companyName: {
5439                        required: "You must select a Company Name from the list provided.
5439<br/>If you do not see your Company Name in the list, please contact us at 888.843.7824.<br/><br/>Monday - Thursday: 8 a.m. - 7 p.m. ET <br/>Friday: 9:15 a.m. - 6 p.m. ET",
5440                        maxlength: "The maximum character length for company name should not exceed 40 character.",
5441                        notEqualToReg: "Company name should not be equal to email address."
5442                    },
5443                    companyName1: {
5444                        required: "You must select a Company Name from the list provided.<br/>If you do not see your Company Name in the list, please contact us at 888.843.7824.<br/><br/>Monday - Thursday: 8 a.m. - 7 p.m. ET <br/>Friday: 9:15 a.m. - 6 p.m. ET",
5445                        maxlength: "The maximum character length for company name should not exceed 40 character.",
5446                        notEqualToReg: "Company name should not be equal to email address."
5447                    },
5448                    companyName2: {
5449                        required: "You must select a Company Name from the list provided.<br/>If you do not see your Company Name in the list, please contact us at 888.843.7824.<br/><br/>Monday - Thursday: 8 a.m. - 7 p.m. ET <br/>Friday: 9:15 a.m. - 6 p.m. ET",
5450                        maxlength: "The maximum character length for company name should not exceed 40 character.",
5451                        notEqualToReg: "Company name should not be equal to email address."
5452                    },
5453                    companyName3: {
5454                        required: "You must select a Company Name from the list provided.<br/>If you do not see your Company Name in the list, please contact us at 888.843.7824.<br/><br/>Monday - Thursday: 8 a.m. - 7 p.m. ET <br/>Friday: 9:15 a.m. - 6 p.m. ET",
5455                        maxlength: "The maximum character length for company name should not exceed 40 character.",
5456                        notEqualToReg: "Company name should not be equal to email address."
5457                    },
5458                    city1: {
5459                        required: "Please enter your City.",
5460                        maxlength: "The maximum character length for branch id should not exceed 30 character."
5461                    },
5462                    city2: {
5463                        required: "Please enter your City.",
5464                        maxlength: "The maximum character length for branch id should not exceed 30 character."
5465                    },
5466                    password: {
5467                        required: "Please enter a Password.",
5468                        checkNoSpace: "Password should not allow space character.",                        
5469                        containsAtLeastOneDigit: "Password must contain at least one digit.",
5470                        containsAtLeastOneLetter: "Password must contain at least one letter.",
5471                        notEqualToReg: "Password can not be equal to email.",
5472                        minlength:"Password must be min of 8 character length."                         
5473                    },
5474                    password1: {
5475                        required: "Please enter a Password.",
5476                        checkNoSpace: "Password should not allow space character.",                        
5477                        containsAtLeastOneDigit: "Password must contain at least one digit.",
5478                        containsAtLeastOneLetter: "Password must contain at least one letter.",
5479                        notEqualToReg: "Password can not be equal to email.",
5480                        minlength:"Password must be min of 8 character length."                         
5481                    },
5482                    password2: {
5483                        required: "Please enter a Password.",
5484                        checkNoSpace: "Password should not allow space character.",                        
5485                        containsAtLeastOneDigit: "Password must contain at least one digit.",
5486                        containsAtLeastOneLetter: "Password must contain at least one letter.",
5487                        notEqualToReg: "Password can not be equal to email.",
5488                        minlength:"Password must be min of 8 character length."                         
5489                    },
5490                    confirmPassword: {
5491                        required: "Please confirm your Password.",
5492                        equalTo: "The Passwords you entered do n
5492ot match."
5493                    },
5494                    confirmPassword1: {
5495                        required: "Please confirm your Password.",
5496                        equalTo: "The Passwords you entered do not match."
5497                    },
5498                    confirmPassword2: {
5499                        required:"Please confirm your Password.",
5500                        equalTo: "The Passwords you entered do not match."
5501                    }
5502                },
5503                // the errorPlacement has to take the table layout into account
5504                errorLabelContainer: $("form[name='registerForm'] .scfValidationSummaryRegister"),
5505                // set this class to error-labels to indicate valid fields
5506                success: function(label) {
5507                    label.css("display","none");
5508                }
5509            });            
5510        },      
5511        
5512	   getErrorMessages: function(errorCode) {
5513
5514        },
5515
5516        clickNext: function() {
5517            $("#next").click(function() {
5518                if(!$("#registerForm").valid()) {
5519                    thf.registerAction.getErrors();
5520                    $("#registerForm").valid(false);
5521                }
5522                if($("#registerForm").valid()) {
5523                   // setPageNameTandC(role);
5524                    $("#registrationMain").css("display", "none");
5525                    $("#errorDIV").css("display", "none");
5526                    $("#checkAgree").css("display", "block");
5527                    
5528                }
5529                function checkAgree() {
5530                    $("#agree").on("click",function() {
5531                    });
5532                }
5533                return false;
5534            });
5535        },
5536
5537        getErrors: function() {
5538            var errorList = new Array();
5539            if(emailExistsError !== "") {
5540                errorList.push(emailExistsError);
5541                emailExistsError = "";
5542            }
5543            $(".scfValidationSummaryRegister label").each(function() {
5544                if($(this).text() !== " ") {
5545                    errorList.push($(this).text());
5546                }
5547            });
5548
5549        },
5550        disableSaveCancelBtn: function(){
5551            $("#savechanges, #cancel").css("cursor","default");
5552            $("#savechanges span, #cancel span").css("cursor","default");                       
5553            $("#savechanges, #cancel").click(function() {
5554                return false;
5555            });
5556        },
5557        enableSaveCancelBtn: function(){
5558            $("#savechanges, #cancel").css("cursor","pointer");
5559            $("#savechanges span, #cancel span").css("cursor","pointer");       
5560            $("#savechanges, #cancel").click(function() {
5561                return true;
5562            });             
5563        },      
5564        clickSubmit: function() {
5565            $("#register, #register1, #register3").click(function() {
5566                if(!$("#registerForm").valid()) {
5567                    thf.registerAction.getErrors();
5568                    $("#registerForm").valid(false);
5569                } else {  
5570                    $(this).removeAttr("id");
5571                    $(this).removeAttr("href");
5572                    $(this).addClass("inactiveBtn");
5573                    thf.registerAction.customSubmit();
5574                }
5575                return true;
5576            });
5577        },
5578        customSubmitRegisterInitiationModal: function() {
5579            
5580           $(".scfValidationSummaryRegister").hide();
5581            dataString = $('#registerForm').serialize();
5582            submitUrl = thf.utils.secureUrl.url + '/bin/thf/servlets/newregistration';
5583            dataString = dataString.substring(dataString.indexOf("source"), dataString.length);  
5584            
5585            jQuery.ajax({
5586                url: submitUrl,
5587                type: 'POST',
5588                data: dataString,
5589                dataType: 'html',
5590                //async: false, [this is depriciated after jquery1.5 - used ajaxSetup]
5591                cache: false,
5592                error: function() {
5593                },
5594                ajaxSetup: function(){
5595                	async: true
5596                },
5597                beforeSend: function () {
5598                    $('#ajaxLoadingregistration').show();
5599                },
5600                success: function(data) {      
5601                    var showloading = 0; 
5602                    var obj = $.parseJSON( data );
5603                    if( obj.result == 'REGISTERED') {
5604                        $(document).scrollTop(0);
5605                        $("#osx-modal-data").scrollTop(0);
5606                        $(".scfValidationSummaryRegister").html("<label class='error'>We've noticed that you already have a profile with us. To access the site, you must <a href='#' class='osx resetPassword'>reset your password</a>.</label>");
5607                        $("#registerForm_emailAddress").removeClass("valid").addClass("error");
5608                        $("#registerForm_emailAddress").parents("div.form-input-wrapper").removeClass("valid").addClass("error");
5609                        $("#registerForm_emailAddress").parents("div.leftHalf").find("label").removeClass("valid").addClass("error");       
5610                        emailExistsError = errorJson["REG_EM_EX"];
5611                        thf.registerAction.getErrors();
5612                        $(".scfValidationSummaryRegister").css("display", "block");                        
5613                        $('input[name="existingEmail"]').val($('input[name="emailAddress"]').val());
5614                        osxOverlay();
5615                    } else if (obj.result === "subsuccess") {
5616                        redirectPostLogin();                              
5617                    } else if(obj.result == 'OTHERS') {
5618                       
5619                        $(document).scrollTop(0);
5620                        $("#osx-modal-data").scrollTop(0);  
5621                        $("#registrationInitiationModal").css("display", "none");
5622                        $("#registrationOthersModal").css("display", "block");
5623                        var passdLeft = (($(window).width()) - ($('#registrationOthersModal').width()))/2;
5624                        $("#osx-container").css('width', $('#registrationOthersModal').width());
5625                        passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
5626                        $("#osx-container").css('width', '630px');
5627                        $("#osx-container").css('left', passdLeft);
5628                        $("#emailOthers").text($('input[name="emailAddress"]').val());
5629                        $( "#registerForm_firstName" ).focus();                        
5630                    } else if(obj.result == 'NONMATCH') {
5631                        $(document).scrollTop(0);
5632                        $("#osx-modal-data").scrollTop(0);
5633                        $("#registrationInitiationModal").css("display", "none");
5634                        $("#registrationNonMatchModal").css("display", "block");
5635                        var passdLeft = (($(window).width()) - ($('#registrationNonMatchModal').width()))/2;
5636                        $("#osx-container").css('width', $('#registrationNonMatchModal').width());
5637                        passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
5638                        $("#osx-container").css('width', '630px');
5639                        $("#osx-container").css('left', passdLeft);
5640                        $("#emailNonMatch").text($('input[name="emailAddress"]').val()); 
5641                        $("#companyNameCityText").hide();
5642                        $("#companyNameOrBranch").hide();
5643                        $( "#registerForm_firstName2" ).focus();                      
5644                    } else if(obj.result == 'MATCH') {
5645                        $(document).scrollTop(0);
5646                        $("#osx-modal-data").scrollTop(0);
5647                        $("#registrationInitiationModal").css("display", "none");
5648                        $("#registrationMatchModal").css("display", "block");
5649                        var passdLeft = (($(window).width()) - ($('#registrationMatchModal').width()))/2;
5650                        $("#osx-container").css('width', $('#registrationMatchModal').width());
5651                        passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
5652                        $("#osx-container").css('width', '630px');
5653                        $("#osx-container").css('left', passdLeft);
5654                        $("#emailMatch").text($('input[name="emailAddress"]').val()); 
5655                        $( "#registerForm_password1" ).focus();                         
5656                        $('input[name="firstName1"]').val(obj.advisor.firstName);
5657                        $('input[name="lastName1"]').val(obj.advisor.lastName);
5658                        $('input[name="companyName1"]').val(obj.advisor.companyName);
5659                        $('input[name="fName"]').val(obj.advisor.firstName);
5660                        $('input[name="lName"]').val(obj.advisor.lastName);
5661                        $('input[name="cName"]').val(obj.advisor.companyName);
5662                        $('input[name="crd"]').val(obj.advisor.crdNumber);
5663                        $('input[name="city"]').val(obj.advisor.city);
5664                        var registeredrole = $('input[name="registrationRole"]').val();
5665                        var subrole = $('input[name="subRole"]:checked').val();
5666                        var email = $('input[name="emailAddress"]').val(); 
5667                        //regMatch(subrole,email,registeredrole);
5667 Commented for SiteCatalyst code cleanup
5668
5669                    } else if (obj.result === "companynotexists"){
5670                        $(document).scrollTop(0);
5671                        $("#osx-modal-data").scrollTop(0);
5672                        $(".scfValidationSummaryRegister").html("<label class='error'>You must select a Company Name from the list provided.<br/>If you do not see your Company Name in the list, please contact us at 888.843.7824.<br/><br/>Monday - Thursday: 8 a.m. - 7 p.m. ET <br/>Friday: 9:15 a.m. - 6 p.m. ET</label>");
5673                        $("#registerForm_companyName").removeClass("valid").addClass("error");
5674                        $("#registerForm_companyName").parents("div.form-input-wrapper").removeClass("valid").addClass("error");
5675                        $("#registerForm_companyName").parents("div.leftHalf").find("label").removeClass("valid").addClass("error");
5676                        $("#registerForm_companyName1").removeClass("valid").addClass("error");
5677                        $("#registerForm_companyName1").parents("div.form-input-wrapper").removeClass("valid").addClass("error");
5678                        $("#registerForm_companyName1").parents("div.leftHalf").find("label").removeClass("valid").addClass("error");                        
5679                        emailExistsError = errorJson["REG_EM_EX"];
5680                        thf.registerAction.getErrors();
5681                        $(".scfValidationSummaryRegister").css("display", "block");
5682                    } else if (obj.result === "invalidcrd") {
5683                        $(document).scrollTop(0);
5684                        $("#osx-modal-data").scrollTop(0);
5685                        //regFailure(role,'FailureRetry'); Commented for SiteCatalyst code cleanup //Analytics
5686                        $("#registerForm_crd1").val("");
5687                        $("#registerForm_companyName2").val("");
5688                        $("#registerForm_city1").val("");
5689                        $("#registrationNonMatchModal").css("display", "none");
5690                        $("#regFailed").css("display", "block");                        
5691                        $("#attempt").val("two");
5692                        var firstName = $("#registerForm_firstName2").val();
5693                        var lastName = $("#registerForm_lastName2").val();
5694                        $("#registerForm_firstName3").val(firstName);
5695                        $("#registerForm_lastName3").val(lastName);
5696                        $( "#registerForm_crd2" ).focus();
5697                    } else if(obj.result === "showcall") {
5698                        $(document).scrollTop(0);
5699                        $("#osx-modal-data").scrollTop(0);
5700                        //regFailed(role,'FailureRetry1'); Commented for the Site Catalyst code clean up.                        
5701                        $("#regFailed").css("display", "none");
5702                        $("#regFailedCall").css("display", "block");
5703                    } else if (obj.result === "fail") {
5704                        $(document).scrollTop(0);
5705                        $("#osx-modal-data").scrollTop(0);
5706                        $(".scfValidationSummaryRegister").html("<label class='error'>An error has occurred. Please try again later.</label>");                       
5707                        emailExistsError = errorJson["REG_EM_EX"];
5708                        thf.registerAction.getErrors();
5709                        $(".scfValidationSummaryRegister").css("display", "block");
5710                    } else if (obj.result === "emailexists") {
5711                        $(document).scrollTop(0);
5712                        $("#osx-modal-data").scrollTop(0);
5713                        $("#registrationInitiationModal").css("display", "block");
5714                        $("#registrationOthersModal").css("display", "none");
5715                        $("#registrationMatchModal").css("display", "none");
5716                        $("#registrationNonMatchModal").css("display", "none");
5717                        $("#osx-container").css('width', $('#registrationInitiationModal').width());
5718                        var passdLeft = (($(window).width()) - ($("#osx-container").outerWidth()))/2;
5719                        $("#osx-container").css('width', '437px');
5720                        $("#osx-container").css('left', passdLeft);
5721                        var appreg2 = $('input[name="appregistration"]').val(); 
5722                        console.log(appreg2);
5723                        if(appreg2!==undefined && appreg2==='appregistration' ){
5724                        	 var extensionredirect = window.location.href;
5725                        	 extensionredirect = extensionredirect.split('?')[1];
5726                             var targetURL = "/content/thf/en/app-pages/login.html" +"?"+extensionredirect;
5727                        	 $(".scfValidationSummaryRegister").html('<label class="error">We\'ve noticed that you already have a profile with us. To access locked content, <a href="' + targetURL + '" class="osx resetPassword">Login</a> or  <a href="/content/thf/en/app-pages/appresetpassword.html" class="osx resetPassword">reset your password</a>.</label>');
5728                         }
5729                        else{
5730							$(".scfValidationSummaryRegister").html("<label class='error'>We've noticed that you already have a profile with us. To access the site, you must <a href='#' class='osx resetPassword'>reset your password</a>.</label>");
5731                        }
5732                        $("#registerForm_emailAddress").removeClass("valid").addClass("error");
5733                        $("#registerForm_emailAddress").parents("div.form-input-wrapper").removeClass("valid").addClass("error");
5734                        $("#registerForm_emailAddress").parents("div.leftHalf").find("label").removeClass("valid").addClass("error");       
5735                        emailExistsError = errorJson["REG_EM_EX"];
5736                        thf.registerAction.getErrors();
5737                        $(".scfValidationSummaryRegister").css("display", "block");
5738                        osxOverlay();
5739                    } else if (obj.result === "success") {
5740                        $(document).scrollTop(0); 
5741                        $("#osx-modal-data").scrollTop(0); 
5742                        $("#registrationOthersModal").css("display", "none");
5743                        $("#registrationMatchModal").css("display", "none");
5744                        $("#registrationNonMatchModal").css("display", "none");
5745                        $("#regFailed").css("display", "none");
5746                        $("#regComplete").css("display", "block");
5747                       // $('#osx-modal-content .close').css('display','none');
5748                        $("#completeField").val("complete");
5749                        var valuesArray = dataString.split("&");
5750                        var message = "You are now registered as ";
5751                        var roleString = "";  
5752                        var userName = obj.user.email;                        
5753                        $('input[name="firstName"]').val(obj.user.firstName);
5754                        $('input[name="lastName"]').val(obj.user.lastName);                       
5755                        if($('input[name="registrationRole"]').val() === "Financial Advisors") {
5756                            message = message + " a Financial Advisor.";
5757                            roleString = "fia";
5758                        } else {
5759                            message = message + "an Institutional Investor / RIA.";
5760                            roleString = "ini";
5761                        }
5762                       // $('#registeredAs').html(message);
5763
5764                        	 var s=document.createElement('script');
5765 							s.async=true;
5766 							s.src="/etc.clientlibs/thf/clientlibs/hf-external/hfforms2.min.js";
5767
5768 							var x = document.getElementsByTagName('script')[0];
5769 							x.parentNode.insertBefore(s, x);
5770                         	s.onload=function(){ 
5771 							 showMarketoSubscriptionForm(userName);
5772 							}
5773
5774                        showloading = 1;
5775                        /*var servletPath = "/bin/thf/servlets/newregistration?role=" + roleString;
5776                        $.get(servletPath, function(jsondata) {
5777                            var subsHtml = "";
5778                            $.each(jsondata, function() {
5779                                $.each(this, function(k, v) {
5780                                    subsHtml = subsHtml + '<p><input type="checkbox"  tabindex="-1" name="subs" value="'+v.subid+'" id="CheckboxGroup2_' + v.subid + '" checked="checked" /><label><b>' + v.subtitle + '</b></label></p><p class="regDesc">'+v.description+'</p>';
5781                                });
5782                            });
5783                            $('#subscriptions').html(subsHtml);                         
5784                        });     
5785                        thf.registerAction.saveSubscriptionSubmit();  
5786                        thf.registerAction.clickSubscriptionCancel();*/
5787                        
5788
5789                            loginuserreg(userName, obj.user.password, resourceStr, action);
5790
5791                        registrationJourney = "RegSuccess";                        
5792                        if($('input[name="source"]').val() == "match") {
5793                            registrationJourney = "RegMatch|RegSuccess";
5794                        } else if($('input[name="source"]').val() == "nonmatch") {
5795                            registrationJourney = "RegNonMatch|RegSuccess";
5796                        } else if($('input[name="source"]').val() == "others") {
5797                            registrationJourney = "RegOthers|RegSuccess";
5798                        } else if($('input[name="source"]').val() == "failed") {
5799                            registrationJourney = "RegFailed|RegSuccess";
5800                        }
5801                        var email = obj.user.email;
5802                        var company = obj.user.company; 
5803                        var firmcity = obj.user.city;
5804                        var subrole = obj.user.subrole;
5805                        var guid = obj.user.guid;
5806                        var registeredrole = $('input[name="registrationRole"]').val();
5807
5808                        //regSuccess(guid, email,role,subrole,registeredrole,company,firmcity,registrationJourney); Commented for SiteCatalyst code cleanup
5809                    }                                
5810                    if (showloading == 0)          
5811                        $('#ajaxLoadingregistration').hide();
5812                }
5813            });
5814            
5815        },      
5816        submitRegisterInitiationModal: function() {
5817            $("#registrationInitiationModal #continue").click(function() {
5818                
5819                $(document).scrollTop(0);
5820                var registeredrole = $('input[name="registrationRole"]').val();
5821                var subrole = $('input[name="subRole"]:checked').val();
5822
5823                if(subrole=='Advisor' || subrole=='Sales Assistant'){
5824                    registeredrole='Financial Advisor';
5825                }
5826                else{
5827					registeredrole='Institutional Investors';
5828                }
5829                $('#registeredrole').val(registeredrole);
5830                var email = $('input[name="emailAddress"]').val(); 
5831                //regInitiation(subrole,email,registeredrole);
5831 Commented for SiteCatalyst code cleanup
5832
5833
5834                    if(!$("#registerForm").valid()) {
5835                    thf.registerAction.getErrors();
5836                    $("#registerForm").valid(false);
5837                } else {
5838                    thf.registerAction.customSubmitRegisterInitiationModal();                                        
5839                }                                      
5840
5841                return false;
5842            });
5843        },
5844        
5845        submitRegisterOthersModal: function() {
5846            $("#registrationOthersModal #complete").click(function() {
5847                $(document).scrollTop(0);
5848                $('input[name="source"]').val('others');
5849                if(!$("#registerForm").valid()) {
5850                    thf.registerAction.getErrors();
5851                    $("#registerForm").valid(false);
5852                } else {
5853                    thf.registerAction.customSubmitRegisterInitiationModal();                                        
5854                }
5855                return false;
5856            });
5857        },
5858        
5859        submitRegisterMatchModal: function() {
5860            $("#registrationMatchModal #complete").click(function() {
5861                $(document).scrollTop(0);               
5862                $('input[name="source"]').val('match');                
5863                if(!$("#registerForm").valid()) {
5864                    thf.registerAction.getErrors();
5865                    $("#registerForm").valid(false);
5866                } else {
5867                    thf.registerAction.customSubmitRegisterInitiationModal();                                        
5868                }
5869                return false;
5870            });
5871        },
5872        
5873        submitRegisterNonMatchModal: function() {
5874            $("#registrationNonMatchModal #complete").click(function() {
5875                $(document).scrollTop(0);
5876                $('input[name="source"]').val('nonmatch');
5877                if(!$("#registerForm").valid()) {
5878                    thf.registerAction.getErrors();
5879                    $("#registerForm").valid(false);
5880                } else {
5881                    thf.registerAction.customSubmitRegisterInitiationModal();                                        
5882                }
5883                return false;
5884            });
5885        },
5886        
5887        submitRegisterFailedModal: function() {
5888            $("#regFailed #complete").click(function() {
5889                $(document).scrollTop(0);
5890                $('input[name="source"]').val('failed');
5891                if(!$("#registerForm").valid()) {
5892                    thf.registerAction.getErrors();
5893                    $("#registerForm").valid(false);
5894                } else {
5895                    thf.registerAction.customSubmitRegisterInitiationModal();                                        
5896                }
5897                return false;
5898            });
5899        },
5900        
5901        saveSubscriptionSubmit: function() {
5902            $("#regComplete #savechanges").click(function() {
5903                $(document).scrollTop(0);
5904                $('input[name="source"]').val('subscription');
5905                $("#completeField").val("complete");
5906                if(!$("#registerForm").valid()) {
5907                    thf.registerAction.getErrors();
5908                    $("#registerForm").valid(false);
5909                } else {                    
5910                    thf.registerAction.customSubmitRegisterInitiationModal();
5911                }
5912                return true;
5913            });
5914        },
5915        clickSubscriptionCancel: function() {           
5916            $("#regComplete #cancel").click(function() {
5917                $(document).scrollTop(0);
5918                $('input[name="source"]').val('subscription');
5919                $("#completeField").val("cancel");
5920                thf.registerAction.customSubmitRegisterInitiationModal();
5921                return true;
5922            });
5923        },
5924        
5925        saveSubmit: function() {
5926            $("#savechanges").click(function() {
5927                if(!$("#registerForm").valid()) {
5928                    thf.registerAction.getErrors();
5929                    $("#registerForm").valid(false);
5930                } else {
5931                    $(this).removeAttr("id");
5932                    $(this).removeAttr("href");
5933                    $(this).addClass("inactiveBtn");
5934                    thf.registerAction.customSubmit();
5935                }
5936                return true;
5937            });
5938        },
5939        clickCancel: function() {
5940            $("#cancel").click(function() {
5941                $("#completeField").val("cancel");
5942                thf.registerAction.customSubmit();
5943                return true;
5944            });
5945        }
5946    }
5947}(window, document, jQuery, thf));
5948
5949$(document).ready(function() {
5950	
5951    var errorJsonParam = $.getJSON('/content/thf/en/messages.redesign_global_registration.html', function(data) {
5952        thf.registerAction.setErrorJson(data);
5953    });
5954
5955    
5956}); 
5957//Form validator
5958var thf = window.thf || {};
5959(function (window, document, $, thf) {
5960  thf.resetPassword = {
5961
5962
5963    disableSelection: function () {
5964      $("form#resetpasswordform button").attr("disabled", "disabled");
5965      $("form#resetpasswordform button").addClass("disabled");
5966      $("form#resetpasswordform").bind("keypress", function (e) {
5967        if (e.keyCode == 13) {
5968          return false;
5969        }
5970      });
5971    },
5972    enableSelection: function () {
5973      // $(".scfValidationSummaryReset").css("display","none");
5974      $("form#resetpasswordform button").removeAttr("disabled");
5975      $("form#resetpasswordform button").removeClass("disabled");
5976      $("form#resetpasswordform").bind("keypress", function (e) {
5977        if (e.keyCode == 13) {
5978          return true;
5979        }
5980      });
5981    },
5982    validatePassword: function () {
5983
5984    /*    var bannedDomains = "edwardjones.com";
5985
5986$.validator.addMethod('domainNotBanned', function(value, elem, param) {
5987  var domain = value.split('@')[1];
5988  return bannedDomains.indexOf(domain) < 0;
5989}, 'Emails from this domain are not allowed.');*/
5990
5991      var validator = $("form[name='resetpasswordform']").validate({
5992        onfocusout: true,
5993        rules: {
5994
5995          emailAddressProfile: {
5996            required: true,
5997            email: true,
5998           // domainNotBanned:true,
5999
6000
6001          }
6002        },
6003        messages: {
6004          emailAddressProfile: {
6005            required: "Please enter a valid email address",
6006             //domainNotBanned:"Attention Edward Jones Representatives: to access this website, you must login via JonesLink"
6007
6008
6009
6010
6011          }
6012        },
6013        // the errorPlacement has to take the table layout into account
6014        errorLabelContainer: $("#osx-modal-data form[name='resetpasswordform'] .scfValidationSummaryReset"),
6015        success: function (label) {
6016          // label.html("&nbsp;").addClass("checked");
6017          label.css("display", "none");
6018        },
6019        // specifying a submitHandler prevents the default submit, good for the
6020        // demo
6021        submitHandler: function () {
6022    		thf.resetPassword.disableSelection();  	
6023          var email = $("#resetpasswordform_emailAddressProfile").val();
6024          dataString = 'emailAddressProfile=' + email;
6025
6026
6027
6028
6029
6030          var host = thf.utils.secureUrl.url;
6031		  var prereg= $("#prereg").val();
6032          var submitUrl = host + '/bin/thf/servlets/resetpassword';
6033           if (prereg != null)
6034           {
6035            submitUrl = host + '/bin/thf/servlets/resetpassword?prereg='+"prereg";
6036           }
6037          
6038          jQuery.ajax({
6039            url: submitUrl,
6040            type: 'POST',
6041            data: dataString,
6042            dataType: 'html',
6043            async: true,
6044            cache: false,
6045            success: function (data) {
6046
6047
6048              if (data == "success") {
6049                $("#reset").html("<p><a class='close' href='#'></a></p><p>If you have an account with us, a password reset email will be sent shortly.</p>");
6050                $('#osx-modal-data #reset .close').on('click', function(e){
6051                    e.preventDefault();
6052                    window.location.reload(true);
6053                });
6054              }
6055			  
6056			  if (data == "presuccess") {
6057                  $("#reset").html("<p><a class='close' href='#'></a></p><p>An email has been sent to the user.</p>");
6058                  $('#osx-modal-data #reset .close').on('click', function(e){
6059                      e.preventDefault();
6060                      window.location.reload(true);
6061                  });
6062                }
6063              
6064
6065              if (data == 'mailerror') {
6066                $(".scfValidationSummaryReset").html("<label class='error'>There is an error while sending mail.</label>");
6067                $(".scfValidationSummaryReset").css("display", "block");
6068             		 thf.resetPassword.enableSelection();                 
6069
6070              }
6071              if (data == 'fail') {
6072                $(".scfValidationSummaryReset").html("<label class='error'>There is an error please try again.</label>");
6073                $(".scfValidationSummaryReset").css("display", "block");
6074             		 thf.resetPassword.enableSelection();
6075              }
6076              
6077              if (data == 'userLocked') {
6078                  $(".scfValidationSummaryReset").html("<label class='error'>User is still Locked , please call service desk.</label>");
6079                  $(".scfValidationSummaryReset").css("display", "block");
6080               		 thf.resetPassword.enableSelection();
6081                }
6082
6083            }
6084          });
6085        }
6086
6087      });
6088    }
6089  };
6090}(window, document, jQuery, thf));
6091// Session expiry overlay - Bootstrap 4.5 version
6092var thf = window.thf || {};
6093(function(window, document, $, thf) {
6094	thf.openSessionModal = function(currentRole){
6095		var contentUrl = "/home.html?sessionTimeout=true#showloginoverlay";
6096		var targethref = thf.utils.secureUrl.url + contentUrl;
6097		
6098		// Bootstrap 4.5.0 Modal - jQuery Plugin Method
6099		if (!$('#sessionTimeout-modal-container').length) {
6100			console.warn('Session timeout modal element not found');
6101			return false;
6102		}
6103		
6104		try {
6105			$('#sessionTimeout-modal-container').modal({
6106				backdrop: 'static',
6107				keyboard: false,
6108				focus: true,
6109				show: true
6110			});
6111		} catch (err) {
6112			console.error('Error initializing Bootstrap Modal:', err);
6113			$('#sessionTimeout-modal-container').show();
6114		}
6115		
6116		// Handle close button clicks
6117		$('#sessionTimeout-modal-container').find('.modalCloseImg, .close').off('click').on('click', function(e){
6118			e.preventDefault();
6119			try {
6120				$('#sessionTimeout-modal-container').modal('hide');
6121			} catch (err) {
6122				$('#sessionTimeout-modal-container').hide();
6123			}
6124			logoutUserSession();
6125			window.location.href = targethref;
6126			return false;
6127		});
6128		
6129		// Handle action buttons
6130		$('#sessionTimeout-modal-container').find('a.button, button.sessionExpiryClose').off('click').on('click', function(e){
6131			e.preventDefault();
6132			try {
6133				$('#sessionTimeout-modal-container').modal('hide');
6134			} catch (err) {
6135				$('#sessionTimeout-modal-container').hide();
6136			}
6137			logoutUserSession();
6138			window.location.href = targethref;			
6139			return false;
6140		});
6141		
6142		// Handle logout overlay link
6143		$('#sessionTimeout-modal-container').find('a.loginOverlay.osx').off('click').on('click', function(e){
6144			e.preventDefault();
6145			sessionModal.hide();
6146			logoutUserSession();
6147			window.location.href = targethref;                                           
6148			return false;
6149		});
6150		
6151		return false;		
6152	};
6153}(window, document, jQuery, thf));
6154var thf = window.thf || {};
6155thf.utils = thf.utils || {};
6156
6157var xmlhttp = null;
6158function getXmlHttp() {
6159    if (xmlhttp) {
6160        return xmlhttp;
6161    }
6162    if (window.XMLHttpRequest) {
6163        xmlhttp = new XMLHttpRequest();
6164    } else {
6165        if (window.ActiveXObject) {
6166            try {
6167                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
6168            } catch (ex) {
6169                try {
6170                    xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
6171                } catch (ex1) {
6172                }
6173            }
6174        }
6175    }
6176    return xmlhttp;
6177}
6178
6179thf.utils.user = {guid:''};
6180
6181thf.utils.secureUrl = {url:''};
6182
6183thf.utils.setSecureUrl = (function(url){
6184    thf.utils.secureUrl = {url: url};
6185});
6186
6187thf.utils.baseUrl = {url:''};
6188
6189thf.utils.setBaseUrl = (function(url){
6190    thf.utils.baseUrl = {url: url};
6191});
6192
6193
6194thf.utils.cartDetailUrl = {url:''};
6195
6196thf.utils.setCartDetailUrl = (function(url){
6197    thf.utils.cartDetailUrl = {url: url};
6198});
6199
6200
6201thf.utils.cookieCartMaxAge = {url:''};
6202
6203thf.utils.setCookieCartMaxAge = (function(url){
6204    thf.utils.cookieCartMaxAge = {url: url};
6205});
6206
6207thf.utils.cartDeliveryUrl = {url:''};
6208
6209thf.utils.setCartDeliveryUrl = (function(url){
6210    thf.utils.cartDeliveryUrl = {url: url};
6211});
6212
6213thf.utils.profileUrl = {url:''};
6214
6215thf.utils.setProfileUrl = (function(url){
6216    thf.utils.profileUrl = {url: url};
6217});
6218
6219thf.utils.printUrl = {url:''};
6220
6221thf.utils.setPrintUrl = (function(url){
6222    thf.utils.printUrl = {url: url};
6223});
6224
6225
6226thf.utils.init = (function() {
6227    var xmlhttp = new XMLHttpRequest(); 
6228    let path = '/bin/thf/servlets/getuserattr' + "?timestamp=" + new Date().getTime();
6229    if (!xmlhttp) {
6230        return false;
6231    }
6232
6233    xmlhttp.onreadystatechange = function() {
6234        if (xmlhttp.readyState == 4) {
6235            var data = JSON.parse(xmlhttp.responseText);
6236            thf.utils.user = data;
6237        }
6238    }
6239    xmlhttp.open('GET', path, true);
6240    xmlhttp.send(null);
6241    return thf.utils.user;
6242});
6243
6244thf.utils.getCookieValue = (function (cookieName) {
6245    var cookievalue = thf.utils.checkCookieValue(cookieName);
6246    if (cookievalue == '') {
6247        return '';
6248    } else {
6249        return cookievalue;
6250    }
6251});
6252
6253thf.utils.checkCookieValue= (function(cookieName) {
6254    var i, name, y, ARRcookies = document.cookie.split(";");
6255    for (i = 0; i < ARRcookies.length; i++) {
6256        name = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
6257        value = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
6258        name = name.replace(/^\s+|\s+$/g, "");
6259        if (name == cookieName) {
6260            return value;
6261
6262        }
6263    }
6264    return '';
6265});
6266
6267thf.utils.getValue = (function(namevalue){
6268    var pair = namevalue.split(':=');
6269    
6270    return pair[1];
6271}); 
6272
6273thf.utils.removeUserIdentifierCookie = (function() {
6274	/*if(document.cookie.indexOf('user') >= 0) {
6275		expiry = new Date();
6276		expiry.setTime(expiry.getTime()-(1*60*1000));
6277
6278		document.cookie = "user=" + thf.utils.user + "; path=/;expires=" + expiry.toGMTString();
6279	}*/
6280	
6281	if(document.cookie.indexOf('identifier') >= 0) {
6282		expiry = new Date();
6283		expiry.setTime(expiry.getTime()-(1*60*1000));
6284
6285		document.cookie = "identifier=0; path=/; expires=" + expiry.toGMTString();
6286	}
6287});
6288
6289$(document).ready(function() {
6290    //thf.utils.init();
6291    thf.utils.removeUserIdentifierCookie();
6292});

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.