// Set this string equal to the host name of the main web server. 
var myLocation = location.hostname;

if(myLocation == "agsosg57.it.statestr.com")
{
	var hostName = 'http://agsosg57.it.statestr.com';
} 
else if(myLocation == "pws-uat.statestreet.ca" || myLocation == "itsdev01.statestr.com") {
	var hostName = 'http://pws-uat.statestreet.ca';
} 
else if(myLocation == "svaw1071.statestr.com") {
	var hostName = 'http://svaw1071.statestr.com';
}
else
{
	var hostName = 'http://www.statestreet.ca';
}

// This string stores the domain used for cookies on the site.
var domainName = hostName.substr(hostName.lastIndexOf('.',hostName.lastIndexOf('.')-1));

// Called when a user selects an international site from the drop down at the top of site pages.
// Sends the user's browser to the selected site.
function jumpsites(myForm)
{
	dropdown=myForm.internationalsite
	site=dropdown.options[dropdown.selectedIndex].value;
	
	if (dropdown.selectedIndex == 0)
	{
		return;
	}
	else if (dropdown.selectedIndex == 2 || dropdown.selectedIndex == 5 || dropdown.selectedIndex == 7)
	{	
		document.location=site;
	}
	else
	{
		window.open(site);
	}
}

// This function returns true if the visitor has the Flash 5 or Flash 6 browser plugin.
// It should be called anywhere a test is made for the Flash plugin
function hasFlash()
{
	return WM_pluginDetect('Flash 5', 'swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.5') || WM_pluginDetect('Flash 6', 'swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.6');
}

// This function returns true if the visitor has previously selected to view the site in DHTML
// It should be called anywhere a test is made for the presence of the DHTML cookie
function hasDHTMLCookie()
{
	var cookies = document.cookie;
	return !(cookies.indexOf("flash=false") == -1);
}

// This function returns true if the visitor is capable of viewing Flash and has not requested DHTML
// It is called in the render_nav() function and should be used anywhere else flash movies are displayed.
function useFlash()
{
	return !hasDHTMLCookie() && hasFlash();
}


