// for Cool Menus
if(window.event + "" == "undefined") event = null;
function showMenu(){return false};
oM = {mout:function(){return false;}};

function target_blank(url){
    tmp = window.open(url);
    tmp = null;
}

function wcInternalPopup(url, height, width, opts){
	var wide = parseInt(width);
	var tall = parseInt(height);
    var halfwide = (wide/2);
    var halftall = (tall/2);
    var pWidth = (((parseInt(screen.width) / 2)) - halfwide);
    var pHeight = (((parseInt(screen.height) / 2)) - halftall);
    var features = opts || 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1';
	features += ',width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
    window.open(url,'internalpopup',features);
}

function wcPopup(url, height, width, disclaimer){
	var disclaimer = parseInt(disclaimer);
	var wide = parseInt(width);
	var tall = parseInt(height);
	var halfwide = (wide/2);
	var halftall = (tall/2);
	var pWidth = (((parseInt(screen.width) / 2)) - halfwide);
	var pHeight = (((parseInt(screen.height) / 2)) - halftall);
	var features = 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
	if (disclaimer)
		showWarning("javascript:void(window.open('"+url+"','externalpopup','"+features+"'))", url, false, disclaimer)
	else
		window.open(url,'externalpopup',features);
}

function openDisc(page){
	var pWidth = ( ((parseInt(screen.width) / 2)) - 300)
	var pHeight = (((parseInt(screen.height) / 2)) - 400)
	bWindow = window.open(page,'discwin',"scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,width=600,height=600,top=" + pHeight + ",left=" + pWidth);
	bWindow = null;
}

/************************************************************************************************************
* This function is used in the onclick of the a tag to display the external site warning. 
* @param msg - Integer specifying the which message to display.
* @param lk - The a link object
* Usage: <a href="http://wwww.mysite.com" onclick="return displayThirdPartyAlert(1,this);">My Site</a>
**************************************************************************************************************/
function displayThirdPartyAlert(msg,lk){
	var description = lk.innerHTML;
	if(description.indexOf('alt="') != -1){
		var x = description.indexOf('alt="')+5;
		var temp = description.substring(x);
		description = temp.substring(0,temp.indexOf("\""));
	}
	showWarning(lk.href, description, lk.target, msg)
	return false;
}

/************************************************************************************************************
* This function is used in the href of the a tag to display the external site warning. 
* @param lk - The url of the site to be opened
* @param desc - The description of the site to be opened, i.e. the name of the site.
* @param target - Allows for the window to opened in a new window
* @param msg - Integer specifying the which message to display.
* Usage: <a href="javascript:showWarning('http://wwww.mysite.com');">My Site</a>
**************************************************************************************************************/

function showWarning(lk, desc, target, msg){ //isPeanutButter can be removed after the PeanutButter express popup is removed on /home/home/about/pbxpress
	desc = (desc) ? desc : "Third Party Site";
//	target = (target) ? target : "_blank";
	msg = (msg) ? msg : 0;
	
	var messages = new Array(6);
	// Standard 3rd Party Warning
    messages[0] = messages[1] = '<h2 style="text-align:center">Third Party Site Disclaimer</h2><p>By accessing the noted link you will be leaving '+fiName+'\'s website and entering a website hosted by another party. '+fiName+' has not approved this as a reliable partner site. Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of '+fiName+'\'s website. We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of '+fiName+'.</p>';
	// Standard Partner Warning
    messages[2] = '<h2 style="text-align:center">Partner Site Disclaimer</h2><p>By accessing the noted link you will be leaving our website and entering a partner site which is hosted by another party. Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of our website. We encourage you to read and evaluate the privacy and security policies of the site which you are entering, which may be different than those of ours.</p>';
	// Standard Affiliate Warning
    messages[3] = '<h2 style="text-align:center">Affiliate Site Disclaimer</h2><p>By accessing the noted link you will be leaving our website and entering an affiliate site located which is hosted by another party. Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of our website. We encourage you to read and evaluate the privacy and security policies of the site which you are entering, which may be different than those of ours.</p>';
	// Customize if requested
    messages[4] = messages[0];
	// Standard mailto: Insecure Warning
    messages[5] = '<h2 style="text-align:center">Email Disclaimer</h2><p>This is <strong>NOT</strong> a secured e-mail transmission. Please <strong>do not send personal/financial information</strong> via this method.</p>';

// Peanutbutter lightbox for onLoad /home/home/about/pbxpress
// This gets called in the template file for the page above showWarning(6)
    messages[6] = '<div class="peanutButterLightBox"><table cellspacing="0" cellpadding="0"><tr><td><img src="'+templateimages+'/pbXpressJar.jpg" border="0" class="pbImageLeft" /></td><td><a href="javascript:void(0)" onclick="TB_remove();return true;"><img src="'+templateimages+'/pbXpressText.gif" border="0" class="pbImageRight" style="display:none;"/></a></td></tr></table></div>';		
		
		
	var content = new Array();
	var index = 0;
	content[index++] = messages[msg];
	
	if(msg == 6) {
		content[index++] = '</div>';
		//TB_show(fiName,content.join(''),{width:652,height:420});
		TB_show(fiName,content.join(''),{width:680,height:425});
		$('#TB_title').hide();
	}
	else { 
		content[index++] = '<div align="center" style="margin-top:1em;"><a href="'+lk+'"'+(target?' target="'+target+'"':'')+' onclick="TB_remove();return true;">Continue</a>&#160;&#160;<a href="#" class="TB_closeWindowButton">Decline</a></div></div>';	
		TB_show(fiName,content.join(''),{width:400,height:260});
	}	
	//$("#ex_dis").html(content.join("")).show();
	//scrollTo(0,0);
	
	//TB_show(fiName,content.join(''),{width:400,height:260});
}

