function OnClickHandler()
{
    if (navigator.appName == "Microsoft Internet Explorer") {
		var el=null;
		var flag=true;
		el = event.srcElement;
		// Do the While loop to find out if any of the parent elements
		// are an A HREF.
		// This is necessary because in Internet Explorer 4.x, you can
		// receive events of any element including the <B> tag.
		while (flag && el)
		{
		  if (el.tagName == "A")
		  {
		    flag=false;
		    if (el.protocol == "javascript:")
		    {
		      execScript(el.href, "javascript");
		      // A window.event.returnValue=false is performed so that the
		      // default action does not happen - which in case of an HREF
		      // will be navigating to a link.
		      window.event.returnValue = false;
		    }
		    if (el.protocol == "vbscript:")
		    {
		      execScript(el.pathname, "vbscript");
		      window.event.returnValue = false;
		    }
		  }
		  else
		    el = el.parentElement;
		  }
	}
}

// set the On click handler for the document
document.onclick = OnClickHandler; 

function clearBox(box) {
	if(box.value==box.defaultValue) {
		box.value = "";
	}
}

function clearBox1(box1) {
	if(box1.value==box1.defaultValue) {
		box1.value = "";
	}
}

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_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 activate(image_name) {
	if (document.images) {
		document[image_name].src = eval(image_name + "On.src");
	}
}

function deactivate(image_name) {
	if (document.images) {
		document[image_name].src = eval(image_name + "Off.src");
	}
}

function login() {
	page = "https://online.ndbt.com/cgi-bin/hb.exe?control=1067.txt&act=login&extra=16&vi=" + document.form0.v1.value + "&v2=" + document.form0.v2.value + "&v3=" + document.form0.v3.value;
	popupwindow(page);}

function enroll() {	//page = "application3.asp";	page = "p_readynetenroll.shtml";
	document.location.href = page;}
function gotoreadynettrust() {
	page = "https://www.tpars.com/prod/login.asp?FI=0180A";
	popupwindow(page);}
function redirectpage1(page) {	document.location.href = page;
}

function redirectpage(page) {	page1 = page;	setTimeout("redirectpage1(page1)",2000);	}

function popupwindow(page) {	var app = window.open(page,'NDB');	app.opener = window.parent; 
	app.opener.name = "opener";
}
function opennewwindow(page) {	if (confirm("The website that you are about to access is not affiliated with North Dallas Bank & Trust Co. or its owners. Security and privacy standards of North Dallas Bank & Trust Co. no longer apply. North Dallas Bank & Trust Co. has not tested any information, software, products or services found on these sites and therefore cannot make any representations whatsoever with respect thereto.") == true) {
		var app = window.open(page,'NorthDallasBank');		app.opener = window.parent; 
		app.opener.name = "opener";
	}	
}

function howarewedoingsurvey() {	var page = "howarewedoingsurvey.asp";
	var second = "width=" + (500) + ",height=" + (500) + ",location=no,toolbar=no,directories=no,status=no,scrollbars=yes,resize=yes,menubar=no";
	var app = window.open(page,'NDBT',second);	app.opener = window.parent; 
	app.opener.name = "opener";
	var readyneturl = "https://online.ndbt.com/cgi-bin/hb.exe?control=1067.txt&control=1067.txt&act=login&v1=" + document.frmLogin.v1.value + "&v2=" + document.frmLogin.v2.value + "&v3" + document.frmLogin.v3.value + "&image.x=8&image.y=5";
	document.location.href = readyneturl;}
function gobackto(page) {	window.opener.location.href = page;
	window.close(self);
}
function doClock() {
	var y=new Date();
	var gy=y.getYear();
	var Hours;
	var Mins;
	var Time;
	Hours = y.getHours();
	if (Hours >= 12) {
		Time = " p.m.";
	}
	else {
		Time = " a.m.";
	}
	if (Hours > 12) {
		Hours -= 12;
	}
	if (Hours == 0) {
		Hours = 12;
	}
	Mins = y.getMinutes();
	if (Mins < 10) {
		Mins = "0" + Mins;
	}
	var dName=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var mName=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var currentDate = dName[y.getDay()] + ", " + mName[y.getMonth()] + " "  + y.getDate() + ", "  + y.getFullYear() + " " + Hours + ":" + Mins + Time ;
	return (currentDate);
 }

function gotoloanapplication() {
	if (document.page.loan.value == "Home Mortgage") {
		page = "http://www.ndbt.com/1003.pdf";
		popupwindow(page);
	}
	else {
		document.location.href = document.page.loan.value;
	}
}

function gotooverdraftapplication() {
	document.location.href = document.page.overdraft.value;
}

function gotosavingsapplication() {
	document.location.href = document.page.savings.value;
}

function gotocheckingapplication() {
	document.location.href = "application5.asp?type1=" + document.page.checking.value;
}