// This function displays the proper navigation (DHTML or Flash) based on the presence of the Flash plugin and the DHTML cookie.
// The function is called on every page that displays the navigation.  It is also called within the render_top() function.
function render_nav()
{

	document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"780\"><img src= \"" + hostName + "\/nav/newtop.gif\" alt=\"\" width=\"780\" height=\"67\" border=\"0\" USEMAP=\"#home\"><MAP NAME=\"home\"><AREA SHAPE=RECT COORDS=\"8,8,156,59\" HREF=\"http://www.statestreet.ca\"  ALT=\"\"></MAP><br clear=\"left\">");

	if (!useFlash())
	{
		if(window.event + "" == "undefined") event = null;
		function HM_f_PopUp(){return false};
		function HM_f_PopDown(){return false};
		popUp = HM_f_PopUp;
		popDown = HM_f_PopDown;

		menuTop = 125;
		menuLeft = 43;
		menuDSpace = 16;
		menuLSpace = 150;

		HM_PG_MenuWidth = 150;
		HM_PG_FontFamily = "verdana,sans-serif,chicago";
		HM_PG_FontSize = 7;
		HM_PG_FontBold = 1;
		HM_PG_FontItalic = 0;
		HM_PG_FontColor = "white";
		HM_PG_FontColorOver = "Gray";
		HM_PG_BGColor = "#DDDDDD";
		HM_PG_BGColorOver = "#FFCCCC";
		HM_PG_ItemPadding = 3;

		HM_PG_BorderWidth = 1;
		HM_PG_BorderColor = "black";
		HM_PG_BorderStyle = "solid";
		HM_PG_SeparatorSize = 1;
		HM_PG_SeparatorColor = "#d0ff00";

		HM_PG_ImageSrc = hostName + "/nav/cap_arrow.gif";
		HM_PG_ImageSrcLeft = "HM_More_black_left.gif";
		HM_PG_ImageSrcOver = hostName + "/nav/cap_arrow_mo.gif";
		HM_PG_ImageSrcLeftOver = "HM_More_white_left.gif";

		HM_PG_ImageSize = 10;
		HM_PG_ImageHorizSpace = 0;
		HM_PG_ImageVertSpace = 0;

		HM_PG_KeepHilite = true;
		HM_PG_ClickStart = 0;
		HM_PG_ClickKill = false;
		HM_PG_ChildOverlap = 20;
		HM_PG_ChildOffset = 10;
		HM_PG_ChildPerCentOver = null;
		HM_PG_TopSecondsVisible = .5;
		HM_PG_StatusDisplayBuild =0;
		HM_PG_StatusDisplayLink = 0;
		HM_PG_UponDisplay = null;
		HM_PG_UponHide = null;
		HM_PG_RightToLeft = 0;

		HM_PG_CreateTopOnly = 0;
		HM_PG_ShowLinkCursor = 1;
		HM_PG_NSFontOver = true;

		document.write( "<table width='780' border='0' cellpadding='0' cellspacing='0'><tr><td class='bodytext' height='135' width='780'><img src='" + hostName + "/nav/nav.gif' USEMAP='#nav' border='0' width='780' height='135' alt=''></td></tr></table>");
		document.write( "<MAP NAME=\"nav\"><AREA SHAPE=RECT COORDS=\"1,19,144,37\" HREF=\"#\"  ALT=\"\"  OnMouseOver=\"popUp('HM_Menu1',event)\"  OnMouseOut=\"popDown('HM_Menu1')\"><AREA SHAPE=RECT COORDS=\"1,38,144,53\" HREF=\"javascript:openSSLink(1,2,0,0)\"  ALT=\"\"  OnMouseOver=\"window.status=' '; return true\"  OnMouseOut=\"window.status=' '; return true\"><AREA SHAPE=RECT COORDS=\"1,54,144,69\" HREF=\"#\"  ALT=\"\"  OnMouseOver=\"popUp('HM_Menu3',event)\"  OnMouseOut=\"popDown('HM_Menu3')\"><AREA SHAPE=RECT COORDS=\"1,70,144,85\" HREF=\"javascript:openSSLink(1,4,0,0)\"  ALT=\"\"  OnMouseOver=\"window.status=' '; return true\"  OnMouseOut=\"window.status=' '; return true\"><AREA SHAPE=RECT COORDS=\"1,86,144,101\" HREF=\"#\"  ALT=\"\" OnMouseOver=\"popUp('HM_Menu5',event)\"  OnMouseOut=\"popDown('HM_Menu5')\"><AREA SHAPE=RECT COORDS=\"145,19,289,37\" HREF=\"#\"  ALT=\"\" OnMouseOver=\"popUp('HM_Menu6',event)\"  OnMouseOut=\"popDown('HM_Menu6')\"><AREA SHAPE=RECT COORDS=\"145,38,289,53\" HREF=\"#\"  ALT=\"\" OnMouseOver=\"popUp('HM_Menu7',event)\"  OnMouseOut=\"popDown('HM_Menu7')\"><AREA SHAPE=RECT COORDS=\"145,54,289,69\" HREF=\"#\"  ALT=\"\" OnMouseOver=\"popUp('HM_Menu8',event)\"  OnMouseOut=\"popDown('HM_Menu8')\"><AREA SHAPE=RECT COORDS=\"145,70,289,85\" HREF=\"#\"  ALT=\"\" OnMouseOver=\"popUp('HM_Menu9',event)\"  OnMouseOut=\"popDown('HM_Menu9')\"><AREA SHAPE=RECT COORDS=\"145,86,289,101\" HREF=\"#\"  ALT=\"\" OnMouseOver=\"popUp('HM_Menu10',event)\"  OnMouseOut=\"popDown('HM_Menu10')\"><AREA SHAPE=RECT COORDS=\"290,19,434,37\" HREF=\"javascript:openSSLink(3,1,0,0)\"  ALT=\"\" OnMouseOut=\"window.status=''; return true\"  OnMouseOver=\"window.status=' '; return true\"><AREA SHAPE=RECT COORDS=\"290,38,434,53\" HREF=\"javascript:openSSLink(3,2,0,0)\"  ALT=\"\" OnMouseOut=\"window.status=''; return true\"  OnMouseOver=\"window.status=' '; return true\"><AREA SHAPE=RECT COORDS=\"290,54,434,69\" HREF=\"javascript:openSSLink(3,5,0,0)\"  ALT=\"\" OnMouseOut=\"window.status=''; return true\"  OnMouseOver=\"window.status=' '; return true\"></MAP>");
		/*HM_Loader.js
		* by Peter Belesis. v4.1.3 011108
		* Copyright (c) 2001 Peter Belesis. All Rights Reserved.
		*/

		HM_DOM = (document.getElementById) ? true : false;
		HM_NS4 = (document.layers) ? true : false;
		HM_IE = (document.all) ? true : false;
		HM_IE4 = HM_IE && !HM_DOM;
		HM_Mac = (navigator.appVersion.indexOf("Mac") != -1);
		HM_IE4M = HM_IE4 && HM_Mac;
		HM_Opera = (navigator.userAgent.indexOf("Opera")!=-1);
		HM_Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);

		HM_IsMenu = !HM_Opera && !HM_Konqueror && !HM_IE4M && (HM_DOM || HM_NS4 || HM_IE4);

		HM_BrowserString = HM_NS4 ? "NS4" : HM_DOM ? "DOM" : "IE4";


		if(window.event + "" == "undefined") event = null;
		function HM_f_PopUp(){return false};
		function HM_f_PopDown(){return false};
		popUp = HM_f_PopUp;
		popDown = HM_f_PopDown;


		HM_GL_MenuWidth          = 150;
		HM_GL_FontFamily         = "Arial,sans-serif";
		HM_GL_FontSize           = 10;
		HM_GL_FontBold           = true;
		HM_GL_FontItalic         = false;
		HM_GL_FontColor          = "black";
		HM_GL_FontColorOver      = "white";
		HM_GL_BGColor            = "transparent";
		HM_GL_BGColorOver        = "transparent";
		HM_GL_ItemPadding        = 3;

		HM_GL_BorderWidth        = 2;
		HM_GL_BorderColor        = "red";
		HM_GL_BorderStyle        = "solid";
		HM_GL_SeparatorSize      = 2;
		HM_GL_SeparatorColor     = "yellow";

		HM_GL_ImageSrc = "HM_More_black_right.gif";
		HM_GL_ImageSrcLeft = "HM_More_black_left.gif";

		HM_GL_ImageSrcOver = "HM_More_white_right.gif";
		HM_GL_ImageSrcLeftOver = "HM_More_white_left.gif";

		HM_GL_ImageSize          = 5;
		HM_GL_ImageHorizSpace    = 5;
		HM_GL_ImageVertSpace     = 5;

		HM_GL_KeepHilite         = false;
		HM_GL_ClickStart         = false;
		HM_GL_ClickKill          = 0;
		HM_GL_ChildOverlap       = 40;
		HM_GL_ChildOffset        = 10;
		HM_GL_ChildPerCentOver   = null;
		HM_GL_TopSecondsVisible  = .5;
		HM_GL_ChildSecondsVisible = .3;
		HM_GL_StatusDisplayBuild = 0;
		HM_GL_StatusDisplayLink  = 1;
		HM_GL_UponDisplay        = null;
		HM_GL_UponHide           = null;

		HM_GL_RightToLeft      = false;
		HM_GL_CreateTopOnly      = HM_NS4 ? true : false;
		HM_GL_ShowLinkCursor     = true;

		if(HM_IsMenu) {
			document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='" + hostName + "/nav/HM_Arrays.js' TYPE='text/javascript'><\/SCR" + "IPT>");
			document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='" + hostName + "/nav/HM_Script"+ HM_BrowserString +".js' TYPE='text/javascript'><\/SCR" + "IPT>");
		}


		//end
	}
	else
	{
		var myNav = checkNav();
		document.write( "<OBJECT id=globalNav classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\/\/download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" WIDTH=780 HEIGHT=135><PARAM NAME=movie VALUE= \"" + hostName + "\/nav/nav.swf?" + myNav + "\"><PARAM NAME=quality VALUE=best><PARAM NAME=bgcolor VALUE=\"#0033CC\"> <embed src= \"" + hostName + "\/nav/nav.swf?" + myNav + "\" width=\"780\" height=\"135\" autostart=\"false\" NAME=\"globalNav\" quality=\"best\" bgcolor=\"#0033CC\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http:\/\/www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></EMBED></OBJECT>");

	}

	document.write( "</td><td align=\"left\"><img src= \"" + hostName + "\/nav/topimage_extended.gif\" alt=\"\" width=\"322\" height=\"202\" border=\"0\"></td><td background= \"" + hostName + "\/nav/background_image.gif\" width=\"100%\">&nbsp;</td></tr></table>");
}

