// HASHTABLE

/**
    This is a Javascript implementation of the Java Hashtable object.
   
    Contructor(s):
     Hashtable()
              Creates a new, empty hashtable
   
    Method(s):
     void clear()
              Clears this hashtable so that it contains no keys.
     boolean containsKey(String key)
              Tests if the specified object is a key in this hashtable.
     boolean containsValue(Object value)
              Returns true if this Hashtable maps one or more keys to this value.
     Object get(String key)
              Returns the value to which the specified key is mapped in this hashtable.
     boolean isEmpty()
              Tests if this hashtable maps no keys to values.
     Array keys()
              Returns an array of the keys in this hashtable.
     void put(String key, Object value)
              Maps the specified key to the specified value in this hashtable. A NullPointerException is thrown is the key or value is null.
     Object remove(String key)
              Removes the key (and its corresponding value) from this hashtable. Returns the value of the key that was removed
     int size()
              Returns the number of keys in this hashtable.
     String toString()
              Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space).
     Array values()
              Returns a array view of the values contained in this Hashtable.
           
*/
function Hashtable(){
    this.clear = hashtable_clear;
    this.containsKey = hashtable_containsKey;
    this.containsValue = hashtable_containsValue;
    this.get = hashtable_get;
    this.isEmpty = hashtable_isEmpty;
    this.keys = hashtable_keys;
    this.put = hashtable_put;
    this.remove = hashtable_remove;
    this.size = hashtable_size;
    this.toString = hashtable_toString;
    this.values = hashtable_values;
    this.hashtable = new Array();
}

/*=======Private methods for internal use only========*/

function hashtable_clear(){
    this.hashtable = new Array();
}

function hashtable_containsKey(key){
    var exists = false;
    for (var i in this.hashtable) {
        if (i == key && this.hashtable[i] != null) {
            exists = true;
            break;
        }
    }
    return exists;
}

function hashtable_containsValue(value){
    var contains = false;
    if (value != null) {
        for (var i in this.hashtable) {
            if (this.hashtable[i] == value) {
                contains = true;
                break;
            }
        }
    }
    return contains;
}

function hashtable_get(key){
    return this.hashtable[key];
}

function hashtable_isEmpty(){
    return (parseInt(this.size()) == 0) ? true : false;
}

function hashtable_keys(){
    var keys = new Array();
    for (var i in this.hashtable) {
        if (this.hashtable[i] != null)
            keys.push(i);
    }
    return keys;
}

function hashtable_put(key, value){
    if (key == null || value == null) {
        throw "NullPointerException {" + key + "},{" + value + "}";
    }else{
        this.hashtable[key] = value;
    }
}

function hashtable_remove(key){
    var rtn = this.hashtable[key];
    this.hashtable[key] = null;
    return rtn;
}

function hashtable_size(){
    var size = 0;
    for (var i in this.hashtable) {
        if (this.hashtable[i] != null)
            size ++;
    }
    return size;
}

function hashtable_toString(){
    var result = "";
    for (var i in this.hashtable)
    {     
        if (this.hashtable[i] != null)
            result += "{" + i + "},{" + this.hashtable[i] + "}\n";  
    }
    return result;
}

function hashtable_values(){
    var values = new Array();
    for (var i in this.hashtable) {
        if (this.hashtable[i] != null)
            values.push(this.hashtable[i]);
    }
    return values;
}

// Rob's Navigation Code

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
  else if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else {
	  return true;
  }
}

var maxNav = 5;
var currentNav = 0;
var hideTimer = null;
function hideNav() {
	clearTimeout(hideTimer);
	hideTimer = setTimeout("changeNav(0);",100);
}

function changeNav(innum) {
	if ( innum != 0 ) {
		clearTimeout(hideTimer);
	}
	currentNav = innum;
	globalDiv = document.getElementById("globalnav");
	newDiv = document.getElementById("globalnav"+innum);
	//globalDiv.innerHTML = newDiv.innerHTML;
}


// Old Link code

