//for resolving jquery conflict with other javascript libraries 
var $j = jQuery.noConflict();

//identifies the current host
var current_host = document.location.host;
var current_page = window.location.href;

//
var countryCode;
var countryLabel;
var roleId;
var roleLabel;
var language;
var langswitch;

var multiPermMap = new Array();
multiPermMap["OIG"] = "Y";
multiPermMap["Global"] = "Y";

var specialHomeUrls = new Array();
specialHomeUrls["OIG"] = "/webapp/features/official_institutions.jsp";

var contactMap = new Array();
contactMap["US"] = "GLMK";
contactMap["BE"] = "BRUS";
contactMap["CA"] = "CANA";
contactMap["AE"] = "DUBA";
contactMap["CN"] = "HONG";
contactMap["IN"] = "IND";
contactMap["GB"] = "LOND";
contactMap["IT"] = "MILN";
contactMap["DE"] = "MUNI";
contactMap["FR"] = "PARI";
contactMap["SG"] = "SING";
contactMap["AU"] = "SYDN";
contactMap["JP"] = "TOK1";
contactMap["CH"] = "ZURI";
contactMap["NL"] = "NL";
contactMap["IE"] = "IRE";

var contact_code_overwrite;


//copyright date
var now = new Date();
var thisYear = now.getFullYear();
function writeYear() {
	document.write(thisYear);
}


var regionCodeMap = new Array();
regionCodeMap["Europe"] = "eu";
regionCodeMap["North America"] = "na";
regionCodeMap["Asia-Pacific"] = "asiapac";
regionCodeMap["Middle East and Africa"] = "africa";


var externalLinkMap = new Array();
externalLinkMap["http://www.statestreet.com/"] = "/disclaimers/sscorp_EN.html";
externalLinkMap["http://www.statestreet.com/csr/"] = "/disclaimers/sscorp_EN.html";
externalLinkMap["http://www.statestreet.com/wps/portal/internet/corporate/home/aboutstatestreet/careers/jobopportunities/"] = "/disclaimers/sscorp_EN.html";
externalLinkMap["http://www.statestreetglobalmarkets.com/"] = "/disclaimers/ssgm_EN.html";
externalLinkMap["http://www.rexiter.co.uk/"] = "/disclaimers/rexiter_EN.html";
externalLinkMap["http://www.sectoral.com/"] = "/disclaimers/sectoral_EN.html";
externalLinkMap["http://www.shott-capital.com/"] = "/disclaimers/shott_EN.html";
externalLinkMap["http://www.ssaris.com/"] = "/disclaimers/ssaris_EN.html";
externalLinkMap["http://www.thetuckermangroup.com/"] = "/disclaimers/tuckerman_EN.html";
externalLinkMap["http://www.statestreet.co.jp/public/footter/privacy_ssga_tokyo_jp.html"] = "/disclaimers/sscorp_JA.html";
externalLinkMap["http://www.statestreet.co.jp/public/footter/right.html"] = "/disclaimers/sscorp_JA.html";
externalLinkMap["http://www.statestreet.co.jp/public/footter/legal.html"] = "/disclaimers/sscorp_JA.html";
externalLinkMap["http://www.statestreet.co.jp/public/footter/conflicts_ssgaj.htm"] = "/disclaimers/sscorp_JA.html";
externalLinkMap["http://www.statestreet.co.jp/public/footter/policy_antisocial_ssgaj.htm"] = "/disclaimers/sscorp_JA.html";
externalLinkMap["http://www.statestreet.com/jp/jp/complaints02.html"] = "/disclaimers/sscorp_JA.html";
externalLinkMap["https://www.fsa.go.jp/sesc/watch/"] = "/disclaimers/sscorp_JA.html";
externalLinkMap["http://www.edhec-risk.com/events/edhec_conferences/ERI_DAYS_2012/index_html"] = "/disclaimers/ssgm_EN.html";
externalLinkMap["http://webreprints.djreprints.com/2840380312940.html"] = "/disclaimers/sscorp_EN.html";

// webtrends utility method
function sendLocation() {
	try {
		if (typeof(sendWTHomepage) == 'undefined' || sendWTHomepage) {
			var country = translateCountry(readCookieWT("session_region"));
			var role = translateRole(readCookieWT("session_role"));
			sendWTRequest("glp_country", country, "glp_role", role);
		}
	} catch(e) {}
}

function sendAssetClass(assetClass, url) {
	try {
		var country = translateCountry(readCookieWT("session_region"));
		var role = translateRole(readCookieWT("session_role"));

		sendWTRequest("glp_asset_class_country", country,
					  "glp_asset_class_role", role,
					  "glp_asset_class", assetClass,
					  false);
	} catch(e) {}
	if (url) {
		window.location.href = url;
	}
}

function sendDCPageLink(page, link) {
	try {
		sendWTRequest("glp_dc_page", page,
					  "glp_dc_link", link);
	} catch(e) {}
}



//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXX FLASH VIDEO PLAYER XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//flashvideoplayer is the flash obj id; sendToActionScript is the name of the ExternalInterface function call, so cannot be changed

//get the flash movie object
function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

//call to play
function callToActionScript(str) {
	getFlashMovie("flashvideoplayer").sendToActionScript(str);    
}


//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXX TOOLTIP FUNCTION XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

this.tooltip = function(){
	xOffset = 20;
	yOffset = 5;
	$j("a.tooltip").hover(function(e){
		$j(this).next().css("top",(e.pageY - yOffset) + "px").css("left",(e.pageX + xOffset) + "px").fadeIn("fast");
	},
	function(){ 
		$j(this).next().css("display", "none");
	});
	$j("a.tooltip").mousemove(function(e){ 
		$j(this).next().css("top",(e.pageY - yOffset) + "px").css("left",(e.pageX + xOffset) + "px");
	});

	$j("a.lang_alert").hover(function(e){
		$j(this).children("p").fadeIn("fast");
	},
	function(){ 
		$j(this).children("p").css("display", "none");
	});
}; 

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXX COOKIE FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXX PROFILE VALIDATION XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

var isHome;

// set by Profile Selector
var profile_region;
var profile_role;

// set by profile map
var label_region;
var label_role;
var dis_str;
var dis_cut;
var dis_url;
var dis_v;
var dis_lang = "EN";
var alt_str;
var alt_cut;
var alt_url;
var alt_lang;
var alt_label;
var ext_url;
var ext_dis;
var ext_site;
var revalidating = false;
var preUser;
var precomplying = false;

// cookie data
var sessionRegion;
var sessionRole;
var sessionLang;
var defaultRegion;
var defaultRole;
var defaultVersion;
var defaultLang;
var regionAccess;

//reset video
var video_reset = "<div id=\"SSgA_Video\"></div>";

function load_homepage (keycode) {
	window.location = homepageMap[keycode];
}

function open_win(valURL) {
	window.open(valURL, '_blank');
}

function open_shared_content (plainurl) {
	window.location = plainurl + "?country=" + PageCountryCode[sessionRegion + "_" + sessionRole] + "&language=" + pageLanguage;
}

function open_library (cmId) {
	if (countryAccess == "OIG") {
	window.location = "/webapp/PublicationDetails?cmId=" + cmId + "&country=OIG" + "&language=EN";
	} else {
	window.location = "/webapp/PublicationDetails?cmId=" + cmId + "&country=" + PageCountryCode[sessionRegion  + "_" + sessionRole] + "&language=" + pageLanguage;
	}
}

function open_transcript (cmId) {
	var transURL = "/webapp/PublicationDetails?cmId=" + cmId + "&transcript=true&country=" + PageCountryCode[sessionRegion  + "_" + sessionRole] + "&language=" + pageLanguage;
	window.open(transURL);
}

function openLibraryWindow(url, name){
name=name.replace(/\./g, "_");
openWindow(url,name,'toolbar=yes,location=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=618,height=520,innerwidth=618,left=0,top=0,screenX=0,screenY=0');
}
function openWindow(theURL,winName,features)
{
pop_win=window.open(theURL,winName,features);
} 
function agreement_data() {
	if(alt_lang){
		$j("#compliance #agreement #nav_languages").show();
		$j("#compliance #agreement #nav_languages a").html(alt_label);
		$j("#compliance #agreement #nav_languages a").attr("href", "javascript:alt_disclaimer()");
	}
	$j("#compliance #agreement #regionD").html(CountryLabel[profile_region + "_" + dis_lang]);
	$j("#compliance #agreement #roleD").html(RoleLabels[profile_role + "_" + dis_lang]);

}

function force_language() {
	if (profile_region == "JP") {
		dis_lang = "JA";
	}
}