function getUrl(){
	var url = document.location.href;
	var urlstart = url.indexOf("newUrl=") + 7;
	var urlToReturn = url.substring(urlstart);
	return urlToReturn;
}

function focusOnLogin() {
	document.Login.userNumber.focus();
}

function rand(number) {
		return Math.ceil((Math.random()* number));       
};

function writeFlashAd()
{
	var swfs= new Array("home-equity-345x191" , "cd-banner-345x191" , "fthb-345x191" , "online-banking-345x191" , "online-billpay-345x191" , "reverse-mortgage-345x191");
	
	var links= new Array("http://watch.moneyminutes.tv/washingtontrust/?start=9011" , "http://watch.moneyminutes.tv/washingtontrust/?start=9014" , "http://watch.moneyminutes.tv/washingtontrust/?start=9012" , "http://watch.moneyminutes.tv/washingtontrust/?start=9009" , "http://watch.moneyminutes.tv/washingtontrust/?start=9010" , "http://watch.moneyminutes.tv/washingtontrust/?start=9013");

	adNum= rand(swfs.length - 1);
	fileName= swfs[adNum];
	fileNameFull= fiDocs + "/" + fileName + ".swf";
	linkUrl= links[adNum];

	code='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="345" height="191" id="' + fileName + '" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="' + fileNameFull + '" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="FlashVars" value="BASECOLOR=&HEADLINE1=&HEADLINE2&HEADLINE3=&LINK=' + linkUrl + '" /><embed src="' + fileNameFull + '" menu="false" quality="high"     bgcolor="#ffffff"     width="345"     height="191"     name="' + fileName + '"    FlashVars="BASECOLOR=&HEADLINE1=&HEADLINE2=&HEADLINE3=&LINK=' + linkUrl + '"     align="middle"     allowScriptAccess="always"     allowFullScreen="false"     type="application/x-shockwave-flash"     pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';
	//alert(code);
	document.write(code);
}

// added By Darnell
/* pops up the demo-popup.html in a pretty pop-up box and renames the current window to "main" to accomodate the
 * pop-up's javascript
 */
function popupdemonow()
{
	window.name="main";
	window.open('/home/fiFiles/static/documents/demo-popup.html', 'demopopup', 'height=350,width=525,status=no,toolbar=no,menubar=no,location=no,resizable=yes');
	return void(0); // so the main window does not navigate to [object]
}

function showCaseStudy(){
	TB_show('A Case Study',$('#caseStudyBody').html(),{width:400,height:300});
	return false;
}

/**
 * ATM & Branch Locator
 * @author Paul McLanahan <paul dot mclanahan at digitalinsight>
 * @modified 3/2/07
 * @copyright 2007 Intuit Inc.
 * @requires jQuery <jquery.com>
 */