function openFooterWin(locale)
{
	var findaninvestmentcenter = "http://www.troweprice.com/common/indexPopUp/0,3017,lnp%253D10306%2526cg%253D1610%2526pgid%253D7899,00.html?src=iramicro_resource_center";
	var companyinformation = "http://www.troweprice.com/common/indexPopUp/0,0,pgid=7789,00.html?scn=header&src=iramicro_resource_center";
	var downloadprospectus = "http://www.troweprice.com/common/index3/0,6549,&pgid=7386,00.html?scn=footer&src=iramicro_resource_center"
    var privacypolicy = "http://www.troweprice.com/common/indexPopUp/0,,pgid=7856,00.html?scn=footer&src=iramicro_resource_center"
	var legalinformation = "http://www.troweprice.com/common/indexPopUp/0,,pgid=7884,00.html?scn=footer&src=iramicro_resource_center"
	var sitemap = "http://www.troweprice.com/common/indexPopUpHtml/0,0,htmlid=21,00.html?scn=footer&src=iramicro_resource_center"
	var search = "http://www3.troweprice.com/cda/public/search/search/0,,,00.html?scn=footer&src=iramicro_resource_center"
	var securitymeasures = "http://www.troweprice.com/common/indexPopUp/0,,pgid=8315,00.html?scn=footer&src=iramicro_resource_center"
	var customeragreement = "http://www.troweprice.com/common/indexPopUp/0,,pgid=8314,00.html?scn=footer&src=iramicro_resource_center"
	var customeragreementpvl = "/pvl/PortfolioValuation/PVAgreement.jsp?scn=footer&src=iramicro_resource_center"
	var siteHelp = "http://www.troweprice.com/common/indexPopUp/0,,pgid=7865,00.html?scn=footer&src=iramicro_resource_center"
	var contact = "http://www.troweprice.com/common/indexPopUp/0,,pgid=7878,00.html?scn=footer&src=iramicro_resource_center"
	var comments = "http://www.troweprice.com/common/indexPopUpHtml/0,0,htmlid=28,00.html?scn=footer&src=iramicro_resource_center"
	var contactfi = "https://www2.troweprice.com/cda/fi/indexPopUpFI/0,,pgid=7772,00.html?scn=footer&src=iramicro_resource_center"		
	var contactpvl = "https://www3.troweprice.com/cda/pvl/PVContactPopup/0,,,00.html?src=iramicro_resource_center"	
	var careers = "http://www.troweprice.com/Careers/careerWelcomeIndex/0,10994,contentid%253D700%2526pgid%253D9800,00.html?scn=footer&src=iramicro_resource_center"
	var sendfriend = "http://www.troweprice.com/common/sendFriendURL/0,,,00.html?scn=footer&src=iramicro_resource_center"
	var sendfriendEPP = "http://www3.troweprice.com/epp/epp/includes/common/sendFriendURL.jsp?scn=footer&src=iramicro_resource_center"
	//Brokerage TradeLink
	var contactTL = "https://www3.troweprice.com/cda/brokerage/contactUsTL?scn=TLfooter&src=iramicro_resource_center";
	var customeragreementTL = "https://www3.troweprice.com/cda/brokerage/customerAgreementTL?scn=TLfooter&src=iramicro_resource_center";
	var siteHelpTL = "https://www3.troweprice.com/cda/brokerage/siteHelpTL?scn=TLfooter&src=iramicro_resource_center";
	var securitymeasuresTL = "https://www3.troweprice.com/cda/brokerage/securityMeasuresTL?scn=TLfooter&src=iramicro_resource_center";

	var url;
	if (locale == 'privacypolicy')
	{
	    url = privacypolicy;
	}
	else if (locale == 'legalinformation')
	{
		url = legalinformation;
	}
	else if (locale == 'securitymeasures')
	{
		url = securitymeasures;
	}
	else if (locale == 'customeragreement')
	{
		url = customeragreement;
	}
	else if (locale == 'customeragreementpvl')
	{
		url = customeragreementpvl;
	}
	else if (locale == 'sitemap')
	{
		url = sitemap;
	}
	else if (locale == 'search')
	{
		url = search;
	} 
	else if (locale == 'siteHelp')
	{
		url = siteHelp;
	}
	else if (locale == 'contact')
	{
		url = contact;
	}
	else if (locale == 'comments')
	{
		url = comments;
	}
	else if (locale == 'contactfi')
	{
		url = contactfi;
	}
	else if (locale == 'contactpvl')
	{
		url = contactpvl;
	}
	else if (locale == 'careers')
	{
		url = careers;
	}
	else if (locale == 'sendfriend')
	{
		url = sendfriend;
	}
	
	//Brokerage TradeLink
	else if (locale == 'contactTL')
	{
		url = contactTL;
	}
	else if (locale == 'customeragreementTL')
	{
		url = customeragreementTL;
	}
	else if (locale == 'siteHelpTL')
	{
		url = siteHelpTL;
	}
	else if (locale == 'securitymeasuresTL')
	{
		url = securitymeasuresTL;
	}
	else if (locale == 'sendfriendEPP')
	{
		url = sendfriendEPP;
	}
	else if (locale == 'downloadprospectus')
	{
		url = downloadprospectus;
	}
	else if (locale == 'companyinformation')
	{
		url = companyinformation;
	}
	else if (locale == 'findinvestmentcenter')
	{
		url = findaninvestmentcenter;
	}
	else if (locale == 'findaninvestmentcenter')
	{
		url = findaninvestmentcenter;
	}
	else url = locale;
	
	if (locale == 'sendfriend')
	{
	//var sendWin = window.open(url,'sendWin','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,windowReference.focus,width=685,height=450'); 
	var sendWin = window.open(url,'sendWin'); 
	sendWin.focus();	
	
	}
	
	else
	{
	
	//var newWin = window.open(url,'pop','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,windowReference.focus,width=685,height=450'); 
	var newWin = window.open(url,'sendWin'); 
	newWin.focus();
	}

}

