var crText = "<p>Elan Visa Credit Cards, information, and account access are provided through a third party business partner, Elan Financial Services (Elan). The link you have selected will bring you to Elan's third-party website. The privacy practices of Elan's websites are not covered by Bangor Savings Bank's Privacy Policy and Bangor Savings Bank is not responsible for the privacy practices, data collection, security, content, or accuracy of Elan's websites. You should review carefully Elan's privacy policy on their website prior to using it.</p>";
var ptText = "<p>The link you have selected will bring you to a third-party website. The privacy practices of linked third-party websites are not covered by Bangor Savings Bank's Privacy Policy and Bangor Savings Bank is not responsible for the privacy practices, data collection, security, content, or accuracy of other websites. You should review carefully any privacy policies posted on linked sites prior to using them.</p>";
var otText = "<p>The link you have selected will bring you to a third-party website. The privacy practices of linked third-party websites are not covered by Bangor Savings Bank's Privacy Policy and Bangor Savings Bank is not responsible for the privacy practices, data collection, security, content, or accuracy of other websites. You should review carefully any privacy policies posted on linked sites prior to using them. Bangor Savings Bank does not endorse or make any representations about the companies, products, or materials found in these websites.</p>"; 
var rpText = "<p>This link will bring you to Trusteer's website where you can download Rapport, view installation instructions and system requirements, access 24-hour support, and read more about what Rapport does to protect you.</p><p>Please note, the privacy practices of linked third-party websites are not covered by Bangor Savings Bank's Privacy Policy and Bangor Savings Bank is not responsible for the privacy practices, data collection, security, content, or accuracy of other websites. You should review carefully any privacy policies posted on linked sites prior to using them.</p>"; 
var curURl;
function initShowHide()
{
	var _box = document.getElementById("login");
	if (_box)
	{
		_links = _box.getElementsByTagName("a");
		for (i=0; i<_links.length; i++)
		{
			if (_links[i].className.indexOf("lnk-control") != -1)
			{
				_links[i].onclick = function()
				{
					if (this.parentNode.className.indexOf("closed") != -1)
					{
						this.parentNode.className = this.parentNode.className.replace("closed", "")
					}
					else
					{
						this.parentNode.className += " closed";
					}
					return false;
				}
			}
		}
	}
}
function Departure(theURL, type) { 
	if (type == "credit"){
		$("#departure_text").html(crText);
		}
	else if (type == "partner"){
		$("#departure_text").html(ptText);
		}
	else if (type == "trusteer"){
		$("#departure_text").html(rpText);
		}
	else
	{
		$("#departure_text").html(otText); 
		}
	curURl = theURL;
	$("#departure_dialog").dialog('open');
	$("#departure_dialog").dialog('option','title','Leaving Bangor.com');

	}

