﻿/* =Helper Functions
----------------------------------------------- */
// Dreamweaver functions
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_jumpMenu(targ,selObj,restore) { //v3.0
	if (selObj.options[selObj.selectedIndex].value !== "") {
		if (selObj.options[selObj.selectedIndex].value.substr(0,4) == "void") {
			eval(selObj.options[selObj.selectedIndex].value);
		} else {
			eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		}
	}
	if (restore) selObj.selectedIndex=0;
}

// Print function
function printCheck() {
	if (window.print) {
		window.print();
	} else { 
		alert("Your browser does not support this print function. Please hit CTRL-P if you are using windows, or APPLE/ALT-P if using a Mac.");
	}
}

// Old school popup function
function myOpen(page,width,height) {
    if (navigator.appName == 'Netscape') {
        adjWidth = width+10;
        adjHeight = height+10;
    }
    else {
        adjWidth = width;
        adjHeight = height;
    }
   
    window.open(page,'windowName','width=' + adjWidth + ',height=' + adjHeight + ',toolbar=no,location=no,directories=no,resizable=yes,status=yes,menubar=yes,scrollbars=yes');
}

// Non-destructive way to add new functions to the window.onload event
function addLoadEvent(func) {
	var oldonload;
  oldonload = window.onload;
  if (typeof window.onload !== 'function') {
    window.onload = func;
  } else {
    window.onload = function () {
      oldonload();
      func();
    };
  }
}

/* =Put focus on the login form
-------------------------------------------------- */
function focusLoginForm(){
   if(document.getElementById("id")){
      document.getElementById("id").focus();
   }
}
addLoadEvent(focusLoginForm);

/* =Preload navMain rollover images on page load
----------------------------------------------- */
function preloadAllImages() {
	MM_preloadImages('images/navMain/nPersonalRollover.png','images/navMain/nBusinessRollover.png','images/navMain/nMortgageRollover.png','images/navMain/nInvestRollover.png','images/navMain/nCustomerRollover.png');
}
addLoadEvent(preloadAllImages);

