//
// Internet Banking login form
//
function setAction () {
	// Fill in the Routing number below.
	var rtNum = "244171902";
	var x = document.forms.BankingLogin;
	
	x.action = 'https://web1.secureinternetbank.com/pbi_pbi1961/Pbi1961.asp?WCI=RemoteLogin&RT=244171902&LogonBy=connect3&PRMACCESS=Portfolio';			
}

function doLoginRefresh () {
	var x = document.forms.BankingLogin;
		
	if (x.AccessIDVisible.value != "") {
		x.AccessID.value = x.AccessIDVisible.value;
		x.AccessIDVisible.value = "";
		
		setAction();
		return true;
	} else {
		alert("Please Enter a valid Access ID.  Thank you!"); 
		return false;
	}	
}

function enableLoginForm () {
	var x = document.forms.BankingLogin;
	x.onsubmit = function () { return doLoginRefresh(); }
}

function onlineBankingSignup () {
if (q = confirm("BEFORE you complete the folowing online signup form, YOU MUST complete an online banking application at either of our offices."))
document.location.href = "https://web1.secureinternetbank.com/pbi_pbi1961/pbi1961.asp?Rt=244171902&LogonBy=connect3&PRMACCESS=Portfolio&enroll=true";
} 

/** IE Hover fix **/
function ieHover() {
	var menuDivs = document.getElementById('onlinebankinglogin').getElementsByTagName('div');
	for (var i=0; i<menuDivs.length; i++) if (menuDivs[i]) {
		ul = menuDivs[i].getElementsByTagName('ul');
		if (ul) {
			ul[0].onmouseover=function() {this.className+=" over"; }
			ul[0].onmouseout=function() {this.className=this.className.replace(new RegExp(' over\\b'), '');}
			title = ul[0].getElementsByTagName('li');
			if (title[0]) submenu = title[0].getElementsByTagName('ul');
			if (submenu[0]) items = submenu[0].getElementsByTagName('li');
		
			for(var j=0; j < items.length; j++) if (items[j]) {
				items[j].onmouseover=function() {this.className+=" over"; }
				items[j].onmouseout=function() {this.className=this.className.replace(new RegExp(' over\\b'), '');}
			}
			
			
		}
	}
}

// this function is need to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
	var result = false;
	if (obj.getAttributeNode("class") != null) {
		result = obj.getAttributeNode("class").value;
	}
	return result;
}   

window.onload = function () {
	//stripe();
	enableLoginForm();
};
//if (window.attachEvent) window.attachEvent('onload', ieHover);
