$(document).ready(function(){var l=$("#widgets a:not(#login)");var a=$('<div id="pc"></div>').prependTo("body");var m=$('<div id="pc_searched_for">you searched for: </div>');var o=$.browser.msie;var e=$.browser.version;var h=[];var q=0;var v=function(){$(".widget").removeClass("current")};var j=function(E){E.parent().addClass("current")};var u=function(){$("#searchbox").addClass("current")};var t=function(){v();a.data("active",null);$("html").unbind("keydown",f);if(o&&e<8){$("#pc .pc_content").hide()}a.animate({opacity:0},200,"linear",function(){a.animate({height:0},400);a.trigger("consoleclose");a.attr("aria-expanded","false");a.addClass("closed");$("#pc_overlay").html("")});return false};var r=function(H,G,E){var F=G.id+"_htabs",I=function(J){return J.toLowerCase().replace(/[\s_]+/g,"-").replace(/[^A-Za-z0-9\-_:\.]/g,"")};$('<div id="'+F+'" class="tabs ui-tabs-horizontal"><ul id="'+F+'_ul"></ul></div>').prependTo(G);$("#"+(E=="console"?"pc #":"")+G.id+" .tab").each(function(){var L=$(this);this.id=I(this.id);var K=L.find("h2,h3").first().text();var J=I(L.attr("id"));$('<li><a href="#'+J+'" title="'+K+'" rel="pageState:'+F+"="+J+'"><span>'+K+"</span></a></li>").appendTo("#"+F+"_ul");L.find("h2,h3").first().remove()});$("div.tabs").find(">ul").each(function(){$(this).children("li:first").addClass("first-tab").end().children("li:last").addClass("last-tab")}).end();setTimeout(function(){$("#"+F).allytabs({selected:0,fx:{opacity:"toggle",duration:"normal"}})},100)};var C=function(){$("#security").each(function(){$(this).attr("href",$(this).attr("href").replace("/index","/welcome"))});if(window.location.href.match("/global-reach/")){$("#globalreach").attr("href","#").attr("rel","").addClass("disabled")}if(window.location.href.match("/contact-us/")){$("#contact").attr("href","#").attr("rel","").addClass("disabled")}if(window.location.href.match("/help/")){$("#help").attr("href","#").attr("rel","").addClass("disabled")}if(window.location.href.match("/security[/-]")){$("#security").attr("href","#").attr("rel","").addClass("disabled")}};var i=function(E){var F=E.parents(".item").find("label").text();if(typeof F=="undefined"){F=""}E.data("label",F);E.val(F)};var g=function(){i($("#pc .fullname"));i($("#pc .emailaddress"));i($("#pc .messagebox"));$("#pc .fullname, #pc .messagebox, #pc .emailaddress").live("focusin",function(){var E=$(this);if(E.val()==E.data("label")){E.val("")}$("<div id='temp_label' />").text(E.data("label")).insertBefore(E).hide().fadeIn("slow")}).live("focusout",function(){var E=$(this);if(E.val()==""){E.val(E.data("label"))}$("div#temp_label").fadeOut("slow",function(){$(this).remove()})})};var n=function(){$("#pc textarea, :text, :password").live("focusin",function(){$(this).parents(".control").addClass("hasfocus")});$("#pc textarea, :text, :password").live("focusout",function(){$(this).parents(".control").removeClass("hasfocus")});$("form.search").each(function(){var F=$(this);var E=$(this).find(".text");if($("#page").is(".dealer")){$(E).live("focusin",function(){$(F).addClass("searchfocus")}).live("focusout",function(){$(F).removeClass("searchfocus")})}else{if($(E).val()==""){$(E).val("search")}$(E).live("focusin",function(){$(F).addClass("searchfocus");$(E).val("")});$(E).live("focusout",function(){$(F).removeClass("searchfocus");if($(E).val()==""){$(E).val("search")}})}$(this).submit(function(G){if($(E).val()==""||$(E).val()=="search"){$(E).focus();G.preventDefault()}})})};var x=function(){var E=[];$("#pc .tab").not("#pc_temp .tab").map(function(F){E[F]=$(this).height()});return E};var c=function(F){var E=[];if(F=="asc"){E=x().sort(function(H,G){return H-G})}else{E=x().sort(function(H,G){return G-H})}return E};var B=function(){var F=$("#help_faq_list ul.questions").clone().css({position:"relative",left:"-999em"}).appendTo("#help_faq_list");F.find("> li").addClass("open");var E=0;F.find(".answer").each(function(){if(E<$(this).height()){E=$(this).height()}});F.remove();return E};var A=function(){if(a.data("active")=="contact"){var G=c("desc");var E=G[1]+150;var F=$("#contactusbyemailform").height()+150;pcHeight=E;if($("#pc li.ui-tabs-selected a[href='#pc-contact-email']").length>0){pcHeight=F}}else{if(a.data("active")=="help"){pcHeight=$("#pc_container").height()+B()+40}else{pcHeight=$("#pc_container").height()+80}}return pcHeight};var p=function(){$("form.search").each(function(){$(this).attr("role","search")});$(".tabs, .wslide-menu, #globalnav").each(function(){$(this).attr("role","navigation")});$(".tab-content").each(function(){$(this).attr("aria-live","assertive")})};var d=function(){$(".global-reach a").click(function(){var E={content:$(this).attr("href"),height:200,width:550,title:"The Global Reach of Ally",handleOversize:"resize",player:"ajax"};ALLY.ui.shadowbox.show(E);return false})};var f=function(E){if($(E.target).closest("form").length===0){if(E.keyCode=="37"||E.keyCode=="40"||E.keyCode=="34"){if($(".viewall").hasClass("active")){$(".wslide-menu").find(".viewall").blur().removeClass("active");$(".wslide-menu").find("#last").click().focus()}else{$(".wslide-menu").find(".wactive").prev().click().focus()}return false}if(E.keyCode=="39"||E.keyCode=="38"||E.keyCode=="33"){if($(".wslide-menu").find("#last").hasClass("wactive")){$(".wslide-menu").find("#last").blur().removeClass("wactive");$(".wslide-menu").find(".viewall").focus().addClass("active")}else{$(".wslide-menu").find(".wactive").next().click().focus()}return false}if(E.keyCode=="36"){$(".wslide-menu").find("#first").click().focus();return false}if(E.keyCode=="35"){$(".wslide-menu").find("#last").click().focus();return false}}};var k=function(){var H=0;$("#pc #current_results .slide_li").each(function(){if($(this).height()>H){H=$(this).height()+35}});var J=1;var G=$("#pc_total-hits,#total-hits").val();var F=$("#pc_search-term,#search-term").val();var I=(G<5)?G:5;var E="1-"+I;$("#pc #current_results").wslide({width:650,height:H,duration:400});$(".wslide-menu").find("a:first-child").attr("id","first");$(".wslide-menu").find("a:last-child").attr("id","last");if(!$("#pc .viewall").length&&G>15){$('<a href="/search/index.html?term='+F+'" class="viewall">view all</a>').appendTo("#pc #current_results-menu")}if($(".wslide-menu a#last").text()=="1"){$(".wslide-menu a#last").attr("href","").css("cursor","default")}$(".wslide-menu a").click(function(){var K=0;if($(this).text()!=J){J=$(this).text();if(J=="1"){K=(G<5)?G:5;E="1-"+K}if(J=="2"){K=(G<10)?G:10;E="6-"+K}if(J=="3"){K=(G<15)?G:15;E="11-"+K}$("#pc .results_count").fadeOut(400,function(){$("#pc .results_count").html('<div id="results_count">Viewing results <strong>'+E+" of "+G+'</strong> for <strong>"'+F+'"</strong></div>').prependTo("#pc .search_listing");$("#pc .results_count").fadeIn(400)});$(".wslide-menu").find(".viewall").blur().removeClass("active")}});if(!$("#pc .results_count").length&&!$("#pc .noresult").length){$('<div class="results_count">Viewing results <strong>'+E+" of "+G+'</strong> for <strong>"'+F+'"</strong></div>').prependTo("#pc .search_listing")}};var s=function(F){var G=new Image();if(typeof F=="string"){G.src=F}else{for(var E=0;E<F.length;E++){G.src=F[E]}}};var z=function(){a.animate({height:A()},400,"linear",function(){if(a.data("active")=="search"){$("a.wactive").focus();$("#pc_overlay #pc_aside").css("visibility","visible");$("#pc_overlay h1").addClass("h1active")}a.animate({opacity:1},400,"linear",function(){a.trigger("consoleopen")})})};var y=function(J){n();if(a.data("active")=="help"){$('<div class="browse_all_help">Not what you were looking for? <a href="'+a.data("consoleHref")+'">Browse all Help</a></div>').insertBefore("#help_faq_list");$("#pc h2").remove()}if(a.data("active")=="globalreach"){}if(a.data("active")=="search"){$("#pc .pagination").remove();$("#pc .results_count").remove();var G=$("#pc .results li");for(var H=0;H<G.length;H+=5){G.removeClass("first");G.removeClass("last");G.slice(H,H+5).wrapAll("<li class='slide_li'><ul></ul></li>")}$("#pc .results").attr("id","current_results").addClass("slide_ul");k();$("html").unbind("keydown",f);$("html").keydown(f);$("#pc a.noresult").live("click",function(){b(decodeURI($(this).attr("href"))+"&type=content&target=pc","openConsole");return false})}if(a.data("active")=="contact"){var E;var F=new Date();var I=new Date(F.getFullYear,F.getMonth()+1,1);$.getScript("/files/pres/js/ally.contactus.js?"+Date.parse(I),function(){$("html").bind("messagesLoaded",function(K){E=$("html").data("messages")});ALLY.contactus.loadValidationMessages();ALLY.contactus.injectContactForm($("div.emailus_fields"),ALLY.pageContext.contactus||"bank")});$("#pc .tab_wrap").each(function(){r(0,this,"console")}).addClass("tabs_horizontal");$("#contact_us_htabs").bind("allytabsshow",function(){J()});$("#pc .messagebox").elastic();$('<div id="pc_not_finding">Not what you were looking for? <a href="/contact-us/">View all contacts</a></div>').prependTo("#pc .contact_us_content")}$('<a class="pc_close">close</a>').prependTo(a);$(".pc_close").live("click",t);a.trigger("consolechange");J()};var D=function(E){a.animate({opacity:0},200,"linear",function(){a.html(a.data(E));pcHeight=A();a.animate({height:pcHeight},400,"linear",function(){n();p();if(a.data("active")=="contact"){$("#contactusprimaryReason_link").menu({content:$("#contactusprimaryReason_wrap").html(),crumbDefaultText:"",width:445});$("#contact_us_htabs").allytabs({selected:0,fx:{opacity:"toggle",duration:"normal"}});g();$("#pc .messagebox").elastic()}if(a.data("active")=="globalreach"){}if(a.data("active")=="help"){questionsanswers._init("single")}a.animate({opacity:1},400,"linear")})})};var b=function(F,G){a.data("consoleHref",F);a.attr("aria-expanded","true");a.removeClass("closed");if(a.data(F)&&a.data("active")!="search"&&a.data("active")!="contact"){if(a.height()===0){a.html('<div id="pc_load"><img src="/files/pres/images/wait-large.gif" width="31" height="31" alt="Loading..." /></div>');a.animate({height:66},400,"linear",function(){D(F)})}else{if(a.data("active")!="search"){$("#pc_overlay").html("")}a.fadeOut(400,function(){a.html('<div id="pc_load_open"><img src="/files/pres/images/wait-large.gif" width="31" height="31" alt="Loading..." style="margin-top:'+(a.height()/2-15)+'px"/></div>')});a.fadeIn(400,function(){D(F)})}}else{var E={type:"content",target:"pc"};$.ajax({url:F,data:E,timeout:15000,beforeSend:function(){if(a.height()<66){a.html('<div id="pc_load"><img src="/files/pres/images/wait-large.gif" width="31" height="31" alt="Loading..." /></div>');a.animate({height:66},400,"linear")}else{a.fadeOut(400,function(){a.html('<div id="pc_load_open"><img src="/files/pres/images/wait-large.gif" width="31" height="31" alt="Loading..." style="margin-top:'+(a.height()/2-15)+'px"/></div>')});a.fadeIn(400)}},error:function(){location=F},success:function(J){var I=$("<div />");I.html(J);$selectedTab=I.find("div#tabs li.ui-tabs-selected");I.find("[id]").each(function(){var K=($(this).hasClass("ui-tabs-panel"))?"pc-":"pc_";K+=$(this).attr("id");$(this).attr("id",K)});I.find("a").unbind("click.pageState");var H="pc-"+a.data("active");J='<div id="pc_container" class="'+H+'">'+I.html()+"</div>";a.animate({opacity:0},200,"linear",function(){a.html(J);switch(a.data("active")){case"contact":$("#pc_overlay").html("");$("#pc").find(".section:first").wrap('<div id="contact_us" class="tab_wrap pc_content contact_us_content"><div class="section tab-content"><div class="ui-tabs-panel"></div></div></div>');break;case"globalreach":$("#pc_overlay").html("");$("#pc_container").addClass("pc_content global-reach");break;case"security":$("#pc_overlay").html("");$("#pc").find(".section:first").children().wrapAll('<div id="how-we-protect-you" class="ui-tabs-panel">').end().wrap('<div id="pc_article" class="cols"><div class="pc_content security_content"></div></div>').addClass("tab-content");$("#pc .section:eq(1)").wrap('<div id="pc_aside"></div>');break;case"search":$("#pc").find(".section:first").wrap('<div id="pc_article" class="pc_content"></div>').addClass("tab-content");if($("#pc_overlay h1").length){$("#pc_overlay h1").html($("#pc h1").html())}else{$("#pc h1").appendTo("#pc_overlay")}$("#pc h1").remove();$("#pc .section:eq(1)").wrap('<div id="pc_aside"></div>');if($("#pc_overlay #pc_aside").length){$("#pc_overlay #pc_aside").html($("#pc #pc_aside").html())}else{$("#pc_aside").appendTo("#pc_overlay")}$("#pc #pc_aside").remove();break;case"help":$("#pc_overlay").html("");$("#pc").find(".section:first").wrap('<div id="pc_article" class="pc_content"></div>').addClass("tab-content");$("#pc .section:eq(1)").wrap('<div id="pc_aside"></div>');$("#pc").find(".questions").wrap('<div id="help_faq_list"></div>');$("#pc_article").css("width","740px");$("#pc li.qa").each(function(){var M=$(this).find("a.a-inline"),K=$(this).find("a.more");var N=K?K.attr("href")+"#":"",L=M?M.attr("name"):"";K.attr("href",N+L);K.prev("p,.answer").append(K)});break}$("#pc .tab-content .tab").find(".section:last").addClass("tab-column-last");$("html").unbind("keydown",f);g();p();y(z);stateName=a.data("consoleHref");if(!$selectedTab.length){a.data(stateName,a.html())}})}})}};l.click(function(E){var F=E.target;if(E.target){F=E.target}else{if(E.srcElement){F=E.srcElement}}if(F.tagName.toUpperCase()=="SPAN"){F=F.parentNode}if(F.rel.toUpperCase()=="PC"){if(a.height()===0){v();j($(this));a.data("active",($(this).attr("id")));b(($(this).attr("href")),"")}else{if(a.data("active")==($(this).attr("id"))){t()}else{v();j($(this));a.data("active",($(this).attr("id")));b(($(this).attr("href")),"openConsole")}}return false}return true});$("ul#textsize-tools").bind("textsizechange",function(){if(a.height()!==0){z()}});$("#searchform").submit(function(K){var G=$("#search_console").val();var I=$(this);var H=$("#search_context").val();var F=$(this).find(".text");var J="/search/index.html?term=";var E=F.val();E=E.replace(/&/g,"%26");if(G=="false"){if($.trim($(F).val())==""||$(F).val()=="search"){$(F).focus();K.preventDefault()}return true}else{if($.trim($(F).val())==""||$(F).val()=="search"){$(F).focus();K.preventDefault()}else{if(a.height()===0){a.data("active","search");v();u();b(J+E+"&context="+H,"")}else{a.data("active","search");v();u();b(J+E+"&context="+H,"openConsole")}return false}}});$("#pc_search").live("submit",function(){var H=$(this);var G=$("#pc_search_context").val();var F=$(this).find(".text");var I="/search/index.html?term=";var E=F.val();if($.trim($(F).val())==""||$(F).val()=="search"){$(F).focus()}else{b(I+E+"&context="+G,"openConsole")}return false});$("#searchbox .btn, #widgets a, #textsize-tools a, .navlink").click(function(){$.each(allUIMenus,function(E){if(allUIMenus[E].menuOpen){allUIMenus[E].kill()}})});$("#pc .slide_li a:not(.noresult)").live("click",function(G){var F=$(this).attr("href");var E=$("#pc_search-term").val();$.cookie("searchTerm",E,{path:"/"});G.preventDefault();location.href=F;return false});$("#pc_overlay .narrow_search_results a").live("click",function(){if(!$(this).parent().hasClass("current")){b(decodeURI($(this).attr("href"))+"&type=content&target=pc","openConsole");$(".narrow_search_results li.current").removeClass("current");$(this).parent().addClass("current")}else{b(decodeURI($(this).attr("href"))+"&type=content&target=pc","openConsole");$(".narrow_search_results li.current").removeClass("current")}return false});a.attr("aria-expanded","false");a.addClass("closed");p();a.bind("tabcontentloaded",function(){z()});l.each(C);$("[rel=chat]").live("click",function(){window.open($(this).attr("href"),"","width=475,height=400,status");return false});a.wrap('<div id="pc_wrap"></div>');$('<div id="pc_overlay"></div>').prependTo("#pc_wrap");$(".tab_wrap").each(r);n();$(document).keyup(function(E){if(E.keyCode==27){t()}});if($.cookie("searchTerm")){var w=$.cookie("searchTerm");$.cookie("searchTerm",null,{path:"/"});a.data("active","search");u();a.html(m);$('<a href="/search/index.html?type=content&target=pc&term='+w+'" class="searched_term">'+w+"</a>").appendTo("#pc_searched_for");$('<a class="pc_close">close</a>').prependTo("#pc_searched_for").click(t);a.delay(1500).animate({height:30},400,function(){$("#pc_searched_for").animate({opacity:1},1000)})}$(".searched_term").live("click",function(){b("/search/index.html?term="+w,"");return false});$("#sendemail,#pc_sendemail").live("submit",function(){var F=$(this);var E=$(this).find("textarea");if($(E).val()==""||$(E).val()=="your message:"||$(E).val()=="please enter your message before submitting"){$(E).val("please enter your message before submitting");return false}});$("form#pc_sendemail span.btn a").attr("href","").live("click",function(){t();return false});h=["/files/pres/images/wait-large.gif","/files/pres/images/wait-small.gif","/files/pres/images/wait-horizontal.gif","/files/pres/shadowbox/images/bg-inner.png","/files/pres/shadowbox/images/modal-close.png","/files/pres/images/clear.png","/files/pres/shadowbox/images/next.png","/files/pres/shadowbox/images/previous.png","/files/pres/shadowbox/images/play.png","/files/pres/shadowbox/images/pause.png","/files/pres/shadowbox/images/frame-top.png","/files/pres/shadowbox/images/frame-rt.png","/files/pres/shadowbox/images/frame-btm.png","/files/pres/shadowbox/images/frame-lt.png","/files/pres/shadowbox/images/frame-lt-btm.png"];s(h)});