// opens compliance agreement
function open_compliance() {
	direct_link = countryLandingPage[profile_region + "_" + profile_role + "_" + dis_lang];
	if((profile_region == "IE" && profile_role == "50")
	   || (profile_region == "US" && profile_role == "8")){
		window.open(direct_link)
	}
	else {
		overlay_on();
		force_language();
		label_region = CountryLabel[profile_region + "_" + dis_lang];
		label_role = RoleLabels[profile_role + "_" + dis_lang];
		dis_str = DisclaimerPage[profile_region + "_" + profile_role + "_" + dis_lang];
		dis_cut = dis_str.indexOf('|');
		if(dis_cut != -1) {
			dis_url = dis_str.substring(0,dis_cut);
			dis_v = dis_str.substring(dis_cut + 1);
			alt_lang = SupportedLanguages[profile_region];
			if(alt_lang) {
				alt_str = DisclaimerPage[profile_region + "_" + profile_role + "_" + alt_lang];
				alt_cut = alt_str.indexOf('|');
				if(alt_cut != -1) {
					alt_url = alt_str.substring(0,alt_cut);
					alt_v = alt_str.substring(alt_cut + 1);
				}
				else { alt_url = alt_str;  }
				alt_label = LanguageLabel[alt_lang];
			}
		}
		else {
			dis_url = dis_str;
		}
		var dater = $j.ajax({type:"GET", url:dis_url, dataType:"html", async: false}).responseText;
		$j("#compliance #agreement").html(dater);
		agreement_data();
		if($j("#change").length > 0) {
			$j("#change").hide();
		}
		$j("#compliance").fadeIn("fast");
		return false;
	}
}

// updates compliance agreement
function recomply() {
	revalidating = true;
	overlay_on();
	label_region = CountryLabel[sessionRegion + "_" + sessionLang];
	label_role = RoleLabels[sessionRole + "_" + sessionLang];
	dis_str = DisclaimerPage[sessionRegion + "_" + sessionRole + "_" + sessionLang];
	dis_cut = dis_str.indexOf('|');
	dis_url = dis_str.substring(0,dis_cut);
	dis_v = dis_str.substring(dis_cut + 1);
	alt_lang = SupportedLanguages[sessionRegion];
	if(alt_lang) {
		if(sessionLang != "EN") {
			alt_lang = "EN";
		}
		alt_str = DisclaimerPage[sessionRegion + "_" + sessionRole + "_" + alt_lang];
		alt_cut = alt_str.indexOf('|');
		alt_url = alt_str.substring(0,alt_cut);
		alt_v = alt_str.substring(alt_cut + 1);
		alt_label = LanguageLabel[alt_lang];
	}
	var dater = $j.ajax({type:"GET", url:dis_url, dataType:"html", async: false}).responseText;
	$j("#compliance #agreement").html(dater);
	agreement_data();
	$j("input[name=save_profile]").attr("checked", true);
	$j("#default_option").hide();
	$j("#compliance").fadeIn("fast");
}

function precomply() {
	precomplying = true;
	overlay_on();
	profile_region = countryAccess;
	profile_role = preUser;
	dis_lang = pageLanguage;
	label_region = CountryLabel[profile_region + "_" + dis_lang];
	label_role = RoleLabels[profile_role + "_" + dis_lang];
	dis_str = DisclaimerPage[profile_region + "_" + profile_role + "_" + dis_lang];
	dis_cut = dis_str.indexOf('|');
	dis_url = dis_str.substring(0,dis_cut);
	dis_v = dis_str.substring(dis_cut + 1);
	alt_lang = SupportedLanguages[profile_region];
	if(alt_lang) {
		/*if(sessionLang && sessionLang != "EN") {
			alt_lang = "EN";
		}*/
		alt_str = DisclaimerPage[profile_region + "_" + profile_role + "_" + alt_lang];
		alt_cut = alt_str.indexOf('|');
		alt_url = alt_str.substring(0,alt_cut);
		alt_v = alt_str.substring(alt_cut + 1);
		alt_label = LanguageLabel[alt_lang];
	}
	var dater = $j.ajax({type:"GET", url:dis_url, dataType:"html", async: false}).responseText;
	$j("#compliance #agreement").html(dater);
	agreement_data();
	$j("#compliance").fadeIn("fast");
}

// sets user profile
function set_profile() {
	createCookie('session_region', profile_region );
	createCookie('session_role', profile_role );
	createCookie('session_lang', dis_lang );
	if($j("input[name=save_profile]").is(":checked")) {
		createCookie('default_version', dis_v, 365 );
		createCookie('default_region', profile_region, 365 );
		createCookie('default_role', profile_role, 365 );
		createCookie('default_lang', dis_lang, 365 );
	}
	
	// send country/role information to webtrends.
	try {
		var country = translateCountry(profile_region);
		var role = translateRole(profile_role);
		sendWTRequest("glp_selected_country", country, "glp_selected_role", role);
	} catch(e) {}
	
	var url_region = countryLandingPage[profile_region + "_" + profile_role + "_" + dis_lang];
	window.location.href = url_region;
	
}

function get_ext(ext_url) {
	var ext_chex = externalLinkMap[ext_url];
	if(ext_chex) {
		ext_dis = ext_chex;
	}
	else {
		ext_dis = "/disclaimers/nonaffiliated_EN.html";
	}
	return ext_dis;
}

// sends user to another website
function leave_site() {
	if(ext_url) {
		ext_site = ext_url;
	}
	else {
		ext_site = countryLandingPage[profile_region + "_" + profile_role + "_" + dis_lang];
	}
	over_off();
	// send country/role information to webtrends.
	try {
		var country = translateCountry(profile_region);
		var role = translateRole(profile_role);
		sendWTRequest("glp_country", country, "glp_role", role);
		sendWTRequest("glp_selected_country", country, "glp_selected_role", role);
	} catch(e) {}
	
	window.open(ext_site);
}

function statestreet() {
	over_off();
	window.open("http://www.statestreet.com/");
}

// for alternate languages
function alt_disclaimer() {
	var dis_switch;
	dis_lang = alt_lang;
	if(alt_lang == "EN") {
		dis_switch = dis_url;
		alt_lang = SupportedLanguages[profile_region];
	}
	else {
		dis_switch = alt_url;
		alt_lang = "EN";
	}
	alt_label = LanguageLabel[alt_lang];
	var dater = $j.ajax({type:"GET", url:dis_switch, dataType:"html", async: false}).responseText;
	$j("#compliance #agreement").html(dater);
	agreement_data();
}

// creates user session
function create_session() {
	createCookie('session_region', defaultRegion );
	createCookie('session_role', defaultRole );
	createCookie('session_lang', defaultLang );
}

// erases user profile
function erase_profile() {
	eraseCookie('session_region');
	eraseCookie('session_role');
	eraseCookie('session_lang');
	eraseCookie('default_version');
	eraseCookie('default_region');
	eraseCookie('default_role');
	eraseCookie('default_lang');
	window.location.href = '/';
}

// returns cookie profile data
function return_profile() {
	sessionRegion = readCookie('session_region');
	sessionRole = readCookie('session_role');
	sessionLang = readCookie('session_lang');
	defaultRegion = readCookie('default_region');
	defaultRole = readCookie('default_role');
	defaultVersion = readCookie('default_version');
	defaultLang = readCookie('default_lang');
}

// Writes profile info into page header
function write_profile() {
	
	$j("div#profile span#region").html(CountryLabel[sessionRegion + "_" + sessionLang]);
	$j("div#profile span#role").html(RoleLabels[sessionRole + "_" + sessionLang]);
	var professional = $j("div#change h3").html();
	$j("div#change h3").html(RoleLabels[sessionRole + "_" + sessionLang] + professional);
	$j("div#ssga_logo a").attr("href", countryLandingPage[sessionRegion + "_" + sessionRole + "_" + sessionLang]);
	if($j("a#home_link").length > 0) {
		$j("a#home_link").attr("href", countryLandingPage[sessionRegion + "_" + sessionRole + "_" + sessionLang]);
	}
	if($j("a#libHomeLink").length > 0) {
		$j("a#libHomeLink").attr("href", countryLandingPage[sessionRegion + "_" + sessionRole + "_" + sessionLang]);
	}
	alt_lang = SupportedLanguages[sessionRegion];

	if (sessionRegion == "JP") {
		$j("#nav_language").html("");
	} else {
		if(alt_lang) {
			$j("#nav_language span").html(LanguageLabel[sessionLang]);
			if(sessionLang != "EN") {
				alt_lang = "EN"
			}
			$j("#nav_language a:not(.lang_alert)").html(LanguageLabel[alt_lang]);
			$j("#nav_language").show();

		}
	}
}
// write a dummy profile for a non cookie special page
function write_dummy_profile(text) {
	$j("div#profile span#region").html(text);
	$j("div#ssga_logo a").attr("href", countryLandingPage[sessionRegion + "_" + sessionRole + "_" + sessionLang]);
	if($j("a#home_link").length > 0) {
		$j("a#home_link").attr("href", countryLandingPage[sessionRegion + "_" + sessionRole + "_" + sessionLang]);
	}
	if($j("a#libHomeLink").length > 0) {
		$j("a#libHomeLink").html("Back to Official Institution Home");
		$j("a#libHomeLink").attr("href", specialHomeUrls[countryAccess]);
	}
	/*
	$j("div#profile span#region").html(text);
	if($j("a#home_link").length > 0) {
		$j("a#home_link").attr("href", specialHomeUrls[countryAccess]);
	}
	if($j("a#libHomeLink").length > 0) {
		$j("a#libHomeLink").attr("href", specialHomeUrls[countryAccess]);
	}
	$j("div#ssga_logo a").attr("href", specialHomeUrls[countryAccess]);
	*/
}

// validates disclaimer version
function validate_version() {
	dis_str = DisclaimerPage[defaultRegion + "_" + defaultRole + "_" + defaultLang];
	dis_cut = dis_str.indexOf('|');
	dis_url = dis_str.substring(0,dis_cut);
	dis_v = dis_str.substring(dis_cut + 1);
	if(defaultVersion != dis_v) {
		//alert(dis_v + " " + dis_url);
		profile_region = defaultRegion ;
		profile_role = defaultRole;
		over_off_blocker();
		recomply();
	}
}

