var securepage;

function clear() {
return true;
}

function Helper (debug)
{
	this.debug = false;
	if (debug && debug == true)
	{
		this.dw = document.getElementById('debug');
		this.dh = document.getElementById('debug_hover');
		if (this.dw != null && this.dh != null)
		{
			this.dh.style.display = 'block';
			this.dh.onmouseover = function () { var h_temp = new Helper(); h_temp.hideObject('debug_hover'); h_temp.showObject('debug'); }
			this.dw.onmouseout = function () { var h_temp = new Helper(); h_temp.hideObject('debug'); h_temp.showObject('debug_hover'); }
			this.debug = true;
		}
	}
}

Helper.prototype.getObject = function (o)
{
	var obj = o;

	if (typeof o == "string")
	{
		obj = document.getElementById(o);
	}

	
	return obj;
	
	
}

Helper.prototype.showObject = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o && o.style)
	{
		o.style.display = '';
	}
}

Helper.prototype.hideObject = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o && o.style)
	{
		o.style.display = 'none';
	}
}

Helper.prototype.selectObject = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o && o.className != null)
	{
		o.className += " selected";
	}
}

Helper.prototype.deselectObject = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o && o.className != null)
	{
		o.className = o.className.replace(/selected/g, '');
	}
}

Helper.prototype.objectSelected = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o.className && o.className.indexOf('selected') >= 0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

Helper.prototype.swapOption = function (oid)
{
	if (this.objectSelected(oid))
	{
		this.deselectObject(oid);
		this.hideObject(oid + "_content");
	}
	else
	{
		this.selectObject(oid);
		this.showObject(oid + "_content");
	}
}

Helper.prototype.drawOption = function (oid)
{
	this.deselectAllSiblings(oid);
	this.selectObject(oid);
	this.showObject(oid + "_content");

  // hack
  this.setNextTo(oid);
}

Helper.prototype.clearOption = function (oid)
{
	this.deselectObject(oid);
	this.hideObject(oid + "_content");

  // hack
  this.unsetNextTo(oid);
}

Helper.prototype.sections = ['personal_finance', 'commercial_banking', 'online_services', 'hours_locations', 'about_twsb'];
Helper.prototype.setNextTo = function (oid)
{
	if (typeof oid != "string")
	{
    if (oid.id) { oid = oid.id; }
    else { oid = ''; }
	}

  for (var i = 0; i < this.sections.length; i++)
  {
    if (i + 1 == this.sections.length) { break; }
    else if (this.sections[i] == oid)
    {
      var o = this.getObject(this.sections[i + 1]);
      if (o && o.className != null)
      {
        o.className += " next_to";
      }
    }
  }
}

Helper.prototype.unsetNextTo = function (oid)
{
	if (typeof oid != "string")
	{
    if (oid.id) { oid = oid.id; }
    else { oid = ''; }
	}

  for (var i = 0; i < this.sections.length; i++)
  {
    if (i + 1 == this.sections.length) { break; }
    else if (this.sections[i] == oid)
    {
      var o = this.getObject(this.sections[i + 1]);
      if (o && o.className != null)
      {
        o.className = o.className.replace(/next_to/g, '');
      }
    }
  }
}

Helper.prototype.trace = function (msg)
{
	if (this.debug)
	{
		this.dw.innerHTML += "<div class=\"debug_message\">" + msg + "</div>\n";
	}
}

Helper.prototype.deselectAllSiblings = function (oid)
{
	var o = this.getObject(oid);
	var siblings = o.parentNode.childNodes; 
	for (var i = 0; i < siblings.length; i++)
	{
		var s = siblings[i];
		this.deselectObject(s);
	}
}

Helper.prototype.getElementsByStyleClass = function (className)
{
	var all = document.all ? document.all : document.getElementsByTagName('*');
	var elements = [];
	for (var i = 0; i < all.length; i++)
	{
		var tagClass = all[i].className;
		var index = tagClass.indexOf(className, 0);
		if (index != -1)
		{
			if (index > 0)  // className isn't the first part of the string
			{
				if (tagClass.charAt(index - 1) == ' ')
				{
					elements.push(all[i]);
				}
			}
			else if (tagClass.length > className.length)  // there's more to the string
			{
				if (tagClass.charAt(className.length) == ' ')
				{
					elements.push(all[i]);
				}
			}
			else  // exact match
			{
				elements.push(all[i]);
			}
		}
	}

	return elements;
}