// This function places a cookie on the visitor's browser indicating that they do not wish to view the site using Flash (creates the DHTML cookie)
function set_flash_cookie()
{
	document.cookie = "flash=false;path=/;domain=" + domainName;
	document.location.reload();
}

// This function removes the cookie indicating that the visitor does not want to view the site using Flash (removes the DHTML cookie)
function kill_flash_cookie()
{
	document.cookie= "flash=true;path=/;expires=0;domain=" + domainName;
	document.location.reload();
}

// This function sets a cookie on the visitor's browser indicating that they have viewed the pre-page and chose to continue without Flash
// This cookie is used to avoid a the pre-page for the next year (+1 year being the expiration date of the cookie)
function set_prepage_cookie()
{
	var nextYear = new Date();
	nextYear.setFullYear(nextYear.getFullYear() + 1);
	document.cookie = "prepage=false;path=/;expires=" + nextYear.toGMTString() + + ";domain=" + domainName;
	window.location = "/index.html";
}

// This function test for the existence of the Flash plugin or pre-page cookie.
// If either are present the visitor is sent to index.html rather than the pre-page.
function prepage_test() {
	if (hasFlash())
	{
		window.location = "/index.html";
	}
	else
	{
		var cookies = document.cookie;
		if (cookies.indexOf("prepage=false") != -1)
		{
			netscape_alert();
			window.location = hostName + "/index.html";
		}
		else
		{
			window.location = hostName + "/prepage.html";
		}
	}
}