// validation
function validate_SSgA () {
		if(countryAccess == "") {
			window.location.href = '/';
		}

		else if(countryAccess == "OIG") {
			$j("#site").show();
			write_dummy_profile("Official Institution");
			$j("#ssc_footer").show();
		}

		else if(sessionRegion && sessionRole) {
					
			regionAccess = PageCountryCode[sessionRegion + "_" + sessionRole];
			if (typeof(matchChildCountry) != "undefined" && matchChildCountry) {
				regionAccess = sessionRegion;
			}
			var sessionURL = countryLandingPage[sessionRegion + "_" + sessionRole + "_" + sessionLang];
			
			if (countryAccess == "GLP") {
				window.location.href = sessionURL;
			}
			else if (multiPermMap[countryAccess] == "Y") {
				$j("#site").show();
				write_profile();				
				$j("#ssc_footer").show();
			}
			else if (countryAccess == regionAccess || countryAccess.indexOf(regionAccess) != -1 || regionAccess.indexOf(countryAccess) != -1) {
				$j("#site").show();
				if(pageLanguage != sessionLang) {
					createCookie('session_lang', pageLanguage );
					sessionLang = pageLanguage;
				}
				write_profile();
				if (defaultRegion && defaultRole && countryAccess == regionAccess) {
					
					validate_version();
				}

			}
			else if(preUser) {
				$j("#site").show();
				over_off_blocker();
				precomply();
			}
			else if(countryAccess == "CA") {
				preUser = "53";
				$j("#site").show();
				over_off_blocker();
				precomply();
			}
			else {
				window.location.href = sessionURL;
			}
			
		}

		else if (defaultRegion && defaultRole) {
			
			regionAccess = PageCountryCode[defaultRegion + "_" + defaultRole];
			if (typeof(matchChildCountry) != "undefined" && matchChildCountry) {
				regionAccess = defaultRegion;
			}
			if(PageCountryCode[defaultRegion + "_" + defaultRole]){
				create_session();
				sessionRegion = defaultRegion;
				sessionRole = defaultRole;
				sessionLang = defaultLang;
				var defaultURL = countryLandingPage[defaultRegion + "_" + defaultRole + "_" + defaultLang];
				if (countryAccess == "GLP") {
					window.location.href = defaultURL;
				}
				else if (multiPermMap[countryAccess] == "Y") {
					$j("#site").show();
					write_profile();
				}
				else if (countryAccess == defaultRegion || countryAccess.indexOf(defaultRegion) != -1 || defaultRegion.indexOf(countryAccess) != -1) {
					$j("#site").show();
					write_profile();
					validate_version();
				}
				else if(preUser) {
					$j("#site").show();
					over_off_blocker();
					precomply();
				}
				else if(countryAccess == "CA") {
					preUser = "53";
					$j("#site").show();
					over_off_blocker();
					precomply();
				}	

				else {
					window.location.href = defaultURL;
				}
			}
			else {
				erase_profile();		
			}
		}

		else {
			$j("#contact #contact_profile").show();
			//$j("#header #home_link").hide();
			$j("#header div#profile").hide();
			if (countryAccess == "GLP") {
				$j("#site").show();
				$j("#ssc_footer").show();
			}
			else if (multiPermMap[countryAccess] == "Y") {
				$j("#site").show();
				$j("#ssc_footer").show();
			}
			else if(preUser) {
				$j("#site").show();
				over_off_blocker();
				precomply();
			}
			else if(countryAccess == "CA") {
				preUser = "53";
				$j("#site").show();
				over_off_blocker();
				precomply();
			}
			else {
				window.location.href = '/';
			}
		}
		
}



//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXX FORM VALIDATION XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

function validate_checkgroup (group, frmID) {
	var error = "";
	if(group == 0) {
		error = "<span>Please select an Area of Interest.</span>";
	}
	return error;
}


function validate_user (strng, frmID) {
	var error = "";
	if (strng == "") {error="User ID"; }
	if (strng == "User ID:") {error="User ID"; }
	if(error != "") {
		$j("#" + frmID + " input[name=USER]").addClass("error");
	}
	else { $j("#" + frmID + " input[name=USER]").removeClass("error");}
	return error;
}

function validate_password (strng, frmID) {
	var error = "";
	if (strng == "") {error="Password";}
	if (strng == "Password:") {error="Password"; }
	if(error != "") {
		$j("#" + frmID + " input[name=display_pwd]").addClass("error");
		$j("#" + frmID + " input[name=PASSWORD]").addClass("error");
	}
	else {
		$j("#" + frmID + " input[name=display_pwd]").removeClass("error");
		$j("#" + frmID + " input[name=PASSWORD]").removeClass("error");
	}
	return error;
}

function validate_first (strng, frmID) {
	var error = "";
	if (strng == "") { error = "<span>Please enter a First Name.</span>"; }
	if (strng.length > 50) { error = "<span>The First Name field is limited to 50 characters.</span>"; }
	if(error != "") { $j("#" + frmID + " input[name=firstName]").addClass("error");}
	else { $j("#" + frmID + " input[name=firstName]").removeClass("error");}
	return error;
}

function validate_last (strng, frmID) {
	var error = "";
	if (strng == "") { error = "<span>Please enter a Last Name.</span>"; }
	if (strng.length > 50) { error = "<span>The Last Name field is limited to 50 characters.</span>";}
	if(error != "") { $j("#" + frmID + " input[name=lastName]").addClass("error");}
	else { $j("#" + frmID + " input[name=lastName]").removeClass("error");}
	return error;
}

function validate_org (strng, frmID) {
	var error = "";
	if (strng == "") { error = "<span>Please enter an Organization.</span>"; }
	if (strng.length > 100) { error = "<span>The Organization field is limited to 100 characters.</span>";}
	if(error != "") { $j("#" + frmID + " input[name=orgName]").addClass("error");}
	else { $j("#" + frmID + " input[name=orgName]").removeClass("error");}
	return error;
}

function validate_pos (strng, frmID) {
	var error = "";
	if (strng == "") { error = "<span>Please enter an Position.</span>"; }
	if (strng.length > 100) { error = "<span>The Position field is limited to 100 characters.</span>";}
	if(error != "") { $j("#" + frmID + " input[name=posName]").addClass("error");}
	else { $j("#" + frmID + " input[name=posName]").removeClass("error");}
	return error;
}

function validate_phone (strng, frmID) {
	var error = "";
	if (strng == "") { error = "<span>Please enter a Phone Number.</span>"; }
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
    if (isNaN(parseInt(stripped)) && strng.length != 0) {
       error = "<span>The phone number contains illegal characters.</span>";
    }
	if(error != "") { $j("#" + frmID + " input[name=phone]").addClass("error");}
	else { $j("#" + frmID + " input[name=phone]").removeClass("error");}
	return error;
}

function validate_email (strng, frmID) {
	var error="";
	if (strng == "" || strng == "Your email address") { error = "<span>Please enter an email address.</span>"; }
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { error = "<span>Please enter a valid email address.</span>"; }
    else {
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
        if (strng.match(illegalChars)) { error = "<span>The email address contains unsupported characters.</span>"; }
    }
	if(error != "") { $j("form[name=" + frmID + "] input[name=email]").addClass("error");}
	else { $j("form[name=" + frmID + "] input[name=email]").removeClass("error");}
	return error;
}

function validate_radios(checkvalue) {
	var error = "";
   	if (!(checkvalue)) { error = "<span>Please check a radio button.</span>"; }
	return error;
}

function validate_dropdown(strng, frmID) {
	var error = "";
    if (strng == 0) { error = "<span>You didn't choose an option from the drop-down list.</span>"; }
	return error;
}

function validate_message(strng, frmID) {
	var error = "";
	if (strng == "" || strng == "Your message") { error = "<span>Please enter text in the Message box.</span>"; }
	if (strng.length > 10000) { error = "<span>There is a 10000 character limit for the Message field.</span>";}
	if(error != "") { $j("#" + frmID + " textarea[name=MESSAGE]").addClass("error");}
	else { $j("#" + frmID + " textarea[name=MESSAGE]").removeClass("error");}
	return error;
}

function form_error(frmID) {
	$j("#" + frmID + " #" + frmID +"Form").hide();
	$j("#" + frmID + " .form_success").hide();
	$j("#" + frmID + " .form_error").show();
}

function form_success(data, frmID) {
	$j("#" + frmID + " #" + frmID +"Form").hide();
	$j("#" + frmID + " .form_success").html(data);
	$j("#" + frmID + " .form_error").hide();
	$j("#" + frmID + " .form_success").show();
}

//reset register form
function reset_form(frmID)  {
	$j("#" + frmID + "  .form_error").hide();
	$j("#" + frmID + "  .form_success").hide();
	$j("#" + frmID + " #" + frmID + "Form").show();
    	$j("#" + frmID + " #" + frmID + "Form input").removeClass("error");
	$j("#" + frmID + " #" + frmID + "Form textarea").removeClass("error");
	$j("#" + frmID + " .error_box").hide();
	$j("#" + frmID + " input:text").attr("value", "");
	$j("#" + frmID + " textarea").attr("value", "");
	if(frmID == "contact") {
		for (i=0, n=document.contactForm.relationship.length; i<n; i++) {
			document.contactForm.relationship[i].checked = false;
		}
	}

}