ATM = {
	all:[],
	sorted:{},
	zips:{},
	searchType:'atm',
	add:function(opts){
		if(opts.city && opts.state && opts.zip){
			ATM.all[ATM.all.length]=opts;
		}
	},
	init:function(){
		// sort all elements 
		$.each(ATM.all,function(i,loc){
			var c = loc.city.toLowerCase(),s = loc.state.toLowerCase(),z = loc.zip;
			// by state and city
			if(!ATM.sorted[s])ATM.sorted[s]={};
			if(!ATM.sorted[s][c])ATM.sorted[s][c]=[];
			ATM.sorted[s][c][ATM.sorted[s][c].length]=i;
			// by zip
			if(!ATM.zips[z])ATM.zips[z]=[];
			ATM.zips[z][ATM.zips[z].length]=i;
		});
	},
	searchZip:function(z){
		ATM.makePopup(ATM.zips[z],[z]);
	},
	searchCity:function(c,s){
		hidePromoDD();
		ATM.makePopup(ATM.sorted[s][c],[c,s]);
	},
	makeCitiesList:function(){
		if(!ATM.sorted){setTimeout(ATM.makeCitiesList,200);return;}
		var stateTrans = {ri:'Rhode Island',ct:'Connecticut',ma:'Massachusetts'},ulEl;
		ATM.searchType = $('input.radioloc:checked').val();
		$ul = (ulEl = document.getElementById('atmLocatorDD'))? $(ulEl) : $('<ul class="promoDDList" id="atmLocatorDD"></ul>').appendTo('#atmLocator');
		var lis = ['<li><a href="/home/contact/other">All Branches</a></li>'];
		$.each(ATM.sorted,function(state,cities){
			// convert cities object to an array so we can sort
			var aCities=[];
			$.each(cities,function(city){aCities[aCities.length]=city;});
			aCities = $.grep(aCities,function(i){
				for(var j=0;j<ATM.sorted[state][i].length;j++){
					if(ATM.all[ATM.sorted[state][i][j]].type.indexOf(ATM.searchType)>-1)
						return true;
				}
				return false;
			});
			if(aCities.length){
				lis[lis.length]='<li><a href="#" class="subhead" onclick="return false;">'+stateTrans[state]+'</a></li>';
				aCities.sort();
				$.each(aCities,function(i,city){
					// capitalize first letter
					var cityCap = city.capitalize();
					lis[lis.length]='<li><a href="#" class="city {city:\''+city+'\',state:\''+state+'\'}">'+cityCap+'</a></li>';
				});
			}
		});
		$ul.html(lis.join(''));
		$ul.find('a.city').bind('click',function(){
			var $this = $(this);
			ATM.searchCity(this.data.city,this.data.state);
			return false;
		});
	},
	makePopup:function(list,aSearch){
		var out=[],showPopup=true;
		ATM.searchType = $('input.radioloc:checked').val();
		// filter out what the user didn't select.
		if(list)list = $.grep(list,function(i){return ATM.all[i].type.indexOf(ATM.searchType)>-1;});
		out[0] = "<h2>Results For "+(ATM.searchType=='atm'?'ATMs':'Branches')+" in "+(aSearch.length>1?aSearch[0].capitalize()+', '+aSearch[1].toUpperCase():aSearch[0])+"</h2>";
		if(!list || !list.length){
			out[1] = "<p><strong>No Locations Found. Please <a onclick=\"TB_remove();return true;\" href=\"#atmLocatorAnc\">try again.</a></strong></p>";
		}
		else{
			$.each(list,function(i,j){
				var o = ATM.all[j];
				o.isBranch = o.type.indexOf('branch') > -1;
				o.hasLink = o.link && o.link.length;
				o.href = !o.hasLink && o.isBranch ? 
					o.href = 'contact.other#'+o.city.toAnchor() : 
					o.hasLink? o.href : null;
				if(list.length==1 && o.isBranch && o.hasLink){
					window.location.href = o.href;
					showPopup = false;
				}
				out[out.length]= '<p><strong>'+(o.href?'<a onclick="TB_remove();return true;" href="'+o.href+'">':'')+o.name+(o.href?'</a>':'')+'</strong><br/>'+o.address+(o.address2?'<br/>'+o.address2:'')+'<br/>'+o.city+', '+o.state+' '+o.zip+(o.phone?'<br/>'+o.phone:'')+(o.services?'<br/>'+o.services:'')+'</p>';
			});
		}
		if(showPopup)TB_show((ATM.searchType=='atm'?'ATM':'Branch')+' Locations Search Results',out.join(''),{width:300,height:300});
	}
};