////////////////////////////////////////////////////////////////////////////////////////////
//
// Utility functions from Webmonkey.com
//
////////////////////////////////////////////////////////////////////////////////////////////
//
// Browser version detector and plugin detector
//
////////////////////////////////////////////////////////////////////////////////////////////

/*
BrowserDetector()
Parses User-Agent string into useful info.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Richard Blaylock
Author Email: blaylock@wired.com

Usage: var bd = new BrowserDetector(navigator.userAgent);
*/


// Utility function to trim spaces from both ends of a string
function Trim(inString) {
  var retVal = "";
  var start = 0;
  while ((start < inString.length) && (inString.charAt(start) == ' ')) {
    ++start;
  }
  var end = inString.length;
  while ((end > 0) && (inString.charAt(end - 1) == ' ')) {
    --end;
  }
  retVal = inString.substring(start, end);
  return retVal;
}

function BrowserDetector(ua) {

// Defaults
  this.browser = "Unknown";
  this.platform = "Unknown";
  this.version = "";
  this.majorver = "";
  this.minorver = "";

  uaLen = ua.length;

// ##### Split into stuff before parens and stuff in parens
  var preparens = "";
  var parenthesized = "";

  i = ua.indexOf("(");
  if (i >= 0) {
    preparens = Trim(ua.substring(0,i));
        parenthesized = ua.substring(i+1, uaLen);
        j = parenthesized.indexOf(")");
        if (j >= 0) {
          parenthesized = parenthesized.substring(0, j);
        }
  }
  else {
    preparens = ua;
  }

// ##### First assume browser and version are in preparens
// ##### override later if we find them in the parenthesized stuff
  var browVer = preparens;

  var tokens = parenthesized.split(";");
  var token = "";
// # Now go through parenthesized tokens
  for (var i=0; i < tokens.length; i++) {
    token = Trim(tokens[i]);
        //## compatible - might want to reset from Netscape
        if (token == "compatible") {
          //## One might want to reset browVer to a null string
          //## here, but instead, we'll assume that if we don't
          //## find out otherwise, then it really is Mozilla
          //## (or whatever showed up before the parens).
        //## browser - try for Opera or IE
    }
        else if (token.indexOf("MSIE") >= 0) {
      browVer = token;
    }
    else if (token.indexOf("Opera") >= 0) {
      browVer = token;
    }
        //'## platform - try for X11, SunOS, Win, Mac, PPC
    else if ((token.indexOf("X11") >= 0) || (token.indexOf("SunOS") >= 0) ||
(token.indexOf("Linux") >= 0)) {
      this.platform = "Unix";
        }
    else if (token.indexOf("Win") >= 0) {
      this.platform = token;
        }
    else if ((token.indexOf("Mac") >= 0) || (token.indexOf("PPC") >= 0)) {
      this.platform = token;
        }
  }

  var msieIndex = browVer.indexOf("MSIE");
  if (msieIndex >= 0) {
    browVer = browVer.substring(msieIndex, browVer.length);
  }

  var leftover = "";
  if (browVer.substring(0, "Mozilla".length) == "Mozilla") {
    this.browser = "Netscape";
        leftover = browVer.substring("Mozilla".length+1, browVer.length);
  }
  else if (browVer.substring(0, "Lynx".length) == "Lynx") {
    this.browser = "Lynx";
        leftover = browVer.substring("Lynx".length+1, browVer.length);
  }
  else if (browVer.substring(0, "MSIE".length) == "MSIE") {
    this.browser = "IE";
    leftover = browVer.substring("MSIE".length+1, browVer.length);
  }
  else if (browVer.substring(0, "Microsoft Internet Explorer".length) ==
"Microsoft Internet Explorer") {
    this.browser = "IE"
        leftover = browVer.substring("Microsoft Internet Explorer".length+1,
browVer.length);
  }
  else if (browVer.substring(0, "Opera".length) == "Opera") {
    this.browser = "Opera"
    leftover = browVer.substring("Opera".length+1, browVer.length);
  }

  leftover = Trim(leftover);

  // # Try to get version info out of leftover stuff
  i = leftover.indexOf(" ");
  if (i >= 0) {
    this.version = leftover.substring(0, i);
  }
  else
  {
    this.version = leftover;
  }
  j = this.version.indexOf(".");
  if (j >= 0) {
    this.majorver = this.version.substring(0,j);
    this.minorver = this.version.substring(j+1, this.version.length);
  }
  else {
    this.majorver = this.version;
  }


} // function BrowserCap