// validate contact form
function validate_contact() {
    	var why = "";
	why += validate_first(document.contactForm.firstName.value, 'contactForm');
	why += validate_last(document.contactForm.lastName.value, 'contactForm');
	why += validate_org(document.contactForm.orgName.value, 'contactForm');
	why += validate_phone(document.contactForm.phone.value, 'contactForm');
	why += validate_email(document.contactForm.email.value, 'contactForm');
	var checkvalue = ""
	for (i=0, n=document.contactForm.relationship.length; i<n; i++) {
        	if (document.contactForm.relationship[i].checked) {
            		checkvalue = document.contactForm.relationship[i].value;
            		break;
        	}
    	}
    	why += validate_radios(checkvalue);
	why += validate_message(document.contactForm.MESSAGE.value, 'contactForm');

	var regionContact = PageCountryCode[sessionRegion + "_" + sessionRole];
	var contact_code;
	var countryName = CountryLabel[sessionRegion + "_" + "EN"];
	if(contact_code_overwrite) {
		contact_code = contact_code_overwrite;
	}
	else {
		if(regionContact) {
			contact_code = contactMap[regionContact];
		}
		else {
			var whoTo = $j("#contact_profile select option:selected").attr("value");
			why += validate_dropdown(whoTo, 'contactForm');
			contact_code = whoTo;
			countryName = $j("#contact_profile select option:selected").html();
		}
	}
	if (why != "") {
       		$j("#contact .error_box").html(why).show();
		return false;
		preventDefault();
    	}
	else {
		$j("#contact .error_box").html(why).hide();
	}
	//form will be submitted if validation reaches here.
	var contact_data = {
		"FIRST_NAME":document.contactForm.firstName.value,
		"LAST_NAME":document.contactForm.lastName.value,
		"ORGANIZATION":document.contactForm.orgName.value,
		"PHONE_NUMBER":document.contactForm.phone.value,
		"EMAIL":document.contactForm.email.value,
		"SSGA_FLAG":checkvalue,
		"MESSAGE":document.contactForm.MESSAGE.value,
		"COUNTRY":contact_code,
		"ROLE_LABEL":RoleLabels[sessionRole + "_" + sessionLang],
		"COUNTRY_LABEL":countryName
	};

	$j.ajax({
 		type: "POST",
		url: "/webapp/ContactUsServlet" ,
 		dataType: "text",
 		data: contact_data,
 		error: form_error("contact"),
 		success: function(data) {
			form_success(data, "contact");
		}
	});
}

// validate contact form
function validate_DCcontact() {
	var contact_code = "DEFC";
	var why = "";
	var interests = '';
	$j("#dc_interest input:checked").each(function(){	
		var intr = $j(this).attr("value");
		if(intr == "Other") {
			intr =$j("#dc_interest input#interest_other").attr("value");	
		}
		if(intr != "") {					
		 interests += intr + ',';
		}
	});
	interests = interests.substring(0, interests.length - 1);
	why += validate_checkgroup(interests.length, "contactForm");
	why += validate_first(document.contactForm.firstName.value, 'contactForm');
	why += validate_last(document.contactForm.lastName.value, 'contactForm');
	why += validate_org(document.contactForm.orgName.value, 'contactForm');
	var whoTo = $j("#dc_profile select option:selected").attr("value");
	why += validate_dropdown(whoTo, 'contactForm');
	if(whoTo == "Other") {
		whoTo = $j("#dc_profile input").attr("value");
		if(whoTo == "") {
			$j("#dc_profile input").addClass("error");
			why += "<span>Please enter a Position.</span>";
		}
	}
	why += validate_phone(document.contactForm.phone.value, 'contactForm');
	why += validate_email(document.contactForm.email.value, 'contactForm');
	var checkvalue = ""
	for (i=0, n=document.contactForm.relationship.length; i<n; i++) {
        	if (document.contactForm.relationship[i].checked) {
            		checkvalue = document.contactForm.relationship[i].value;
            		break;
        	}
    	}
    	why += validate_radios(checkvalue);
	why += validate_message(document.contactForm.MESSAGE.value, 'contactForm');
	if (why != "") {
       		$j("#contact .error_box").html(why).show();
		return false;
		preventDefault();
    	}
	else {
		$j("#contact .error_box").html(why).hide();
	}
	//form will be submitted if validation reaches here.
	var contact_data = {
		"AREA_INTEREST":interests,
		"FIRST_NAME":document.contactForm.firstName.value,
		"LAST_NAME":document.contactForm.lastName.value,
		"ORGANIZATION":document.contactForm.orgName.value,
		"POSITION":whoTo,
		"PHONE_NUMBER":document.contactForm.phone.value,
		"EMAIL":document.contactForm.email.value,
		"SSGA_FLAG":checkvalue,
		"MESSAGE":document.contactForm.MESSAGE.value,
		"SAVE_MORE":savemore,
		"COUNTRY":contact_code,
		"ROLE_LABEL":RoleLabels[sessionRole + "_" + sessionLang],
		"COUNTRY_LABEL":CountryLabel[sessionRegion + "_" + "EN"]
	};
	$j.ajax({
 		type: "POST",
		url: "/webapp/ContactUsServlet" ,
 		dataType: "text",
 		data: contact_data,
 		error: form_error("contact"),
 		success: function(data) {
			form_success(data, "contact");
		}
	});
}


// validate register form
function validate_register() {
    	var why = "";
	why += validate_first(document.registerForm.firstName.value, 'registerForm');
	why += validate_last(document.registerForm.lastName.value, 'registerForm');
	why += validate_org(document.registerForm.orgName.value, 'registerForm');
	why += validate_pos(document.registerForm.posName.value, 'registerForm');
	why += validate_phone(document.registerForm.phone.value, 'registerForm');
	why += validate_email(document.registerForm.email.value, 'registerForm');
	var checkvalue = ""
	for (i=0, n=document.registerForm.requestedSite.length; i<n; i++) {
        	if (document.registerForm.requestedSite[i].checked) {
            		checkvalue = document.registerForm.requestedSite[i].value;
            		break;
        	}
    	}
    	why += validate_radios(checkvalue);
    	if (why != "") {
       		$j("#register .error_box").html(why).show();
		return false;
		preventDefault();
    	}
	else {
		$j("#register .error_box").html(why).hide();
	}

	//form will be submitted if validation reaches here.
	var regionContact = PageCountryCode[sessionRegion + "_" + sessionRole];
	var register_data = {"FIRST_NAME":document.registerForm.firstName.value,
	"LAST_NAME":document.registerForm.lastName.value,
	"ORGANIZATION":document.registerForm.orgName.value,
	"POSITION":document.registerForm.posName.value,
	"PHONE_NUMBER":document.registerForm.phone.value,
	"EMAIL":document.registerForm.email.value,
	"REQUESTED_SITE":checkvalue,
	"COUNTRY":contactMap[regionContact],
	"ROLE_LABEL":RoleLabels[sessionRole + "_" + sessionLang],
	"COUNTRY_LABEL":CountryLabel[sessionRegion + "_" + "EN"]
	};

	$j.ajax({
 		type: "POST",
		url: "/webapp/RegistrationServlet",
 		dataType: "text",
 		data: register_data,
 		error: function() {
			form_error("register");
		},
 		success: function(data) {
			form_success(data, "register");
		}
	});

}

// validate information request form
function validate_request() {
    	var why = "";
	why += validate_email(document.requestForm.email.value, 'requestForm');
	why += validate_message(document.requestForm.MESSAGE.value, 'requestForm');
    	if (why != "") {
       		$j("#request .error_box").html(why).show();
		return false;
		preventDefault();
    	}
	else {
		$j("#request .error_box").html(why).hide();
	}
	var cntct_cd = $j("#requestForm a.btn_form").attr("title");
	//form will be submitted if validation reaches here.
	var request_data = {
		"EMAIL":document.requestForm.email.value,
		"MESSAGE":document.requestForm.MESSAGE.value,
		"CONTACT_SUBJECT_CODE":cntct_cd,
		"SUBJECT":document.title
	};

	$j.ajax({
 		type: "POST",
		url: "/webapp/ContactSolutionServlet",
 		dataType: "text",
 		data: request_data,
 		error: function() {
			form_error("request");
		},
 		success: function(data) {
			form_success(data, "request");
		}
	});
}


// validate login form
var formID;
function validate_login(thisForm) {
    	var why = "";
	usrstrng = $j("#" + thisForm + " input[name=USER]").attr("value");
	why += validate_user(usrstrng, thisForm);
	psswrdstrng = $j("#" + thisForm + " input[name=PASSWORD]").attr("value");
	why += validate_password(psswrdstrng, thisForm);
    	if (why != "") {
		return false;
    	}
	else {
		if($j("#header .login").is(":visible")){
			click_off();
			$j("#header .login").slideUp();
		}
		overlay_on();
		var dater = $j.ajax({type:"GET", url:"/disclaimers/ssgaprivate_EN.html", dataType:"html", async: false}).responseText;
		$j("#compliance #agreement").html(dater);
		$j("#compliance").fadeIn("fast");
		formID = thisForm;
	}
}

