function SearchMe(e){
	if(e.keyCode == 13){
		if(document.frmsearch.txtsearch.value==""){
			alert("Enter Search Value");
			return false;
		}
		return true;
	}
}

function isEmpty(strval) {
    if (strval == "" || strval == null)
    {
    return false;
    }
	else
	return true;
  }

//function to check valid email address
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = strEmail;
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
     return false;
    } 
    return true; 
}

function passthis()  {
	var err="";
	
	if(document.theform.inquiry.value=="-")
	err+="How should we direct your inquiry?\n";
	if(!isEmpty(document.theform.help.value))
	err+="How can we help you?\n";
	//if(document.theform.loan_type.value=="-")
	//err+="Loan Type\n";		
	if(!isEmpty(document.theform.name.value))
	err+="Name\n";
	//if(!isEmpty(document.theform.cname.value))
	//err+="Company Name\n";
	if(!isEmpty(document.theform.phone.value))
	err+="Phone Number\n";	
	if(!isEmpty(document.theform.email.value))
	err+="Email\n";
	if(!isValidEmail(document.theform.email.value))
	err+="Invalid email!\n";
	if(!isEmpty(document.theform.maddress.value))
	err+="Mailing Address\n";
	if(!isEmpty(document.theform.contact.value))
	err+="Select 'How would you prefer to be contacted?'\n";
	if(!isEmpty(document.theform.vericode.value))
	err+="Enter the verification code as it is shown\n";
	
	if(err!="") {
		alert("Following Field(s) are required!\n----------------------------\n"+err);
		return false;
	}
	return true;
}

function jumpto(id)

{

	/*if(document.frmOnline.onlinebank[document.frmOnline.onlinebank.selectedIndex].value=="-"){

	alert("Please select 'Banking' option");

	return false;

	} */

	/*else{ */

	if(id==1){

	var URL = "https://www.on-lineenterprise.com/PBI_PBI1961/pbi1961.asp?Rt=011302742&LogonBy=Connect3&PRMAccess=Account";

    window.open(URL, "_blank",'status=yes,resizable=yes,width=650px,scrollbars=yes,height=400px');

	return false;

	}

	else if(id==2){	

	var URL = "https://www.on-lineenterprise.com/EBC_EBC1961/EBC1961.ASP?WCI=Process&WCE=Request&RID=3000&RTN=011302742&MFA=2";

    window.open(URL, "_blank",'status=yes,resizable=yes,width=650px,scrollbars=yes,height=400px');

	return false;

	}

	/*}*/

}

function showmenu() {
	document.frmOnline.onlinebank.style.visibility = "visible";	
}

function findPos(){
    x=0; y=0; var el,temp
    el = document.all?document.all["btnlogin"]:document.getElementById("btnlogin");
    if(el.offsetParent){
      temp = el
      while(temp.offsetParent){ //Looping parent elements to get the offset of them as well
        temp=temp.offsetParent;
        x+=temp.offsetLeft
        y+=temp.offsetTop;
      }
    }
    x+=el.offsetLeft
    y+=el.offsetTop

  //Returning the x and y as an array
  return [x,y]
}


function ShowCatList(){
	pos = findPos();
	el1 = document.all?document.all["catlist"]:document.getElementById("catlist");
	if(el1){
		el1.style.visibility = "visible";
		el1.style.left = pos[0]+"px";
		el1.style.top = pos[1]+16+"px";
	}
}

function CloseCatList(){
	document.getElementById('catlist').style.visibility = "hidden";
}

/******************************************** Added for search */
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}


function ebc_search () {
	if(document.searchForm) {
			searchtext = trim(document.searchForm.search.value);
			if(searchtext.length > 0) {
				document.searchForm.AS_search.value = searchtext
				document.searchForm.submit();
			}
	}
}

function showLocation(el) {
	if(!el.title) { el.title = 'Enterprisebank';}
	
Shadowbox.open({
		content:'<div id="welcome-msg"><img src="'+el.href+'"></div>',
		player:"html",
		title:'<p style="margin:0;padding:0; float:left;margin-left:5px;">'+el.title+'</p><p style="margin:0;padding:0; float:right; margin-right:5px;"><a href="javascript:Shadowbox.close();" style="color:white;" title="Close">X</a>',
		height:512,
		width:512
});
return false;
}

function leavingSitealert() {
	alert("Please be advised you are now leaving Enterprise Bank's site.");
}
