var menuBgColor = "#e6eaee";
var menuBgColorOver = "#ccd6e0";
var disableHide = false;
var lastLayer = ""; // keep the last open layer name

var layerList = new Object();
var layerIdx  = 0;

// compatibility
if ( typeof isW3C == "undefined" ) var isW3C = (document.getElementById) ? true : false;
if ( typeof isIE4 == "undefined" ) var isIE4 = (document.all && !isW3C) ? true : false;
if ( typeof isNS4 == "undefined" ) var isNS4 = (document.layers && !isW3C) ? true : false;
if ( typeof isOpera == "undefined" ) var isOpera = (window.opera) ? true : false;

function UBS_seekLayerImage( doc, name )
{
	var theImg;
	for ( var i=0; i < doc.layers.length; i++ )
	{
		var laydoc = doc.layers[i].document;
		if ( laydoc.images && laydoc.images[ name ] ) return laydoc.images[ name ];

		// search sub layers as well
		if ( laydoc.layers.length > 0 ) theImg = UBS_seekLayerImage( laydoc, name );
	}
	return theImg;
}

function UBS_getImagePosition( imgName )
{
	var obj = document.images[imgName];
	if ( !obj && isNS4 ) obj = UBS_seekLayerImage( document, imgName );

	var coords = new Object();
	coords.x = UBS_getX( obj );
	coords.y = UBS_getY( obj );

	return coords;
}

function UBS_getX( obj )
{
	var x = 0;
	if ( obj )
	{
		if ( isNS4 ) x = obj.x;
		else x = ( obj.offsetParent == null ) ? obj.offsetLeft : obj.offsetLeft+UBS_getX( obj.offsetParent );
	}
	return parseInt( x );
}

function UBS_getY( obj )
{
	var y = 0;
	if ( obj )
	{
		if ( isNS4 ) y = obj.y;
		else y = ( obj.offsetParent == null ) ? obj.offsetTop : obj.offsetTop+UBS_getY(obj.offsetParent);
	}
	return parseInt( y );
}

// compatibility
function UBS_updateLayerPosition( layerName, imgName )
{
	return UBS_setLayer( layerName, imgName );
}

function UBS_writeLayer( layerName, html, x, y, isVisible )
{
	if ( isNS4 )
	{
		var obj = document.layers[layerName];
		if ( html != "" )
		{
			obj.document.open();
			obj.document.write(html);
			obj.document.close();
		}
		obj.x = x;
		obj.y = y;
		if ( isVisible ) obj.visibility = "show";
	}
	else
	{
		var obj = ( isIE4 ) ? document.all[layerName] : document.getElementById(layerName);
		obj.align = "left"; // override td alignment
		if ( html != "" ) obj.innerHTML = html;
		obj.style.left = x;
		obj.style.top  = y;
		if ( isVisible ) obj.style.visibility = "visible";
	}
}

function UBS_setLayer(layerName,imgName,adjustX,adjustY,id) {
	// set default values
	if ( typeof adjustX == "undefined" ) adjustX = 0;
	if ( typeof adjustY == "undefined" ) adjustY = 6;
	
	var html = "";
	var hideLayer = true;
	var isDropdownLayer = ( layerName.substring(0,10) == "LeftColumn" || layerName.substring(0,11) == "RightColumn" );

	// special handling for homepage column layers
	if ( layerName == "copyrightsignlayer" ) {
		hideLayer = false;
	}
	else if ( isDropdownLayer )	{
		// get layer height: calculate position to open layer "upwards"
		var coordsTop    = UBS_getImagePosition("t"+id);
		var coordsBottom = UBS_getImagePosition("b"+id);
		var height = coordsBottom.y - coordsTop.y;
		var border = ( isNS4 ) ? 12 : 6;
		if ( height > 0 ) adjustY -= ( height + border ); // add border
	}

	// check list for layers to hide
	if ( hideLayer )
	{
		var isFound=false;
		for ( var i in layerList )
		{
			if (layerList[i].name==layerName)
			{
				isFound=true; 
				break;
			}
		}
		if ( !isFound )
		{
			var obj=new Object();
			obj.name=layerName;
			layerList[layerIdx++]=obj;
		}
	}

	if ( lastLayer == layerName )
	{
		UBS_hideAll(layerName);
	}
	else
	{
		disableHide = false;
		UBS_hideAll();
	}

	var coords = UBS_getImagePosition(imgName);
	var x = coords.x + adjustX;
	var y = coords.y + adjustY;

	// check if layer can be opened "upwards"
	if ( isDropdownLayer )
	{
		var top = ( document.all ) ? document.body.scrollTop : window.pageYOffset;
		if ( y < top || adjustY == 0 ) y = coords.y + 18; // open layer downwards
	}

	UBS_writeLayer( layerName, html, x, y, true );

	if ( hideLayer )
	{
		// cover layer disable the clickability of the link on netscape 7
		// by delaying the show of this layer, the surfer is able to click on it
		//setTimeout( "UBS_showLayer('coverlayer')", 1000 );

		if ( isW3C || isIE4 )
		{
			disableHide = true;
			setTimeout( "UBS_enableHide()", 1000 );
		}
	}

	lastLayer = layerName;
	
	return false;
}

