jQuery.cookie=function(key,value,options){if(arguments.length>1&&String(value)!=="[object Object]"){options=jQuery.extend({},options);if(value===null||value===undefined){options.expires=-1;}if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days);}value=String(value);return(document.cookie=[encodeURIComponent(key),'=',options.raw?value:encodeURIComponent(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''));}options=value||{};var result,decode=options.raw?function(s){return s;}:decodeURIComponent;return(result=new RegExp('(?:^|; )'+encodeURIComponent(key)+'=([^;]*)').exec(document.cookie))?decode(result[1]):null;};$.fn.equalHeights=function(px){$(this).each(function(){var currentTallest=0;$(this).children().each(function(i){if($(this).height()>currentTallest){currentTallest=$(this).height();}});if($.browser.msie&&$.browser.version==6.0){$(this).children().css({'height':currentTallest});}$(this).children().css({'min-height':currentTallest});});return this;};$.fn.divideHeights=function(){var container=$(this).height();var children=$(this).children().length;var results=container/children;$(this).children().each(function(i){$(this).css({'height':results+'px'});});if(('.divideheights h2').length){$('.divideheights h2:not(.twoline)').each(function(i){var headHeight=$(this).parent().height();$(this).css({'height':headHeight-1+'px','line-height':headHeight-1+'px','padding-top':0});});$('.divideheights h2.twoline').each(function(i){var headHeight=$(this).parent().height();var headlineHeight=$(this).children().height();var desiredCenter=(headHeight-headlineHeight)/2;$(this).css({'padding-top':desiredCenter+'px'});});}return this;};$.fn.calltoaction=function(){var container=$(this).height();var children=$(this).children().length;var results=container/children;$(this).children().each(function(i){});if(('.calltoaction h2').length){$('.calltoaction h2:not(.twoline)').each(function(i){var headHeight=$(this).parent().height();$(this).css({'height':headHeight-1+'px','line-height':headHeight-1+'px','padding-top':0});});$('.calltoaction h2.twoline').each(function(i){var headHeight=$(this).parent().height();var headlineHeight=$(this).height();var desiredCenter=(headHeight-headlineHeight)/2;$(this).css({'padding-top':desiredCenter+'px'});});}return this;};$.fn.equalWidths=function(px){$(this).each(function(){var currentWidest=0;$(this).children().each(function(i){if($(this).width()>currentWidest){currentWidest=$(this).width();}});if(!px||!Number.prototype.pxToEm)currentWidest=currentWidest.pxToEm();if($.browser.msie&&$.browser.version==6.0){$(this).children().css({'width':currentWidest});}$(this).children().css({'min-width':currentWidest});});return this;};Number.prototype.pxToEm=String.prototype.pxToEm=function(settings){settings=jQuery.extend({scope:'body',reverse:false},settings);var pxVal=(this=='')?0:parseFloat(this);var scopeVal;var getWindowWidth=function(){var de=document.documentElement;return self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;};if(settings.scope=='body'&&$.browser.msie&&(parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(1)>0.0){var calcFontSize=function(){return(parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(3)*16;};scopeVal=calcFontSize();}else{scopeVal=parseFloat(jQuery(settings.scope).css("font-size"));};var result=(settings.reverse==true)?(pxVal*scopeVal).toFixed(2)+'px':(pxVal/scopeVal).toFixed(2)+'em';return result;};$(document).ready(function(){$('.jsSubmit .btn').hide();$('.jsSubmit select').css("width","100%");var $tabs='<ul class="tabs">';$tabs+='<li class="first current"><span>Home loans</span></li>';$tabs+='<li class="last"><span>Investments</span></li>';$tabs+='</ul>';$('.rates h3').after($tabs);$('.rates h4').each(function(){$(this).addClass('hidden');});$('.rates .block:not(.default)').each(function(){$(this).hide();});$('ul.tabs').each(function(){$(this).find('li').each(function(i){$(this).click(function(){$(this).addClass('current').siblings().removeClass('current').parents('div.rates').find('div.block').hide().end().find('div.block:eq('+i+')').fadeIn(150);});});});$('.addhover').hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');});$('.products .unit:not(.divideheights)').hover(function(){if(($(this).find('ul').length)){$(this).addClass('nocursor');}$(this).addClass('hover');$(this).find('h2').addClass('hover');},function(){if($(this).find('ul').length){$(this).removeClass('nocursor');}$(this).removeClass('hover');$(this).find('h2').removeClass('hover');});$('.products .unit').bind('click',function(){if($(this).find('ul').length){$(this).addClass('nocursor');}else{window.location=$(this).find('a').attr('href');}});$('.products .divideheights h2').hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');});$('.equalheights').equalHeights();$('.products .line').equalHeights();$('.divideheights').divideHeights();$('.calltoaction').calltoaction();$.fn.focus_blur=function(){return this.focus(function(){if(this.value==this.defaultValue){this.value="";}}).blur(function(){if(!this.value.length){this.value=this.defaultValue;}});};$("#askInput").focus_blur();$.fn.rememberSelection=function(cookieName){var bankingMenuSelect=$(this);var bankingMenuCookie=$.cookie(cookieName);$(bankingMenuSelect).change(function(){$.cookie(cookieName,bankingMenuSelect.val(),{expires:365,path:'/'});});if(bankingMenuCookie){$(bankingMenuSelect).val(bankingMenuCookie);};};$('select#bankingMenu').rememberSelection('bankingMenu');if($.browser.msie&&$.browser.version<=7){$('.action a:not(:last-child)').after('<br>');}function recordOutboundLink(link,category,action,label){_gat._getTrackerByName()._trackEvent(category,action,label);setTimeout('document.location = "'+link+'"',100);}function isExternalLink(link){if((link.match(/^https?\:/i))&&(!link.match(document.domain))){return true;}}jQuery(function(){jQuery('a[href$=".pdf"]').click(function(){_gaq.push(['_trackEvent','Download','PDF',this.href]);})});jQuery(function(){jQuery('a[href$=".doc"]').click(function(){_gaq.push(['_trackEvent','Download','Word doc',this.href]);})});jQuery(function(){jQuery('a[href$=".zip"]').click(function(){_gaq.push(['_trackEvent','Download','Zip file',this.href]);})});jQuery(function(){jQuery('a[href^="mailto"]').click(function(){_gaq.push(['_trackEvent','Contact Us','Mailto link',this.href]);})});$('.jsSubmit select').change(function(){var href=$(this).val();var siteArea=getSiteAreaValue();if(href){if(isExternalLink(href)){recordOutboundLink(href,siteArea,'Dropbox-'+$(this).parent().prev().val(),$("option:selected",this).text());}else{_gaq.push(['_trackEvent',siteArea,'Dropbox-'+$(this).parent().prev().val(),$("option:selected",this).text()]);window.location.href=href;}}});$('.searchform').bind('submit',function(event){if($('#searchInput').val()){}else{event.preventDefault();}});$('.askform').bind('submit',function(event){var url='http://westpac.custhelp.com/app/answers/list/kw/';if($('#askInput').val()){recordOutboundLink(url+escape($('#askInput').val()),'Global','Ask Westpac',window.location.pathname);}event.preventDefault();});$('.login').bind('submit',function(event){if($('.login select').val()){recordOutboundLink($('.login select').val(),'Global',$('.login option:selected').text(),window.location.pathname);}event.preventDefault();});$('#facebookshare,#twittershare,#linkedinshare').click(function(){var sTitle=getDocTitleValue();_gaq.push(['_trackEvent','Share',$(this).attr('id'),sTitle]);});});
