/* --------------------------------------------------
Site:     Hills Bank (www.hillsbank.com)
Author:   Bryan Sullivan
Created:  January 15, 2007
-------------------------------------------------- */

/* Revisions ----------------------------------------
Date:         January 15, 2007
Author:       Bryan Sullivan
Description:  Sample revision
-----------------------------------------------------
Date:         January 15, 2007
Author:       Bryan Sullivan
Description:  Sample revision
-------------------------------------------------- */

/* =Base 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_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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.");
	}
}

function testBrowser() {
	window.open('https://www.banksafe.com/check.cfm','test','scrollbars=yes,resizable=yes,width=400,height=450');
}

/* =Disclaimers
-------------------------------------------------- */
function emailDisc(passedAddress) {
	if (confirm("Messages sent to Hills Bank via email are sent over the Internet and are not transmitted in an encrypted or secure form. Do not email account numbers, social security numbers, or other confidential information.")) {
		window.location = passedAddress;
	}
}

function linkDisc(passedWebsite) {
	if (confirm("HillsBank.com provides links to other web sites for convenience and informational purposes only.  Users should be aware that all web sites are not protected.  Hills Bank and Trust Company is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites.  Hills Bank and Trust Company is not responsible for any transmission received from a linked site.")) {
		var oWin = window.open(passedWebsite,"newWindow");
		if (oWin == null || typeof(oWin) == "undefined") {
			window.location.href = passedWebsite;
		} else {
			return true;
		}
	}
}

/* =Menus
-------------------------------------------------- */
var timeOut = null;

function navIn() {
  if (timeOut != null) {window.clearTimeout(timeOut);}
}

function navTimer(navItem, action) {
  if (timeOut != null) {window.clearTimeout(timeOut);}
	timeOut = window.setTimeout('hideMenuObjects()',500);
}

function hideMenuObjects(){
	menuObj = document.getElementById("nav-main");
	menus = menuObj.getElementsByTagName("ul");
	for(n=0;n<menus.length;n++){
		if (menus[n].className == "menu") {
			menus[n].style.visibility = "hidden";
		}
	}
}

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];}}}
}

//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) {
			objLink.className = "bulletPlusListMtxTd";
			objDisp.className = "hideObject";
		} else {
			objLink.className = "hideObject";
			objDisp.className = "bulletListMtxTdNone";
			//Adding code to pull in the image if we need it
			if(arrImage){
				if(arrImage[n-1].length > 0){
					if(document.getElementById("showHideImage" + n).src != arrImage[n-1]){
						document.getElementById("showHideImage" + n).src = arrImage[n-1];
					}
				}
			}			
		}
	}
	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";
		//Adding code to pull in the image if we need it
		if(arrImage){
			if(arrImage[id-1].length > 0){
				if(document.getElementById("showHideImage" + id).src != arrImage[id-1]){
					document.getElementById("showHideImage" + id).src = arrImage[id-1];
				}
			}
		}
	}
	return;
}

/* =Locations Show/Hide Code
-------------------------------------------------- */
function toggleVisibility(status,id) {
	if(status == 0) {
			var obj = document.getElementById("linkObject" + id);
			obj.style.display = "block";
			var obj2 = document.getElementById("displayObject" + id);
			obj2.style.display = "none";
		} else {
			var obj = document.getElementById("linkObject" + id);
			obj.style.display = "none";
			var obj2 = document.getElementById("displayObject" + id);
			obj2.style.display = "block";
		}
	return;
}

function toggleSectionVisibility(status,id){
	if(status == 0) {
		var linkObjectStyle = "block";
		var displayObjectStyle = "none";
	} else {
		var linkObjectStyle = "none";
		var displayObjectStyle = "block";
	}
	var theDTs = document.getElementById(id).getElementsByTagName("dt");
	for(var n=0; n <theDTs.length;n++){
		if(theDTs[n].id != "") theDTs[n].style.display = linkObjectStyle;
	}
	var theDDs = document.getElementById(id).getElementsByTagName("dd");
	for(var n=0; n <theDDs.length;n++){
		if(theDDs[n].id != "") theDDs[n].style.display = displayObjectStyle;					
	}
}