openWin = openFooterWin;

function getPDJunctionName()
{
	var junction = document.neededForPD.action;
		
	if (junction != null && junction.length <= 1)
	{
		return "";
	}
	return junction;
}

function openWindow(url)
{
	if (url.charAt(0) == '/')
	{
		url = getPDJunctionName() + url;
	}
	//var win = window.open(url, 'popup', 'resizable=yes,scrollbars=yes,width=798,height=568');
	var win = window.open(url, 'popup');
	win.focus();
}

function openEppWindow(hostName, module, section)
{
	eppHostName = hostName;
	var url = "http://" + eppHostName + "/epp/epp/" + module + "/index.do?rfpgid=10875&scn=" + section;
	var name = "epp2";
	//var features = "scrollbars=yes,width=790,height=510";
	//eppWindowOpener = window.open(url, name, features);
	eppWindowOpener = window.open(url, name);
	eppWindowOpener.focus();
}

var bStr;
var pStr;
var mStr;
var sStr = window.location.search;
if (sStr.length != 0) {
	sStr = sStr.slice(1, sStr.length);
	var kvPairs = sStr.split("&");
	for (i = 0; i <= kvPairs.length - 1; i++) {
		var keyValues = kvPairs[i].split("=");
		if (keyValues[0] == "phone" && keyValues[1] == "") {
			bStr = "6066";
		}
		else if ( keyValues[0] == "phone" ) {
			bStr = keyValues[1];
		}
		else if (keyValues[0] == "movie") {
			mStr = keyValues[1];
		}
	}
} else {
	bStr = "6066";
	mStr = "";
}

var phoneHash = new Hashtable();

// begin numbers added 12-19-05 for ira site
phoneHash.put("1506","1-800-541-1506");
phoneHash.put("7558","1-800-250-7558");
phoneHash.put("6310","1-800-705-6310");
phoneHash.put("6364","1-800-705-6364");
phoneHash.put("6885","1-800-207-6885");
phoneHash.put("7155","1-800-469-7155");
phoneHash.put("7157","1-800-469-7157");
phoneHash.put("7162","1-800-207-7162");
phoneHash.put("7816","1-800-207-7816");
phoneHash.put("8189","1-800-207-8189");
phoneHash.put("8615","1-800-207-8615");
phoneHash.put("3193","1-800-421-3193");
phoneHash.put("3194","1-800-421-3194");
phoneHash.put("9784","1-800-599-9784");
phoneHash.put("9195","1-800-599-9195");
phoneHash.put("9781","1-800-577-9781");
phoneHash.put("2236","1-800-597-2236");
// end numbers added 12-19-05

phoneHash.put("9184","1-800-599-9184");
phoneHash.put("1215","1-800-341-1215");
phoneHash.put("3509","1-866-893-3509");
// end numbers added 1-17-06

phoneHash.put("1303","1-800-395-1303");
phoneHash.put("3310","1-800-791-3310");
phoneHash.put("4990","1-800-750-4990");
// end numbers added 2-27-06

phoneHash.put("9136","1-800-250-9136");
phoneHash.put("4283","1-800-267-4283");
// end numbers added 3-13-06

phoneHash.put("6730","1-800-207-6730");
phoneHash.put("5271","1-800-613-5271");
phoneHash.put("4067","1-800-421-4067");
phoneHash.put("2247","1-888-790-2247");
phoneHash.put("2242","1-888-790-2242");
phoneHash.put("3504","1-800-421-3504");
phoneHash.put("4360","1-800-421-4360");
phoneHash.put("8104","1-800-365-8104");
phoneHash.put("5611","1-800-566-5611");
phoneHash.put("5711","1-800-566-5711");
phoneHash.put("4154","1-800-421-4154");
phoneHash.put("8131","1-800-365-8131");
// end numbers added 03-31-06