function gotoopenanaccount() {
	document.location.href = document.openanaccount.typeofaccount.value;
}

function gotomakeloanpayment() {
	page = "loanpayment.asp?accountnumber=" + document.loanpayment.accountnumber.value;
	popupwindow(page);
}

function quickfind() {
	if (document.homepage.help.value == "Financial Tools") {
		page = "http://k2.secure-banking.com/ift/index.cfm?xid=1067";
		opennewwindow(page);
	}
	else if (document.homepage.help.value == "Fraud Protection Login") {
		page = "https://pospay.ndbt.com/sco/index.html";
		popupwindow(page);
	}
	else if (document.homepage.help.value == "Validate a Check") {
		page = "https://pospay.ndbt.com/vch/logout.do";
		popupwindow(page);
	}
	else if (document.homepage.help.value == "Loan Payments") {
		page = "loanpayment.asp";
		popupwindow(page);
	}
	else {
		document.location.href = document.homepage.help.value;
	}
}

function isblank(s) {
                for(var i=0; i<s.length; i++) {
                        var c = s.charAt(i);
                        if((c != ' ') && (c != '\n') && (c != '\t')) 
                        {
                                return false;
                        }
                }
                return true;
}

function verify(f) {
                var msg;
                var empty_fields = "";
                var errors = "";
                
                for (var i=0; i<f.length; i++) 
                {
                        var e = f.elements[i];
                        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) 
                        {
                                if ((e.value == null) || (e.value == "") || isblank(e.value)) 
                                {
                                        empty_fields += "\n" + e.name;
                                        continue;
                                }
                                if (e.numeric || (e.min != null) || (e.max != null)) 
                                {
                                        var v = parseFloat(e.value);
                                        if (isNan(v) || ((e.min != null) && (v < e.min)) ||  ((e.max != null) && (v > e.max))) 
                                        {
                                                errors += "- The field " + e.name + " must be a number";
                                                if (e.min != null)
                                                {
                                                        errors += " that is greater than " + e.min;
                                                }
                                                if (e.max != null && e.min != null)
                                                {
                                                        errors += " and less than " + e.max;
                                                }
                                                else if (e.max != null)
                                                {
                                                        errors += " that is less than " + e.max;
                                                }
                                                errors += ".\n";
                                        }
                                }
                        }
                }
				               
               if (!empty_fields && !errors) 
                {
					return true;
                }
                
                msg = "__________________________________\n\n";
                 msg += "Your email can not be sent without all required information. Please review your form and fill in the needed information before submitting.\n";
                msg += "_________________________________\n\n";
                
                if (empty_fields) 
                {                        
                        msg += "- The following required field(s) are empty:" + empty_fields + "\n";
                        if (errors) msg += "\n";
                }

               msg += errors;
                                
               alert(msg);
                return false;
}

function verifycustomerservice(f) {
                var msg;
                var empty_fields = "";
                var errors = "";
                
                for (var i=0; i<f.length; i++) 
                {
                        var e = f.elements[i];
                        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) 
                        {
                                if ((e.value == null) || (e.value == "") || isblank(e.value)) 
                                {
                                        empty_fields += "\n" + e.name;
                                        continue;
                                }
                                if (e.numeric || (e.min != null) || (e.max != null)) 
                                {
                                        var v = parseFloat(e.value);
                                        if (isNan(v) || ((e.min != null) && (v < e.min)) ||  ((e.max != null) && (v > e.max))) 
                                        {
                                                errors += "- The field " + e.name + " must be a number";
                                                if (e.min != null)
                                                {
                                                        errors += " that is greater than " + e.min;
                                                }
                                                if (e.max != null && e.min != null)
                                                {
                                                        errors += " and less than " + e.max;
                                                }
                                                else if (e.max != null)
                                                {
                                                        errors += " that is less than " + e.max;
                                                }
                                                errors += ".\n";
                                        }
                                }
                        }
                }
			
				if (document.customerservice.email.value  == document.customerservice.email2.value ) {}
				else   
				  {
				     errors += "Please make sure your email address is correct in both email fields.\n";
				  }
				               
               if (!empty_fields && !errors) 
                {
					return true;
                }
                
                msg = "__________________________________\n\n";
                 msg += "Your email can not be sent without all required information. Please review your form and fill in the needed information before submitting.\n";
                msg += "_________________________________\n\n";
                
                if (empty_fields) 
                {                        
                        msg += "- The following required field(s) are empty:" + empty_fields + "\n";
                        if (errors) msg += "\n";
                }

               msg += errors;
                                
               alert(msg);
                return false;
}