// helpers
String.prototype.capitalize=function(){
	return this.replace(/\b[a-z]/g,function(b){return b.toUpperCase();});
}
String.prototype.toAnchor=function(){
	return this.capitalize().replace(/[-_ ]([a-z])/ig,function(a,b){return b.toUpperCase();});
}

// Accordion
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('3.11.q({k:9(O){a v=[];7.M(9(){13(a i=7.J;i;i=i.J){8(i.15!=1)16;8(3.t(O,[i]).r.I)18;v.19(i)}});c 7.1a(v)},h:9(2){2=3.q({},3.h.w,{6:3(\':1b-1c\',7)[0].1d},2);a l=7,5=2.5?3(2.5,7):2.5===K?3("<1e>"):3(2.6,7).1g(0),f=0;l.1h(2.6).1j(5||"").k(2.6).N();5.P(2.n);9 s(g){a 4=3(g.F);8(4.1k(2.6).I){Q(!4.H(2.6)){4=4.R()}}a e=4[0]==5[0];8(f||(2.m&&e)||!4.H(2.6))c;5.T(2.n);8(!e){4.P(2.n)}a b=4.k(2.6),j=5.k(2.6),E=[4,5,b,j];5=e?3([]):4;f=j.A()+b.A();a d=9(B){f=B?0:--f;8(f)c;l.L("W",E)};8(2.G){8(!2.m&&e){b.X(2.x);d(o)}u{j.t(":Y").M(d).Z().t(":10").12(2.z,d);b.14(2.x,d)}}u{8(!2.m&&e){b.17()}u{j.N();b.1i()}d(o)}c K};9 D(g,p){s({F:3(2.6,7)[p]})};c l.C(2.g,s).C("y",D)},y:9(p){c 7.L(\'y\',[p||0])}});3.h={};3.q(3.h,{w:{n:"1f",x:\'S\',z:\'V\',m:o,G:o,g:"1l"},U:9(2){3.q(3.h.w,2)}});',62,84,'||settings|jQuery|clicked|active|header|this|if|function|var|toShow|return|finished|clickedActive|running|event|Accordion||toHide|nextUntil|container|alwaysOpen|selectedClass|true|index|extend||clickHandler|filter|else|match|defaults|showSpeed|activate|hideSpeed|size|cancel|bind|activateHandlder|data|target|animated|is|length|nextSibling|false|trigger|each|hide|expr|addClass|while|parent|slow|toggleClass|setDefaults|fast|change|slideToggle|hidden|end|visible|fn|slideUp|for|slideDown|nodeType|continue|toggle|break|push|pushStack|first|child|tagName|div|selected|eq|find|show|not|parents|click'.split('|'),0,{}))

