/* =Onload Functions
-------------------------------------------------- */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload !== 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		};
	}
}

/* =Helper 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;
}

/* =Main Navigation
-------------------------------------------------- */

var timeOut = null;

function navIn() {
	if (timeOut != null) {
		window.clearTimeout(timeOut);
	}
}
function navTimer() {
	if (timeOut != null) {
		window.clearTimeout(timeOut);
	}
	timeOut = window.setTimeout('hideMenuObjects()',250);
}
function hideNav(navItem, action) {
	MM_showHideLayers(navItem,'',action);
}
function hideMenuObjects(){
	if (!document.getElementsByTagName || !document.getElementById || !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";
	}
}
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];}}}
}

/* =Window Functions
----------------------------------------------- */
function windowFunctions() {
	if (!document.getElementsByTagName) { return false; }
	var links, i;
	links = document.getElementsByTagName("a");
	for (i = 0; i < links.length; i++) {
		if (links[i].className.match("extLink")) {
			links[i].onclick = function() {
				disclaimer(this.href);
				return false;
			};
		}
		if (links[i].className.match("emailLink")) {
			links[i].onclick = function() {
				mailConfirm(this.href);
				return false;
			};
		}
		if (links[i].className.match("newWindow")) {
			links[i].onclick = function() {
				window.open(this.href);
				return false;
			};
		}
	}
}
addLoadEvent(windowFunctions);

/* =Disclaimers
----------------------------------------------- */
var mailDisclaimer = "Email is a simple and cost effective method of communication, however requests and inquiries needing immediate attention should not be sent via email. Please contact the bank by telephone or in person for urgent matters, as email messages may not be immediately received by our staff. We also ask that you not send sensitive information like account numbers, social security numbers, PIN numbers or passwords by email.\n\nIf you feel it is necessary to send sensitive information, please log-in to online banking and send us a secured message by clicking on contact  in top right corner then click on the add message button.";
function mailConfirm(passedAddress) {
	if (confirm(mailDisclaimer)) {
		window.location.href = passedAddress;
	}
}
var linkDisclaimer = "Third Coast Bank ssb does not control the content of or approve any website that is linked through this browser or site. Any search results are not filtered or screened by the bank or any of its agents, representatives or service providers. Users who search the Internet using this browser do so at their own risk and are responsible for the results.";
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;
		}
	}
}

// How the matchColumns function works: Apply the CSS class of 'column' to your pages' main columns
function matchColumns() { 
    var divs, contDivs, maxHeight, divHeight, d, i, j; 
    // get all <div> elements in the document 
    divs = document.getElementsByTagName('div');
    contDivs = []; 
    // initialize maximum height value 
    maxHeight = 0;     
	// iterate over all <div> elements in the document 
    for (i = 0;i < divs.length;i++) {     
		// make collection with <div> elements with class attribute 'container' 
        if (/\bcolumn\b/.test(divs[i].className)) { 
            d = divs[i]; 
            contDivs[contDivs.length] = d;             
			// determine height for <div> element 
            if (d.offsetHeight) { 
                divHeight = d.offsetHeight;
            }
            else if (d.style.pixelHeight) {
                divHeight = d.style.pixelHeight;
            }
			// calculate maximum height 
            maxHeight = Math.max(maxHeight, divHeight);
			if (maxHeight < 375) {
				maxHeight = 375;	
			}
        }
    }    
	// assign maximum height value to all of container <div> elements
    for (j = 0; j < contDivs.length; j++) {
        contDivs[j].style.height = maxHeight + "px";
    }
}

// Runs the matchColumns function when the page loads
addLoadEvent(matchColumns);

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 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,450);
			}
			else void myOpen(linkURL,500,450);
		break;
	}
}