phoneHash.put("9031","1-800-599-9031");
phoneHash.put("8481","1-800-599-8481");
phoneHash.put("3508","1-800-469-3508");
phoneHash.put("2617","1-800-469-2617");
phoneHash.put("4541","1-800-421-4541");
// end numbers added 04-07-06"

phoneHash.put("6287","1-800-705-6287");
// end numbers added 04-13-06


phoneHash.put("0062","1-800-408-0062");
phoneHash.put("0915","1-800-409-0915");
phoneHash.put("0944","1-800-409-0944");
phoneHash.put("0278","1-800-414-0278");
phoneHash.put("7208","1-800-414-7208");
phoneHash.put("9802","1-800-414-9802");
// end numbers added 06-20-06
//NOTE:  the 1 phone code that is in double quotes is so because it is a valid octal number and is not a string


phoneHash.put("3701","1-800-416-3701");
phoneHash.put("5713","1-800-416-5713");
// end numbers added 06-23-06


phoneHash.put("3717","1-800-416-3717");
// end number added 06-28-06

//added 9-28-2006
phoneHash.put("7558","(800)250-7558");
phoneHash.put("3712","(866)831-3712");
phoneHash.put("1893","(866)521-1893");
phoneHash.put("5711","(800)566-5711");
phoneHash.put("8206","(800)365-8206");
phoneHash.put("4283","(800)267-4283");
phoneHash.put("2252","(888)790-2252");
phoneHash.put("5155","(877)218-5155");
phoneHash.put("2241","(888)790-2241");
phoneHash.put("5271","(800)613-5271");
phoneHash.put("1309","(800)366-1309");
phoneHash.put("3194","(800)421-3194");
phoneHash.put("6885","(800)207-6885");
phoneHash.put("3509","(866)893-3509");
phoneHash.put("8039","(877)235-8039");
phoneHash.put("3310","(800)791-3310");
phoneHash.put("9717","(800)207-9717");
phoneHash.put("4154","(800)421-4154");

phoneHash.put("5593","(800)341-5593");
phoneHash.put("7657","(800)365-7657");
phoneHash.put("9916","(800)207-9916");
phoneHash.put("4406","(800)820-4406");

phoneHash.put("1506","(800)541-1506");
phoneHash.put("3699","(866)831-3699");
phoneHash.put("4270","(800)378-4270");
phoneHash.put("5611","(800)566-5611");
phoneHash.put("8131","(800)365-8131");
phoneHash.put("9136","(800)250-9136");
phoneHash.put("2247","(888)790-2247");
phoneHash.put("5350","(800)541-5350");
phoneHash.put("2239","(888)790-2239");
phoneHash.put("2236","(800)597-2236");
phoneHash.put("0198","(800)366-0198");
phoneHash.put("6730","(800)207-6730");
phoneHash.put("6066","(800)541-6066");

// Added 12-29-2006
// Also added Hashtable code for easier addition of phone numbers
phoneHash.put("9514","(800)416-9514");
phoneHash.put("9096","(800)417-9096");
phoneHash.put("9456","(800)417-9456");
phoneHash.put("0713","(800)583-0713");
phoneHash.put("3342","(800)671-3342");
phoneHash.put("3385","(800)671-3385");
phoneHash.put("3403","(800)671-3403");
phoneHash.put("3406","(800)671-3406");
phoneHash.put("4059","(800)725-4059");
phoneHash.put("4075","(800)725-4075");
phoneHash.put("4078","(800)725-4078");
phoneHash.put("4086","(800)725-4086");
phoneHash.put("6013","(800)736-6013");
phoneHash.put("9368","(800)416-9368");
phoneHash.put("6407","(800)417-6407");
phoneHash.put("9413","(800)417-9413");
phoneHash.put("9610","(800)417-9610");
phoneHash.put("3341","(800)671-3341");
phoneHash.put("3372","(800)671-3372");
phoneHash.put("3402","(800)671-3402");
phoneHash.put("3405","(800)671-3405");
phoneHash.put("4058","(800)725-4058");
phoneHash.put("4068","(800)725-4068");
phoneHash.put("4077","(800)725-4077");
phoneHash.put("4082","(800)725-4082");
phoneHash.put("4089","(800)725-4089");

// Added 01-19-2007
phoneHash.put("6150","(800)736-6150");

if ( phoneHash.containsKey(bStr) ) {
	pStr = phoneHash.get(bStr);
}

if (pStr == null)
{
	pStr = "(800)541-6066";
}