function verifyyearendcdrompersonal(f) {
                var msg;
                var empty_fields = "";
                var errors = "";
                
                for (var i=0; i<f.length; i++) 
                {
                        var e = f.elements[i];
                        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) 
                        {
                                if ((e.value == null) || (e.value == "") || isblank(e.value)) 
                                {
                                        empty_fields += "\n" + e.name;
                                        continue;
                                }
                                if (e.numeric || (e.min != null) || (e.max != null)) 
                                {
                                        var v = parseFloat(e.value);
                                        if (isNan(v) || ((e.min != null) && (v < e.min)) ||  ((e.max != null) && (v > e.max))) 
                                        {
                                                errors += "- The field " + e.name + " must be a number";
                                                if (e.min != null)
                                                {
                                                        errors += " that is greater than " + e.min;
                                                }
                                                if (e.max != null && e.min != null)
                                                {
                                                        errors += " and less than " + e.max;
                                                }
                                                else if (e.max != null)
                                                {
                                                        errors += " that is less than " + e.max;
                                                }
                                                errors += ".\n";
                                        }
                                }
                         }
                }
				               
				if (document.yearendcdrompersonal.disclosure.checked != true) {
					errors += "Please read and acknowledge that you have read the disclosure.\n";
				}

               if (!empty_fields && !errors) 
                {
					return true;
                }
                
                msg = "__________________________________\n\n";
                 msg += "Your email can not be sent without all required information. Please review your form and fill in the needed information before submitting.\n";
                msg += "_________________________________\n\n";
                
                if (empty_fields) 
                {                        
                        msg += "- The following required field(s) are empty:" + empty_fields + "\n";
                        if (errors) msg += "\n";
                }

               msg += errors;
                                
               alert(msg);
                return false;
}

function verifyyearendcdrombusiness(f) {
                var msg;
                var empty_fields = "";
                var errors = "";
                
                for (var i=0; i<f.length; i++) 
                {
                        var e = f.elements[i];
                        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) 
                        {
                                if ((e.value == null) || (e.value == "") || isblank(e.value)) 
                                {
                                        empty_fields += "\n" + e.name;
                                        continue;
                                }
                                if (e.numeric || (e.min != null) || (e.max != null)) 
                                {
                                        var v = parseFloat(e.value);
                                        if (isNan(v) || ((e.min != null) && (v < e.min)) ||  ((e.max != null) && (v > e.max))) 
                                        {
                                                errors += "- The field " + e.name + " must be a number";
                                                if (e.min != null)
                                                {
                                                        errors += " that is greater than " + e.min;
                                                }
                                                if (e.max != null && e.min != null)
                                                {
                                                        errors += " and less than " + e.max;
                                                }
                                                else if (e.max != null)
                                                {
                                                        errors += " that is less than " + e.max;
                                                }
                                                errors += ".\n";
                                        }
                                }
                         }
                }
				               
				if (document.yearendcdrombusiness.disclosure.checked != true) {
					errors += "Please read and acknowledge that you have read the disclosure.\n";
				}

               if (!empty_fields && !errors) 
                {
					return true;
                }
                
                msg = "__________________________________\n\n";
                 msg += "Your email can not be sent without all required information. Please review your form and fill in the needed information before submitting.\n";
                msg += "_________________________________\n\n";
                
                if (empty_fields) 
                {                        
                        msg += "- The following required field(s) are empty:" + empty_fields + "\n";
                        if (errors) msg += "\n";
                }

               msg += errors;
                                
               alert(msg);
                return false;
}

function verifyestatement(f) {
                var msg;
                var empty_fields = "";
                var errors = "";
                
                for (var i=0; i<f.length; i++) 
                {
                        var e = f.elements[i];
                        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) 
                        {
                                if ((e.value == null) || (e.value == "") || isblank(e.value)) 
                                {
                                        empty_fields += "\n" + e.name;
                                        continue;
                                }
                                if (e.numeric || (e.min != null) || (e.max != null)) 
                                {
                                        var v = parseFloat(e.value);
                                        if (isNan(v) || ((e.min != null) && (v < e.min)) ||  ((e.max != null) && (v > e.max))) 
                                        {
                                                errors += "- The field " + e.name + " must be a number";
                                                if (e.min != null)
                                                {
                                                        errors += " that is greater than " + e.min;
                                                }
                                                if (e.max != null && e.min != null)
                                                {
                                                        errors += " and less than " + e.max;
                                                }
                                                else if (e.max != null)
                                                {
                                                        errors += " that is less than " + e.max;
                                                }
                                                errors += ".\n";
                                        }
                                }
                         }
                }
				               
				if (document. estatement. agreementcheck.checked != true) {
					errors += "Please read and acknowledge that you have read the E-Statement Agreement.\n";
				}

               if (!empty_fields && !errors) 
                {
					return true;
                }
                
                msg = "__________________________________\n\n";
                 msg += "Your email can not be sent without all required information. Please review your form and fill in the needed information before submitting.\n";
                msg += "_________________________________\n\n";
                
                if (empty_fields) 
                {                        
                        msg += "- The following required field(s) are empty:" + empty_fields + "\n";
                        if (errors) msg += "\n";
                }

               msg += errors;
                                
               alert(msg);
                return false;
}