var ns = (navigator.appName.indexOf('Netscape')>-1);
var ie = (navigator.appName.indexOf('Microsoft Internet Explorer')>-1);

var olBankingMenuItems = new Array(
   ["olBankLogIn", "https://www.cuconline.net/auth_user.jsp?cid=72qk5R2ybOBogRdgCx", "Sign In"],
   ["olBankLearn", "cuHome.htm", "Learn More"]);

var mastercardMenuItems = new Array(
   ["mastercardLogIn", "https://www.gotomycard.com/stefcu/", "Access Online"]);

var olLendingMenuItems = new Array(
   ["olLendingLogIn", "https://WWW.LOANLINER.COM/lrpresenter/lr1loantypes.asp?cuid=04205649", "Apply For Loan"],
   ["olLendingLearn", "olLendingLearn.htm", "Learn More"],
   ["olLendingLoanCalc", "https://www.loanliner.com/ICE/presenter/default.asp?CuIdNr=04205649&ProtPkgIdNr=0287269408343092704&ORIGIN_CHANNEL_ID=0643218900177045423&ORIGIN_LOCATION_ID=0643218900177045423", "Loan Calculator"]);
   
var memberServicesMenuItems = new Array(
   ["memberServices1", "https://reorder.libertysite.com", "Reorder Checks"]);

var youthServicesMenuItems = new Array(
   ["googolplex", "http://googolplex.cuna.org/index.html?sub_id=30569", "Googolplex website"]);

var depAccountsMenuItems = new Array(
   ["share", "share.htm", "Share"],
   ["shareDraft", "checking.htm", "Checking"],
   ["moneyMarket", "moneyMarket.htm", "Money Market"],
   ["christmasclub", "christmasClub.htm", "Christmas Club"],
   ["termshare", "termShare.htm", "Certificates of Deposit"],
   ["ira", "ira.htm","IRA"]);

var youthProgramsMenuItems = new Array(
   ["youthProgramsBoom", "moneyRules.htm", "Money Rule$"],
   ["youthProgramsPlanetM", "kidsCount.htm", "Kid$ Count"]);

var loansMenuItems = new Array(
   ["loansStandard", "standardLoans.htm", "Standard"]);

var stdServicesMenuItems = new Array(
   ["stdServcheckCard", "visa.htm", "VISA Check Card"],
   ["stdServMastercard", "mastercard.htm", "STFCU MasterCard"],
   ["stdServCUHome", "cuHome.htm", "CU@Home"],
   ["stdServODPriv", "odprivilege.htm", "Overdraft Privilege"],
   ["stdServDirectDeposit", "directDeposit.htm", "Direct Deposit"],
   ["stdServPayrollDeduction", "payrollDeduction.htm", "Payroll Deduction"],
   ["stdServAutoTransfers", "autoTransfers.htm", "Automatic Transfers"],
   ["stdServOverdraft", "overdraftProtection.htm", "Overdraft Protection"],
   ["stdServTheForce", "siteDrafts.htm", "Sight Drafts"]);

var otherInfoMenuItems = new Array(
   ["otherInfoFundAvail", "fundsAvail.htm", "Funds Availability"],
   ["otherInfoEqualCredit", "equalCredit.htm", "Equal Credit Opportunity"],
   ["otherInfoPrivacy", "privacyNotice.htm", "Privacy Notice & Disclosure"],
   ["otherInfoRepos", "repos.htm", "Current Repos"],
   ["otherInfoCheck21", "check21.htm", "Check 21"],
   ["otherInfoRegD", "regD.htm", "Regulation D"],
   ["otherInfoCheckCash", "checkCash.htm", "Check Cashing Fee"]);

function createMenu(menuName, menuItems)
{
   var divHTML = '<DIV ID="' + menuName + 'MenuDiv" CLASS="DivMenu"';
   divHTML = divHTML + 'onmouseout="return hideMenu(this, ' + menuName.length + ',event)">';

   var tableHTML = '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 ID="' + 
      menuName + 'Table"><TBODY ID="' + menuName + 'TableBody">';
   var tableRowHTML = "";
   var rowCount;
   var totalNoRows = menuItems.length;
   for (rowCount = 0; rowCount < totalNoRows; rowCount++)
   {
      tableRowHTML = tableRowHTML + '<TR ID="' + menuName + 
         menuItems[rowCount][0] +  'TR"><TD ID="' + menuName + 
         menuItems[rowCount][0];
      tableRowHTML = tableRowHTML + '" onclick="goPage(\'' + 
         menuItems[rowCount][1] + '\')"';
      tableRowHTML = tableRowHTML + 'CLASS="TDMenu">' + menuItems[rowCount][2] +
         '</TD></TR>';
   }
  
   return divHTML + tableHTML + tableRowHTML + '</TBODY></TABLE></DIV>';
}

