PageSourceSearch

http://www.tryamillion.com/wp-content/themes/rehub/js/custom.js?ver=6.9

js tryamillion.com collected 2026-10-05 17:56:54 UTC 96,047 bytes, 2,122 lines download raw bytes

1/*
2   Author: Igor Sunzharovskyi.
3   Author URI: https://wpsoul.com
4*/
5/****** Helpers JS *****/
6
7/* equalHeightColumns.js 1.2, https://github.com/PaulSpr/jQuery-Equal-Height-Columns */
8(function(e){e.fn.equalHeightColumns=function(t){defaults={minWidth:-1,maxWidth:99999,setHeightOn:"min-height",defaultVal:0,equalizeRows:false,checkHeight:"height"};var n=e(this);t=e.extend({},defaults,t);var r=function(){var r=e(window).width();var i=Array();if(t.minWidth<r&&t.maxWidth>r){var s=0;var o=0;var u=0;n.css(t.setHeightOn,t.defaultVal);n.each(function(){if(t.equalizeRows){var n=e(this).position().top;if(n!=u){if(i.length>0){e(i).css(t.setHeightOn,o);o=0;i=[]}u=e(this).position().top}i.push(this)}s=e(this)[t.checkHeight]();if(s>o){o=s}});if(!t.equalizeRows){n.css(t.setHeightOn,o)}else{e(i).css(t.setHeightOn,o)}}else{n.css(t.setHeightOn,t.defaultVal)}};r();e(window).resize(r);n.find("img").load(r);if(typeof t.afterLoading!=="undefined"){n.find(t.afterLoading).load(r)}if(typeof t.afterTimeout!=="undefined"){setTimeout(function(){r();if(typeof t.afterLoading!=="undefined"){n.find(t.afterLoading).load(r)}},t.afterTimeout)}}})(jQuery);
9!function(t){function e(){var e,i,n={height:a.innerHeight,width:a.innerWidth};
9return n.height||(e=r.compatMode,(e||!t.support.boxModel)&&(i="CSS1Compat"===e?f:r.body,n={height:i.clientHeight,width:i.clientWidth})),n}function i(){return{top:a.pageYOffset||f.scrollTop||r.body.scrollTop,left:a.pageXOffset||f.scrollLeft||r.body.scrollLeft}}function n(){var n,l=t(),r=0;if(t.each(d,function(t,e){var i=e.data.selector,n=e.$element;l=l.add(i?n.find(i):n)}),n=l.length)for(o=o||e(),h=h||i();n>r;r++)if(t.contains(f,l[r])){var a,c,p,s=t(l[r]),u={height:s.height(),width:s.width()},g=s.offset(),v=s.data("inview");if(!h||!o)return;g.top+u.height>h.top&&g.top<h.top+o.height&&g.left+u.width>h.left&&g.left<h.left+o.width?(a=h.left>g.left?"right":h.left+o.width<g.left+u.width?"left":"both",c=h.top>g.top?"bottom":h.top+o.height<g.top+u.height?"top":"both",p=a+"-"+c,v&&v===p||s.data("inview",p).trigger("inview",[!0,a,c])):v&&s.data("inview",!1).trigger("inview",[!1])}}var o,h,l,d={},r=document,a=window,f=r.documentElement,c=t.expando;t.event.special.inview={add:function(e){d[e.guid+"-"+this[c]]={data:e,$element:t(this)},l||t.isEmptyObject(d)||(l=setInterval(n,250))},remove:function(e){try{delete d[e.guid+"-"+this[c]]}catch(i){}t.isEmptyObject(d)&&(clearInterval(l),l=null)}},t(a).bind("scroll resize scrollstop",function(){o=h=null}),!f.addEventListener&&f.attachEvent&&f.attachEvent("onfocusin",function(){h=null})}(jQuery);
10/** PgwModal - Version 2.0 Copyright 2014, Jonathan M. Piat http://pgwjs.com - http://pagawa.com Released under the GNU GPLv3 license - http://opensource.org/licenses/gpl-3.0*/
11(function(a){a.pgwModal=function(i){var c={};var g={mainClassName:"pgwModal",backdropClassName:"pgwModalBackdrop",maxWidth:500,titleBar:true,closable:true,closeOnEscape:true,closeOnBackgroundClick:true,closeContent:'<span class="pm-icon"></span>',loadingContent:"Loading in progress...",errorContent:"An error has occured. Please try again in a few moments."};if(typeof window.pgwModalObject!="undefined"){c=window.pgwModalObject}if((typeof i=="object")&&(!i.pushContent)){if(!i.url&&!i.target&&!i.content){throw new Error('PgwModal - There is no content to display, please provide a config parameter : "url", "target" or "content"')}c.config={};c.config=a.extend({},g,i);window.pgwModalObject=c}var k=function(){var o='<div id="pgwModalBackdrop"></div><div id="pgwModal"><div class="pm-container"><div class="pm-body"><span class="pm-close"></span><div class="pm-title"></div><div class="pm-content"></div></div></div></div>';a("body").append(o);a(document).trigger("PgwModal::Create");return true};var l=function(){a("#pgwModal .pm-title, #pgwModal .pm-content").html("");a("#pgwModal .pm-close").html("").unbind("click");return true};var f=function(){angular.element('body').injector().invoke(function($compile){var scope=angular.element($('#pgwModal .pm-content')).scope();$compile($('#pgwModal .pm-content'))(scope);scope.$digest()});return true};var d=function(o){a("#pgwModal .pm-content").html(o);if(c.config.angular){f()}m();a(document).trigger("PgwModal::PushContent");return true};var m=function(){a("#pgwModal, #pgwModalBackdrop").show();var q=a(window).height();var o=a("#pgwModal .pm-body").height();var p=Math.round((q-o)/3);if(p<=0){p=0}a("#pgwModal .pm-body").animate({marginTop: p}, 200);return true};var h=function(){return c.config.modalData};var e=function(){var o=a('<div style="width:50px;height:50px;overflow:auto"><div></div></div>').appendTo("body");var q=o.children();if(typeof q.innerWidth!="function"){return 0}var p=q.innerWidth()-q.height(90).innerWidth();o.remove();return p};var b=function(){return a("body").hasClass("pgwModalOpen")};var n=function(){a("#pgwModal, #pgwModalBackdrop").removeClass().hide();a("body").css("padding-right","").removeClass("pgwModalOpen");l();a(window).unbind("resize.PgwModal");a(document).unbind("keyup.PgwModal");a("#pgwModal").unbind("click.PgwModalBackdrop");try{delete window.pgwModalObject}catch(o){window.pgwModalObject=undefined}a(document).trigger("PgwModal::Close");return true};var j=function(){if(a("#pgwModal").length==0){k()}else{l()}a("#pgwModal").removeClass().addClass(c.config.mainClassName);a("#pgwModalBackdrop").removeClass().addClass(c.config.backdropClassName);if(!c.config.closable){a("#pgwModal .pm-close").html("").unbind("click").hide()}else{a("#pgwModal .pm-close").html(c.config.closeContent).click(function(){n()}).show()}if(!c.config.titleBar){a("#pgwModal .pm-title").hide()}else{a("#pgwModal .pm-title").show()}if(c.config.title){a("#pgwModal .pm-title").text(c.config.title)}if(c.config.maxWidth){a("#pgwModal .pm-body").css("max-width",c.config.maxWidth)}if(c.config.url){if(c.config.loadingContent){a("#pgwModal .pm-content").html(c.config.loadingContent)}var o={url:i.url,success:function(q){d(q)},error:function(){a("#pgwModal .pm-content").html(c.config.errorContent)}};if(c.config.ajaxOptions){o=a.extend({},o,c.config.ajaxOptions)}a.ajax(o)}else{if(c.config.target){d(a(c.config.target).html())}else{if(c.config.content){d(c.config.content)}}}if(c.config.closeOnEscape&&c.config.closable){a(document).bind("keyup.PgwModal",function(q){if(q.ke
11yCode==27){n()}})}if(c.config.closeOnBackgroundClick&&c.config.closable){a("#pgwModal").bind("click.PgwModalBackdrop",function(s){var r=a(s.target).hasClass("pm-container");var q=a(s.target).attr("id");if(r||q=="pgwModal"){n()}})}a("body").addClass("pgwModalOpen");var p=e();if(p>0){a("body").css("padding-right",p)}a(window).bind("resize.PgwModal",function(){m()});a(document).trigger("PgwModal::Open");return true};if((typeof i=="string")&&(i=="close")){return n()}else{if((typeof i=="string")&&(i=="reposition")){return m()}else{if((typeof i=="string")&&(i=="getData")){return h()}else{if((typeof i=="string")&&(i=="isOpen")){return b()}else{if((typeof i=="object")&&(i.pushContent)){return d(i.pushContent)}else{if(typeof i=="object"){return j()}}}}}}}})(window.Zepto||window.jQuery);
12/*Fitvid http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ */
13(function(e){"use strict";e.fn.fitVids=function(t){var n={customSelector:null,ignore:null};if(!document.getElementById("fit-vids-style")){var r=document.head||document.getElementsByTagName("head")[0];var i=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";var s=document.createElement("div");s.innerHTML='<p>x</p><style id="fit-vids-style">'+i+"</style>";r.appendChild(s.childNodes[1])}if(t){e.extend(n,t)}return this.each(function(){var t=["iframe[src*='player.vimeo.com']","iframe[src*='youtube.com']","iframe[src*='youtube-nocookie.com']","iframe[src*='kickstarter.com'][src*='video.html']","object","embed"];if(n.customSelector){t.push(n.customSelector)}var r=".fitvidsignore";if(n.ignore){r=r+", "+n.ignore}var i=e(this).find(t.join(","));i=i.not("object object");i=i.not(r);i.each(function(){var t=e(this);if(t.parents(r).length>0){return}if(this.tagName.toLowerCase()==="embed"&&t.parent("object").length||t.parent(".fluid-width-video-wrapper").length){return}if(!t.css("height")&&!t.css("width")&&(isNaN(t.attr("height"))||isNaN(t.attr("width")))){t.attr("height",9);t.attr("width",16)}var n=this.tagName.toLowerCase()==="object"||t.attr("height")&&!isNaN(parseInt(t.attr("height"),10))?parseInt(t.attr("height"),10):t.height(),i=!isNaN(parseInt(t.attr("width"),10))?parseInt(t.attr("width"),10):t.width(),s=n/i;if(!t.attr("id")){var o="fitvid"+Math.floor(Math.random()*999999);t.attr("id",o)}t.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",s*100+"%");t.removeAttr("height").removeAttr("width")})})}})(window.jQuery||window.Zepto)
14/*! jQuery Unveil http://luis-almeida.github.com/unveil Licensed under the MIT license. */
15!function(t){t.fn.unveil=function(i,e){function n(){var i=a.filter(function(){var i=t(this);if(!i.is(":hidden")){var e=o.scrollTop(),n=e+o.height(),r=i.offset().top,s=r+i.height();return s>=e-u&&n+u>=r}});r=i.trigger("unveil"),a=a.not(r)}var r,o=t(window),u=i||0,s=window.devicePixelRatio>1,l=s?"data-src-retina":"data-src",a=this;return this.one("unveil",function(){var t=this.getAttribute(l);t=t||this.getAttribute("data-src"),t&&(this.setAttribute("src",t),"function"==typeof e&&e.call(this))}),o.on("scroll.unveil resize.unveil lookup.unveil",n),n(),this}}(window.jQuery||window.Zepto);
16/* Cut tab.js v3.3.6*/
17+function(a){"use strict";function c(c){return this.each(function(){var d=a(this),e=d.data("rh.tab");e||d.data("rh.tab",e=new b(this)),"string"==typeof c&&e[c]()})}var b=function(b){this.element=a(b)};b.prototype.show=function(){var b=this.element,c=b.closest("ul"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a"),f=a.Event("hide.rh.tab",{relatedTarget:b[0]}),g=a.Event("show.rh.tab",{relatedTarget:e[0]});if(e.trigger(f),b.trigger(g),!g.isDefaultPrevented()&&!f.isDefaultPrevented()){var h=a(d);this.activate(b.closest("li"),c),this.activate(h,h.parent(),function(){e.trigger({type:"hidden.rh.tab",relatedTarget:b[0]}),b.trigger({type:"shown.rh.tab",relatedTarget:e[0]})})}}},b.prototype.activate=function(a,b){function d(){c.removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),a.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0)}var c=b.find("> .active");d()};var d=a.fn.tab;a.fn.tab=c,a.fn.tab.Constructor=b,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(b){b.preventDefault(),c.call(a(this),"show")};a(document).on("click.rh.tab.data-api",'[data-toggle="tab"]',e)}(jQuery);
18
19
20/***** BASIC CUSTOM JS *****/
21
22//CHARTS
23var table_charts = function() {
24   jQuery('.table_view_charts').each(function(index){
25      var rowcount = jQuery(this).find('.top_chart_row_found').data('rowcount');
26      for (var rowcountindex = 0; rowcountindex < rowcount; rowcountindex++) {
27
28         //Equal height for each row
29         var heightArray = jQuery(this).find('li.row_chart_'+ rowcountindex +'').map( function(){
30            return  jQuery(this).height();
31         }).get();
32         var maxHeight = Math.max.apply( Math, heightArray);
33         jQuery(this).find('li.row_chart_'+ rowcountindex +'').height(maxHeight);
34
35         //Find differences
36         var recomparecolvalue;
37         jQuery(this).find('.top_chart_wrap li.row_chart_'+ rowcountindex +'').each(function(n) {
38            if (jQuery(this).html() != recomparecolvalue && n > 0) {
39               jQuery(this).closest('.table_view_charts').find('li.row_chart_'+ rowcountindex +'').addClass('row-is-different');
40            }
41            else {
42               recomparecolvalue = jQuery(this).html();
43            }
44         });
45      }
46   });
47}
48
49//FOR VC ROW
50var re_sizebg = function(){
51    'use strict';
52    jQuery('.vc_custom_row_width').each(function() {
53       var ride = jQuery(this).data('bg-width');
54       var ancenstor,parent;
55       parent = jQuery(this).parent();
56       if(ride=='container_width'){
57          ancenstor = jQuery('.main-side').parent().parent();
58       }
59       else if(ride == 'window_width'){
60          ancenstor = jQuery('html');
61       }
62       var al= parseInt( ancenstor.css('paddingLeft') );
63       var ar= parseInt( ancenstor.css('paddingRight') )
64       var w = al+ar + ancenstor.width();
65       var bl = - ( parent.offset().left - ancenstor.offset().left );
66       //if ( bl > 0 ) { left = 0; }
67       if (jQuery('body.rtl').length > 0) {
68          jQuery(this).css({'width': w,'margin-right': bl });
69       }
70       else {
71          jQuery(this).css({'width': w,'margin-left': bl }) ;
72       } 
73    });
74};
75
76function isVisibleOnScroll(elem)
77{
78   var $elem = jQuery(elem);
79   var $window = jQuery(window);
80   var docViewTop = $window.scrollTop();
81   var docViewBottom = docViewTop + $window.height();
82   var elemTop = $elem.offset().top;
83   var elemBottom = elemTop + $elem.height();
84   return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop));
85}
86
87//Here we will cache data from ajax calls
88var re_ajax_cache = {
89    data: {},
90    remove: function (cache_id) {
91        delete re_ajax_cache.data[cache_id];
92    },
93    exist: function (cache_id) {
94        return re_ajax_cache.data.hasOwnProperty(cache_id) && re_ajax_cache.data[cache_id] !== null;
95    },
96    get: function (cache_id) {
97        return re_ajax_cache.data[cache_id];
98    },
99    set: function (cache_id, cachedData) {
100        re_ajax_cache.remove(cache_id);
101        re_ajax_cache.data[cache_id] = cachedData;
102    }
103};
104
105var re_ajax_search = {
106
107    // Some variables
108    _current_selection_index:0,
109    _last_request_results_count:0,
110    _first_down_up:true,
111    _is_search_open:false,
112
113    init: function init() {
114
115        // Search icon show/hide
116        jQuery(document).on( 'click', '.icon-search-onclick', function(e) {
117            e.stopPropagation();
118            jQuery( '.main-nav' ).toggleClass( 'top-search-onclick-open' );
119            if (re_ajax_search._is_search_open === true) {
120                re_ajax_search._is_search_open = false;
121            }
122            else {
123                re_ajax_search._is_search_open = true;
124                if (jQuery('html').hasClass('flash')) {
125                    setTimeout(function(){
126                        jQuery( '.main-nav .search-header-contents input[name="s"]' ).focus();
127                    }, 200);
128                }                
129            }
130        });
131  
132        jQuery(document).click( function(e){ 
133            if( jQuery(e.target).closest(".head_search").length || jQuery(e.target).closest(".custom_search_box").length) 
134                return;
135            jQuery( '.head_search .re-aj-search-wrap' ).removeClass( 're-aj-search-open' ).empty();
136            jQuery( '.custom_search_box .re-aj-search-wrap' ).removeClass( 're-aj-search-open' ).empty();
137            e.stopPropagation();
138            if (re_ajax_search._is_search_open === true) {
139                re_ajax_search._is_search_open = false;
140            }            
141        });
142
143        jQuery(document).click( function(e){ 
144            if( jQuery(e.target).closest(".search-header-contents").length ) 
145                return;
146            jQuery( '.main-nav' ).removeClass( 'top-search-onclick-open' );
147            e.stopPropagation();
148            if (re_ajax_search._is_search_open === true) {
149                re_ajax_search._is_search_open = false;
150            }            
151        });        
152
153        // keydown on the text box
154        jQuery('.re-ajax-search').keydown(function(event) {
155            var ajaxsearchitem = jQuery(this);
156            if (
157                (event.which && event.which == 39)
158                || (event.keyCode && event.keyCode == 39)
159                || (event.which && event.which == 37)
160                || (event.keyCode && event.keyCode == 37))
161            {
162                //do nothing on left and right arrows
163                re_ajax_search.re_ajax_set_focus(ajaxsearchitem);
164                return;
165            }
166
167            if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
168                // on enter
169                var re_ajax_search_cur = jQuery(this).parent().parent().find('.re-sch-cur-element');
170                if (re_ajax_search_cur.length > 0) {
171                    var re_searchopen_url = re_ajax_search_cur.find('.re-search-result-title a').attr('href');
172                    window.location = re_searchopen_url;
173                } else {
174                    jQuery(this).parent().submit();
175                }
176                return false; //redirect for search on enter
177            } else {
178
179                if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) {
180                    // down
181                    re_ajax_search.re_aj_search_move_key_down(ajaxsearchitem);
182                    return false; //disable the envent
183
184                } else if((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) {
185                    //up
186                    re_ajax_search.re_aj_search_move_key_up(ajaxsearchitem);
187                    return false; //disable the envent
188                } else {
189
190                    //for backspace we have to check if the search query is empty and if so, clear the list
191                    if ((event.which && event.which == 8) || (event.keyCode && event.keyCode == 8)) {
192                        //if we have just one character left, that means it will be deleted now and we also have to clear the search results list
193                        var search_query = jQuery(this).val();
194                        if (search_query.length == 1) {
195                            jQuery(this).parent().parent().find('.re-aj-search-wrap').removeClass( 're-aj-search-open' ).empty();
196                        }
197
198                    }
199
200                    //various keys
201                    re_ajax_search.re_ajax_set_focus(ajaxsearchitem);
202                    //jQuery('.re-aj-search-wrap').empty();
203                    setTimeout(function(){
204                        re_ajax_search.do_ajax_call(ajaxsearchitem);
205                    }, 100);
206                }
207                return true;
208            }
209        });
210
211    },
212
213    /**
214     * moves the select up
215     */
216    re_aj_search_move_key_up: function re_aj_search_move_key_up(elem) {
217        if (re_ajax_search._first_down_up === true) {
218            re_ajax_search._first_down_up = false;
219            if (re_ajax_search._current_selection_index === 0) {
220                re_ajax_search._current_selection_index = re_ajax_search._last_request_results_count - 1;
221            } else {
222                re_ajax_search._current_selection_index--;
223            }
224        } else {
225            if (re_ajax_search._current_selection_index === 0) {
226                re_ajax_search._current_selection_index = re_ajax_search._last_request_results_count;
227            } else {
228                re_ajax_search._current_selection_index--;
229            }
230        }
231        elem.parent().parent().find('.re-search-result-div').removeClass('re-sch-cur-element');
232        if (re_ajax_search._current_selection_index  > re_ajax_search._last_request_results_count -1) {
233            //the input is selected
234            elem.closest('form').fadeTo(100, 1);
235        } else {
236            re_ajax_search.re_search_input_remove_focus(elem);
237            elem.parent().parent().find('.re-search-result-div').eq(re_ajax_search._current_selection_index).addClass('re-sch-cur-element');
238        }
239    },
240
241    /**
242     * moves the select prompt down
243     */
244    re_aj_search_move_key_down: function re_aj_search_move_key_down(elem) {
245        if (re_ajax_search._first_down_up === true) {
246            re_ajax_search._first_down_up = false;
247        } else {
248            if (re_ajax_search._current_selection_index === re_ajax_search._last_request_results_count) {
249                re_ajax_search._current_selection_index = 0;
250            } else {
251                re_ajax_search._current_selection_index++;
252            }
253        }
254        elem.parent().parent().find('.re-search-result-div').removeClass('re-sch-cur-element');
255        if (re_ajax_search._current_selection_index > re_ajax_search._last_request_results_count - 1 ) {
256            //the input is selected
257            elem.closest('form').fadeTo(100, 1);
258        } else {
259            re_ajax_search.re_search_input_remove_focus(elem);
260            elem.parent().parent().find('.re-search-result-div').eq(re_ajax_search._current_selection_index).addClass('re-sch-cur-element');
261        }
262    },
263
264    /**
265     * puts the focus on the input box
266     */
267    re_ajax_set_focus: function re_ajax_set_focus(elem) {
268        re_ajax_search._current_selection_index = 0;
269        re_ajax_search._first_down_up = true;
270        elem.closest('form').fadeTo(100, 1);
271        elem.parent().parent().find('.re-search-result-div').removeClass('re-sch-cur-element');
272    },
273
274    /**
275     * removes the focus from the input box
276     */
277    re_search_input_remove_focus: function re_search_input_remove_focus(elem) {
278        if (re_ajax_search._last_request_results_count !== 0) {
279            elem.closest('form').css('opacity', 0.5);
280        }
281    },
282
283    /**
284     * AJAX: process the response from the server
285     */
286    process_ajax_response: function (data, callelem) {
287        var current_query = callelem.val();
288
289        //the search is empty - drop results
290        if (current_query == '') {
291            callelem.parent().parent().find('.re-aj-search-wrap').empty();
292            return;
293        }
294
295        var td_data_object = jQuery.parseJSON(data); //get the data object
296        //drop the result - it's from a old query
297        if (td_data_object.re_search_query !== current_query) {
298            return;
299        }
300
301        //reset the current selection and total posts
302        re_ajax_search._current_selection_index = 0;
303        re_ajax_search._last_request_results_count = td_data_object.re_total_inlist;
304        re_ajax_search._first_down_up = true;
305
306
307        //update the query
308        callelem.parent().parent().find('.re-aj-search-wrap').addClass( 're-aj-search-open' ).html(td_data_object.re_data);
309        var iconsearch = callelem.parent().find('.fa-refresh'); 
310        iconsearch.removeClass('fa-refresh fa-spin').addClass('fa-search');
311        callelem.removeClass('searching-now');
312        var winheight = jQuery(window).height();
313        if (winheight < 700){
314          callelem.parent().parent().find('.re-aj-search-wrap').addClass( 're-aj-search-overflow' );
315        }
316
317    },
318
319    /**
320     * AJAX: do the ajax request
321     */
322    do_ajax_call: function do_ajax_call(elem) {
323        var posttypes = elem.data('posttype');
324        var enable_compare = elem.data('enable_compare');
325        var catid = elem.data('catid');
326        var callelem = elem;
327        if (elem.val() == '') {
328            re_ajax_search.re_ajax_set_focus(callelem);
329            return;
330        }
331
332        var search_query = elem.val();
333
334        //do we have a cache hit
335        if (re_ajax_cache.exist(search_query)) {
336            re_ajax_search.process_ajax_response(re_ajax_cache.get(search_query), callelem);
337            return;
338        }
339
340        var iconsearch =  elem.parent().find('.fa-search');     
341        iconsearch.removeClass('fa-search').addClass('fa-refresh fa-spin');
342        elem.addClass('searching-now');
343
344        jQuery.ajax({
345            type: 'POST',
346            url: translation.ajax_url,
347            data: {
348                action: 'rehub_ajax_search',
349                re_string: search_query,
350                posttypesearch: posttypes,
351                enable_compare : enable_compare,
352                catid : catid,
353            },
354            success: function(data, textStatus, XMLHttpRequest){
355                re_ajax_cache.set(search_query, data);
356                re_ajax_search.process_ajax_response(data, callelem);
357            },
358            error: function(MLHttpRequest, textStatus, errorThrown){
359                //console.log(errorThrown);
360            }
361        });
362    }
363};
364
365//MOBILE MENU AND MEGAMENU
366var NavOverlayRemoved = true;
367var revMenuStyle = function() { 
368    var menu = jQuery('.responsive_nav_wrap'),
369        openMenu = menu.find('#dl-trigger'),
370        navMenu = menu.find('#slide-menu-mobile'),
371        menuList = menu.find('#slide-menu-mobile > .menu'),
372        subMenu = menu.find('.sub-menu'),
373        header = jQuery('#main_header'),
374        windowWidth = window.innerWidth,
375        windowHeight = jQuery(window).height();
376    menuList.addClass('off-canvas').css('height', windowHeight - 52);
377    if (menuList.find('.close-menu').length === 0) {
378        menuList.append('<li class="close-menu"><span><i class="fa fa-times" aria-hidden="true"></i></span></li>');
379    }
380    jQuery('#slide-menu-mobile .menu-item-has-children').children('a').after('<span class="submenu-toggle"><i class="fa fa-angle-right"></i></span>');
381    jQuery('#slide-menu-mobile .menu-item-has-children:not(.rh-mobile-linkable)').children('a').addClass('submenu-toggle');
382    menuList.on('click', '.submenu-toggle', function(evt) {
383        evt.preventDefault();
384        jQuery(this)
385            .siblings('.sub-menu')
386            .addClass('sub-menu-active');
387    });
388    subMenu.each(function() {
389        var $this = jQuery(this);
390        if ($this.find('.back-mb').length === 0) {
391            $this.prepend('<li class="back-mb"><span class="rehub-main-color">'+translation.back+'</span></li>');
392        }
393        menu.on('click', '.back-mb span', function(evt) {
394            evt.preventDefault();
395            jQuery(this)
396                .parent()
397                .parent()
398                .removeClass('sub-menu-active');
399        });
400    });
401    openMenu.on('click', function() {
402    	jQuery('#wpadminbar').css('z-index', '999');
403    	navMenu.fadeIn(100);
404        menuList.addClass('off-canvas-active');
405        jQuery(this).addClass('toggle-active');                
406        if(NavOverlayRemoved){
407        	jQuery('body').append(jQuery('<div class="offsetnav-overlay"></div>').hide().fadeIn());
408        	NavOverlayRemoved = false;
409    	}
410        jQuery('#slide-menu-mobile').find('img.lazyimages').each(function(){
411          var source = jQuery(this).attr("data-src");
412          jQuery(this).attr("src", source).css({'opacity': '1'});
413        });
414    });
415    jQuery('#slide-menu-mobile .vc_tta-panel-heading a').on('click', function(e){
416        e.stopPropagation();
417        e.preventDefault();
418        jQuery('#slide-menu-mobile .vc_tta-panel-heading a').removeClass('active');      
419        jQuery('#slide-menu-mobile .vc_tta-panel-body').slideUp();
420        jQuery(this).addClass('active').closest('.vc_tta-panel').find('.vc_tta-panel-body').slideDown();
421    });    
422    jQuery(document).on('click', '.close-menu, .offsetnav-overlay', function(event) {
423        menuList.removeClass('off-canvas-active');
424        openMenu.removeClass('toggle-active');
425        jQuery('.sub-menu').removeClass('sub-menu-active');                
426        if(!NavOverlayRemoved){
427            jQuery('.offsetnav-overlay').remove();
428            NavOverlayRemoved = true;
429        }                       
430    });
431
432}
433
434jQuery(document).ready(function($) {
435   'use strict';
436    // Lazy load images
437    $("img.lazyimages").unveil(40, function() {
438        $(this).load(function() {
439            this.style.opacity = 1;
440        });
441    });
442
443    $('.tabs, .vc_tta, .wpsm-tabs, .tab-pane').find('img.lazyimages').trigger("unveil");
444
445    // Header and menu
446    var res_nav = $("#main_header .top_menu").html();   
447    $("#main_header .responsive_nav_wrap").html('<div id="slide-menu-mobile">'+res_nav+'</div>');
448    if ($('#re_menu_near_logo').length > 0) { 
449    	var header_responsive_menu = $("#re_menu_near_logo ul").html();
450    	$("#main_header .responsive_nav_wrap > ul").prepend(header_responsive_menu);
451    } 
452    if ($('#main_header .top-nav ul.menu').length > 0) { 
453        var header_top_menu_add = $("#main_header .top-nav ul.menu").html();
454        $("#main_header .responsive_nav_wrap > ul").append(header_top_menu_add);
455    }   
456    if ($('#main_header .top-social .social_icon').length > 0) { 
457        var header_social_menu_add = $("#main_header .top-social .social_icon").html();
458        $("#main_header .responsive_nav_wrap > ul").append('<li id="social_icons_in_panel" class="social_icon">'+header_social_menu_add+'</li>');
459    }    
460    $('#main_header .responsive_nav_wrap' ).wrapInner(function() {
461        return "<div id='dl-menu' class='dl-menuwrapper'></div>";
462    });
463    if ($('.rehub-custom-menu-item.rh_woocartmenu').length > 0) { 
464    	$( "#main_header .responsive_nav_wrap #dl-menu" ).prepend( $(".rehub-custom-menu-item.rh_woocartmenu").html());
465        if ($('.logo_image_mobile').length > 0){
466            $('#dl-menu .logo_image_mobile img').css('left', '90px');
467        }
468    }   
469    if ($('.rh_woocartmenu_cell').length > 0) { 
470    	$( "#main_header .responsive_nav_wrap #dl-menu" ).prepend( $(".rh_woocartmenu_cell").html());
471    }   
472    if ($('.rehub-custom-menu-item.rehub-top-login-onclick .act-rehub-login-popup').length > 0) {
473        $( "#main_header .responsive_nav_wrap #dl-menu" ).prepend( "<button class='act-rehub-login-popup' data-type='login'><i class='fa fa-sign-in'></i></button>" ); 
474    } 
475    if ($('.rehub-custom-menu-item.rehub-top-login-onclick .user-dropdown-intop').length > 0) {
476        $( "#main_header .responsive_nav_wrap #dl-menu" ).prepend( $(".rehub-custom-menu-item.rehub-top-login-onclick").html()); 
477    } 
478    if ($('#main_header .responsive_nav_wrap #dl-menu .rehub-custom-menu-item').length > 0) {
479    	$( "#main_header .responsive_nav_wrap #dl-menu .rehub-custom-menu-item" ).remove();
480    }
481    if ($('.logo-section .mobileinmenu').length > 0) {
482        $( "#main_header .responsive_nav_wrap #dl-menu" ).prepend( $(".logo-section .mobileinmenu").clone()); 
483    }        
484    if ($(".main-nav .subline").length > 0) {
485        $(".main-nav").addClass("subline-enabled");
486    } 
487    if ($('#logo_mobile_wrapper').length > 0) { 
488        $( "#main_header .responsive_nav_wrap #dl-menu" ).prepend($('#logo_mobile_wrapper').html() );
489    }       
490    if ($('.main-nav .logo-inmenu').length > 0) { 
491        $( "#main_header .responsive_nav_wrap #dl-menu .menu-item.logo-inmenu" ).remove();
492    }   
493    $( "#main_header .responsive_nav_wrap #dl-menu" ).prepend( "<button id='dl-trigger' class='dl-trigger'><i class='fa fa-bars'></i></button>" );
494    $( "#main_header .responsive_nav_wrap #dl-menu" ).prepend( "<button class='icon-search-onclick'><i class='fa fa-search'></i></button>" );
495
496    re_sizebg();
497    revMenuStyle(); 
498    re_ajax_search.init(); 
499
500    if ($('.right_aff .price_count').length > 0) {
501    	var width_ofcontainer = $('.right_aff .price_count').innerWidth() / 2;
502    	$('.right_aff .price_count').append('<span class="triangle_aff_price" style="border-width: 14px ' + width_ofcontainer + 'px 0 ' + width_ofcontainer + 'px"></span>');
503    }   
504
505   /* scroll to # */
506   $('.rehub_scroll, #kcmenu a, .kc-gotop').bind('click.smoothscroll',function (e) {
507      e.preventDefault();
508      if (typeof $(this).data('scrollto') !== 'undefined') {
509         var target = $(this).data('scrollto');
510         var hash = $(this).data('scrollto');
511      } 
512      else {
513         var target = $(this.hash + ', a[name="'+ this.hash.replace(/#/,"") +'"]').first();
514         var hash = this.hash;
515      }
516      var $target = $(target);
517      $('html, body').stop().animate({
518         'scrollTop': $target.offset().top - 45
519      }, 500, 'swing', function () {
520         window.location.hash = hash;
521      });
522   });   
523   
524   /* tabs */
525   $('.tabs-menu').delegate('li:not(.current)', 'click', function() {
526      $(this).addClass('current').siblings().removeClass('current').parents('.tabs').find('.tabs-item').hide().eq($(this).index()).fadeIn(700);
527	    $(this).closest('.tabs').find('img.lazyimages').each(function(){
528	        var source = $(this).attr("data-src");
529	        $(this).attr("src", source).css({'opacity': '1'});
530	    });    
531   })
532   $('.tabs-menu li:first-child').trigger('click');
533
534   $('.wpsm-tabs:not(.vc_tta)').each(function(){
535      $(this).tabs();
536   }); 
537
538   /*bar*/  
539   $('.wpsm-bar').each(function(){
540      $(this).find('.wpsm-bar-bar').animate({ width: $(this).attr('data-percent') }, 1500 );
541   });   
542
543   $('.progress-animate-onclick').on("click", ".trigger-progress-bar", function(e){
544      $(this).closest('.progress-animate-onclick').find('.cssProgress').addClass('active');
545      $(this).closest('.progress-animate-onclick').find('.cssProgress-bar').animate({ width: '100%' }, 18000);    
546   });   
547
548   /* accordition */
549   $(".wpsm-accordion").each(function(){
550      $(this).accordion({heightStyle: "content" });
551   });
552
553   /* toggle */
554   $("h3.wpsm-toggle-trigger").click(function(){
555      $(this).toggleClass("active").next().slideToggle("fast");return false;
556   });
557
558	if ($('.wpsm-tooltip-sw').length > 0) {
559   		$(".wpsm-tooltip-sw").tipsy({gravity: "sw", fade: true, html: true });
560   	}
561
562   /* review woo tabs */
563   $('.rehub_woo_tabs_menu').delegate('li:not(.current)', 'click', function() {
564      $(this).addClass('current').siblings().removeClass('current').parents('.rehub_woo_review').find('.rehub_woo_review_tabs').hide().eq($(this).index()).fadeIn(700);
565	    $(this).closest('.rehub_woo_review').find('img.lazyimages').each(function(){
566	        var source = $(this).attr("data-src");
567	        $(this).attr("src", source).css({'opacity': '1'});
568	    });       
569   })
570   $('.rehub_woo_tabs_menu li:first-child').trigger('click');
571   $('.btn_offer_block.choose_offer_woo').click(function(event){     
572      event.preventDefault();
573      $('.rehub_woo_tabs_menu li.woo_deals_tab').trigger('click');
574   });
575    
576   /* widget dropdown */
577   $('.cat_widget_custom .children').parent().find('a').append('<span class="drop_list">&nbsp; +</span>');  
578      $('.tabs-item .drop_list').click(function() {
579       $(this).parent().parent().find('.children').slideToggle();
580        return false
581    });  
582
583    /* offer archive dropdown */  
584    $(document).on('click', '.r_offer_details .r_show_hide', function(e){
585      $(this).parent().find('.open_dls_onclk').slideToggle();
586      $(this).toggleClass('r_show_active');
587    });  
588
589   	$('.expand_all_offers').click(function() {
590   		var $expand = $(this).closest('.widget_merchant_list');
591   		if($expand.hasClass('expandme')){
592   			$expand.removeClass('expandme');
593   			$(this).find('.expandme').html('-');
594   		}
595   		else{
596   			$expand.addClass('expandme');
597   			$(this).find('.expandme').html('+');
598   		}
599    });    
600
601   	/* Category search */
602	if(jQuery("#rh-category-search").length>0){
603		var a=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("long_name","key_word"),queryTokenizer:Bloodhound.tokenizers.whitespace,local:typeahead_categories});
604		a.initialize(),jQuery("#rh-category-search .typeahead").typeahead({hint:!1,highlight:!0,minLength:1,autoselect:!0},{name:"categories",displayKey:"long_name",source:a.ttAdapter(),templates:{empty:['<div class="empty-message">','<strong>No results found.</strong>',"</div>"].join("\n")}}),jQuery("#category-search .typeahead").focus(),jQuery(".js-clear-search").on("click",function(){jQuery(this).parent().find(".typeahead").val(""),jQuery(this).addClass("hide")}),jQuery("#rh-category-search .typeahead").keyup(function(){jQuery(this).val().length>=3?jQuery(".js-clear-search").removeClass("hide"):jQuery(".js-clear-search").addClass("hide")}),jQuery(document).on("typeahead:selected",function(a,b){window.location=""+b.html_name})
605	}
606
607   if($('.rh-tilled-gallery').length > 0){
608      $('.rh-tilled-gallery').each(function(){
609         var galleryid = $(this).data('galleryid');
610         $(this).justifiedGallery({
611            lastRow : 'nojustify', 
612            rowHeight : 200, 
613            rel : 'prettyPhoto[rehub_postthumb_gallery_'+ galleryid + ']',
614            margins : 10,
615            captions : false,
616         }).on('jg.complete', function () {
617            $(this).find('a[rel^="prettyPhoto"]').prettyPhoto({social_tools:false, default_width: 854,default_height: 480});
618         });          
619      });    
620   }
621
622   	/* responsive video*/
623	$('.rh-container').find( 'iframe[src*="player.vimeo.com"], iframe[src*="youtube.com"]' ).each( function() {
624		var $video = $(this);
625		if ( $video.parents( 'object' ).length ) return;
626		if ($video.parent().hasClass('wpb_video_wrapper')) return;
627		if ($video.parent().hasClass('video-container')) return;
628		if ($video.parent().parent().hasClass('slides')) return;
629		if ( ! $video.prop( 'id' ) ) $video.attr( 'id', 'rvw' + Math.floor( Math.random() * 999999 ) );
630		$video.wrap( '<div class="video-container"></div>')
631	});          
632
633   // Coupon Modal
634   $(document).on("click", ".masked_coupon:not(.expired_coupon)", function(e){
635   	e.preventDefault();
636      var $this = $(this);
637      var codeid = $this.data('codeid');
638      var codetext = $this.data('codetext');
639      if (typeof $this.data('codeid') !== 'undefined') {var couponpage = window.location.pathname + "?codeid=" + codeid;}
640      if (typeof $this.data('codetext') !== 'undefined') {var couponpage = window.location.pathname + "?codetext=" + codetext;}
641      var couponcode = $this.data('clipboard-text'); 
642      var destination = $this.data('dest'); 
643      if( destination != "" || destination != "#" ){
644         window.location.href= destination;
645      }
646      window.open(couponpage);
647   });
648
649   function GetURLParameter(sParam){
650      var sPageURL = window.location.search.substring(1);
651      var sURLVariables = sPageURL.split('&');
652      for (var i = 0; i < sURLVariables.length; i++) 
653      {
654         var sParameterName = sURLVariables[i].split('=');
655         if (sParameterName[0] == sParam) 
656         {
657            return sParameterName[1];
658         }
659      }
660   }  
661
662   var coupontrigger = GetURLParameter("codeid");
663   if(coupontrigger){
664      var $change_code = $(".rehub_offer_coupon.masked_coupon:not(.expired_coupon)[data-codeid='" + coupontrigger +"']");
665      var couponcode = $change_code.data('clipboard-text');       
666      $.pgwModal({
667         url: translation.ajax_url + "?action=ajax_code&codeid=" + coupontrigger,
668         titleBar: false,
669         maxWidth: 650,
670         mainClassName : 'pgwModal coupon-reveal-popup',
671         ajaxOptions : {
672            success : function(response) {
673               if (response) {
674                  $.pgwModal({ pushContent: response });
675                  $change_code.removeClass('masked_coupon woo_loop_btn coupon_btn btn_offer_block wpsm-button').addClass('not_masked_coupon').html( '<i class="fa fa-scissors fa-rotate-180"></i><span class="coupon_text">'+ couponcode +'</span>' );                                  
676                  $change_code.closest('.reveal_enabled').removeClass('reveal_enabled');
677               } else {
678                  $.pgwModal({ pushContent: 'An error has occured' });
679               }
680            }
681         }
682      });
683   };
684
685   $(document).on("click", "a.not_masked_coupon", function(e){
686      e.preventDefault();
687   });
688
689   $(document).on("click", ".csspopuptrigger", function(e){
690      e.preventDefault();
691      var destination = '#' + $(this).data('popup');
692      $(destination).toggleClass('active');
693   });
694
695   $(document).on("click", ".csspopup .cpopupclose", function(e){
696      e.preventDefault();
697      $(this).closest('.csspopup').removeClass('active');
698   });
699
700   $(document).on("click", ".toggle-this-table", function(e){
701      e.preventDefault();
702      $(this).closest('.rh-tabletext-block').toggleClass('closedtable');
703   });          
704
705   $(".rehub_offer_coupon.masked_coupon.expired_coupon").each(function() {
706      var couponcode = $(this).data('clipboard-text');
707      $(this).removeClass('masked_coupon woo_loop_btn coupon_btn btn_offer_block wpsm-button').addClass('not_masked_coupon').text(couponcode);
708      $(this).closest('.reveal_enabled').removeClass('reveal_enabled');
709   });  
710
711   //Coupons copy code function
712   if($('.rehub_offer_coupon:not(.expired_coupon)').length > 0){
713      var client = new Clipboard( '.rehub_offer_coupon:not(.expired_coupon)' );
714      var OfferCoupon = $('.rehub_offer_coupon:not(.expired_coupon)');
715      client.on( 'success', function(e) {
716         OfferCoupon.find('i').replaceWith( '<i class="fa fa-check-square"></i>' );
717         OfferCoupon.find('i').fadeOut( 2500, function() {
718            OfferCoupon.find('i').replaceWith( '<i class="fa fa-scissors fa-rotate-180"></i>' ).fadeIn('slow');
719         });
720      });
721      client.on( 'error', function(e) {
722         console.log(e);       
723      });      
724   }    
725
726   	//external links
727   $('.ext-source').replaceWith(function(){
728      return '<a href="' + $(this).data('dest') + '" target="_blank" rel="nofollow">' + $(this).html() + '</a>';
729   });
730
731   $('.int-source').replaceWith(function(){
732      return '<a href="' + $(this).data('dest') + '">' + $(this).html() + '</a>';
733   });    
734
735   //Infinite scroll js
736   $('.inf_scr_wrap_auto').each(function() {
737      var $this = $(this);
738      $this.infinitescroll({
739         navSelector: ".more_post",
740         nextSelector: ".more_post a",
741         itemSelector: ".inf_scr_item",
742         loading: {
743            finishedMsg: '<em>' + translation.fin + '</em>',
744            msgText: '',
745            img: translation.templateurl + '/images/preload.gif',
746         },        
747      }, function(){
748         $this.find('img.lazyimages').each(function(){
749            var source = $(this).attr("data-src");
750            $(this).attr("src", source).css({'opacity': '1'});
751         });      
752      }
753      );      
754   });   
755
756   //fix for VC responsive sidebar
757   //$('.vc_col-sm-4, .vc_col-sm-3').find('.sidebar').closest('.vc_row').addClass('vc_rehub_container'); 
758
759   $('.eq_height_post').equalHeightColumns({
760      minWidth: 767,
761      afterTimeout: 500,
762      checkHeight: 'innerHeight'
763   });  
764   $('.eq_height_inpost').equalHeightColumns({
765      minWidth: 767,
766      afterTimeout: 500,
767      checkHeight: 'innerHeight'
768   });    
769
770    //category pager
771   $('.cat-pagination').on('click', 'a:not(.active) ', function(){
772      var multi_cat = $(this).closest('.multi_cat');
773      var multi_cat_wrap = multi_cat.find('.multi_cat_wrap');
774      var page = $(this).data('paginated');
775      var data = {
776         'action': 'multi_cat',
777         'page': page,
778         'tax': multi_cat.data('tax'),
779         'term': multi_cat.data('term'),
780         'nonce' : translation.nonce,
781      };
782
783      multi_cat_wrap.addClass('loading');
784
785      $.post(translation.ajax_url, data, function(response) {
786         if (response !== 'fail') {
787            multi_cat_wrap.html(response);
788            multi_cat.find('.cat-pagination a').removeClass('active');
789            multi_cat.find('.cat-pagination a[data-paginated="' + page + '"]').addClass('active');
790         }
791         multi_cat_wrap.removeClass('loading');
792      });
793   }); 
794
795   //Sharing popups JS
796   jQuery(document).on( 'click', '.share-link-image', function( event ) {
797      var href    = jQuery( this ).data( "href" ),
798         service = jQuery( this ).data( 'service' ),
799         width   = 'pinterest' == service ? 750 : 600,
800         height  = 'twitter' == service ? 250 : 'pinterest' == service ? 320 : 300,
801         top     = ( screen.height / 2 ) - height / 2,
802         left    = ( screen.width / 2 ) - width / 2;
803      var options = 'top=' + top + ',left=' + left + ',width=' + width + ',height=' + height;
804      event.preventDefault();
805      event.stopPropagation();
806      window.open( href, service, options );
807   });   
808
809   //Comment filtering
810   $(document).on('click', '#rehub-comments-tabs span', function() {
811      if(typeof rating_tabs_ajax_send!=='undefined' && rating_tabs_ajax_send)
812         return;
813      var post_id = $('#rehub-comments-tabs').data('postid');
814      var rating_tabs_ajax_send = true;
815      var p = $(this).parent().children().removeClass('active');
816      $(this).addClass('active');
817      if ($(this).data('tabid')==1) {
818         $('#loadcomment-list').html('');
819         $('#tab-1').show();
820         rating_tabs_ajax_send = false;
821         return;
822      }
823      $.ajax({
824         type: 'post',
825         data: 'action=show_tab&post_id='+post_id+'&tab_number='+$(this).data('tabid')+'&rating_tabs_id='+translation.rating_tabs_id,
826         url: translation.ajax_url,
827         beforeSend: function() {
828            $('#tab-1').hide();
829            $('#loadcomment-list').html('<div class="text-center loadingcomment"><i class="fa fa-refresh fa-spin"></i></div>');
830         },
831         error: function(jqXHR, textStatus, errorThrown) {
832            $('#loadcomment-list').html('error: '+errorThrown);
833         },
834         success : function(html_data) {
835            rating_tabs_ajax_send = false;
836            $("#loadcomment-list").html(html_data);
837         }
838      });
839   });  
840
841   // Search icon show/hide 
842   $(window).resize(function(){
843	re_sizebg();
844      var w = $(window).width();
845      if (w > 1023){
846        $('#slide-menu-mobile').hide();
847        $('.offsetnav-overlay').hide();
848      }
849   });  
850
851   // Add modal on links for non logged in comment form
852
853   if ($('.ap-login-message-wrapper').length > 0) {
854      if ($('#rehub-login-popup').length > 0) {
855         $( ".ap-login-message-wrapper .ap-login-message + a" ).addClass('act-rehub-login-popup'); 
856      }   
857   }  
858
859   if ($('#respond .must-log-in a').length > 0) {
860      if ($('#rehub-login-popup').length > 0) {
861         $( "#respond .must-log-in a" ).addClass('act-rehub-login-popup'); 
862      }   
863   } 
864
865   if ($('#comments .comment-reply-login').length > 0) {
866      if ($('#rehub-login-popup').length > 0) {
867         $( ".comment-reply-login" ).addClass('act-rehub-login-popup'); 
868      }   
869   }        
870
871   // Open login/register modal
872   $(document).on('click', 'body:not(.logged-in) .act-rehub-login-popup', function(e) {
873      e.preventDefault();
874      var acttype = $(this).data('type');
875      if (acttype == 'login') {
876         $.pgwModal({
877            titleBar: false,
878            target: '#rehub-login-popup',
879            mainClassName : 'pgwModal re-user-popup-wrap',
880         });
881         $('.re-user-popup-wrap .rehub-errors').html('');
882      }
883      else if(acttype == 'register') {
884         $.pgwModal({
885            titleBar: false,
886            target: '#rehub-register-popup',
887            mainClassName : 'pgwModal re-user-popup-wrap',
888         });  
889         $('.re-user-popup-wrap .rehub-errors').html('');
890         $('.re-user-popup-wrap .recaptchamodail').attr('id', 'recaptchamodail');       
891      }
892      else if(acttype == 'resetpass') {
893         $.pgwModal({
894            titleBar: false,
895            target: '#rehub-reset-popup',
896            mainClassName : 'pgwModal re-user-popup-wrap',
897         }); 
898         $('.re-user-popup-wrap .rehub-errors').html('');        
899      } 
900      else if(acttype == 'restrict') {
901         $.pgwModal({
902            titleBar: false,
903            target: '#rehub-restrict-login-popup',
904            mainClassName : 'pgwModal re-user-popup-wrap',
905         });         
906      } 
907      else if(acttype == 'url') {
908      	if($(this).attr('href')){
909      		var gocustomurl = $(this).attr('href');  
910      	}else{
911      		var gocustomurl = $(this).data('customurl');
912      	}
913      	window.location.href = gocustomurl;
914      }       
915      else {
916         if($('#rehub-custom-login-url').length > 0){
917            var gocustomurl = $('#rehub-custom-login-url').data('customloginurl');
918            window.location.href = gocustomurl;
919         }else{
920            $.pgwModal({
921               titleBar: false,
922               target: '#rehub-login-popup',
923               mainClassName : 'pgwModal re-user-popup-wrap',
924            });
925            $('.re-user-popup-wrap .rehub-errors').html('');            
926         }
927      }                
928   });
929
930   // Post login form submit 
931   $(document).on('submit','.re-user-popup-wrap #rehub_login_form_modal',function(e){
932      e.preventDefault();
933      var button = $(this).find('button.rehub_main_btn');
934      button.addClass('loading');
935      $.post(translation.ajax_url, $(this).serialize(), function(data){
936         var obj = $.parseJSON(data);
937         $('.rehub-login-popup .rehub-errors').html(obj.message);       
938         if(obj.error == false){
939            if(obj.redirecturl){
940              window.setTimeout(function(){window.location.href = obj.redirecturl;},200);
941            }
942            else{
943              window.setTimeout(function(){location.reload()},200);
944            }
945            button.hide();
946         }
947         button.removeClass('loading');
948      });
949   });
950
951   // Post register form
952   $(document).on('submit','.re-user-popup-wrap #rehub_registration_form_modal',function(e){
953      e.preventDefault();
954      var button = $(this).find('button.rehub_main_btn');
955      button.addClass('loading');
956      $.post(translation.ajax_url, $(this).serialize(), function(data){       
957         var obj = $.parseJSON(data);
958         $('.rehub-register-popup .rehub-errors').html(obj.message);       
959         if(obj.error == false){
960            $('.rehub-register-popup').addClass('registration-complete');
961            if(obj.redirecturl){
962            	window.setTimeout(function(){window.location.href = obj.redirecturl;},4000);
963            }
964            else{
965            	window.setTimeout(function(){location.reload()},4000);
966            }
967            //button.hide();
968         }
969         $('.rehub-register-popup').removeClass('registration-complete');
970         button.removeClass('loading');       
971      });
972   });
973
974   // Reset Password
975   $(document).on('submit','.re-user-popup-wrap #rehub_reset_password_form_modal',function(e){
976      e.preventDefault();
977      var button = $(this).find('button.rehub_main_btn');
978      button.addClass('loading');
979      $.post(translation.ajax_url, $(this).serialize(), function(data){
980         var obj = $.parseJSON(data);
981         $('.rehub-reset-popup .rehub-errors').html(obj.message);    
982         if(obj.error == false){
983            window.setTimeout(function(){location.reload()},3000);  
984         }
985         button.removeClass('loading');
986      });
987   });
988
989   // drop down for user menu
990   $( '.user-ava-intop' ).click(function(e) {
991      e.stopPropagation();
992      $( this ).parent().find( '.user-dropdown-intop-menu' ).toggleClass('user-dropdown-intop-open');
993      $(this).toggleClass('user-ava-intop-open');
994   });
995   $( '.user-dropdown-intop-menu' ).click(function(e) {
996      e.stopPropagation();
997   });    
998   $( document ).click(function() {
999      $( '.user-dropdown-intop-menu' ).removeClass('user-dropdown-intop-open');
1000      $( '.user-ava-intop' ).removeClass('user-ava-intop-open');
1001      $( '.re_tax_dropdown' ).removeClass('active');
1002   }); 
1003
1004	// Open offer modal
1005 
1006
1007	// Send form data
1008	$('body').on('click', '#rehub_add_offer_form_modal .rehub_main_btn', function(e){
1009		e.preventDefault();
1010		var error;
1011		var button = $(this);
1012		var ref = button.closest('form').find('input.required');
1013		var data = button.closest('form').find('input');
1014		
1015		// Validate form
1016        $(ref).each(function() {
1017            if ($(this).val() == '') {
1018                var errorfield = $(this);
1019                $(this).addClass('error').parent('.re-form-group').prepend('<div class="redcolor"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></div>');
1020                error = 1;
1021                $(":input.error:first").focus();
1022                return;
1023            }
1024        });
1025		
1026		if(!(error==1)) {
1027			button.addClass('loading');
1028			$.ajax({
1029				type: 'POST',
1030				url: translation.ajax_url,
1031				data: data,
1032				success: function() {
1033					setTimeout(function(){ button.removeClass('loading'); }, 500);
1034					$('.rehub-offer-popup').toggleClass('rhhidden');
1035					$('.rehub-offer-popup-ok').toggleClass('rhhidden');
1036				},
1037				error: function(xhr, str) {
1038					alert('Error: ' + xhr.responseCode);
1039				}
1040			});
1041        }
1042        return false;		
1043	}); 
1044
1045
1046   /* gallery hover */
1047   $(".media_owl_carousel .photo-item").hover(function(){
1048      $(this).children('.gp-overlay').stop(true, true).fadeIn(500);
1049   }, function(){
1050      $(this).children('.gp-overlay').stop(true, true).fadeOut(500);
1051   });
1052
1053   //Thumbs up function with overall score
1054   $(document).on("click", ".post_thumbs_meter .thumbplus:not(.alreadyhot)", function(e){
1055      e.preventDefault();
1056      var $this = $(this);
1057      if ($this.hasClass("restrict_for_guests")) {
1058        return false;
1059      }      
1060      var post_id = $(this).data("post_id");  
1061      var informer = parseInt($(this).attr("data-informer"));      
1062      $(this).addClass("loading");            
1063      $.ajax({
1064         type: "post",
1065         url: translation.ajax_url,
1066         data: "action=hot-count&hotnonce="+translation.hotnonce+"&hot_count=hot&post_id="+post_id,
1067         success: function(count){
1068            $this.removeClass("loading"); 
1069            $this.addClass('alreadyhot').parent().find('.thumbminus').addClass('alreadyhot');      
1070            informer=informer+1;
1071            $this.closest('.post_thumbs_meter').find('#thumbscount' + post_id + '').text(informer);
1072            $this.attr("data-informer",informer);           
1073         }
1074      });
1075      
1076      return false;
1077   });
1078
1079   //Heart function
1080   $(document).on("click", ".heart_thumb_wrap .alreadyhot.heartplus", function(e){
1081      e.preventDefault();
1082      var $this = $(this);
1083      if ($this.hasClass("restrict_for_guests")) {
1084        return false;
1085      }       
1086      var post_id = $(this).data("post_id");  
1087      var informer = parseInt($(this).attr("data-informer"));     
1088      $(this).addClass("loading");            
1089      $.ajax({
1090         type: "post",
1091         url: translation.ajax_url,
1092         data: "action=hot-count&hotnonce="+translation.hotnonce+"&hot_count=cold&heart=1&post_id="+post_id,
1093         success: function(count){
1094            $this.removeClass("loading"); 
1095            $this.removeClass('alreadyhot');      
1096            informer=informer-1;
1097            $this.closest('.post_thumbs_meter').find('#thumbscount' + post_id + '').text(informer);
1098            $this.attr("data-informer",informer);         
1099         }
1100      });    
1101      return false;
1102   });   
1103
1104   $(document).on("click", ".post_thumbs_meter .thumbminus:not(.alreadyhot)", function(e){
1105      e.preventDefault();
1106      var $this = $(this);
1107      if ($this.hasClass("restrict_for_guests")) {
1108        return false;
1109      }       
1110      var post_id = $(this).data("post_id");  
1111      var informer = $(this).data("informer");      
1112      $(this).addClass("loading");
1113      $.ajax({
1114         type: "post",
1115         url: translation.ajax_url,
1116         data: "action=hot-count&hotnonce="+translation.hotnonce+"&hot_count=cold&post_id="+post_id,
1117         success: function(count){
1118            $this.removeClass("loading"); 
1119            $this.addClass('alreadyhot').parent().find('.thumbplus').addClass('alreadyhot');          
1120            informer=informer-1;
1121            $this.closest('.post_thumbs_meter').find('#thumbscount' + post_id + '').text(informer);         
1122         }
1123      });    
1124      return false;
1125   }); 
1126
1127   $(document).on("click", ".hotmeter .hotplus:not(.alreadyhot)", function(e){
1128      e.preventDefault();
1129      if ($(this).hasClass("restrict_for_guests")) {
1130        return false;
1131      }       
1132      var post_id = $(this).data("post_id");  
1133      var informer = $(this).data("informer");
1134      $(this).addClass('alreadyhot').parent().parent().find('.hotminus').addClass('alreadyhot');
1135      $('#textinfo' + post_id + '').html("<i class='fa fa-spinner fa-spin'></i>");            
1136      $.ajax({
1137         type: "post",
1138         url: translation.ajax_url,
1139         data: "action=hot-count&hotnonce="+translation.hotnonce+"&hot_count=hot&post_id="+post_id,
1140         success: function(count){
1141            $('#textinfo' + post_id + '').html('');       
1142            informer=informer+1;
1143            $('#temperatur' + post_id + '').text(informer+"°"); 
1144            if(informer>translation.max_temp){ informer=translation.max_temp; }            
1145            if(informer>=0){ 
1146               $('#scaleperc' + post_id + '').css("width", informer / translation.max_temp * 100+'%').removeClass('cold_bar');
1147               $('#temperatur' + post_id + '').removeClass('cold_temp'); 
1148            }
1149            else {
1150               $('#scaleperc' + post_id + '').css("width", informer / translation.min_temp * 100+'%');
1151            }          
1152         }
1153      });
1154      
1155      return false;
1156   });
1157
1158   $(document).on("click", ".hotmeter .hotminus:not(.alreadyhot)", function(e){
1159      e.preventDefault();
1160      if ($(this).hasClass("restrict_for_guests")) {
1161        return false;
1162      }       
1163      var post_id = $(this).data("post_id");  
1164      var informer = $(this).data("informer");
1165      $(this).addClass('alreadyhot').parent().parent().find('.hotplus').addClass('alreadyhot');
1166      $('#textinfo' + post_id + '').html("<i class='fa fa-spinner fa-spin'></i>");
1167      $.ajax({
1168         type: "post",
1169         url: translation.ajax_url,
1170         data: "action=hot-count&hotnonce="+translation.hotnonce+"&hot_count=cold&post_id="+post_id,
1171         success: function(count){
1172            $('#textinfo' + post_id + '').html('');          
1173            informer=informer-1;
1174            $('#temperatur' + post_id + '').text(informer+"°");
1175            if(informer<translation.min_temp){ informer=translation.min_temp; } 
1176            if(informer<0){ 
1177               $('#scaleperc' + post_id + '').css("width", informer / translation.min_temp * 100+'%').addClass('cold_bar');
1178               $('#temperatur' + post_id + '').addClass('cold_temp'); 
1179            }
1180            else {
1181               $('#scaleperc' + post_id + '').css("width", informer / translation.max_temp * 100+'%');
1182            }          
1183         }
1184      });
1185      
1186      return false;
1187   });
1188
1189	$(document).on("click", ".rh-user-favor-shop", function(e){
1190		e.preventDefault();
1191		var heart = $(this);
1192		var user_id = heart.data("user_id");
1193		heart.find(".favorshop_like").html("<i class='fa fa-spinner fa-spin'></i>");
1194		
1195		$.ajax({
1196			type: "post",
1197			url: translation.ajax_url,
1198			data: "action=rh-user-favor-shop&favornonce="+translation.hotnonce+"&rh_user_favorite_shop=&user_id="+user_id,
1199			success: function(count){
1200				if( count.indexOf( "already" ) !== -1 )
1201				{
1202					var lecount = count.replace("already","");
1203					if (lecount == 0)
1204					{
1205						var lecount = "0";
1206					}
1207					heart.find(".favorshop_like").html("<i class='fa fa-heart-o'></i>");
1208					heart.removeClass("alreadyinfavor");
1209					heart.find(".count").text(lecount);
1210				}
1211				else
1212				{
1213					heart.find(".favorshop_like").html("<i class='fa fa-heart'></i>");
1214					heart.addClass("alreadyinfavor");
1215					heart.find(".count").text(count);
1216				}
1217			}
1218		});
1219		
1220		return false;
1221	});    
1222
1223    //AJAX PAGINATION on click button
1224   	$(document).on('click', '.re_ajax_pagination_btn', function(e){
1225   		e.preventDefault();
1226   		var $this = $(this);   		
1227      	var containerid = $this.data('containerid');
1228      	var activecontainer = $('#'+containerid);      	
1229      	var sorttype = $this.data('sorttype');
1230      	var offset = $this.data('offset');  
1231      	var filterargs = activecontainer.data('filterargs');
1232      	var innerargs = activecontainer.data('innerargs');
1233      	var template = activecontainer.data('template');       	   
1234		var data = {
1235		 	'action': 're_filterpost',		 	
1236		 	'sorttype': sorttype,
1237		 	'filterargs' : filterargs,
1238		 	'template' : template, 
1239		 	'containerid' : containerid,
1240		 	'offset' : offset, 
1241		 	'innerargs' : innerargs     
1242		};
1243      	$this.parent().find('span').removeClass('active');
1244      	$this.addClass('active');
1245
1246	    $.ajax({
1247	        type: "POST",
1248	        url: translation.ajax_url,
1249	        data: data,
1250	        success: function(response){
1251				if (response !== 'fail') {
1252					activecontainer.find('.re_ajax_pagination').remove();					
1253					if (template == 'query_type3') {
1254						var $content = $( response);
1255						activecontainer.find('.masonry_grid_fullwidth').append($content).masonry( 'appended', $content );
1256					}	
1257					else{
1258						activecontainer.append($(response).hide().fadeIn(1000));
1259					}
1260			        activecontainer.find('img.lazyimages').each(function(){
1261			            var source = $(this).attr("data-src");
1262			            $(this).attr("src", source).css({'opacity': '1'});
1263			        }); 
1264					activecontainer.find('.eq_height_inpost').equalHeightColumns({
1265					  	minWidth: 767,
1266					  	afterTimeout: 500,
1267					  	checkHeight: 'innerHeight'
1268					});			        					
1269				}        
1270	        }
1271	    });      	
1272   	});    
1273
1274    //AJAX PAGINATION infinite scroll on inview
1275   	$(document).on('inview', '.re_aj_pag_auto_wrap .re_ajax_pagination_btn', function(e){
1276   		e.preventDefault();
1277   		var $this = $(this);   		
1278      	var containerid = $this.data('containerid');
1279      	var activecontainer = $('#'+containerid);      	
1280      	var sorttype = $this.data('sorttype');
1281      	var offset = $this.data('offset');  
1282      	var filterargs = activecontainer.data('filterargs');
1283      	var innerargs = activecontainer.data('innerargs');      	
1284      	var template = activecontainer.data('template');       	   
1285		var data = {
1286		 	'action': 're_filterpost',		 	
1287		 	'sorttype': sorttype,
1288		 	'filterargs' : filterargs,
1289		 	'template' : template, 
1290		 	'containerid' : containerid,
1291		 	'offset' : offset,   
1292		 	'innerargs' : innerargs     
1293		};
1294      	$this.parent().find('span').removeClass('active');
1295      	$this.addClass('active');
1296
1297	    $.ajax({
1298	        type: "POST",
1299	        url: translation.ajax_url,
1300	        data: data,
1301	        success: function(response){
1302				if (response !== 'fail') {
1303					activecontainer.find('.re_ajax_pagination').remove();	
1304					if (template == 'query_type3') {
1305						var $content = $( response);
1306						activecontainer.find('.masonry_grid_fullwidth').append($content).masonry( 'appended', $content );
1307					}	
1308					else{
1309						activecontainer.append($(response).hide().fadeIn(1000));
1310					}		
1311			        activecontainer.find('img.lazyimages').each(function(){
1312			            var source = $(this).attr("data-src");
1313			            $(this).attr("src", source).css({'opacity': '1'});
1314			        }); 
1315					activecontainer.find('.eq_height_inpost').equalHeightColumns({
1316					  	minWidth: 767,
1317					  	afterTimeout: 500,
1318					  	checkHeight: 'innerHeight'
1319					});			        					
1320				}        
1321	        }
1322	    });      	
1323   	});     
1324
1325    //AJAX SORTING PANEL
1326   	$('.re_filter_panel').on('click', '.re_filtersort_btn:not(.active)', function(e){
1327   		e.preventDefault();
1328   		var $this = $(this);   		
1329      	var containerid = $this.data('containerid');
1330      	var activecontainer = $('#'+containerid);      	
1331      	var sorttype = $this.data('sorttype');  
1332      	var filterargs = activecontainer.data('filterargs');
1333      	var innerargs = activecontainer.data('innerargs');
1334      	var template = activecontainer.data('template');       	   
1335		var data = {
1336		 	'action': 're_filterpost',		 	
1337		 	'sorttype': sorttype,
1338		 	'filterargs' : filterargs,
1339		 	'template' : template, 
1340		 	'containerid' : containerid, 
1341		 	'innerargs' : innerargs     
1342		};
1343      	$this.closest('ul').addClass('activeul'); 
1344      	$this.addClass('re_loadingbefore');     	
1345      	activecontainer.addClass('sortingloading');
1346
1347	    $.ajax({
1348	        type: "POST",
1349	        url: translation.ajax_url,
1350	        data: data,
1351	        success: function(response){
1352				if (response !== 'fail') {					
1353					if (template == 'query_type3') {
1354						var $content = $(response);
1355						activecontainer.find('.masonry_grid_fullwidth').html('').prepend($content).masonry( 'prepended', $content );
1356					}	
1357					else{
1358						activecontainer.html($(response).hide().fadeIn(1000));
1359					}
1360			        activecontainer.find('img.lazyimages').each(function(){
1361			            var source = $(this).attr("data-src");
1362			            $(this).attr("src", source).css({'opacity': '1'});
1363			        }); 
1364					activecontainer.find('.eq_height_inpost').equalHeightColumns({
1365					  	minWidth: 767,
1366					  	afterTimeout: 500,
1367					  	checkHeight: 'innerHeight'
1368					});			        					
1369				}   
1370      			$this.closest('.re_filter_panel').find('span').removeClass('active');
1371      			$this.removeClass('re_loadingbefore').addClass('active');				
1372				activecontainer.removeClass('sortingloading'); 
1373				$this.closest('ul').removeClass('activeul'); 
1374				if($this.closest('ul').hasClass('re_tax_dropdown')){
1375					$this.closest('.re_tax_dropdown').find('.rh_choosed_tax').html($this.html()).show();
1376					$this.closest('.re_tax_dropdown').find('.rh_tax_placeholder').hide();
1377					$this.closest('.re_filter_panel').find('.re_filter_ul li:first-child span').addClass('active');
1378				} 
1379				if($this.closest('ul').hasClass('re_filter_ul')){
1380					$this.closest('.re_filter_panel').find('.rh_tax_placeholder').show();
1381					$this.closest('.re_filter_panel').find('.rh_choosed_tax').hide();
1382				}				  
1383	        }
1384	    });      	
1385   	});  
1386
1387   //Collapse filters in sort panel
1388   $('.re_filter_panel').on('click', '.re_filter_ul .re_filtersort_btn.active', function(e) {
1389         e.preventDefault();
1390         $(this).closest('.re_filter_panel').find('ul.re_filter_ul span').toggleClass('showfiltermobile');
1391   });
1392
1393    //Collapse filters in tabs panel
1394    $('.rh_tab_links').on('click', 'a.active', function(e) {
1395        e.preventDefault();
1396        $(this).closest('.rh_tab_links').find('a').toggleClass('showtabmobile');
1397    });
1398
1399    //Collapse filters in wc pro vendor dashboard
1400    $('.wcv-navigation ul.menu.horizontal').on('click', 'li.active', function(e) {
1401        e.preventDefault();
1402        $(this).closest('.menu').find('li').toggleClass('showtabmobile');
1403    });  
1404
1405    //Collapse filters in wc pro vendor dashboard
1406    $('.dokan-dash-sidebar .dokan-dashboard-menu').on('click', 'li.active', function(e) {
1407        e.preventDefault();
1408        $(this).closest('.dokan-dashboard-menu').find('li').toggleClass('showtabmobile');
1409    });       
1410
1411    //Collapse filters in tax dropdown
1412   $('.re_tax_dropdown').on('click', '.label', function(e) {
1413   		e.stopPropagation();
1414         e.preventDefault();
1415         $(this).closest('.re_tax_dropdown').toggleClass('active');
1416   });    	  	
1417
1418    //AJAX GET FULL CONTENT
1419   	$('body').on('click', '.showmefulln', function(e){
1420   		e.preventDefault();
1421   		var $this = $(this);   		
1422      	var postid = $this.data('postid'); 
1423      	var aj_get_full_enabled = $this.attr('data-enabled'); 	   
1424		var data = {
1425		 	'action': 're_getfullcontent',		 	
1426		 	'postid': postid,    
1427		};
1428		var newshead = $this.parent().find('.featured_newscom_left');
1429		var newscont = $this.parent().find('.newscom_detail');		
1430		var newsheadfull = $this.parent().find('.newscom_head_ajax');
1431		var newscontfull = $this.parent().find('.newscom_content_ajax');	
1432		var newsbtn = $this.parent().find('.newscom_btn_block').html();	
1433      	var headcontent = $this.parent().find('.newscom_head').html();      	   	      	
1434
1435      	if(aj_get_full_enabled==1) {
1436      		newsheadfull.fadeOut(500, function() {
1437      			newshead.fadeIn(500);
1438      			$this.attr('data-enabled', 2).removeClass('compress');      			
1439  			});
1440      		newscontfull.fadeOut(500, function() {
1441      			newscont.fadeIn(500);
1442  			});      		   		   		
1443      	}
1444      	else if (aj_get_full_enabled==2){
1445      		newshead.hide(10);
1446      		newscont.hide(10);
1447      		newsheadfull.fadeIn(1000);
1448      		newscontfull.fadeIn(1000);
1449      		$this.attr('data-enabled', 1).addClass('compress');
1450      	}
1451      	else {
1452      		$this.addClass('re_loadingafter');
1453		    $.ajax({
1454		        type: "POST",
1455		        url: translation.ajax_url,
1456		        data: data,
1457		        success: function(response){
1458					if (response !== 'fail') {
1459						newscont.hide(10);
1460						newshead.hide(10);
1461						newscontfull.html($(response).hide().fadeIn(1000).append(newsbtn));
1462						newsheadfull.html($(headcontent).hide().fadeIn(1000));											
1463					}   
1464					$this.attr('data-enabled', 1).removeClass('re_loadingafter').addClass('compress');     
1465		        }
1466		    });  		        		
1467      	}      	
1468   	});
1469
1470   	//Woocommerce better categories
1471	$('.product-categories .show-all-toggle').each(function(){
1472		if( $(this).siblings('ul').length > 0 ) {
1473			var $toggleIcon = $('<span class="toggle-show-icon"><i class="fa fa-angle-right"></i></span>');
1474
1475			$(this).siblings('ul').hide();
1476			if($(this).siblings('ul').is(':visible')){
1477				$toggleIcon.addClass( 'open' );
1478				$toggleIcon.html('<i class="fa fa-angle-up"></i>');
1479			}
1480
1481			$(this).on( 'click', function(){
1482				$(this).siblings('ul').toggle( 'fast', function(){
1483					if($(this).is(':visible')){
1484						$toggleIcon.addClass( 'open' );
1485						$toggleIcon.closest('.closed-woo-catlist').removeClass('closed-woo-catlist');
1486						$toggleIcon.html('<i class="fa fa-angle-up"></i>');
1487					}else{
1488						$toggleIcon.removeClass( 'open' );
1489						$toggleIcon.html('<i class="fa fa-angle-right"></i>');
1490					}
1491				});
1492				return false;
1493			});
1494			$(this).append($toggleIcon);
1495		}
1496	});
1497
1498	//Print function
1499	jQuery.fn.print=function(){var is_chrome = Boolean(window.chrome); if(this.size()>1)return void this.eq(0).print();if(this.size()){var t="printer-"+(new Date).getTime(),o=$("<iframe name='"+t+"'>");o.css("width","1px").css("height","1px").css("position","absolute").css("left","-9999px").appendTo($("body:first"));var i=window.frames[t],e=i.document,n=$("<div>").append("<style>body {-webkit-print-color-adjust: exact;}.printcoupon{max-width: 550px;margin: 20px auto; border: 2px dashed #cccccc;}.printcouponheader{background-color: #eeeeee;padding: 15px; margin-bottom:20px}.printcoupontitle{font-size: 20px;font: 22px/24px Georgia;margin-bottom: 8px;text-transform: uppercase;}.printcoupon_wrap{font-weight: bold;padding: 20px;background-color: #e7f3d6; margin: 0 auto 20px auto;}.expired_print_coupon{font-size:12px; color: #999;}.printcouponcentral, .printcouponheader{text-align: center;}.save_proc_woo_print{margin: 0 auto 20px auto;display: inline-block;position: relative;color: #000000;padding-right: 45px;}.countprintsale{font: bold 70px/70px Arial;}.procprintsale{right: 0;font: bold 36px/35px Tahoma;position: absolute;top: 2px;}.wordprintsale{right: 0;font: 20px Georgia;position: absolute;bottom: 9px;}.printcoupon_wrap {font: bold 20px/24px Arial;padding: 20px;background-color: #e7f3d6;margin: 0 30px;}.printcoupondesc{padding: 30px;}.printcoupondesc span{font: 13px/20px Georgia;}.printimage{float: left;width: 120px;margin: 0 25px 15px 0;}.printimage img{max-width:100%; height:auto}.couponprintend{text-align: center;padding: 20px;border-top: 2px dotted #eeeeee;margin: 0 30px;font: italic 12px Arial; clear:both}.couponprintend span{color: #cc0000;}.storeprint{margin-top:10px;}.storeprint a{text-decoration:none}.printcouponimg{text-align:center; margin:20px auto}.printcouponimg img{max-width:100%; height:auto;}</style>");e.open(),e.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'),e.write("<html>"),e.write("<body>"),e.write("<head>"),e.write("<title>"),e.write(document.title),e.write("</title>"),e.write(n.html()),e.write("</head>"),e.write(this.html()),e.write("</body>"),e.write("</html>"); if (is_chrome) {setTimeout(function(){e.close(),i.focus(),i.print(),o.remove()},254);}else{e.close(),i.focus(),i.print(),setTimeout(function(){o.remove()},6e4);} }};	
1500	$(document).on("click", "span.printthecoupon", function(e){
1501		e.preventDefault();
1502		var printid = $(this).data('printid');
1503		$("#printcoupon" + printid ).print();
1504	});
1505
1506	$(document).on('click', '.rh_gmw_map_in_wcv_profile', function (e) {
1507		e.preventDefault();
1508		$('.wcvendor_profile_menu_items li').removeClass('active');
1509		$('div[role="tabvendor"]').removeClass('active');
1510		$('#vendor-location').addClass('active');
1511		$('html, body').stop().animate({
1512		 'scrollTop': $('#vendor-location').offset().top - 60
1513		}, 500, 'swing', function () {
1514		 window.location.hash = '#vendor-location';
1515		});			
1516	});
1517
1518	$('.table_view_charts').on('click', '.re-compare-show-diff', function(e){
1519	  	if ($(this).is(':checked')){
1520	     	$(this).closest('.table_view_charts').find('li[class^="row_chart"]').filter(':not(.heading_row_chart)').filter(':not(.row-is-different)').addClass('low-opacity');
1521	  	} 
1522	  	else {
1523	     	$(this).closest('.table_view_charts').find('li[class^="row_chart"]').filter(':not(.heading_row_chart)').filter(':not(.row-is-different)').removeClass('low-opacity');
1524	  	}     
1525	});	
1526
1527	if( $('#content-sticky-panel').length > 0 ){
1528		$('article.post').waypoint({
1529  			handler: function(direction) {
1530  				$('#content-sticky-panel').toggleClass('floating', direction=='down');
1531  			}, offset: 30
1532		});	
1533		var commenttitle = $('#comments .title_comments').first().html();
1534		if(commenttitle){
1535			$('#content-sticky-panel ul').append('<li class="top"><a href="#comments">'+commenttitle+'</a></li>');
1536			$('#comments .title_comments').waypoint({
1537	  			handler: function(direction) {
1538	  				$('#content-sticky-panel a').removeClass('active');
1539	    			$('#content-sticky-panel a[href="#comments"]').addClass('active');
1540	  			}, offset: 30
1541			});			
1542		}
1543		$('.kc-gotop').hide();
1544		$('#content-sticky-panel').on('click', '#mobileactivate', function(){
1545			$('#content-sticky-panel').toggleClass('mobileactive');
1546		});
1547		if ($(window).width() < 1300){
1548			var heightpost = $('article.post').offset().top;
1549			$('#content-sticky-panel').css('top', heightpost);
1550		}
1551	}
1552
1553	$('#content-sticky-panel a').each(function(){
1554		$('a[name="'+ this.hash.replace(/#/,"") +'"]').waypoint({
1555  			handler: function(direction) {
1556  				$('#content-sticky-panel a').removeClass('active');
1557    			var corrlink = $(this.element).attr('name');
1558    			$('#content-sticky-panel a[href="#'+corrlink+'"]').addClass('active');
1559  			}, offset: 45
1560		})
1561	});
1562
1563}); //END Document.ready
1564
1565// User Rate functions
1566jQuery(document).on('mouseenter', '.user-rate-active .starrate' , function (e) {
1567    var rated = jQuery(this);
1568    var rateditem = jQuery(this).closest('.user-rate');
1569    var current_rated_count = rated.attr('data-ratecount');
1570    if( rateditem.hasClass('rated-done') ){
1571      return false;
1572    }
1573    rateditem.find('.starrate').removeClass('active');
1574    for (i = 1; i <= current_rated_count; i++) {
1575        rateditem.find('.starrate'+i).addClass('active');
1576    }
1577});
1578jQuery(document).on('mouseleave', '.user-rate-active .starrate' , function (e) {
1579    var rated = jQuery(this);
1580    var rateditem = jQuery(this).closest('.user-rate');
1581    var current_rateddiv = rateditem.attr('data-rate');
1582    if( rateditem.hasClass('rated-done') ){
1583      return false;
1584    }
1585    rateditem.find('.starrate').removeClass('active');
1586    for (i = 1; i <= current_rateddiv; i++) {
1587        rateditem.find('.starrate'+i).addClass('active');
1588    }
1589});
1590jQuery(document).on('click', '.user-rate-active .starrate' , function (e) {
1591    var rated = jQuery(this);
1592    var rateditem = jQuery(this).closest('.user-rate');
1593    var current_rated_count = rated.attr('data-ratecount');    
1594    if( rateditem.hasClass('rated-done') ){
1595      return false;
1596    }
1597    rateditem.find('.post-norsp-rate').hide();
1598    rateditem.append('<span class="rehub-rate-load"><i class="fa fa-circle-o-notch fa-spin"></i></span>');
1599    var post_id = rateditem.attr('data-id');
1600    var rate_type = rateditem.attr('data-ratetype');
1601    var numVotes = rateditem.parent().find('.userrating-count').text();
1602    jQuery.post(translation.ajax_url, { action:'rehub_rate_post' , post:post_id , type:rate_type , value:current_rated_count}, function(data) {
1603        if(data){
1604            var post_rateed = '.rate-post-'+post_id;
1605            jQuery( post_rateed ).addClass('rated-done').attr('data-rate',data);
1606            for (i = 1; i <= current_rated_count; i++) {
1607                rateditem.find('.starrate'+i).addClass('active');
1608            }     
1609            jQuery(".rehub-rate-load").fadeOut(function () {
1610                rateditem.parent().find('.userrating-score').html( current_rated_count );
1611                if( (jQuery(rateditem.parent().find('.userrating-count'))).length > 0 ){
1612                    numVotes =  parseInt(numVotes)+1;
1613                    rateditem.parent().find('.userrating-count').html(numVotes);
1614                }else{
1615                    rateditem.parent().find('small').hide();
1616                }
1617                rateditem.parent().find('strong').html(translation.your_rating);
1618                rateditem.find('.post-norsp-rate').fadeIn();
1619            });
1620        }
1621    }, 'html');
1622    return false;
1623});
1624
1625// Rate bar annimation
1626jQuery(function($){
1627'use strict';  
1628  $(document).ready(function(){   
1629    $('.rate_bar_wrap').bind('inview', function(event, visible) {
1630      if (visible) {
1631        $('.rate-bar').each(function(){
1632         $(this).find('.rate-bar-bar').animate({ width: $(this).attr('data-percent') }, 1500 );
1633         $('.rate_bar_wrap').unbind('inview');
1634        });
1635      }
1636    });
1637
1638    $('.rate-line').bind('inview', function(event, visible) {
1639      if (visible) {
1640        $('.rate-line .line').each(function(){
1641         $(this).find('.filled').animate({ width: $(this).attr('data-percent') }, 1500 );
1642         $('.rate-line').unbind('inview');
1643        });
1644      }
1645    });
1646
1647   $(document).on('inview', '.top_rating_block, .top_table_block, .top_chart', function(event, visible) {
1648      if (visible) {
1649        $('.radial-progress').each(function(){
1650          $(this).find('.circle .mask.full, .circle .fill:not(.fix)').animate({  borderSpacing: $(this).attr('data-rating')*18 }, {
1651              step: function(now,fx) {
1652                $(this).css('-webkit-transform','rotate('+now+'deg)'); 
1653                $(this).css('-moz-transform','rotate('+now+'deg)');
1654                $(this).css('transform','rotate('+now+'deg)');
1655              },
1656              duration:'slow'
1657          },'linear');
1658
1659          $(this).find('.circle .fill.fix').animate({  borderSpacing: $(this).attr('data-rating')*36 }, {
1660              step: function(now,fx) {
1661                $(this).css('-webkit-transform','rotate('+now+'deg)'); 
1662                $(this).css('-moz-transform','rotate('+now+'deg)');
1663                $(this).css('transform','rotate('+now+'deg)');
1664              },
1665              duration:'slow'
1666          },'linear');                   
1667  
1668        });
1669      }
1670   }); 
1671
1672  });
1673});  
1674  
1675   
1676//Scroll To top
1677var pretimer;
1678jQuery(window).scroll(function(){
1679'use strict';
1680
1681   var postheight = jQuery('.post-inner').height() + jQuery('#main_header').height() - 100;
1682   if (jQuery(this).scrollTop() > 500) {
1683      clearTimeout(pretimer); 
1684      jQuery('#topcontrol, #float-posts-nav, #rh_social_panel_footer').addClass('scrollvisible');
1685      var refresh=function(){jQuery('#topcontrol, #float-posts-nav').removeClass('scrollvisible');}      
1686      pretimer=setTimeout(refresh,15000);
1687
1688   } else {
1689      jQuery('#topcontrol').removeClass('scrollvisible');
1690      jQuery('#float-posts-nav').removeClass('scrollvisible');
1691   }
1692   if (jQuery(this).scrollTop() > postheight) {
1693      jQuery('#float-posts-nav').addClass('openedprevnext');
1694   } else {
1695      jQuery('#float-posts-nav').removeClass('openedprevnext');
1696   } 
1697
1698   if (jQuery('.footer-bottom').length > 0) {
1699      if (jQuery('#re-compare-panel').length > 0) {
1700         if(isVisibleOnScroll(jQuery('.footer-bottom'))) {
1701            jQuery('#re-compare-panel').addClass('collapsed-onscroll');
1702         }
1703         else {
1704            jQuery('#re-compare-panel').removeClass('collapsed-onscroll');
1705         }
1706      }
1707   }
1708
1709});
1710
1711
1712jQuery(window).load(function() {
1713
1714   //CAROUSELS
1715   var makesiteCarousel = function() {
1716      if(jQuery().carouFredSel) {                 
1717
1718         jQuery('.top_chart_wrap').each(function() {
1719            var carousel = jQuery(this).find('.top_chart_carousel');
1720            var directionrtl = (jQuery('body.rtl').length > 0) ? "right" : "left";
1721            var windowsize = jQuery(this).width();                      
1722            if (windowsize <= 280) {
1723               var passItems = 1;
1724            } else if (windowsize > 280 && windowsize <= 480) {
1725               var passItems = 2;               
1726            } else if (windowsize > 480) {
1727               var passItems = 4;
1728            }            
1729            carousel.carouFredSel({
1730               circular: false,
1731               infinite: false,                
1732               responsive: true,
1733               direction: directionrtl,
1734               auto: {
1735                  play: false
1736               },
1737               swipe: {
1738                  onTouch: true,
1739                  onMouse: true,
1740                  onAfter : function () {
1741                     var items = carousel.triggerHandler("currentVisible");
1742                     carousel.children().removeClass( "activecol" );
1743                     items.addClass( "activecol" );
1744                  }                  
1745               },               
1746               items: {
1747                  height: 'variable',
1748                  width: 220,  
1749                  visible   : {
1750                     min      : 1,
1751                     max      : passItems
1752                  },
1753               },
1754               scroll : {
1755                  onAfter : function () {
1756                     var items = carousel.triggerHandler("currentVisible");
1757                     carousel.children().removeClass( "activecol" );
1758                     items.addClass( "activecol" );
1759                  }          
1760               },               
1761               prev: {
1762                  button: function() {return jQuery(this).parent().parent().parent().children(".top_chart_controls").find(".prev");} 
1763               },
1764               next: {
1765                  button: function() {return jQuery(this).parent().parent().parent().children(".top_chart_controls").find(".next");}
1766               },
1767               pagination  : function() {return jQuery(this).parent().parent().parent().children(".top_chart_controls").find(".top_chart_pagination");},
1768               height: 'variable',
1769               width: "100%", 
1770               onCreate: function () {
1771                  var items = carousel.triggerHandler("currentVisible");
1772                  items.addClass( "activecol" );
1773               }                              
1774            });
1775         });         
1776
1777      }
1778   }   
1779   table_charts();
1780   makesiteCarousel(); 
1781   jQuery(".sticky-cell").parent().each(function() {
1782      var stickyheight = (jQuery('.re-stickyheader').length > 0) ? jQuery('.re-stickyheader').height() : 0; 
1783      var length = jQuery(this).closest('.table_view_charts').height() - jQuery(this).height() - stickyheight + jQuery(this).closest('.table_view_charts').offset().top;
1784      var cell = jQuery(this);
1785      var width = cell.outerWidth();
1786      var height = cell.height() + 'px';
1787      var outerheight = cell.outerHeight() + 'px';
1788      cell.wrap(function() {
1789         return '<div class="sticky-wrapper" style="height:'+ outerheight +'"></div>';
1790      });
1791
1792      jQuery(window).scroll(function () {
1793         var scroll = jQuery(this).scrollTop();
1794        
1795         if (scroll < jQuery('.table_view_charts').offset().top) {
1796            cell.closest('.sticky-wrapper').removeClass('is-sticky');
1797            cell.css({
1798               'position': '',
1799               'top': '',
1800               'width': '',
1801            });             
1802
1803         } else if (scroll > length) { 
1804            cell.closest('.sticky-wrapper').removeClass('is-sticky');
1805            cell.css({
1806               'position': '',
1807               'top': '',
1808               'width': '',
1809            });                     
1810         } else {
1811            cell.closest('.sticky-wrapper').addClass('is-sticky');
1812            cell.css({
1813               'position': 'fixed',
1814               'top': stickyheight + 'px',
1815               'width': width
1816            });
1817         }
1818      });
1819   });  
1820   jQuery(".table_view_charts").each(function() {
1821      jQuery(this).removeClass('loading');
1822   });  
1823
1824   /* OWL CAROUSEL */
1825   jQuery(".re_carousel").each(function(){
1826      jQuery(this).on('initialized.owl.carousel', function(e) {jQuery(this).parent().removeClass('loading')});
1827      var carouselplay = (jQuery(this).data('auto')==1) ? true : false;
1828      var showrow = (jQuery(this).data('showrow') !='') ? jQuery(this).data('showrow') : 4;
1829      var laizy = (jQuery(this).data('laizy') == 1) ? true : false;
1830      var navdisable = (jQuery(this).data('navdisable') == 1) ? false : true;
1831      var loopdisable = (jQuery(this).data('loopdisable') == 1) ? false : true;
1832      var rtltrue = (jQuery('body').hasClass('rtl')) ? true : false;
1833      if (jQuery(this).data('fullrow') == 1) {
1834         var breakpoint = {
1835            0:{
1836               items:1,
1837               nav:true,
1838            },
1839            530:{
1840               items:2,
1841            },
1842            730:{
1843               items:3,
1844            },
1845            1024:{
1846               items:4,
1847            },                        
1848            1224:{
1849               items:showrow,
1850            }
1851         }
1852      }
1853      else if (jQuery(this).data('fullrow') == 2) {
1854         var breakpoint = {
1855            0:{
1856               items:1,
1857               nav:true,
1858            },
1859            768:{
1860               items:2,
1861            },
1862            1120:{
1863               items:3,
1864            },                        
1865            1224:{
1866               items:showrow,
1867            }
1868         }
1869      }      
1870      else {
1871         var breakpoint = {
1872            0:{
1873               items:1,
1874               nav:true,
1875            },
1876            510:{
1877               items:2,
1878            },
1879            600:{
1880               items:3,
1881            },            
1882            1024:{
1883               items:showrow,
1884            }
1885         }
1886      }         
1887
1888      jQuery(this).owlCarousel({
1889      	rtl:rtltrue,
1890         loop:loopdisable,
1891         dots:false,
1892         nav: navdisable,
1893         lazyLoad: laizy,
1894         autoplay: carouselplay,
1895         responsiveClass:true,
1896         navText :["", ""],
1897         navClass: ["controls prev","controls next"],
1898         responsive: breakpoint
1899      });    
1900   });     
1901
1902   var canSlide = true;
1903
1904    // Setup a callback for the YouTube api to attach video event handlers
1905   window.onYouTubeIframeAPIReady = function(){
1906      // Iterate through all videos
1907      jQuery('.gallery_top_slider iframe').each(function(){
1908         var slider = jQuery('.gallery_top_slider');
1909         // Create a new player pointer;
1909 "this" is a DOMElement of the player's iframe
1910         var player = new YT.Player(this, {
1911            playerVars: {
1912               autoplay: 0
1913            }
1914         });
1915 
1916         // Watch for changes on the player
1917         player.addEventListener("onStateChange", function(state){
1918            switch(state.data)
1919            {
1920               // If the user is playing a video, stop the slider
1921               case YT.PlayerState.PLAYING:
1922                  slider.flexslider("stop");
1923                  canSlide = false;
1924                  break;
1925               // The video is no longer player, give the go-ahead to start the slider back up
1926               case YT.PlayerState.ENDED:
1927               case YT.PlayerState.PAUSED:
1928                  slider.flexslider("play");
1929                  canSlide = true;
1930                  break;
1931            }
1932         });
1933 
1934         jQuery(this).data('player', player);
1935      });
1936   }          
1937
1938   //SLIDER
1939   var flexslidersiteInit = function() {
1940   if(jQuery().flexslider) {
1941
1942      jQuery('.featured_slider').each(function() {
1943         var slider = jQuery(this);
1944         slider.flexslider({
1945            animation: "slide",
1946            selector: ".slides > .slide",
1947            slideshow: false,  
1948            start: function(slider) {
1949               slider.find('img.lazyimages').trigger("unveil");                               
1950            }             
1951         });
1952      });
1953
1954
1955      jQuery('.blog_slider').each(function() {
1956         var slider = jQuery(this); 
1957         var autoplay = jQuery(this).hasClass('autoplayfs') ? true : false;
1958         slider.flexslider({
1959            animation: "slide",
1960            controlNav: false,
1961            smoothHeight: true,
1962            slideshow: autoplay,
1963            start: function(slider) {
1964               slider.removeClass('loading');
1965               var first_height = jQuery('.blog_slider .slides li:last-child img').height();
1966               jQuery('.flex-viewport').height(first_height);
1967            }      
1968         });
1969      }); 
1970      
1971      jQuery('.gallery_top_slider').each(function() {
1972         var tag = document.createElement('script');
1973         tag.src = "//www.youtube.com/iframe_api";
1974         var firstScriptTag = document.getElementsByTagName('script')[0];
1975         firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);         
1976         var slider = jQuery(this); 
1977         slider.flexslider({
1978            animation: "fade",
1979            controlNav: "thumbnails",
1980            slideshow: false,
1981            video: true,
1982            //useCSS: false, 
1983            before: function(){                 
1984               if(!canSlide)
1985                  slider.flexslider("stop");
1986            },            
1987            start: function(slider) {
1988               slider.find('img.lazyimages').trigger("unveil");               
1989               slider.removeClass('loading');
1990               jQuery('.flex-control-thumbs img').each(function() {
1991                  var widththumb = jQuery(this).width();
1992                  jQuery(this).height(widththumb);
1993               });                
1994            }
1995         });
1996         slider.on("click", ".flex-prev, .flex-next, .flex-control-nav", function(){
1997            canSlide = true;
1998            jQuery('.gallery_top_slider iframe').each(function(){
1999               jQuery(this).data('player').pauseVideo();
2000            });
2001            if (jQuery('.gallery_top_slider .flex-active-slide iframe').length > 0) {
2002               jQuery('.gallery_top_slider .flex-active-slide iframe').data('player').playVideo();
2003            }
2004         });  
2005         jQuery(".play3").fitVids();          
2006      }); 
2007
2008      jQuery('.main_slider').each(function() {
2009         var slider = jQuery(this);
2010         slider.flexslider({
2011            animation: "slide", 
2012            start: function(slider) {
2013               slider.removeClass('loading');
2014            }                
2015         });
2016      });
2017
2018      jQuery('.rtl .main_slider').each(function() {
2019         var slider = jQuery(this);
2020         slider.flexslider({
2021            animation: "slide",
2022            rtl: true, 
2023            start: function(slider) {
2024               slider.removeClass('loading');
2025            }                
2026         });
2027      });      
2028
2029      jQuery('.re_thing_slider').each(function() {
2030         var slider = jQuery(this);
2031         slider.flexslider({
2032            animation: "slide", 
2033            start: function(slider) {
2034               slider.removeClass('loading');
2035            }                
2036         });
2037      });      
2038
2039      jQuery('.flexslider').each(function() {
2040         var slider = jQuery(this);
2041         slider.flexslider({
2042            animation: "slide",
2043            start: function(slider) {
2044               jQuery( slider ).removeClass( 'loading' );
2045            }                 
2046         });
2047      });                        
2048
2049   }}
2050
2051   flexslidersiteInit();   
2052});
2053
2054//Check responsive nav pills
2055jQuery(function() {
2056   if(jQuery('.responsive-nav-greedy').length > 0){
2057
2058      var $btnnavgreedy = jQuery('.responsive-nav-greedy .togglegreedybtn');
2059      var $vlinksgreedy = jQuery('.responsive-nav-greedy .rhgreedylinks');
2060      var $hlinksgreedy = jQuery('.responsive-nav-greedy .hidden-links');
2061
2062      var numOfItemsGreedy = 0;
2063      var totalSpaceGreedy = 0;
2064      var breakWidthsGreedy = [];
2065
2066      var greedytimer = function() {
2067            $hlinksgreedy.addClass('rhhidden');
2068         };      
2069
2070      // Get initial state
2071      $vlinksgreedy.children().width(function(i, w) {
2072         totalSpaceGreedy += w;
2073         numOfItemsGreedy += 1;
2074         breakWidthsGreedy.push(totalSpaceGreedy);
2075      });
2076
2077      var availableSpace, numOfVisibleItems, requiredSpace;
2078
2079      var rh_responsive_pills_check = function() {
2080
2081      // Get instant state
2082      availableSpace = $vlinksgreedy.width() - 10;
2083
2084      numOfVisibleItems = $vlinksgreedy.children().length;
2085      requiredSpace = breakWidthsGreedy[numOfVisibleItems - 1];
2086
2087      // There is not enought space
2088      if (requiredSpace > availableSpace) {
2089         $vlinksgreedy.children().last().prependTo($hlinksgreedy);
2090         numOfVisibleItems -= 1;
2091         rh_responsive_pills_check();
2092      // There is more than enough space
2093      } else if (availableSpace > breakWidthsGreedy[numOfVisibleItems]) {
2094         $hlinksgreedy.children().first().appendTo($vlinksgreedy);
2095         numOfVisibleItems += 1;
2096      }
2097      // Update the button accordingly
2098      $btnnavgreedy.attr("count", numOfItemsGreedy - numOfVisibleItems);
2099      if (numOfVisibleItems === numOfItemsGreedy) {
2100         $btnnavgreedy.addClass('rhhidden');
2101      } else $btnnavgreedy.removeClass('rhhidden');
2102      }
2103
2104      // Window listeners
2105      jQuery(window).resize(function() {
2106         rh_responsive_pills_check();
2107      });
2108
2109      $btnnavgreedy.on('click', function() {
2110         $hlinksgreedy.toggleClass('rhhidden');
2111         clearTimeout(greedytimer);
2112      });
2113
2114      $hlinksgreedy.on('mouseleave', function() {
2115         setTimeout(greedytimer, 2000);
2116      }).on('mouseenter', function() {
2117         clearTimeout(greedytimer);
2118      });      
2119
2120      rh_responsive_pills_check();
2121   }
2122});

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.