/*

Plugin Detector()

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
Author Email: webmonkey@giantant.com

*/

// this is where we write out the VBScript for MSIE Windows
var WM_startTagFix = '</';
var msie_windows = 0;
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)){
  msie_windows = 1;
  document.writeln('<scr' + 'ipt language="VBscript">');
  document.writeln('\'This will scan for plugins for all versions of Internet Explorer that have a VBscript engine version 2 or greater.');
  document.writeln('\'This includes all versions of IE4 and beyond and some versions of IE 3.');
  document.writeln('Dim WM_detect_through_vb');
  document.writeln('WM_detect_through_vb = 0');
  document.writeln('If ScriptEngineMajorVersion >= 2 then');
  document.writeln('  WM_detect_through_vb = 1');
  document.writeln('End If');
  document.writeln('Function WM_activeXDetect(activeXname)');
  document.writeln('  on error resume next');
  document.writeln('  If ScriptEngineMajorVersion >= 2 then');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('     WM_activeXDetect = IsObject(CreateObject(activeXname))');
  document.writeln('     If (err) then');
  document.writeln('        WM_activeXDetect = False');
  document.writeln('     End If');
  document.writeln('   Else');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('   End If');
  document.writeln('End Function');
  document.writeln(WM_startTagFix+'scr' + 'ipt>');
}


function WM_pluginDetect(plugindescription, pluginxtension, pluginmime, activeXname){

  //This script block will test all user agents that have a real plug-in array

  //(i.e. Netscape) and set the variables, otherwise it directs the routine

  // to WM_activeXDetect to detect the activeX control.



  // First define some variables
  var i,plugin_undetectable=0,detected=0, daPlugin=new Object();


  // Then we check to see if it's an MSIE browser that you can actually

  // check for the plugin in question.

  if (msie_windows && WM_detect_through_vb){
      plugin_undetectable = 0;
  } else {
      plugin_undetectable = 1;
  }



  // If it has a real plugins or mimetypes array, we look there for the plugin first

  if(navigator.plugins) {
      numPlugins = navigator.plugins.length;
      if (numPlugins > 1) {
	  if (navigator.mimeTypes && navigator.mimeTypes[pluginmime] && navigator.mimeTypes[pluginmime].enabledPlugin && (navigator.mimeTypes[pluginmime].suffixes.indexOf(pluginxtension) != -1)) { // seems like we have it, let's just make sure and check the version (if specified)
	      if ((navigator.appName == 'Netscape') && (navigator.appVersion.indexOf('4.0') != -1)) { // stupid, stupid Netscape can't handle the references to navigator.plugins by number, sooo...
		  for(i in navigator.plugins) {
		      if ((navigator.plugins[i].description.indexOf(plugindescription) != -1) || (i.indexOf(plugindescription) != -1)) { // some versions of quicktime have no description. feh!
			  detected=1;
			  break;
		      }
		  }
	      } else {
		  for (i = 0; i < numPlugins; i++) {
		      daPlugin = navigator.plugins[i];
		      if ((daPlugin.description.indexOf(plugindescription) != -1) || (daPlugin.name.indexOf(plugindescription) != -1)) {
			  detected=1;
			  break;
		      }
		  }
	      }

	      // Mac weirdness
      if (navigator.mimeTypes[pluginmime] == null) {
		  detected = 0;
	      }
	  }
	  return detected;
      } else if((msie_windows == 1) && !plugin_undetectable){
	  return WM_activeXDetect(activeXname);
      } else {
	  return 0;
      }
  } else {
      return 0;
  }
}