function showMenu(menuToShow, e)
{
   if (ns)
   {
      var srcElement = e.target;
   } 
   else
   {
      var srcElement = event.srcElement; 
   }
   var xPos = parseInt(srcElement.style.left);
   var yPos = parseInt(srcElement.style.top); 
   menuToShow.style.left = xPos + (parseInt(srcElement.style.width)) - 4;
   menuToShow.style.top = yPos + 2;
}

function hideMenu(menuToHide, menuIDLength, e)
{   
   var toElementID;
   if (ns)
   {
      var mouseLastIn = e.relatedTarget;       
   }
   else
   {
      var mouseLastIn =  event.toElement; 
   }
   if (mouseLastIn != null)
   {
      if (mouseLastIn.nodeType == 3)
      {
         mouseLastIn = mouseLastIn.parentNode; 
      }
      toElementID = mouseLastIn.id;
   }
   else 
   {  
       return false;
   }

   if (typeof(toElementID) == "undefined")
   {
      toElementID = "UNDEF";
   }
   toElementID = toElementID.substr(0,menuIDLength);
   var divMenuID = menuToHide.id;
   divMenuID = divMenuID.substr(0,menuIDLength);
   if (toElementID != divMenuID)
   {
      menuToHide.style.left = -200 + 'px';
      menuToHide.style.top = -1000 + 'px';
   }
}

function document_onmouseover(e) 
{
   if (ns)
   {
      var srcElement = e.target;
   } 
   else
   {
      var srcElement = event.srcElement;
   }

   if (srcElement.nodeType == 3)
   {
       srcElement = srcElement.parentNode; 
   }
   if (srcElement.className == "TDMenu")
   {
      srcElement.style.color = "white";
      srcElement.style.backgroundColor = "#00406e";
   }
   if (srcElement.className == "TDMenuBase")
   {
      srcElement.style.color = "white";
      srcElement.style.backgroundColor = "#00406e";
   }
}

function document_onmouseout(e) 
{
    if (ns)
   {
      var srcElement = e.target;
   } 
   else
   {
      var srcElement = event.srcElement;
   }

   if (srcElement.nodeType == 3)
   {
      srcElement = srcElement.parentNode; 
   }
   if (srcElement.className == "TDMenu")
   {
      srcElement.style.color ="black";
      srcElement.style.backgroundColor = "white";
   }
   if (srcElement.className == "TDMenuBase")
   {
      srcElement.style.color ="black";
      srcElement.style.backgroundColor = "white";
   }
}

function goPage(src)
{
   window.location.href = src;
}

function goRepo()
{
	settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=200,height=230,left=300,top=200";
 	repoWindow = window.open("repoWindow.htm","repoWindow",settings);
	repoWindow.focus();
}

function noStatementFormSubmit()
	{
		var returnValue = false;

		if (document.statementForm.account.value == "")
		{
			alert("Please enter an account number");
			document.statementForm.account.focus();
		}
		else if (document.statementForm.fname.value == "")
		{
			alert("Please enter a first name");
			document.statementForm.fname.focus();
		}
		else if (document.statementForm.lname.value == "")
		{
			alert("Please enter a last name");
			document.statementForm.lname.focus();
		}
		else if (document.statementForm.address.value == "")
		{
			alert("Please enter an address");
			document.statementForm.address.focus();
		}
		else if (document.statementForm.city.value == "")
		{
			alert("Please enter a city");
			document.statementForm.city.focus();
		}
		else if (document.statementForm.state.value == "")
		{
			alert("Please enter a state");
			document.statementForm.state.focus();
		}
		else if (document.statementForm.zip.value == "")
		{
			alert("Please enter a zip code");
			document.statementForm.zip.focus();
		}
		else if (document.statementForm.id_inquiry.value == "")
		{
			alert("Please enter last 4 digits of Social Security Number");
			document.statementForm.id_inquiry.focus();
		}
		else if (!document.statementForm.authorize.checked)
		{
			alert("Please click on the checkbox authorizing STFCU to stop your statement mailing");
			document.statementForm.authorize.focus();
		}
		else
		{
			returnValue = true;
		}

		return returnValue;
	}

