var HW = {}; /* setting some flags */ (function(){ HW.isIE = $.browser.msie; HW.isIE6 = HW.isIE && $.browser.version.substring(0,1) === '6'; })(); HW.HeaderLoginLinks = { config:{ classLoginItem:"jsHeaderLoginItem" }, CBI_win:null, // this openIBank function is carried from existing JavaScript code openIBank:function(url){ var BrowserName = navigator.appName; var BrowserVersion = parseInt(navigator.appVersion); var BrowserHeight2 = screen.height-150; var BrowserWidth2 = screen.width-30; var CBI_win = this.CBI_win; if(!CBI_win || CBI_win.closed) { CBI_win = window.open(url,"CBI","toolbar=0,width="+BrowserWidth2+",height="+BrowserHeight2+",status=1,scrollbars=1,resizable=1,menubar=0,top=0,left=0"); }else{ CBI_win.focus(); } this.CBI_win = CBI_win; }, init:function(){ var obj = this; var config = obj.config; // Header login items var loginItems = $("."+config.classLoginItem); loginItems.click(function(e){ e.preventDefault(); obj.openIBank($(this).attr("href")); }); } } HW.FooterLinks = { config:{ idFooter:"jsFooter", classOverlay:"jsOverlayNormal" }, init:function(){ var config = this.config; var footer = $("#"+config.idFooter); if(!footer.length) return; var footerLinks = footer.find("."+config.classOverlay); if(!footerLinks.length) return; footerLinks.each(function(){ var footerLink = $(this); // using HW JS overlay plugin footerLink.click( function(e){ e.preventDefault(); $.portal(footerLink.attr("href")); } ); }); } } HW.RotatingBanner = { banner:[], rotatingItems:[], config:{ idBanner:"jsBanner", classRotatingItem:"jsBannerItem", classCurrent:"jsCurrent" }, loop:function(banner){ var obj = HW.RotatingBanner, config = obj.config; obj.rotatingItems.eq(obj.banner.data('currentItem')).fadeOut(500,function(){ $(this).removeClass('jsCurrent'); }); // update the current item index var current = (obj.banner.data('currentItem') + 1 == obj.banner.data('totalItems')) ? 0 : obj.banner.data('currentItem') + 1; obj.rotatingItems.eq(current).fadeIn(1000,function(){ $(this).addClass('jsCurrent'); obj.banner.data('currentItem',current); }); }, init:function(){ var obj = this, config = obj.config; obj.banner = $('#'+config.idBanner); // pre-mature exit when there is no banner if(obj.banner.length == 0) { return; } obj.rotatingItems = obj.banner.find('.'+config.classRotatingItem); // store the total number of items obj.banner.data('totalItems',obj.rotatingItems.length); // find out which item has the current class defined by the user obj.banner.data('currentItem', obj.rotatingItems.filter('.' + config.classCurrent).index() ); // when no current item is selected, use the first item if(obj.banner.data('currentItem') < 0){ obj.rotatingItems.eq(0).addClass('jsCurrent'); obj.banner.data('currentItem',0); } // add the JS class to HTML to avoid flickering in IE6 if(HW.isIE6) { $("html").addClass("js"); } // start rotating setInterval(HW.RotatingBanner.loop,8000); }// end init }; HW.Tab = { config:{ classContainer:"jsTab", classTrigger:"jsTabTrigger", classTarget:"jsTabTarget", classDefaultItem:"jsTabTargetDefault" }, init:function(){ var obj = this, config = obj.config; var container = $("."+config.classContainer); var targets, triggers, defaultItem; // pre-mature exit if container does not exist if(container.length == 0) { return; } targets = $("."+config.classTarget); triggers = $("."+config.classTrigger); defaultItem = $("."+config.classDefaultItem); // if default item does not exist, show the first target item if(defaultItem.length == 0) { targets.eq(0).show(); triggers.eq(0).closest('li').addClass('selected'); } // handle selection triggers.each(function(){ // $(this) here is the current trigger in the loop var delegate = $(this).closest('li'); delegate.data('targetTab',$('.'+config.classTrigger,delegate).attr('href').substring(1)); delegate.click(function(evt){ evt.preventDefault(); if(defaultItem.length > 0 && defaultItem.is(':visible')){ defaultItem.hide(); } // 'this' is now the LI element that its jsTabTrigger is clicked $(this).siblings('li').removeClass('selected'); targets.hide(); $("#"+delegate.data('targetTab')).show(); $(this).addClass('selected'); }); }); }// end init }; HW.ContentOverlay = { config:{ classTrigger:".jsContentOverlayTrigger" }, init:function(){ var config = this.config; var triggers = $(config.classTrigger); if(!triggers.length) { return; } triggers.each(function(){ var trigger = $(this); // using HW JS overlay plugin trigger.click( function(e){ e.preventDefault(); $.ajaxportal($(this).attr("href")); } ); }); }// end init }; HW.Popup = { config:{ classPopup:".jsPopup" }, init:function(){ var config = this.config; var triggers = $(config.classPopup); if(!triggers.length) { return; } triggers.each(function(){ $(this).click(function(evt){ evt.preventDefault(); evt.stopPropagation(); window.open($(this).attr('href'),"popup","width=720,height=500,top=0,left=100,scrollbars=1,location=0,menubar=0,resizable=1"); }); }); }// end init } $(document).ready(function(){ HW.HeaderLoginLinks.init(); HW.FooterLinks.init(); HW.RotatingBanner.init(); HW.Tab.init(); HW.ContentOverlay.init(); HW.Popup.init(); });