function UBS_setLayerVisiblity( layerName, status )
{
	if ( isNS4 )
	{
		document.layers[layerName].visibility = ( status == "hidden" ) ? "hide" : "show";
	}
	else
	{
		var obj = (isIE4) ? document.all[layerName] : document.getElementById(layerName);
		if ( !obj ) return;

		obj.style.visibility = status;
	}
}

function UBS_hideLayer( layerName )
{
	if ( disableHide ) return;

	UBS_setLayerVisiblity( layerName, "hidden" );
}

function UBS_showLayer( layerName )
{
	UBS_setLayerVisiblity( layerName, "visible" );
}

function UBS_hideAll( layerToIgnore )
{
	for ( var i in layerList )
	{
		var layerName = layerList[i].name;
		if ( layerName != layerToIgnore ) UBS_hideLayer(layerName);
	}
}

function UBS_tableHTML( layerObj )
{
	var html = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"136\">";
	// ns4 bug: first row is not displayed
	if (isNS4) html += "<tr><td><img src=\"/0.gif\" alt=\"\"></td></tr>";

	for (var i in layerObj.links)
	{
		var text = layerObj.links[i].text;
		var link = layerObj.links[i].link;
		var bold = layerObj.links[i].bold ? "bold":"";

		if (link=="")
		{
			html += "<tr bgcolor=\""+menuBgColor+"\">";
			html += "<td><p class=\"metamenuitem\"><span class=\"menutext"+bold+"\">"+text+"</span></p></td>";
			html += "</tr>";
		}
		else
		{
			html += "<tr bgcolor=\""+menuBgColor+"\" onmouseover=\"this.bgColor='"+menuBgColorOver+"';\" onmouseout=\"this.bgColor='"+menuBgColor+"';\">";
			html += "<td><p class=\"metamenuitem\"><a href=\""+link+"\" class=\"menutext"+bold+"\">"+text+"</a></p></td>";
			html += "</tr>";
		}
	}
	html += "</table>";

	return html;
}

function UBS_layerHTML( layerObj )
{
	layerList[layerIdx++] = layerObj;

	var layerName = layerObj.name;
	var html = "";

	if ( layerName == "coverlayer" ) return UBS_layerCover();

	if ( isNS4 )
	{
		html = "<layer name=\""+layerName+"\" bgcolor=\"#e6eaee\" z-index=\"15\" onmouseover=\"UBS_showLayer('"+layerName+"')\" onmouseout=\"UBS_hideLayer('"+layerName+"')\" visibility=\"hidden\">"+UBS_tableHTML(layerObj)+"</layer>";
	}
	else
	{
		var style = "font-family:arial,helvetica,sans-serif;font-size:11px;color:#003366;position:absolute;background-color:#e6eaee;border:1px solid #ccd6e0;visibility:hidden;z-index:15;";

		html = "<div id=\""+layerName+"\" onmouseover=\"UBS_showLayer('"+layerName+"')\" onmouseout=\"UBS_hideLayer('"+layerName+"')\" style=\""+style+"\">"+UBS_tableHTML(layerObj)+"</div>";
	}

	return html;
}

