//------------------------------------------------------------------------------------
function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
//------------------------------------------------------------------------------------
function trimFields()
{
	for(var i=0; i < obj.elements.length; i++)
	{
		if(obj.elements[i].type == "text" || obj.elements[i].type == "textarea" || obj.elements[i].type == "password")
		{
			obj.elements[i].value = strTrim(obj.elements[i].value);
		}
	}
}
//------------------------------------------------------------------------------------
//Function to validate email
//-----------------------------------------------------------------------------------
function chkEmail(tmpStr)
{
	var email_pat = /^[a-z][a-z0-9_\.\-]*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*\.[a-z]+$/i;
	return(email_pat.test(tmpStr));
}

//------------------------------------------------------------------------------------
//Function to validate search field
//-----------------------------------------------------------------------------------
function validateSearch()
{
	obj = document.frmSearch;
	obj.keywords.value = strTrim(obj.keywords.value);
	if(obj.keywords.value == '' || obj.keywords.value == 'Search out site')
	{
		alert("Please enter your Keywords.");
		obj.keywords.value = '';
		obj.keywords.focus();
		return false;
	}
}
//------------------------------------------------------------------------------------
//Function to check valid url
//------------------------------------------------------------------------------------
function chkURL(tmpStr)
{
	var url_pat = /^(http|https|ftp):\/\/([\w-]+\.)+[\w-]+(\/[\w-\.\/?%&amp;,=#@\/:]*)?/;
	return(url_pat.test(tmpStr));
}

//------------------------------------------------------------------------------------
//Function to open New Window
//-----------------------------------------------------------------------------------
function NewWindow(pageName)
{
	window.open(pageName, '', 'width=720,height=630,toolbar=0,menubar=0,location=0,left=25,top=25');
}

function validateInternetBanking()
{
	var loginURL = objLogin.login_type[0].checked?'http://www.wabt.com/demo/loa.htm':'http://www.wabt.com/eCorp/summary.html';
	if(objLogin.user_id.value == '' || objLogin.user_id.value == 'User ID')
	{
		alert('Please enter User ID.');
		objLogin.user_id.focus();
		return;
	}
	if(objLogin.password.value == '' || objLogin.password.value == '********')
	{
		alert('Please enter Password.');
		objLogin.password.focus();
		return;
	}

	window.open(loginURL);
}
//------------------------------------------------------------------------------------
//Online Banking Login
//-----------------------------------------------------------------------------------
        function setAction()
        {
               //Fill in the Routing number below.
               var rtNum = "062205704";
               var x = document.forms.Remote;
               
               if(x.loginTo[0].checked) {
                       x.action = 'https://web4.secureinternetbank.com/pbi_pbi1961/Pbi1961.asp?WCI=RemoteLogin&RT=062205704&LogonBy=connect3&PRMACCESS=Account';                   
               } else {
                       x.nmUID.value = x.AccessID.value;
                       x.nmRTN.value = rtNum;
                       x.action = 'https://web4.secureinternetbank.com/ebc_ebc1961/ebc1961.asp?WCI=Process&WCE=RemoteLogon&IRL=T&RT=062205704&MFA=2';
               }
        }
           
        function doLoginRefresh()
        {
               var x = document.forms.Remote;
               
               if (x.AccessIDVisible.value != "") {
                       x.AccessID.value = x.AccessIDVisible.value;
                       x.AccessIDVisible.value = "";
                       
                       setAction();
                       return true;
               } else {
                       alert("Please Enter a valid Access ID.  Thank you!"); 
                       return false;
               }       
        }
//------------------------------------------------------------------------------------
//Leaving Site Disclaimer
//-----------------------------------------------------------------------------------
//function LeavingSite()
//	{	
//	confirm("Notice: You are leaving the West Alabama Bank web site. West Alabama Bank does not provide, nor is it respsonsible for, the content or performance of the web site you are about to access. West Alabama Bank suggests that you consult the Privacy Principles on the site for further information.\n\n" +
//				"Press OK to continue.\n" +
//				"Press CANCEL to return to the West Alabama Bank Web Site.\n\n" +
  //              "Thank You.\n" +
    //            "West Alabama Bank\n\n" +"");
//	}
var disclaimer = "Notice: You are leaving the West Alabama Bank web site. West Alabama Bank does not provide, nor is it respsonsible for, the content or performance of the web site you are about to access. West Alabama Bank suggests that you consult the Privacy Principles on the site for further information.\n\n" +
				"Press OK to continue.\n" +
				"Press CANCEL to return to the West Alabama Bank Web Site.\n\n" +
                "Thank You.\n" +
                "West Alabama Bank\n\n" +"";