//Array, String, and Date functions
//  plus rollover and searchField plugins
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('A.1i.2h=5(u){e 1b=A.1Q({N:\'1T\',1j:\'1R\'},u);8 2.Q(5(){e B=2;B.u=1b;A(\'1V,1J[@1N="1Z"]\',2).O(\'[@n*="\'+B.u.N+\'."]\').Q(5(){p=2;p.V=G 17();p.T=G 17();p.T.n=p.n;p.V.n=p.n.H(G 23(B.u.N+"\\.([a-z]{3,4})$",\'i\'),B.u.1j+".$1")}).26(5(){2.n=2.V.n},5(){2.n=2.T.n})})};A.1i.2i=5(){8 2.Q(5(){e $2=A(2);f(2.L&&2.L.c&&!2.q.c){$2.2k(2.L);$2.2m(\'L\')}f(2.q.c){2.S=2.q;$2.2E(5(){f(2.q==2.S)2.q=\'\'}).2n(5(){f(!2.q.c)2.q=2.S})}})};j.Z=[\'2p\',\'2q\',\'2r\',\'2s\',\'2t\',\'2u\',\'2v\'];j.Y=[\'2w\',\'2x\',\'2y\',\'2z\',\'2A\',\'2D\',\'2F\'];j.12=[\'2H\',\'2I\',\'2L\',\'2M\',\'16\',\'2O\',\'2P\',\'2g\',\'2f\',\'2e\',\'2d\',\'2c\'];j.10=[\'2b\',\'2a\',\'1r\',\'1u\',\'16\',\'24\',\'1v\',\'22\',\'21\',\'1y\',\'1z\',\'1Y\'];(5(){5 9(o,v){f(!j.x[o]){j.x[o]=v}};9("14",5(){e y=2.U();8(y%4==0&&y%1D!=0)||y%1U==0});9("X",5(){8 2.I()==0||2.I()==6});9("1H",5(){8!2.X()});9("1I",5(){8[t,(2.14()?29:28),t,C,t,C,t,t,C,t,C,t][2.M()]});9("1K",5(F){8 F?j.Y[2.I()]:j.Z[2.I()]});9("1O",5(F){8 F?j.10[2.M()]:j.12[2.M()]});9("19",5(){e K=G j("1/1/"+2.U());8 W.1S((2.1l()-K.1l())/1W)});9("20",5(){8 W.25(2.19()/7)});9("27",5(1c){2.1e(0);2.1f(1c);8 2});9("2j",5(h){2.2l(2.U()+h);8 2});9("2o",5(h){e K=2.J();2.1e(2.M()+h);f(K>2.J())2.1k(-2.J());8 2});9("1k",5(h){2.1f(2.J()+h);8 2});9("2B",5(h){2.2G(2.2J()+h);8 2});9("2N",5(h){2.2Q(2.1n()+h);8 2});9("1o",5(h){2.1q(2.1s()+h);8 2})})();(5(){5 9(o,v){f(!15.x[o]){15.x[o]=v}};9("1x",5(k,d){d=d||D;w(e i=0;i<2.c;i++)k.E(d,2[i],i,2)});9("1A",5(k,d){d=d||D;w(e i=0;i<2.c;i++)f(!k.E(d,2[i],i,2))8 P;8 13});9("1C",5(k,d){d=d||D;w(e i=0;i<2.c;i++)f(k.E(d,2[i],i,2))8 13;8 P});9("1F",5(k,d){d=d||D;e r=[];w(e i=0;i<2.c;i++)r[r.c]=k.E(d,2[i],i,2);8 r});9("O",5(k,d){d=d||D;e r=[];w(e i=0;i<2.c;i++)f(k.E(d,2[i],i,2))r[r.c]=2[i];8 r});9("1a",5(11,l){w(e i=l||0;i<2.c;i++)f(2[i]===11)8 i;8-1});9("1X",5(){8 2.O(5(1h,1d,18){8 18.1a(1h)>=1d})})})();(5(){5 9(o,v){f(!1g.x[o]){1g.x[o]=v}}9("2K",5(){8 2.H(/(^\\s+|\\s+$)/g,"")});9("1t",5(){8 2.H(/[-1w]([a-z])/1E,5(z,b){8 b.1L()})});9("1P",5(R,l){e l=l||0;f(l<0||l>2.c)8 P;8 2.1m(l,l+R.c)==R});9("2C",5(m){8 2.1m(2.c-m.c)==m});9("1p",5(c,m){c=c||C;m=m===1G?"...":m;8 2.c>c?2.1M(0,c-m.c)+m:2});9("1B",5(){8 2.H(/<\\/?[^>]+>/2R,\'\')})})();',62,178,'||this|||function|||return|add|||length|scope|var|if||num||Date|handler|offset|suffix|src|name|el|value|||31|opts|method|for|prototype|||jQuery|root|30|window|call|abbreviated|new|replace|getDay|getDate|tmpdtm|title|getMonth|off|filter|false|each|prefix|defaultValue|outObj|getFullYear|overObj|Math|isWeekend|abbrDayNames|dayNames|abbrMonthNames|subject|monthNames|true|isLeapYear|Array|May|Image|array|getDayOfYear|indexOf|settings|day|index|setMonth|setDate|String|element|fn|on|addDays|getTime|substring|getMinutes|addSeconds|truncate|setSeconds|Mar|getSeconds|camelize|Apr|Jul|_|forEach|Oct|Nov|every|stripTags|some|100|ig|map|undefined|isWeekDay|getDaysInMonth|input|getDayName|toUpperCase|slice|type|getMonthName|startsWith|extend|_on|floor|_off|400|img|86400000|unique|Dec|image|getWeekOfYear|Sep|Aug|RegExp|Jun|ceil|hover|setDayOfYear|||Feb|Jan|December|November|October|September|August|rollovers|searchField|addYears|val|setFullYear|removeAttr|blur|addMonths|Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sun|Mon|Tue|Wed|Thu|addHours|endsWith|Fri|focus|Sat|setHours|January|February|getHours|trim|March|April|addMinutes|June|July|setMinutes|gi'.split('|'),0,{}))