function UBS_layerCover()
{
	// special layer to hide layers (ie: bug when moving the mouse to fast)
	var html = "";

	if ( isNS4 )
	{
		var mywidth  = document.width-20;
		var myheight = document.height;
		html = "<layer name=\"coverlayer\" onmouseover=\"UBS_hideAll()\" left=\"0\" top=\"0\" width=\""+mywidth+"\" height=\""+myheight+"\" z-index=\"1\" visibility=\"hidden\"></layer>";
	}
	else
	{
		var mywidth  = document.body.offsetWidth-20;
		var myheight = document.body.offsetHeight-5;
		html = "<div id=\"coverlayer\" onmouseover=\"UBS_hideAll()\" onmousemove=\"UBS_hideAll()\" style=\"position:absolute;visibility:hidden;width:"+mywidth+";height:"+myheight+";left:0;top:0;background-color:#e6eaee;z-index:1;\"></div>";
	}
	return html;
}

function UBS_buildLinks( str )
{
	var pairs = str.split("|");
	var links = new Object();
	
	// compatibility: check splitting character
	var c = (str.indexOf("¦")>0) ? "¦" : ",";
	
	for (var i in pairs)
	{
		var values = pairs[i].split(c);

		links[i] = new Object();
		links[i].text = values[0];
		links[i].link = values[1];
		if (values[2]) links[i].bold = values[2];
	}
	
	return links;
}

function UBS_enableHide()
{
	disableHide = false;
}


//-----------------externalLinkValidation.js file -----------------------------

var thispagedomain = ExtractDomainName(document.URL);

function buildPopup(url) {
  window.open("/mcs/cda/externalLinkWarning.jsp?exturl="+url,null,"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");
}

for(var i = 0; i <= document.links.length - 1; i++) {
  var url = document.links[i].href.toLowerCase();
  if(url.indexOf('http://') != 0) { continue; }
  var hrefdomain = ExtractDomainName(url);
  if(thispagedomain != hrefdomain) {
 	document.links[i].href = 'javascript:buildPopup(url)';
  }
}

function ExtractDomainName(s) {
  var i = s.indexOf('//');
  if(i > -1) { s = s.substr(i+2); }
  i = s.indexOf('/');
  if(i > -1) { s = s.substr(0,i); }
  i = s.indexOf(':');
  if(i > -1) { s = s.substr(0,i); }
  var re = /[a-z]/i;
  if(! re.test(s)) { return s; }
  var a = s.split('.');
  if(a.length < 2) { return s; }
  var domain = a[a.length-2] + '.' + a[a.length-1];
  if(a.length > 2) {
    if(a[a.length-2].length==2 && a[a.length-1].length==2) {
      domain = a[a.length-3] + '.' + domain;
      }
    }
  return domain.toLowerCase();
}

//------------------jspUtils.js -------------------------------
// jspUtils.js

///// Mouse Over Drop Down Begin

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (typeof menuwidth == "undefined") {
	var menuwidth = "";
}

if (typeof menubgcolor == "undefined") {
	var menubgcolor = "";
}

if (typeof hidemenu_onclick == "undefined") {
	var hidemenu_onclick = "";
}

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')


function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
	dropmenuobj.style.left=dropmenuobj.style.top="-500px"
	if (menuwidth!=""){
	dropmenuobj.widthobj=dropmenuobj.style
	dropmenuobj.widthobj.width=menuwidth
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	obj.visibility=visible
	else if (e.type=="click")
	obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
	var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
	dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
	if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
	edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
	var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
	var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
	dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
	if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
	edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
	if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
	edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
	}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
	dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
	//alert("in dropdownmenu");
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)

if (ie4||ns6){
	showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
	dropmenuobj.x=getposOffset(obj, "left")
	dropmenuobj.y=getposOffset(obj, "top")
	dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
	dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
	if (ie4||ns6) return false
	else return true
}

function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function dynamichide(e){
	if (ie4&&!dropmenuobj.contains(e.toElement))
	delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
	delayhidemenu()
}

function hidemenu(e){
	if (typeof dropmenuobj!="undefined"){
	if (ie4||ns6)
	dropmenuobj.style.visibility="hidden"
	}
}