/* =Menu Functions
----------------------------------------------- */
// This makes the menus functions. Created by Project VII
function P7_autoLayers() { //v1.5 by PVII
 var g,b,k,f,u,k,j,args=P7_autoLayers.arguments,a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";f=false;
 for(j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}

// Reset the timer
var timeOut = null;

function navIn() {
	if (timeOut != null) {
		window.clearTimeout(timeOut);
	}
}

function navTimer() {
	navIn();
	timeOut = window.setTimeout('hideMenuObjects()',250);
}

function hideMenuObjects(){
	if (!document.getElementsByTagName || !document.getElementById("navMain")) { return false; }	
	var menuObj, menus, n;
	menuObj = document.getElementById("navMain");
	menus = menuObj.getElementsByTagName("div");
	for ( n = 0; n < menus.length; n++) {
		menus[n].style.visibility = "hidden";
	}
}

/* =Disclaimers
----------------------------------------------- */
var emailDisclaimer = "Messages sent to Your Community Bank via email are sent over the internet and may not be transmitted in an encrypted or secure form. Caution is urged in the use of confidential information. Please do not send or ask for confidential information (social security number, account number, pin, etc.) via email.";

var linkDisclaimer = "You are leaving Your Community Bank website. The site you have chosen is independent of Your Community Bank and we can not attest to the accuracy of information provided by linked sites. Linking to a website does not constitute an endorsement by Your Community Bank, or any of its employees, of the sponsors of the site or the products presented on the site.";

function mailConfirm(passedAddress) {
	if (confirm(emailDisclaimer)) {
		window.location.href = passedAddress;
	}
}

function disclaimer(passedWebsite) {
	var oWin;
	if (confirm(linkDisclaimer)) {
		oWin = window.open(passedWebsite,"newWindow");
		if (oWin === null || typeof(oWin) === "undefined") {
			window.location.href = passedWebsite;
		} else {
			return true;
		}
	}
}

/* The code below is for the Show/hide functionality. Any page that calls these functions needs to have the following 
	variables created and set on the page within script tags. Each unique object needs its own flag.
		
		var objectFlag1 = 0;
		var objectFlag2 = 0;
		var objectFlag3 = 0;
		var startObject = 1;
		var stopObject = 3;
*/

//Product Matrix Show/Hide Code.
function toggleMoreInfo(id) {
	var obj = document.getElementById("moreInfo" + id);
	if (obj.className == "hideObject") {
		eval("objectFlag" + id + " = 1;");
		obj.className = "showMoreInfo";
		var obj = document.getElementById("linkText" + id);
		obj.innerHTML = "Hide&laquo;";
	}
	else {
		eval("objectFlag" + id + " = 0;");
		obj.className = "hideObject";
		var obj = document.getElementById("linkText" + id);
		obj.innerHTML = "More&raquo;";
	}
}

//Product Matrix Show/Hide Code With Gray Bar Background.
function toggleMoreInfoGrayBar(id) {
	var obj = document.getElementById("moreInfo" + id);
	if (obj.className == "hideObject") {
		eval("objectFlag" + id + " = 1;");
		obj.className = "showMoreInfo";
		var obj = document.getElementById("linkText" + id);
		obj.innerHTML = "Hide&laquo;";
		var obj = document.getElementById("productRowHighlight" + id);
		obj.className = "mtxRowGrayBar";
	}
	else {
		eval("objectFlag" + id + " = 0;");
		obj.className = "hideObject";
		var obj = document.getElementById("linkText" + id);
		obj.innerHTML = "More&raquo;";
		var obj = document.getElementById("productRowHighlight" + id);
		obj.className = "mtxRowWhiteBar";
	}
}
function toggleMoreInfoGrayBarCDs(id1,id2) {
	var objMoreInfo = document.getElementById("moreInfo" + id1);
	if (objMoreInfo.className == "hideObject") {
		eval("objectFlag" + id1 + " = 1;");
		objMoreInfo.className = "showMoreInfo";
		var obj = document.getElementById("linkText" + id1);
		obj.innerHTML = "Hide&laquo;";
	}
	else {
		eval("objectFlag" + id1 + " = 0;");
		objMoreInfo.className = "hideObject";
		var obj = document.getElementById("linkText" + id1);
		obj.innerHTML = "More&raquo;";
	}
	for(i=id1 ;i<=id2;i++) {
		if (objMoreInfo.className == "hideObject") {
			eval("objectFlag" + i + " = 1;");
			var obj = document.getElementById("productRowHighlight" + i);
			obj.className = "mtxRowWhiteBar";
		}
		else {
			eval("objectFlag" + i + " = 0;");
			var obj = document.getElementById("productRowHighlight" + i);
			obj.className = "mtxRowGrayBar";
		}
	}
}

//Generic Show/Hide Code.
function showAll(status,startRow,stopRow) {
	for(n=startRow;n<=stopRow;n++) {
		var objLink = document.getElementById("linkObject" + n);
		var objDisp = document.getElementById("displayObject" + n);
		if(status==0) {
			if(objLink.className=="hideObject") {
				objLink.className = "bulletPlusListMtxTd";
				objDisp.className = "hideObject";
			}
		} else {
			if(objLink.className!="hideObject") {
				objLink.className = "hideObject";
				objDisp.className = "bulletListMtxTdNone";
			}
		}
	}
	return;
}

function toggleShowAllVisibility(id) {
	var objLink = document.getElementById("linkObject" + id);
	var objDisp = document.getElementById("displayObject" + id);
	if(objLink.className=="hideObject") {
		objLink.className = "bulletPlusListMtxTd";
		objDisp.className = "hideObject";
	} else {
		objLink.className = "hideObject";
		objDisp.className = "bulletListMtxTdNone";
	}
	return;
}

function showSingleTable(id) {
	if(eval("objectFlag" + id) == 1) {
		eval("objectFlag" + id + " = 0;");
		var obj = document.getElementById("displayObject" + id);
		obj.className = "hideObject";	
	}
	else {
		eval("objectFlag" + id + " = 1;");
		var obj = document.getElementById("displayObject" + id);
		obj.className = "showRowObject";
	}
	return;
}

function accordShow(sectionID,state){
	if(state == 0){
		document.getElementById("ratesLink" + sectionID).className = "showRowObject";	
		document.getElementById("ratesDetail" + sectionID).className = "hideObject";	
	}else{
		document.getElementById("ratesLink" + sectionID).className = "hideObject";	
		document.getElementById("ratesDetail" + sectionID).className = "showRowObject";	
	}
	return;
}