function PopEmail(theURL) { 


$("#email_notice").dialog('open');
$("#email_notice").dialog('option','title','You are about to send us email.<span style="display:none;" id="hspan" rel="'+ theURL + '"></span>');

}
function initClear()
{
	_inp = document.getElementsByTagName("input");
	_txt = document.getElementsByTagName("textarea");
	for (i=0; i<_inp.length; i++)
	{
		if (_inp[i].type == "text")
		{
			_inp[i]._default = _inp[i].value;
			_inp[i].onfocus = function()
			{
				if (this.value == this._default)
				{
					this.value = "";
				}
			}
			_inp[i].onblur = function()
			{
				if (this.value == "")
				{
					this.value = this._default;
				}
			}
		}
	}
	for (i=0; i<_txt.length; i++)
	{
		_txt[i]._default = _txt[i].value;
		_txt[i].onfocus = function()
		{
			if (this.value == this._default)
			{
				this.value = "";
			}
		}
		_txt[i].onblur = function()
		{
			if (this.value == "")
			{
				this.value = this._default;
			}
		}
	}
}
function initDropDown()
{
	var n = document.getElementById("side-nav");
	if (n)
	{
		var lis = n.getElementsByTagName("li");
		for (var i = 0; i < lis.length; i++)
		{
			if (lis[i].getElementsByTagName("ul").length)
			{
				var a = lis[i].getElementsByTagName("a").item(0);
				if (a)
				{
					a.onclick = function ()
					{
						var p = this.parentNode;
						if (p.className.indexOf("active") != -1)
							p.className = p.className.replace("active", "");
						else
							p.className += " active";
						 return false;
					}
				}
				// TB Added 7-8-10
				var b = lis[i].getElementsByTagName("a").item(0);
				if (b)
				{
					a.onclick = function ()
					{
						var p = this.parentNode;
						if (p.className.indexOf("active") != -1)
							p.className = p.className.replace("active", "");
						else
							p.className += " active";
						return false;
					}
				} // End addition
			}
		}
	}
}
function initFocus()
{
	var _fieldsets = document.getElementsByTagName("fieldset");
	for (i=0; i<_fieldsets.length; i++)
	{
		if (_fieldsets[i].className.indexOf("secure-form") != -1)
		{
			_inputs = _fieldsets[i].getElementsByTagName("input");
			for (j=0; j<_inputs.length; j++)
			{
				if (_inputs[j].type == "text")
				{
					_inputs[j].onfocus = function()
					{
						if (this.parentNode.className.indexOf("focus") == -1)
						{
							this.parentNode.className += " focus";
						}
					}
					_inputs[j].onblur = function()
					{
						if (this.parentNode.className.indexOf("focus") != -1)
						{
							this.parentNode.className = this.parentNode.className.replace("focus", "");
						}
					}
				}
			}
		}
	}
}
function initActiveState()
{
	_anchors = document.getElementsByTagName("a");
	for (i=0; i<_anchors.length; i++)
	{
		if ((_anchors[i].className.indexOf("btn") != -1) || (_anchors[i].className.indexOf("btn-submit") != -1))
		{
			_anchors[i].onmousedown = function()
			{
				this.className += " pressed";
			}
			_anchors[i].onmouseup = function()
			{
				this.className = this.className.replace("pressed", "");
			}
			_anchors[i].onmouseout = function()
			{
				this.className = this.className.replace("pressed", "");
			}
		}
	}
}
function initAll()
{
	initShowHide();
	initClear();
//	initDropDown();
//	initFocus();
//	initActiveState();
}
if (window.addEventListener) window.addEventListener("load", initAll, false);
else if (window.attachEvent) window.attachEvent("onload", initAll);


// Background Rotator
day=new Date()
x=day.getHours()


if(x>=0 && x<4) {
   document.write('<style type="text/css">body{background:#d6d0c1 url(/images/BSB_Background_4.jpg) no-repeat 50% 0;}></style>')
} else
if(x>=4 && x<12) {
   document.write('<style type="text/css">body{background:#d6d0c1 url(/images/BSB_Background_1.jpg) no-repeat 50% 0;}></style>')
} else
if(x>=12 && x<17) {
   document.write('<style type="text/css">body{background:#d6d0c1 url(/images/BSB_Background_2.jpg) no-repeat 50% 0;}</style>')
} else
if(x>=17 && x<24) {
   document.write('<style type="text/css">body{background:#d6d0c1 url(/images/BSB_Background_4.jpg) no-repeat 50% 0;}</style>')
}

function LastPage() {
	if (document.referrer == "")
		window.location = "/Your-Business-Banking/Business-Insight-Center.aspx";
	else
	{
		if(document.referrer.indexOf("dev.forgeworldwide.com") == -1)
			window.location = "/Your-Business-Banking/Business-Insight-Center.aspx";			
		else
			history.back();
	}
}
// Initiate Secure Online Banking Login Box
	/*					
 $(document).ready(function() {

            $(".dropdown dt a").click(function() {
                $(".dropdown dd ul").toggle();
            });
                        
            $(".dropdown dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown dt a span").html(text);
                $(".dropdown dd ul").hide();
            });
			 $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown"))
                    $(".dropdown dd ul").hide();
            });
			
        }); */
 
 // Rates Print DIV Function
function doPrint(divArea)
    {
        var text;
        monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
        now = new Date;

        text = document.getElementById(divArea).innerHTML;
        document.open();
        document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
        document.write('<html><head><style> b{font-size:14px;} .hide{visibility:hidden;} p, td, a {font: 12px/19px Arial, Verdana, Tahoma, sans-serif;}</style></head><body>');
        document.write('<div style="text-align:center;padding-bottom:30px;"><img src="/images/BSB-logo-forprint.jpg"></div>');
        document.write(text);
        document.write('<hr><p>' + monName[now.getMonth()] + ' ' + now.getDate() + ', ' + now.getFullYear() + '</p>');
        document.write('</body></html>');
        document.close();
        print();
        window.setTimeout("history.go(-1)",1000);
    }
	