function delayhidemenu(){
	if (ie4||ns6)
	delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
	if (typeof delayhide!="undefined")
	clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu
//////// end Mouse Over Drop Down ////////

// --------------------jumpinPage.js ----------------------------
function keepInfo (goToPage, pageFlag) {
	//check for query string
	var queryStrFound = location.href.indexOf("?start=");
	var additionalQueryString = getAdditionalQueryString();
	var siteHomeDir = "";
	
	//check to see if client is on the Home page or a special site page
	var onSitesHomeOrSpecPage = false;
	if (location.href.indexOf(location.host+"/fa/") > 0 || location.href.indexOf(location.host+"/branch/")  > 0 || location.href.indexOf(location.host+"/team/") > 0 ){
		onSitesHomeOrSpecPage = true;
	}
	
	//get the query string "?start=" value
	var theQueryString = "";
	if (queryStrFound > 0 && !onSitesHomeOrSpecPage) {
		theQueryString = location.href.split("?")[1];
		siteHomeDir = getRequestParameter("start");
	}

	if(theQueryString == "" && onSitesHomeOrSpecPage){
		//client is attempting to go to a common page from the site's Home page or one of the special pages
		var sitePath = new String(location.href);
		var splitString = sitePath.split("/");
		window.location = goToPage+"?start=/"+splitString[3]+"/"+splitString[4] + getAdditionalQueryString();
	} else if (pageFlag != "HomeSpecialPages" && theQueryString != "") {
		//client is attempting to go a common page from anoher common page
		window.location = goToPage+"?" + theQueryString;
	} else if (pageFlag == "HomeSpecialPages" && siteHomeDir != "") {
		//client is attempting to go to the site's Home page or one of the special pages from a common page
		window.location = siteHomeDir +"/"+goToPage;
	} else {
		window.location = goToPage;
	}
}

function getAdditionalQueryString() {
	var form = document.forms['siteConfigForm'];
	var additionalQueryString = "";
	if (typeof  form != "undefined") {
		additionalQueryString += "&fawAppID=" + form.fawAppID.value;
		additionalQueryString += "&siteName=" + form.siteName.value;
		additionalQueryString += "&siteType=" + form.siteType.value;
	}
	return additionalQueryString;
}

function getRequestParameter(paramName) {
	var paramValue = "";
	
	var sitePath = new String(location.href);
	var splitString = sitePath.split("?");
	var params = new Array();
	
	if (splitString.length > 1) {
		var requestParamString = splitString[1];
		var reqParams = requestParamString.split("&");
		for (i=0;i<reqParams.length;i++) {
			var keyValuePair = reqParams[i].split("=");
			var key = keyValuePair[0];
			var value = keyValuePair[1];
			params[key] = value;
		}
	}
	
	if (typeof(params[paramName]) != "undefined") {
		paramValue = params[paramName];
	}
	
	return URLDecode(paramValue);
}

function getFAWAppID() {
	var fawAppID = getRequestParameter("fawAppID");
	return fawAppID;
}

function getSiteType() {
	var siteType = getRequestParameter("siteType");
	return siteType;
}

function getSiteName() {
	var siteName = getRequestParameter("siteName");
	return siteName;
}

//------------------ load_concept_module.js ---------------------------
function resizePicture() {	
	var imageSmall = "/staticfiles/pws/images/bg_small_noflash.jpg";	
	var imageBig   = "/staticfiles/pws/images/bg_big_noflash.jpg";
	
	var flashcontent = document.getElementById("flashcontent");
	var noFlashImg = document.getElementById("noFlashImg");
	if (flashcontent != null && noFlashImg != null) {
		if (document.getElementById("flashcontent").offsetWidth <= 510 && document.getElementById("noFlashImg") != null) {		
			document.getElementById("noFlashImg").src = imageSmall;	
		} else if (document.getElementById("noFlashImg") != null) {		
			document.getElementById("noFlashImg").src = imageBig;	
		}
	}
}

function loadSWF() {
	var so = new SWFObject("/cda/libraries/concept.swf", "concept_module", "100%", "100%", "8", "#003366");	
	so.addVariable("xmldata", "/staticfiles/pws/documents/data.xml");
	so.write("flashcontent");
}

//------------------------- ubs_liquid.js ----------------------------
var switchSize = 1024;

// Open PopUp PDF window
function openpdfWindow(theURL) {
	window.open(theURL,'PopUp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=500');
}

// Open HTMl page in PopUp window
function openWindow(theURL) {
	window.open(theURL,'PopUp','width=700,height=500, toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
}

// Open HTMl page in PopUp window

function openWebWindow(theURL) {
	window.open(theURL,'PopUp','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=700');
}

// Open OLS tour page in PopUp window
function openOlsWindow(theURL) {
	window.open(theURL,'PopUp','scrollbars=yes,width=764,height=540,top=50,left=50');
} 

function MM_openBrWindow(theURL,winName,features) { 
	window.open(theURL,winName,features);
}

// optionally pass a querystring to parse
function Querystring(qs) { 
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

	// Turn <plus> back to <space>
	// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
	// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

function openNewWindow(theURL, width, height, warn, siteId, warnf) {
	if (width == null)
		width = 700;
	if (height == null)
		height = 500;
	if (warn == null) 
		warn = false;

	// This retrieves values from incoming request, and parses respectively
	var qs = new Querystring();
		
	// Determine if we are previewing on the CMA. If yes, then the location of the warning message will be different than CDA.
	var preview = qs.get('prev','no');
	var host = location.hostname;
	var port = location.port;
	// Initialize host to be preappended to the location of the warning.
	var preappender = "";
	
	if (preview == "yes") {
		// preappender = "oos";			
	} else {
		// Set the hostname
		preappender = "http://" + host + ":" + port;
	}

	if (warn == "true") {
		var url = preappender + '/staticfiles/'+siteId+'/documents/'+warnf+'?exturl='+theURL+'&openincaller=false';
        window.open(url, 'ExtPopUp','width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');			        
	} else {
		window.open(theURL, 'ExtPopUp', 'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
	}
}

// Open confirm before open external window in pop-up
function openConfWindow(url, width, height){
	if (typeof width == 'undefined' || width == null || parseInt(width) == 'NaN') width = 700;
	if (typeof height == 'undefined' || height == null || parseInt(height) == 'NaN') height = 500;
  	if (confirm("You are leaving our web site")) {
    	window.open(url,'mywindow','width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
  	}
}

// This function is used when opening a new site in the active window.
// warn is boolean on whether to redirect user to a warning page prior to the external site.
function openNewSite(url, aid, warningfilename) {
	// This retrieves values from incoming request, and parses respectively
	var qs = new Querystring();
	
	// Determine if we are previewing on the CMA. If yes, then the location of the warning message will be different than CDA.
	var preview = qs.get('prev', 'no');
	var host = location.hostname;
	var port = location.port;
	// Initialize host to be preappended to the location of the warning.
	var preappender = "";
	
	if (preview == "yes") {
		// preappender = "oos";			
	} else {
		// Set the hostname
		preappender = "http://" + host + ":" + port;
	}
	
	// This was commented, as the warning is no longer optional and not passed in any longer as parameter.
	//if (warn == 'true') { 
    var newUrl = preappender + '/staticfiles/' + aid + '/documents/' + warningfilename + '?exturl=' + url + '&openincaller=true';
    window.open(newUrl,'ExtPopUp','width=700,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
	//} else {
	//	document.location=theURL;
	//}
}

/***
document.writeln("<style type=\"text/css\">\n");
// define styles that can only be used for last generation browser
if (w3c || ie4)
{
	document.writeln(".textinput { font-size: 11px; background-color: #ffffff; color: #003366; border-width: 1px; border-style: solid; border-color: #647c8c; height: 17px; padding-left: 2px; }\n");
}
else
{
	document.writeln(".textinput { font-size: 11px; background-color: #ffffff; color: #003366; height: 17px; padding-left: 2px; }\n");
}
document.writeln("</style>\n");
**/

function UBS_getBrowserWidth() {
	var outerWidth = (document.all) ? document.body.clientWidth + 28 : window.outerWidth;
	return outerWidth;
}

function UBS_getBrowserWidth12() {
	//alert("coming here");
	browserNm = getBrowserName();
	if (browserNm == "NN") {
	  var switchSizeBody = 1024;
	  var browserWidth = (document.all) ? document.body.clientWidth + 28 : window.outerWidth;
	  //alert("browserWidth is " + browserWidth);
	} else {
	  var switchSizeBody = 1024;
	  var browserWidth = window.document.body.scrollWidth + 28;
	  //alert("browserWidth is vvv" + browserWidth);
  	  return browserWidth;
    }	  
}

function UBS_getContentWidth( type ) {
	var contentWidth;
	var browserWidth = UBS_getBrowserWidth();
	//alert("browserWidth is " + browserWidth);
    //alert("browserWidth --" + browserWidth + ";  switchSize --" +switchSize);
	if (checkHighResolution()) {
		switch( type ) {
			case "homepage": contentWidth = 726; break;
			case "homeleft": contentWidth = 265; break; // 252+13
			case "homemiddle": contentWidth = 259; break; // 246+13
			case "rightfeature": contentWidth = 526; break; //with left nav, mid, right box
			case "rightfeaturemiddle": contentWidth = 291; break; //with left nav, mid, right box. ONLY FOR TOP IMAGES
			case "restop": contentWidth = 688; break; //top image
			case "rightfeatureworbox": contentWidth = 651; break; //with left nav, mid
			case "box": contentWidth = 200; break; //middle subnode
			case "teaser": contentWidth = 168; break; //width of teasers
			default: contentWidth = 648;
			//alert(browserWidth);
		}
	}
	else {
		switch( type ) {
			case "homepage": contentWidth = 585; break;
			case "homeleft": contentWidth = 159; break; // 146+13
			case "homemiddle": contentWidth = 224; break; // 211+13
			case "rightfeature": contentWidth = 385; break; //with left nav, mid, right box
			case "rightfeaturemiddle": contentWidth = 150; break; //with left nav, mid, right box. ONLY FOR TOP IMAGES
			case "restop": contentWidth = 547; break; //top image
			case "rightfeatureworbox": contentWidth = 510; break; //with left nav, mid
			case "box": contentWidth = 154; break; //middle subnode
			case "teaser": contentWidth = 121; break; //width of teasers
			default: contentWidth = 506;
			//alert(browserWidth);
		}
	}

	return contentWidth;
}

function getBrowserName() {
	var browserName = navigator.appName;
	var browserVer = parseInt(navigator.appVersion);
	if (browserName == "Netscape"){
		var ver = "NN";
	} else if (browserName == "Microsoft Internet Explorer"){
		var ver = "IE";	
	}
	return ver; 
}
	
function UBS_getContentBodyWidth( type ) {
	var contentWidth;
	
	if (checkHighResolution()) {
		switch( type ) {
			case "homepage": contentWidth = 726; break;
			case "homeleft": contentWidth = 265; break; // 252+13
			case "homemiddle": contentWidth = 259; break; // 246+13
			case "rightfeature": contentWidth = 526; break; //with left nav, mid, right box
			case "rightfeaturemiddle": contentWidth = 291; break; //with left nav, mid, right box. ONLY FOR TOP IMAGES
			case "rightfeatureworbox": contentWidth = 651; break; //with left nav, mid
			case "teaser": contentWidth = 168; break; //width of teasers
			default: contentWidth = 648;
		}
	}
	else {
		switch( type ) {
			case "homepage": contentWidth = 585; break;
			case "homeleft": contentWidth = 159; break; // 146+13
			case "homemiddle": contentWidth = 224; break; // 211+13
			case "rightfeature": contentWidth = 385; break; //with left nav, mid, right box
			case "rightfeaturemiddle": contentWidth = 150; break; //with left nav, mid, right box. ONLY FOR TOP IMAGES
			case "rightfeatureworbox": contentWidth = 510; break; //with left nav, mid
			case "teaser": contentWidth = 121; break; //width of teasers
			default: contentWidth = 506;
		}
	}
	return contentWidth;
}

function UBS_getBackgroundImage( type, image ) {
	var width = UBS_getContentWidth( type );
	return "<img src=\"/cda/images/bg_"+image+"_"+width+"x1.gif\" width=\""+width+"\" height=\"1\" alt=\"\" border=\"0\">";
}

function UBS_getContentImage( type ) {
	return "<img src=\"/cda/images/1px_trans.gif\" width=\""+UBS_getContentWidth( type )+"\" height=\"1\" alt=\"\" border=\"0\">";
}

function checkHighResolution() {
	var browserWidth = UBS_getBrowserWidth();
    var hasHighResolution = isHighResolution();

    if(typeof disableLowResolution != "undefined") {
	    if (disableLowResolution) {
			hasHighResolution = true;
		}
    }
	
	//return hasHighResolution;
	return true;
}

function UBS_getContentImageWithWidth( maxWidth, minWidth) {
	var width = minWidth;
	if (checkHighResolution()) {
		width = maxWidth;
	}
	var content = "<img src=\"/cda/images/1px_trans.gif\" width=\"" + width + "\" height=\"1\" alt=\"\" border=\"0\">";
	return content;
}
function UBS_getContentBodyImage( type ) {
	return "<img src=\"/cda/images/1px_trans.gif\" width=\""+UBS_getContentBodyWidth( type )+"\" height=\"1\" alt=\"\" border=\"0\">";
}
function UBS_getContentTable( type ) {
	return "<table width=\""+UBS_getContentWidth( type )+"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
}
function isHighResolution() {
	var switchSizeBody = 0, browserWidth = 0;
	var isHighResolution = false;
	browserNm = getBrowserName();
	
	if (browserNm == "NN") {
		switchSizeBody = 1024;
		browserWidth = (document.all) ? document.body.clientWidth + 28 : window.outerWidth;
	} else {
	  	switchSizeBody = 1024;
	  	browserWidth = window.document.body.scrollWidth + 28;
	}

	if (browserWidth >= switchSizeBody)	{
		isHighResolution = true;		
	}
	
	return isHighResolution;
}
function KeyPress(e){
	if(e==13){
		findFAbyZip('afterHittingSearchByZipCodeSubmitButton');
	}
}
function findFAbyZip(type){
	var formobj = eval("document.searchFinancialAdvisorFormBean");
	var actTyp = type;
	var url = "/mcs/faSearch.do";
 
	if (typeof formobj == "object" && typeof actTyp == "string") {
		if ("zipCodeForFASearchByLoc" in formobj) {
			var zipcode = formobj.zipCodeForFASearchByLoc.value;
			if (!isZip(zipcode)) {
				alert("Please enter a zip code");
				return false;
			}
	 		url += "?actTyp=" + actTyp + "&distanceSelectedForSearchByZipcode=25";
	 		url += "&zipCodeForFASearchByLoc=" + zipcode;
		}
	 	formobj.action = url;
	 	return true;
	}

    document.location.replace(url);
    return false;
}
// Search FA by Zip code
function validateZip(field) {
	var formobj = eval("document.searchFinancialAdvisorFormBean");
   	var actTyp = "afterHittingSearchByZipCodeSubmitButton";
   	var url = "/mcs/faSearch.do";

	if (typeof field == "string" && typeof formobj == "object") {
   		var zipcode = field;
		if (!isZip(zipcode)) {
			alert("Please enter a zip code");
			return false;
		}
		url += "?actTyp=" + actTyp + "&aid=pws&distanceSelectedForSearchByZipcode=25";
 	   	url += "&zipCodeForFASearchByLoc=" + zipcode;
 	   	formobj.action = url;
		formobj.submit();
  	   	return true;
	}

	document.location.replace(url);
	return false;
}
// Check for correct zip code
function isZip(s) {
	reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);

	if (!reZip.test(s)) {
		return false;
	}
	return true;
}

//--------------------cwfobject.js -------------------------

// JavaScript Document
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
		deconcept.SWFObject.doPrepUnload = true;
	}
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', false);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	useExpressInstall: function(path) {
		this.xiSWFPath = !path ? "expressinstall.swf" : path;
		this.setAttribute('useExpressInstall', true);
	},
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs[variablePairs.length] = key +"="+ variables[key];
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
//				document.write("player v: "+ counter);
				PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { // Win IE (non mobile)
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if (param == null) { return q; }
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i--) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
	if (!deconcept.unloadSet) {
		deconcept.SWFObjectUtil.prepUnload = function() {
			__flash_unloadHandler = function(){};
			__flash_savedUnloadHandler = function(){};
			window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
		}
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet = true;
	}
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;

function URLDecode(psEncodeString) {
	// Create a regular expression to search all +s in the string
	var lsRegExp = /\+/g;
	// Return the decoded string
	return unescape(String(psEncodeString).replace(lsRegExp, " ")); 
}