function login_private(formID) {
	document.forms[formID].action='https://' + current_host + '/siteminderagent/forms/InternetRetry.fcc';
	document.forms[formID].TARGET.value='$SM$https://' + current_host + '/weblogic/private/privateHome';
	document.forms[formID].submit();
}


// validate password reset form
function validate_passwordReset(thisForm) {
	var why = "";
	var frmstrng = $j("#" + thisForm + " input").attr("value");
	why += validate_email(frmstrng, thisForm);
    	if (why != "") {
		$j("#" + thisForm + " .error_box").html(why).show();
		$j("#" + thisForm + " input").addClass("error");
       		return false;
		
    	}
	else {
		$j("#" + thisForm + " input").removeClass("error");
		$j("#" + thisForm + " .error_box").hide().html("");
	}
	var sendThis = {
		"email":frmstrng
	};

	$j.ajax({
 		type: "post",
		url: "/webapp/ForgotPasswordServlet" ,
 		dataType: "text",
 		data: sendThis,
		error: function() {
			form_error("passwordReset");
		},
 		success: function(data) {
			
			form_success(data, "passwordReset");
		}

	});
}


//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXX OVERLAY FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


function overlay_on() {
	var docH = $j(document).height();
	var docW = $j(document).width();
	$j("#overlay_area").height(docH);
	$j("#overlay_area").width(docW);
	$j("#overlay_area div").height(docH);
	$j("#overlay_area div").width(docW);
	$j("div.overlay_content").css("left", docW/2 - $j("div.overlay_content").width()/2).hide();
	if($j("#pdf_wrapper").length > 0) {
		if($j.browser.msie || $j.browser.mozilla) {
			$j("#pdf_wrapper object").hide();
		}
	}
	$j("#overlay_area").fadeIn("fast");
}


function click_on() {
	$j("#header .login").css("z-index", "200");
	$j("#header #meta_area").css("z-index", "300");
	$j("#header #nav_meta").css("z-index", "300");
	var docH = $j(document).height();
	var docW = $j(document).width();
	$j("#overlay_area").height(docH);
	$j("#overlay_area").width(docW);
	$j("#overlay_area div").height(docH);
	$j("#overlay_area div").width(docW);
	$j("#overlay_area div").css("opacity", "0.01");
	$j("#overlay_area").show();
}

function click_off() {
	$j("#header .login", window.parent.document).css("z-index", "2");
	$j("#header #meta_area", window.parent.document).css("z-index", "3");
	$j("#header #nav_meta", window.parent.document).css("z-index", "3");
	$j("#overlay_area", window.parent.document).hide();
	$j("#overlay_area div", window.parent.document).css("opacity", "0.3");
	$j("#overlay_area div", window.parent.document).show();
}

function over_off() {
	if(revalidating == true) {
		erase_profile();
	}
	else if(precomplying == true) {
		window.location.href = '/';
	}
	else {
		$j("#overlay_area").hide();
		$j("div.overlay_content").hide();
		$j("#overlay_blocker").hide();
		if($j("#pdf_wrapper").length > 0) {
			if($j.browser.msie || $j.browser.mozilla) {
				$j("#pdf_wrapper object").show();
			}	
		}
		$j("#agreement").html("");
		dis_lang = "EN";
		ext_url = null;
	}
}

function over_off_blocker() {
	var docH = $j(document).height();
	var docW = $j(document).width();
	$j("#overlay_blocker").height(docH);
	$j("#overlay_blocker").width(docW);
	$j("#overlay_blocker").show();
}

function productInfoOverlay(desc) {
	$j("#product_info div.white").html(desc);
	overlay_on();
	$j("#product_info").fadeIn("fast");
	return false;
}


