var website = website || {}; website.navigation = website.navigation || {}; (function($){ function TabbedContentController(config){ this._init(config); } TabbedContentController.prototype = { welcomePages: new Array(), curPage: 0, pageHeight: 0, fullPages: new Array(), subPages: new Array(), curHeight: 0, paging: null, currentTestimonial:0, testimonials: null, mobile: false, _init: function(config){ var me = this; try{ this.respFull = new jqFrp.data.Responsive({ minWidth: 960 }); this.respTablet = new jqFrp.data.Responsive({ maxWidth: 960, minWidth: 750 }); this.respPhone = new jqFrp.data.Responsive({ maxWidth: 750 }); } catch(err){} $.extend(me,config); this._initEvents(); this._initWelcomeMessage(false); if($('.testimonials-item').length){ this.testimonials = $('.testimonials-item'); this._initTestimonials(); } if($(window).width() <= 750){ $(this.respPhone).trigger("inResponsive"); } if ($('.tabbed-content .tab').first().attr('id') == 'locations-tab'){ $(window).load(function(){ $('#locations-tab').click(); }); } }, _initEvents: function(){ var me = this; $('.tabbed-content .tab').on("click", function(){ if(me.mobile){ $(this).siblings('.tab-content').slideToggle(); } else { $('.tabbed-content .tab-content').hide(); $('.tabbed-content .tab.active').removeClass("active"); $(this).parent().children('.tab-content').show(); $(this).addClass("active"); } }); $('.tab-content').on("click",'#welcome-next-page',function(){ me.nextPage(); }); $('.tab-content').on("click",'#welcome-prev-page',function(){ me.prevPage(); }); $('#testimonials-tab').on("click", function(){ $(me.testimonials).hide(); $(me.testimonials[me.currentTestimonial]).show(); }); $('#home-page').on("click",".welcome-page-indicator:not(.active-page)",function(){ me.gotoPage(parseInt($(this).attr('page'))); }); $([me.respFull,me.respTablet,me.respPhone]).on("inResponsive",function(){ me._initWelcomeMessage(true); if(this === me.respPhone){ me.mobile = true; me.adjustForPhone(); } }); $(me.respPhone).on("outResponsive", function(){ me.mobile = false; me.revertForPhone(); }); }, adjustForPhone: function(){ var el = $('#tabbed-content-container').children('.tabbed-content').get(0); if ($(el).children('#welcome-container').length) { $(el).attr("id",'mobile-welcome'); $(el).children('.tab').hide(); $('#tabbed-content-container').before(el); } }, revertForPhone: function(){ var el = $('#mobile-welcome'); if ($(el).children('#welcome-container').length) { $(el).children('.tab').show(); $('#tabbed-content-container').prepend(el); $('#welcome-tab').click(); } }, _initTestimonials: function(){ var me = this; this.testInterval = setInterval(function(){ var prevTest = me.currentTestimonial; if(prevTest == me.testimonials.length - 1 ){ me.currentTestimonial = 0; } else { me.currentTestimonial++; } $(me.testimonials[prevTest]).fadeOut(); $(me.testimonials[me.currentTestimonial]).fadeIn(); },13000); }, _initWelcomeMessage: function(rebuild){ if ($('#welcome-container').parent().hasClass('tab-content') !== true) { return false; } var me = this; var para = ""; if(rebuild) { para = $('.welcome-page img, .welcome-page h1, .welcome-page p, .welcome-page div, .welcome-page ul, .welcome-page li'); $(".welcome-page").remove(); me.curPage = 0; } else { para = $('#welcome-inner-container img, #welcome-inner-container h1, #welcome-inner-container p, #welcome-inner-container div, #welcome-inner-container ul, #welcome-inner-container li'); } this.pageHeight = $('#welcome-container').height(); var page = $('
'); var tmp = $(""); $('body').append(tmp); $(tmp).append(page); $.each(para, function(){ $(page).append(this); if($(page).height() > me.pageHeight){ $(this).remove(); me.welcomePages.push(page); page = $(''); $(tmp).append(page); $(page).append(this); } }); me.welcomePages = $(".welcome-page"); $('#welcome-inner-container').html(''); $('#welcome-inner-container').append($(tmp).children()); if(this.welcomePages.length > 1){ this._addWelcomeControls(rebuild); } }, _addWelcomeControls: function(rebuild){ if(rebuild){ $("#welcome-paging").remove(); } this.paging = $(""); var pageI = null; for(var i=0;i