var h;

// cleans up some of the HTML by automating the onmouseover and onmouseout events for the main menu
var loadHelper = function ()
{
	h = new Helper(true);

	// set up event handling on all sub navigational options
	var sub_navs = h.getElementsByStyleClass('sub_nav');
	for (var i = 0; i < sub_navs.length; i++)
	{
		var sub_nav_options = sub_navs[i].childNodes;

		for (var j = 0; j < sub_nav_options.length; j++)
		{
			var sub_nav_option = sub_nav_options[j];

			if (sub_nav_option.className != "separator")
			{
				sub_nav_option.onmouseover = function () { h.deselectAllSiblings(this); h.selectObject(this); };
				sub_nav_option.onmouseout = function () { h.deselectObject(this); };
			}
		}
	}
	
	if(securepage) {clear();if (!bPasswordFocus) dofocus();}
	
}

window.onload = loadHelper;

// CALL TO CORRECT DIRECTORY BELOW
var imgdir = "../images/";
var sitedir = "";
var securedir = "";
var homedir = "../";
if(window.homepage)
{
imgdir="images/";
sitedir="site/";
securedir="site/";
homedir="";
}
else if(window.absolutepage)
{
imgdir="http://www.twsb.com/images/"
sitedir="http://www.twsb.com/site/"
securedir="http://www.twsb.com/site/"
homedir="http://www.twsb.com/"
}
else if(window.securepage)
{
imgdir="https://www.twsb.com/images/"
sitedir="http://www.twsb.com/site/"
securedir="https://www.twsb.com/site/"
homedir="http://www.twsb.com/"
}


function showWarning(url){
var content = new Array();
var index = 0;
content[index++] = "<div align='center'><h3 style='margin-top: 2px;'>Third Party Site Disclaimer</h3>By accessing the noted link you will be leaving Washington Savings Bank's website and entering a website hosted by another party. Washington Savings Bank has not approved this as a reliable partner site.  Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of Washington Savings Bank's website. We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Washington Savings Bank's.";
content[index++] = "<br /><br /><br />";
content[index++] = "<div align=\"center\"><a href='javascript:window.location=\""+url+"\";'>Continue</a>&nbsp;&nbsp;&nbsp;<a href=\"javascript:void('0');\" onclick=\"document.getElementById('ex_dis').style.display = 'none'\">Decline</a></div></div>";	
document.getElementById("ex_dis").innerHTML = content.join("");
document.getElementById("ex_dis").style.display = "block";
scrollTo(0, 0);
}

function showMail(url){
var content = new Array();
var index = 0;
content[index++] = "<div align='center'><h3 align='center'>Please Note</h3>This is <strong>NOT</strong> secure e-mail, do not send personal/financial information. ";
content[index++] = "<br /><br />";
content[index++] = "<div align=\"center\"><a href='"+url+"' onclick=\"document.getElementById('ex_dis').style.display = 'none'\">Continue</a>&nbsp;&nbsp;&nbsp;<a href=\"javascript:void('0');\" onclick=\"document.getElementById('ex_dis').style.display = 'none'\">Decline</a></div></div>";	
document.getElementById("ex_dis").innerHTML = content.join("");
document.getElementById("ex_dis").style.display = "block";
scrollTo(0, 0);
}

function kidsPage() {
window.open( "http://www.twsb.com/kids/ocean/index.html", "kidsPage", 
"status = 1, height = 510, width = 765, resizable = 0" )
}


function rcpDemo() {
window.open( "http://www.twsb.com/cb_rdemo.html", "rcpDemo", 
"status = 1, height = 510, width = 765, resizable = 1" )
}

document.write('<div id="ex_dis" style="background-color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; color: #000000; text-align: left; position:absolute; top:125px; left:300px; border: medium solid #1C3751; padding: 15px; display: none; z-index: 3000; width:350px;"></div>');
// OTHER FUNCTIONS ABOVE
