/*var page = window.location.href;
var imgdir;
var sitedir;
if ( /skynet/.test(page) ) {
	page = page.substring(51);
	if( /\//.test(page) ) {
		imgdir = '../images/';
		sitedir = '../';
	}
	else {
		imgdir = 'images/';
		sitedir = './';
	}
}
else {
	if ( /^https:\/\/www\./.test(page) ) {
		page = page.substring(20);
		if( /\//.test(page) ) {
			imgdir = '../images/';
			sitedir = '../';
		}
		else {
			imgdir = 'images/';
			sitedir = './';
		}
	}
	else if ( /^http:\/\/www\./.test(page) ) {
		page = page.substring(19);
		if( /\//.test(page) ) {
			imgdir = '../images/';
			sitedir = '../';
		}
		else {
			imgdir = 'images/';
			sitedir = './';
		}
	}
	else if ( /^http:\/\//.test(page) ) {
		page = page.substring(15);
		if( /\//.test(page) ) {
			imgdir = '../images/';
			sitedir = '../';
		}
		else {
			imgdir = 'images/';
			sitedir = './';
		}
	}
}*/
	

function third_party(url)
{
	var popup = "third_party_popup.html?location=" + url;
	var swidth = ( ((parseInt(screen.width) / 2)) - 190)
	var sheight = (((parseInt(screen.height) / 2)) - 165)
	window.open(popup, '', "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=380,height=330,top=" + sheight + ",left=" + swidth );
}

function mapWindow(url)
{
	
	window.open(url, '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=480,height=460');
}

function galleryWindow(url)
{
	
	window.open(url, '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=640,height=800');
}

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 = ['consulting_practice', 'software_solutions', 'professionals', 'seminars_publications', 'corporate_equality'];
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
window.onload = 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); };
			}
		}
	}
}


// global footer
function makeFooter() {
	var content = "";

	content += '<div id="footer_nav"><img src="images/footer.gif" border="0" usemap="#footer_map" alt="" />';
	content += '<map name="footer_map" id="footer_map">';
	content += '<area shape="rect" coords="452,6,520,16" href="mailto:aic@ffbh.com" alt="aic@ffbh.com" />';
	content += '</map></div></div></div>';
	content += '<div id="footer">';
	content += '<div id="footer_shadow"></div>';
	content += '<div id="footer_end" align="center">';
	content += '<table width="100%">';
	content += '<tr>';
	content += '<td align="center" colspan="2">';
	content += '<a href="index.html">Home</a> | <a href="current_rates.html">Current Rates</a> | ';
	content += '<a href="personal.html">Personal Banking</a> | <a href="business.html">Business Banking</a> | ';
	content += '<a href="loan.html">Loan Center</a> | ';
	content += '<a href="investment_services.html">Investment Services</a> | ';
	content += '<a href="investor.html">Investor Relations</a> <br />';
	//begin second line of links
	content += '<a href="contact_locations.html">Locations</a> | <a href="contact.html">Contact Us</a> | ';
	content += '<a href="about.html">About Us</a> | <a href="about_pressroom.html">Pressroom</a> | ';
	content += '<a href="privacy.html">Privacy Policy</a> | <a href="security.html">Security</a> | ';
	content += '<a href="help.html">Help</a> | <a href="sitemap.html">Site Map</a>';
	content += '</td>';
	content += '</tr>';
	content += '<tr>';
	content += '<td colspan="2">&nbsp;</td>';
	content += '</tr>';
	content += '<tr>';
	content += '<td align="left">';
	content += '<br />';
	content += 'Copyright &copy; 2010 First Federal Bank.  All Rights Reserved';
	content += '<br /></td>';
	content += '<td align="right">';
	content += '<a href="javascript:third_party(\'http://www.facebook.com/firstfederalbank\');"><img src="images/facebook-f.jpg" alt="Facebook" style="border-right: 1px solid black; padding-right: 4px;" /></a>&nbsp;';
	content += '<a href="javascript:third_party(\'http://www.nasdaq.com/scripts/redir.asp?symbol=FFBH&amp;page=quotes\');"><img src="images/NASDAQ.gif" alt="NASDAQ" /></a>&nbsp;';
	content += '<a href="javascript:third_party(\'http://www.checksconnect.com/\');"><img src="images/ReorderChecks.gif" alt="Reorder Checks" /></a>&nbsp;';
	content += '<img src="images/EHL_FDIC.gif" border="0" usemap="#EHL_FDIC" alt="" />';
	content += '<map name="EHL_FDIC" id="EHL_FDIC">';
	content += '<area shape="rect" coords="0,0,25,29" href="javascript:third_party(\'http://www.hud.gov/offices/fheo/index.cfm\');" alt="Equal Housing Lender" />';
	content += '<area shape="rect" coords="35,0,90,29" href="javascript:third_party(\'http://www.fdic.gov/\');" alt="FDIC" />';
	content += '</map>';
	content += '</td>';
	content += '</tr>';
	content += '</table>';
	content += '</div>';
	content += '</div><!-- end footer -->';

	document.write(content);
}