function olBankEnrollFormSubmit()
	{
		var returnValue = false;

		if (document.frmOLBankEnroll.account.value == "")
		{
			alert("Please enter an account number");
			document.frmOLBankEnroll.account.focus();
		}
		else if (document.frmOLBankEnroll.fname.value == "")
		{
			alert("Please enter a first name");
			document.frmOLBankEnroll.fname.focus();
		}
		else if (document.frmOLBankEnroll.lname.value == "")
		{
			alert("Please enter a last name");
			document.frmOLBankEnroll.lname.focus();
		}
		else if (document.frmOLBankEnroll.address.value == "")
		{
			alert("Please enter an address");
			document.frmOLBankEnroll.address.focus();
		}
		else if (document.frmOLBankEnroll.city.value == "")
		{
			alert("Please enter a city");
			document.frmOLBankEnroll.city.focus();
		}
		else if (document.frmOLBankEnroll.state.value == "")
		{
			alert("Please enter a state");
			document.frmOLBankEnroll.state.focus();
		}
		else if (document.frmOLBankEnroll.zip.value == "")
		{
			alert("Please enter a zip code");
			document.frmOLBankEnroll.zip.focus();
		}
		else if (document.frmOLBankEnroll.member_email.value == "")
		{
			alert("Please enter a valid email address");
			document.frmOLBankEnroll.member_email.focus();
		}
		else if (document.frmOLBankEnroll.maiden.value == "")
		{
			alert("Please enter your mother's maiden name");
			document.frmOLBankEnroll.maiden.focus();
		}	
		else if (document.frmOLBankEnroll.ssn.value == "")
		{
			alert("Please enter last 4 digits of Social Security Number");
			document.frmOLBankEnroll.ssn.focus();
		}
		else if (document.frmOLBankEnroll.password.value == "")
		{
			alert("Please enter your initial password");
			document.frmOLBankEnroll.password.focus();
		}
		else if (document.frmOLBankEnroll.password_ver.value == "")
		{
			alert("Please retype your initial password for verification");
			document.frmOLBankEnroll.password_ver.focus();
		}
		else if (document.frmOLBankEnroll.password.value != document.frmOLBankEnroll.password_ver.value)
		{
			alert("Passwords do not match, please enter passwords again");
			document.frmOLBankEnroll.password.focus();
		}
		else
		{
			returnValue = true;
		}

		return returnValue;
	}


function surveyFormSubmit()
	{
		var returnValue = false;
		
		if (document.surveyForm.radioChoice[0].checked)
		{
			returnValue = true;
			setCookie("surveyFlag","yes","","");
		}
		else if (document.surveyForm.radioChoice[1].checked)
		{
			returnValue = true;
			setCookie("surveyFlag","yes","","");
		}
		else
		{
			alert("Please pick an answer first");
		}

		return returnValue;
	}

function setCookie(cookieName, cookieValue, cookiePath, cookieExpires)
{//setCookie
	cookieValue = escape(cookieValue);
	if (cookieExpires == "")
	{//if no expire date, set expire date to 4 months in future
		var nowDate = new Date();
		nowDate.setMonth(nowDate.getMonth() + 4);
		cookieExpires = nowDate.toGMTString();
	}
	if (cookiePath != "")
	{//if path included set cookie path
		cookiePath = ";Path=" + cookiePath;
	}
	document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;
}//setCookie

function getCookieValue(cookieName)
{//getCookieValue
	var cookieValue = document.cookie;
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
	if (cookieStartsAt == -1)
	{
		cookieStartsAt = cookieValue.indexOf(cookieName + "=");
	}
	if (cookieStartsAt == -1)
	{
		cookieValue = null;
	}
	else
	{
		cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
		var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
		if (cookieEndsAt == -1)
		{
			cookieEndsAt = cookieValue.length;
		}
		cookieValue = unescape(cookieValue.substring(cookieStartsAt,cookieEndsAt));
	}
	return cookieValue;
}//getCookieValue