function contact_overlay() {							
	if($j("#header .login").is(":visible")){
		click_off();
		$j("#header .login").slideUp();
	}
	reset_form("contact");
	overlay_on();
	$j("#contact").fadeIn("fast");
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXX LIBRARY FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// filter for library results
function mediaElect(mediaOn) {
	if(mediaOn == "Both" || mediaOn == "All"){
			$j("#result_list div.item").show();
	}
	else{
		if(mediaOn == "Articles") {
			$j("#result_list div.article").show();
			$j("#result_list div.video").hide();
		}
		else if (mediaOn == "Video"){
			$j("#result_list div.article").hide();
			$j("#result_list div.video").show();
		}

	}
}

function filter_list() {
	var mediaOn = $j("#result_filters input:radio[name=media]:checked").val();
	mediaElect(mediaOn);
}


function date_parser(date_sent) {
	var month_extract = date_sent.substring(0,2);
	var year_extract = date_sent.substring(3,7);
	var date_number = year_extract + month_extract;
	return date_number;
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Flash Functions XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//function to dynamically resize a div
function setupHTMLDiv(myHeight,myDiv){
 var myDivToResize=document.getElementById(myDiv);
  myDivToResize.style.height=myHeight+"px";
}


function updateLocation(value) {
	profile_region = value;
}
function updateRole(value) {
	profile_role = value;
}
function showOverlay(overlay_id) {
	overlay_on();
	$j("#" + overlay_id).fadeIn("fast");
}

function openDCPageLink() {
	sendDCPageLink('DC Home', 'Promo Box (Learn More)');
	window.location = "/webapp/us/dc/dc_promo.jsp";
}

function openLanguageURL(value) {
	var thisURL = value;
	var urlAppender = '?';
	if (thisURL.indexOf('?') > 0) {
		urlAppender = '&';
	}
	window.location = thisURL + urlAppender + "country=" + PageCountryCode[sessionRegion  + "_" + sessionRole] + "&language=" + sessionLang;	
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

	$j(".collapse_menu div a").live("click",function(){
			if($j(this).parent().parent().is("div.collapse_menu")) {
				if($j(this).hasClass("active")) {
					$j(this).next().slideUp().removeClass("active");
					$j(this).removeClass("active");
				}
				else {
					$j(this).next().slideDown();
					$j(this).addClass("active");
				}
				return false;
			}
			else {}
		}
	);


	$j("a.lang_code").live("click", function(){			
			var thisURL = $j(this).attr("href");
			if($j(this).parent().parent().attr("id") == "agreement") {
				window.open(thisURL + "?country=" + PageCountryCode[profile_region  + "_" + profile_role] + "&language=" + dis_lang);
			}
			else {
				if(sessionRegion && sessionRole ) {openLanguageURL(thisURL);}
				else {window.location = thisURL;}
				/*
				if (countryAccess == "OIG") {
					window.location = thisURL + "?country=" + countryAccess;
					
				} else {
					if(sessionRegion && sessionRole ) {openLanguageURL(thisURL);}
					else {window.location = thisURL;}
				}
				*/
			}
			return false;
		}
	);


	$j("a.ext_link").live("click", function(){
		ext_url = $j(this).attr("href");
		get_ext(ext_url);
		overlay_on();
		var dater = $j.ajax({type:"GET", url:ext_dis, dataType:"html", async: false}).responseText;
		$j("#compliance #agreement").html(dater);
		agreement_data();
		window.scroll(0,0);
		$j("#compliance").fadeIn("fast");
		return false;
		}
	);


//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX PROMO PARSING XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//Cycler
var inter;
var pictures;

function cycler(whatit) {
	whatit = pictures;
	$j("#imgs div.open").each(function() {
			var lknss = $j(this).attr("id");
			$j(this).fadeOut().removeClass("open");
			$j("#buttons a." + lknss).removeClass("active");
			if($j(this).is(":last-child")) {
				$j(this).parent().children(":first").fadeIn().addClass("open");
				$j("#buttons a:first").addClass("active");
				clearInterval(inter);
			}
			else {
				$j("#buttons a." + lknss).next().addClass("active");
				$j(this).next().fadeIn().addClass("open");
			}
		});
}


function recycler(whatit) {
	whatit = pictures;
	$j("#oig_facts span.active").each(function() {
			$j(this).hide().removeClass("active");
			if($j(this).is(":last-child")) {
				$j(this).parent().children(":first").fadeIn().addClass("active");
			}
			else {
				$j(this).next().fadeIn().addClass("active");
			}
		});
}

function promos_run() {
	$j("#spotlight_area #buttons a").click(function(){
			clearInterval(inter);								
			if($j(this).hasClass("active")){}
			else {
				$j("#imgs div:visible").fadeOut();	
				var whoami = $j(this).attr("class");
				$j("#imgs div#" + whoami).fadeIn();
 				$j(this).parent().children().removeClass("active");
				$j(this).addClass("active");
			}
			return false;
		}
	);
}

function write_promos(xml) {
	$j("<div id='promos'><div id='imgs'></div><div id='buttons'></div></div>").appendTo("#spotlight_area");
	$j(xml).find("spotlight").each(function(){
		var promo_img = $j(this).find("imageUrl").text();
		var promo_text = $j(this).find("imageText").text();	
		var promo_no = 	$j(this).attr("iconText");
		var promo_url = $j(this).find("promoUrl").text();
		var link_text = $j(this).find("linkText").text();
		if(promo_no == 1) {
			$j("<div class='open' id='promo" + promo_no + "'><img src='" + promo_img + "' alt='" + promo_text + "' /><a href='" + promo_url + "'>" + link_text + "</a></div>").appendTo("#imgs");
			$j("<a href='#' class='promo" + promo_no + " active'>" + promo_no + "</a>").appendTo("#buttons");
				
		}
		else{
			$j("<div id='promo" + promo_no + "'><img src='" + promo_img + "' alt='" + promo_text + "' /><a href='" + promo_url + "'>" + link_text + "</a></div>").appendTo("#imgs");
			$j("<a href='#' class='promo" + promo_no + "'>" + promo_no + "</a>").appendTo("#buttons");	
		}		

	});
	promos_run();
	pictures = $j("#imgs div.open");
	inter = window.setInterval("cycler()", 7000);

}


function f_ext_link (ext_link) {
		ext_url = ext_link;
    		get_ext(ext_url);
    		overlay_on();
    		var dater = $j.ajax({type:"GET", url:ext_dis, dataType:"html", async: false}).responseText;
    		$j("#compliance #agreement").html(dater);
    		agreement_data();
    		window.scroll(0,0);
    		$j("#compliance").fadeIn("fast");
}
	
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX PROFILER PARSING XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

function profiler_run() {
	$j("a#change_location").click(function(){
			var loc = $j("#profiler_regions span.selection").attr("name");
			$j("#profiler_roles").hide();
			$j("div.roles").hide();
			$j("#profiler_locations span.selection").html("").hide();
			$j("#change_location").hide();
			$j("p.not_listed").show();
			$j("div#" + loc).show();
			return false;
		}
	);
	$j("a#change_region").click(function(){
			$j("#profiler_locations").hide();
			$j("div.locations").hide();
			$j("#profiler_roles").hide();
			$j("div.roles").hide();
			$j("span.selection").html("").hide();
			$j("div.regions").show();
			$j("#change_location").hide();
			$j("#change_region").hide();
			return false;
		}
	);
	$j("div.regions a").click(function(){
			clearInterval(inter);
			var loc = $j(this).attr("class");
			$j("div#profiler_regions div.regions").hide();
			$j("div#profiler_regions span.selection").html($j(this).html()).attr("name", loc).show();	
			$j("div#" + loc).show();
			$j("div#profiler_locations").slideDown();
			$j("#change_region").show();
			return false;
		}
	);
	$j("div.locations a").click(function(){
			var loc = $j(this).attr("class");
			profile_region = loc;
			$j("div#profiler_locations div.locations").hide();
			$j("div#profiler_locations span.selection").html($j(this).html()).show();	
			$j("div#" + loc).show();
			$j("div#profiler_roles").slideDown();
			$j("#change_location").show();
			$j("p.not_listed").hide();
			return false;
		}
	);
	$j("div.roles a").click(function(){
			var loc = $j(this).attr("class");
			profile_role = loc;
			open_compliance();
			return false;
		}
	);

}


function write_profiler(xml, parseto) {
	$j("<div id='profiler_holder'><div id='profiler_title'>Our Investment Capabilities</div><div id='profiler_select'>Select from the choices below:</div><div id='profiler_regions'><div id='label_region' class='profiler_label'>Region:</div><span class='selection'></span><a href='#' id='change_region'>Change</a></div><div id='profiler_locations'><div id='label_location' class='profiler_label'>Location:</div><span class='selection'></span><a href='#' id='change_location'>Change</a></div><div id='profiler_roles'><div id='label_role' class='profiler_label'>Role:</div><span class='selection'></span></div><div id='profiler_oig'><div id='label_role' class='profiler_label'>Institution:</div><a href='/webapp/features/official_institutions.jsp'>Official Institution &raquo;</a></div></div>").appendTo("#" + parseto);

	$j("<div class='regions'></div>").appendTo("#profiler_regions");	
	$j(xml).find("region").each(function(){
		var regionName = $j(this).attr("name");
		var regionCode = regionCodeMap[regionName];
		$j("<a href='#' class='" + regionCode + "'>" + regionName + "</a>").appendTo("div.regions");
		$j("<div class='locations' id='" + regionCode + "'></div>").appendTo("#profiler_locations");
		$j(this).find("country").each(function(){
			var countryName = $j(this).attr("name");
			var countryCode = $j(this).attr("code");
			$j("<a class='" + countryCode + "'>" + countryName + "</a>").appendTo("div#" + regionCode);
			$j("<div class='roles' id='" + countryCode + "'></div>").appendTo("#profiler_roles");
			$j(this).find("role").each(function(){
				var roleName = $j(this).attr("name");
				var roleCode = $j(this).attr("id");
				var roleExt = $j(this).attr("external");
				var roleOrder = $j(this).attr("refId");
				if(roleExt == "true") {
					$j("<a class='" + roleCode + "' title='" + roleOrder + "'><span class='ext_role'>" + roleName + "</span></a>").appendTo("div#" + countryCode);
				}
				else{
					$j("<a class='" + roleCode + "' title='" + roleOrder + "'>" + roleName + " &raquo;</a>").appendTo("div#" + countryCode);	
				}
			});										   
		});									 
	});
	$j("<p class='not_listed'>Your location not listed?<br/>Please <a href='javascript:contact_overlay()'>contact SSgA</a><br/>for information.</p>").appendTo("#profiler_locations");
		
	$j('div.regions>a').tsort({order:"asc"});
	$j('div.locations>a').tsort({order:"asc"});
	$j('div.roles>a').tsort({order:"asc", attr:"title"});
	$j('div.locations').each(function(){
		if($j(this).children().length > 11){
			var linkNos = Math.round(($j(this).children().length)/2) - 1;
			$j("<div class='locations_cL'></div><div class='locations_cR'></div>").appendTo($j(this));
			$j(this).children("a:gt("+linkNos +")").appendTo($j(this).children("div.locations_cR"));
			$j(this).children("a").appendTo($j(this).children("div.locations_cL"));

		}
	});
	$j('div.roles>a').removeAttr("title");
	profiler_run();
}


//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX DOM READY XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

$j(document).ready(function(){

	//returns cookie data
	return_profile();
	
	//validates cookie data
	if(countryAccess != "inframe") {
		validate_SSgA ();
	}

	$j("#nav_meta a").each(function(){
			var whereweat = $j(this).attr("href");
			if(whereweat != "/" && whereweat != "" && current_page.indexOf(whereweat) != -1 && $j(this).attr("id") != "home_link") {
					$j(this).addClass("active");
			}
		}
	);

	if(current_page.indexOf("tab=") != -1) {
		var tab_cut =  current_page.indexOf("tab=") + 4;
		var tabNo = current_page.substring(tab_cut, tab_cut + 1);
		var tab_name = "tab" + tabNo;
		$j("div#about_tabs a").removeClass("active");
		$j("#about_promos div").removeClass("active");
		$j("#about_sec div.section").removeClass("active");
		$j("#about_promos div." + tab_name ).addClass("active");
		$j("#about_sec div." + tab_name ).addClass("active");
		$j("div#about_tabs a." + tab_name ).addClass("active");
		if(current_page.indexOf("sec=") != -1) {
			var sect_cut =  current_page.indexOf("sec=") + 4;
			var sectNo = current_page.substring(sect_cut, sect_cut + 1);
			var sect_name = "sect" + sectNo;
			$j("#about_sec div." + tab_name + " div.sec_left a").removeClass("active");
			$j("#about_sec div." + tab_name + " div.sec_left a." + sect_name).addClass("active");
			$j("#about_sec div." + tab_name + " div.sec_right div").removeClass("active");
			$j("#about_sec div." + tab_name + " div.sec_right div." + sect_name).addClass("active");	
		}				
	}

	// rewrites cookie values for language toggle
	$j("#nav_language a:not(.lang_alert)").click(function(){
		createCookie('session_lang', alt_lang);
		if(isHome == true) {
			window.location.href =	countryLandingPage[sessionRegion + "_" + sessionRole + "_" + alt_lang];
		}
		else {
			alt_str = current_page;

			alt_cut = alt_str.indexOf("&language=") + 10;

			var alt_end = alt_str.substring(alt_cut);
			var alt_cut2 = alt_end.indexOf("&");
			if(alt_cut2 != -1) {
				var alt_endEnd = alt_end.substring(alt_cut2);
				alt_url = alt_str.substring(0,alt_cut) + alt_lang + alt_endEnd;
			}
			else {
				alt_url = alt_str.substring(0,alt_cut) + alt_lang;
			}
			window.location.href = alt_url;
		}
		return false;
	});


	if($j("#btn_play").length > 0 && $j("#videoID").html() != "") {
		var videoIDno = $j("#videoID").html();
		$j("#btn_play").attr("href", videoIDno);
		$j("#btn_play").show();
		var flashvars = {
			stage_width: "380",
			stage_height: "240",
			fontpath: "/flash/welcome_fonts.swf",
			csspath: "/flash/welcome.css",
			vidnumber: videoIDno

		};
		var params = {
			allowNetworking: "all",
			allowScriptAccess: "always",
			menu: "false",
			wmode: "transparent"
		};
		var attributes = {
			name: "flashvideoplayer"
		};
		swfobject.embedSWF("/flash/videoplayer_small.swf", "flashvideoplayer", "420", "240", "9.0.0","/flash/expressInstall.swf", flashvars, params, attributes);



	}

	$j("#btn_play").click(function(){
		if($j("#video_player").hasClass("nothere")){		
			$j("div.intro").hide();
			$j("div.authorName").hide();
			$j("div.authorTitle").hide();
			$j("img.authorImage").hide();
			$j("#video_player").removeClass("nothere");
			$j("#btn_transcript").attr("href",$j("#transcript").html()).show();
			$j("#btn_back").show();
		} else {
			callToActionScript("play");
		}
		if($j(this).hasClass("play")) {
			$j(this).removeClass("play");
			$j(this).addClass("pause");
		}
		else {
			$j(this).removeClass("pause");
			$j(this).addClass("play");	
		}
		return false;
	}
	);

	$j("#btn_back").click(function(){
		if($j("#video_player").hasClass("nothere")){
		}
		else {			
			$j("div.intro").show();
			$j("div.authorName").show();
			$j("div.authorTitle").show();
			$j("img.authorImage").show();
			callToActionScript("play");
			$j("#video_player").addClass("nothere");
			$j("#btn_transcript").hide();
			$j("#btn_back").hide();
			$j("#btn_play").removeClass("pause").addClass("play");
		}
		return false;
	}
	);
	


	//flash embedding code for welcome area
	if($j("#welcome_area").length > 0) {
		var flashvars = {
			stage_width: "750",
			stage_height: "246",
			countrycode: sessionRegion,
			roleid: sessionRole,
			languagecode: sessionLang,
			fontpath: "/flash/welcome_fonts.swf",
			csspath: "/flash/welcome.css",
			xmlspotlightpath: dctFlashParams["welcome.spotlight.xmlpath"],
			cssspotlightpath: dctFlashParams["welcome.spotlight.csspath"],
			fontspotlightpath: dctFlashParams["welcome.spotlight.fontpath"]
		};
		var params = {
			allowNetworking: "all",
			allowScriptAccess: "always",
			menu: "false",
			wmode: "transparent"
		};
		var attributes = {
			name: "welcome"
		};
		swfobject.embedSWF("/flash/welcome.swf", "welcome", "944", "246", "9.0.0","/flash/expressInstall.swf", flashvars, params, attributes);
	}

	//flash embedding code for service page welcome area
	if($j("#prdsrv_welcome").length > 0) {
		
		var flashvars = {
			stage_width: "662",
			stage_height: "246",
			countrycode: sessionRegion,
			roleid: sessionRole,
			languagecode: sessionLang,
			fontpath: "/flash/welcome_fonts.swf",
			csspath: "/flash/welcome.css",
			xmlspotlightpath: dctFlashParams["welcome.spotlight.xmlpath"],
			cssspotlightpath: dctFlashParams["welcome.spotlight.csspath"],
			fontspotlightpath: dctFlashParams["welcome.spotlight.fontpath"]
		};
		var params = {
			allowNetworking: "all",
			allowScriptAccess: "always",
			menu: "false",
			wmode: "transparent"
		};
		var attributes = {
			name: "welcome"
		};
		swfobject.embedSWF("/flash/welcome.swf", "welcome", "662", "246", "9.0.0","/flash/expressInstall.swf", flashvars, params, attributes);
	}


	//flash embedding code for product area
	if($j("#product_area").length > 0) {
		var flashvars = {
			stage_width: "944",
			stage_height: "300",
			countrycode: sessionRegion,
			roleid: sessionRole,
			languagecode: sessionLang,
			xmlpath: "/webapp/ProductServlet?",
			xmlpaths: dctFlashParams["product.xmlpaths"],
			fontpath: "/flash/product_fonts.swf",
			csspath: "/flash/product.css"
		};
		var params = {
			allowNetworking: "all",
			allowScriptAccess: "always",
			menu: "false",
			wmode: "transparent"
		};
		var attributes = {name: "product"};
		swfobject.embedSWF("/flash/product.swf", "product", "944", "300", "9.0.0","/flash/expressInstall.swf", flashvars, params, attributes);
	}

	//img cycler GLP
	if($j("#spotlight_area").length > 0) {
		$j.ajax({
 			url: "/xml/glp_spotlight.xml" ,
			dataType: "xml",
			error: function() {},
 			success: function(xml) {
				write_promos(xml);
			}
		});
		$j.ajax({
 			url: "/xml/glp_profile_selector.xml" ,
			dataType: "xml",
			error: function() {},
 			success: function(xml) {
				write_profiler(xml, 'spotlight_area');
			}
		});
	}



	if($j("#change_profile").length > 0 && $j("#spotlight_area").length <= 0) {
		$j.ajax({
 			url: "/xml/glp_profile_selector.xml" ,
			dataType: "xml",
			error: function() {
			},
 			success: function(xml) {
				write_profiler(xml, 'change_profile');
			}
		});
	}

	//flash embedding code for global locations
	if($j("#global_locations").length > 0) {
		var flashvars = {
			theList: "/xml/global_locations.xml"
		};
		var params = {
			 menu: "false",
			 wmode: "transparent"
		};
		var attributes = {
			name: "global_locations"
		};
		swfobject.embedSWF("/flash/global_locations.swf", "global_locations", "585", "600", "9.0.0","/flash/expressInstall.swf", flashvars, params, attributes);
	}

	$j("#product_promo div div.lead a").click(function(){
			var urlstring = $j(this).attr("href");
			urlstring = urlstring.substring(25, urlstring.length -2);
			var flashvars = {
				videofile: "?videofile=VID" + urlstring,
				domain: "http://"+current_host,
				servletpath: "/webapp/VideoInfoServlet",
				countrycode: sessionRegion,
				languagecode: sessionLang,
				csspath: "/flash/video_player.css"
			};
			var params = {allowNetworking: "all", allowScriptAccess: "always", menu: "false", wmode: "transparent"};
			var attributes = {name: "SSgA_Video"};
			swfobject.embedSWF("/flash/videoplayer.swf", "SSgA_Video", "710", "400", "9.0.0","/flash/expressInstall.swf", flashvars, params, attributes);
			overlay_on();
			$j("#video").fadeIn("fast");
			return false;
		}
	);


	$j("#GLP_loginForm .loginForm_enter").click(function(){                       
			validate_login("GLP_loginForm");
		}
	);

	$j("#loginForm .loginForm_enter").click(function(){
			validate_login("loginForm");
		}
	);

	$j("#loginForm input").keypress(function(event){
			if(event.which == '13') {
				validate_login("loginForm");
			}
		}
	);

	$j("#GLP_loginForm input").keypress(function(event){
			if(event.which == '13') {
				validate_login("GLP_loginForm");
			}
		}
	);


	$j("a.login_BIAM").click(function(){
			window.open("http://www.biam.ie/cl.htm");
		}
	);

	
	$j("#clientlogin .passwordForm_link").click(function(){
			reset_form("passwordReset");
			overlay_on();
			$j("#passwordReset").fadeIn("fast");
			return false;
		}
	);
	

	$j("#GLP_loginForm .passwordForm_link").click(function(){
			$j("html, body").animate({scrollTop:0},"fast");
			overlay_on();
			$j("#passwordReset").fadeIn("fast");
			return false;
		}
	);

	$j(".login form input[name=USER]").focus(function(){
			if($j(this).attr("value") == "User ID:") {
				$j(this).attr("value", "");
			}
			$j(this).removeClass("error");
		}
	);

	$j(".login form input[name=PASSWORD]").focus(function(){
			if($j(this).attr("value") == "Password:") {
				$j(this).attr("value", "");
			}
			$j(this).removeClass("error");
		}
	);




	$j("form#passwordResetForm input[name=email]").focus(function(){
			$j(this).removeClass("error");
			$j("form#passwordResetForm div.error_box").hide().html("");
		}
	);

	$j("#passwordResetForm input").keypress(function(event){
			if(event.which == '13') {
				validate_passwordReset("passwordResetForm");
				return false;
			}
		}
	);

	$j("#passwordResetForm .passwordForm_submit").click(function(){
			validate_passwordReset("passwordResetForm");
			return false;
		}
	);


	$j("#profile a.change").click(function(){
			overlay_on();
			$j("#change").fadeIn("fast");
			return false;
		}
	);

	$j(".overlay_content div.close_overlay a").click(function(){
			if($j("#video").length > 0) {
				$j("#video div.white div.video_frame").html(video_reset);
			}
			over_off();
			return false;
		}
	);


	$j("a.cancel_overlay").click(function(){
			if($j("#video").length > 0) {
				$j("#video div.white div.video_frame").html(video_reset);
			}
			over_off();
			return false;
		}
	);

	if($j("#oig_facts").length > 0) {
		pictures = $j("#oig_facts span.active");
		inter = window.setInterval("recycler()", 7000);
	}
	
	$j("#oig_links a").click(function(){
			if($j(this).hasClass("contact_link")) {}
			else { showOverlay($j(this).attr("class"));}
			return false;
		}
	); 


	$j("#product_results table td a").click(function(){
			var detailURL = $j(this).attr("href");
    			if($j(this).hasClass("product_static_link")) {
				window.open(detailURL);
			}
			else if ($j(this).parent().hasClass("product_last") || detailURL.indexOf('.csv') > 0) {}
			else {
				$j("html, body").animate({scrollTop:0},"fast");
				
				var detailLoad = $j.ajax({type:"POST", url:detailURL, dataType:"html", async: false}).responseText;
				$j("#product_detail #detail_content").html(detailLoad);
				overlay_on();
				$j("#product_detail").fadeIn("fast");
				return false;
			}
		}
	);


	$j("a.contact_link").click(function(){
			over_off();
			reset_form("contact");
			if($j(this).hasClass("contact_overwrite")) {
				$j("#contact_profile").hide();				
				contact_code_overwrite = $j(this).attr("title");
			}
			else if(countryAccess == "OIG") {
				$j("#contact_profile").hide();				
				contact_code_overwrite = "GLMK";					
			}
			else {
				if(sessionRegion && sessionRole) {}
				else {$j("#contact_profile").show();}
				contact_code_overwrite = null;
			}			
			overlay_on();
			$j("#contact").fadeIn("fast");
			
			var name = $j(this).attr("name");
			switch(name) {
				case "header_contact_link":
					sendDCPageLink("DC Home", "Contact us from the header");
					break;
				case "sell_it_contact_link":
					sendDCPageLink("Promo Landing", "Contact us from Sell it");
					break;
				case "article_summary_contact_link":
					sendDCPageLink("Promo Landing", "Contact us from Article Summary");
					break;
				case "presentation_contact_link":
					sendDCPageLink("Participant Communication Presentation", "Contact us from Presentation");
					break;
			}
			
			return false;
		}
	);

	$j("a.savemore").click(function(){
			savemore = true;
	
		}
	);

	$j("#dc_carousel a.btn_form").click(function(){
		$j("#dc_carousel").fadeOut("fast");	
	
		}
	);

	$j("a#contact_submit").click(function(){
		if(preUser == "8" && sessionRegion == "US") {
			validate_DCcontact();
		}
		else {
			validate_contact();
		}
			return false;
		}
	);

	$j("a.register_link").click(function(){
			$j("html, body").animate({scrollTop:0},"fast");
			reset_form("register");
			overlay_on();
			$j("#register").fadeIn("fast");
			return false;
		}
	);

	$j("a#register_submit").click(function(){
			validate_register();
			return false;
		}
	);

	$j("a.bio_link").click(function(){
			overlay_on();
			$j("#biography").fadeIn("fast");
			return false;
		}
	);

	$j("#dc_why a").click(function(){
			overlay_on();
			$j("#dc_matters").fadeIn("fast");
			sendDCPageLink("DC Home", "View more from Why Retirement Matters");
			return false;
		}
	);

	$j("a.dc_presentation").click(function(){
			overlay_on();
			$j("#dc_carousel").fadeIn("fast");
			
			var name = $j(this).attr("name");
			switch(name) {
				case "view_presentation_from_yourplan":
					sendDCPageLink("DC Home", "View Participant Communications Presentation from Your Plan");
					break;
				case "view_presentation_from_approach":
					sendDCPageLink("DC Home", "View presentation from Our Unique Approach");
					break;
			}
			
			return false;
		}
	);


	$j("a.team_toggle").click(function(){
			if($j(this).hasClass("closed")) {
				$j(this).next().slideDown();				
				$j(this).removeClass("closed").addClass("open");
			}
			else {
				$j(this).next().slideUp();
				$j(this).removeClass("open").addClass("closed");

			}
			return false;
		}
	);

	$j("a.bio_close").click(function(){
			$j(this).parent().hide();
			$j(this).parent().parent().children(".bio_links").fadeIn();
			return false;
		}
	);

	$j("div.bio_link a").click(function(){
		var the_person = $j(this).parent().children("span.person").html();
		var forTeam = $j(this).parent().parent().parent().parent().attr("id");
		if(multiPermMap[countryAccess] == "Y") {
			$j("div.bio_holder div p span.person").each(function(){
				if($j(this).html() == the_person) {
					$j(this).parent().parent().parent().parent().children(".bio_links").hide();
					$j(this).parent().parent().parent().fadeIn();
				}
			}
			);
		}
		else {	
			$j("#" + forTeam + " div.bio_holder div p span.person").each(function(){
				if($j(this).html() == the_person) {
					$j(this).parent().parent().parent().parent().children(".bio_links").hide();
					$j(this).parent().parent().parent().fadeIn();
				}
			}
			);
		}
		return false;
		}
	);	

	$j("#overlay_area").click(function(){
		if($j("#header .login").is(":visible")){
			click_off();
			$j("#header .login").slideUp();
			return false;
		}
		else {
			if($j("#video").length > 0) {
				$j("#video div.white div.video_frame").html(video_reset);
			}
			over_off();
		}
		}
	);

	$j("#header #nav_meta a.meta_login").click(function(){
		overlay_on();
		$j("#clientlogin").fadeIn("fast");
		return false;

		}

	);

	$j("#feature_leadership .article_links a").mouseover(function(){
		if($j(this).hasClass("reactive")){}
		else {
			$j("#feature_leadership .article_links a").removeClass("reactive");
			$j(this).addClass("reactive");	
		}

	}
	);



	if($j("#publications_area").length > 0) {
		$j("#publications_area div:nth-child(4)").css("clear", "left");
	}

	$j("a.filter_toggle").click(function(){
			if($j(this).hasClass("open")) {
				$j(this).next().slideUp();
				$j(this).removeClass("open");
			}
			else {
				$j(this).next().slideDown();
				$j(this).addClass("open");
			}
			return false;

		}
	)

	if($j("#result_list").length > 0) {

		$j("#result_list div.item").each(function(){
					var date_data = date_parser($j(this).children("div.date").html());
					$j(this).children("div.date").attr("alt", date_data);
			}
		);

	}

	$j("div#dc_tabs a").click(function(){

		if($j(this).hasClass("active")){

		}
		else {
			var whichOne = $j(this).attr("class");
			$j("div#dc_tabs a").removeClass("active");
			$j("#dc_sec div.section").removeClass("active");
			$j("#dc_sec div." + whichOne ).addClass("active");
			$j(this).addClass("active");
			sendDCPageLink("DC Home", $j(this).html());
		}
		return false;
		}
	);


	$j("div.subsect_nav a").click(function(){

		if($j(this).hasClass("active")){

		}
		else {
			var whichOne = $j(this).attr("class");
			$j(this).parent().parent().children("div.subsection").removeClass("active");
			$j(this).parent().children().removeClass("active");
			$j(this).parent().parent().children("div." + whichOne ).addClass("active");
			$j(this).addClass("active");
		}
		return false;
		}
	);




	$j("div#about_tabs a").click(function(){

		if($j(this).hasClass("active")){

		}
		else {
			var whichOne = $j(this).attr("class");
			$j("div#about_tabs a").removeClass("active");
			$j("#about_promos div").removeClass("active");
			$j("#about_sec div.section").removeClass("active");
			$j("#about_promos div." + whichOne ).addClass("active");
			$j("#about_sec div." + whichOne ).addClass("active");
			$j(this).addClass("active");
		}
		return false;
		}
	);	


	$j("div.section div.sec_left a").click(function(){

		if($j(this).hasClass("active") || $j(this).hasClass("ext_link")){
		}
		
		else {
			var wizzit = $j(this).attr("class");
			$j(this).parent().children().removeClass("active");
			$j(this).parent().parent().children("div.sec_right").children().removeClass("active");
			$j(this).parent().parent().children("div.sec_right").children("div." + wizzit).addClass("active");
			$j(this).addClass("active");
			return false;

		}
		}
		
	);

	$j("div.releases a").click(function(){
		var releaseURL = $j(this).attr("href");
		$j.ajax({
 			type: "POST",
			url: releaseURL,
 			dataType: "text",
 			data: releaseURL,
 			error: function() {
			},
 			success: function(data) {
				$j("div.releases").hide();
				$j("div.release_holder div").html(data).show();
				$j("div.release_holder").fadeIn();
			}
		});

		return false;
		}
		
	);


	$j("div.release_holder a.release_close").click(function(){
			$j("div.release_holder").hide();
			$j("div.release_holder div").html("");
			$j("div.releases").fadeIn();
			return false;
		}
		
	);

	$j("a.release_link").click(function(){
		var releaseURL = $j(this).attr("href");
		$j.ajax({
 			type: "POST",
			url: releaseURL,
 			dataType: "text",
 			data: releaseURL,
 			error: function() {
				$j("#press_release div.release_holder").html("error message");
			},
 			success: function(data) {
				$j("#press_release div.release_holder").html(data);		
			}
		});
			overlay_on();
			$j("#press_release").fadeIn("fast");
			return false;
		}	
	);

	$j("#dc_profile select").change(function() {
		var whatOne = $j("#dc_profile select option:selected").attr("value");
		if(whatOne == "Other") {
			$j("#dc_profile input").show();
		}
		else {
			$j("#dc_profile input").hide();
		}
	});
	
	$j('#dc_interest input:checkbox[value="Other"]').click(function() {
		if($j(this).is(":checked")) {
			$j("#dc_interest #interest_other").show();
		}
		else {
			$j("#dc_interest #interest_other").hide();
		}		

	});

	$j(".cam_portal a").click(function() {
		window.open("https://cam.ssga.com/");		

	});

	$j("#requestForm input").focus(function() {
		if($j(this).attr("value") == "Your email address") {
			$j(this).attr("value", "");
		}
	});

	$j("#requestForm textarea").focus(function() {
		if($j(this).html() == "Your message") {
			$j(this).html("");
		}
	});

	$j("#requestForm a.btn_form").click(function() {
		validate_request();
	});

	$j().mousemove(function(e){});

	tooltip();

	$j("form input#searchTermInput").keypress(function(event){
			if(event.which == '13') {
				appendSearchKeyToUrl();
				return false;
			}
		}
	);

});