/* =Home Page Locations
-------------------------------------------------- */

function toggleLocationTabs(whichDiv) {
	if (!document.getElementById) return false;
	var container = document.getElementById("hmpgLocations");
	var offices = document.getElementById("officeLinks");
	var atms = document.getElementById("atmLinks");
	var officeButton = document.getElementById("officeButton");
	var atmButton = document.getElementById("atmButton");
	if (whichDiv == 0) {
		offices.style.display = "block";
		atms.style.display = "none";
		officeButton.setAttribute("src","images/headers/homepage/locationsOffice_f2.gif");
		atmButton.setAttribute("src","images/headers/homepage/locationsATM.gif");
	} else {
		offices.style.display = "none";
		atms.style.display = "block";
		officeButton.setAttribute("src","images/headers/homepage/locationsOffice.gif");
		atmButton.setAttribute("src","images/headers/homepage/locationsATM_f2.gif");
	}
}
function filterText(){
	if (navigator.appName != "Netscape"){
		var form = document.forms[0];
		var i;
		var j;
		var holdVar = '';
		var holdCharCode;
	
		for (i=0; i < form.elements.length; i++){
			if (form.elements[i].type == 'text')
			{
				holdVar = '';	
				for (j=0;j < form.elements[i].value.length; j++)
				{
					holdCharCode = form.elements[i].value.charCodeAt(j);
					if (navigator.appName == "Netscape")
					{
						if ((holdCharCode >= 96 && holdCharCode <= 122) || (holdCharCode >= 65 && holdCharCode <= 90) || (holdCharCode >= 48 && holdCharCode <= 57) || holdCharCode == 64 || holdCharCode == 35 || holdCharCode == 36 || holdCharCode == 38 || holdCharCode == 44 || holdCharCode == 39 || holdCharCode == 32 || holdCharCode == 45 || holdCharCode == 46 || holdCharCode == 47 || holdCharCode == 40 || holdCharCode == 41 || form.elements[i].value.charAt(j)=="/")
						{
							holdVar = holdVar + form.elements[i].value.charAt(j);
						}
					}
					else //Using IE
					{
						if ((holdCharCode >= 97 && holdCharCode <= 122) || (holdCharCode >= 48 && holdCharCode <= 57) || (holdCharCode >= 65 && holdCharCode <= 90) || holdCharCode == 64 || holdCharCode == 35 || holdCharCode == 36 || holdCharCode == 38 || holdCharCode == 46 || holdCharCode == 44 || holdCharCode == 38 || holdCharCode == 39 || holdCharCode == 32 || holdCharCode ==45 || holdCharCode == 40 || holdCharCode == 41 || holdCharCode == 46 || holdCharCode == 47 || holdCharCode == 95 || form.elements[i].value.charAt(j)=="/")
						{						
							holdVar = holdVar + form.elements[i].value.charAt(j);
						}
					} 				
				}
				form.elements[i].value = holdVar;
			}
		}	
	}	
	return true;
}
function evalLink(linkURL,linkTarget,disclaimerFlag,disclaimerText) {
	var regexp = /&quote;/g;
	disclaimerText = disclaimerText.replace(regexp,"\"");
	switch(linkTarget) {
		case 0: //Same window
			if(disclaimerFlag == 1) {
				if(confirm(disclaimerText)) window.location = linkURL;
			}
			else window.location = linkURL;		
		break;
		case 1: // New Window
			if(disclaimerFlag == 1) {
				if(confirm(disclaimerText)) window.open(linkURL);
			}
			else window.open(linkURL);		
		break;
		case 2: // Popup Window
			if(disclaimerFlag == 1) {
				if(confirm(disclaimerText)) void myOpen(linkURL,500,500);
			}
			else void myOpen(linkURL,500,500);
		break;
	}
}
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');
}
function mailConfirm(passedAddress) {
	if (confirm("You are about to send information over the Internet that may not be transmitted in an encrypted or secure form. It might be possible for others to see what you are sending, therefore, you should assume that this email is not secure. For your protection, please do not send any personal information (i.e., Social Security Number, Account Number, Date of Birth, PIN Number, etc.)."))
		window.location = passedAddress;
}