$(function(){
	var currentURL = location.href.split('#')[1];
	switch( currentURL ) {
		case('security1'):
			rot_div('1');
			break;
		case('security2'):
			rot_div('2');
			break;
		case('security3'):
			rot_div('3');
			break;
		case('security4'):
			rot_div('4');
			break;
		case('security5'):
			rot_div('5');
			break;
		case('fraud1'):
			showDiv('div1','mainDivs');
			break;
		case('fraud2'):
			showDiv('div2','mainDivs');
			break;
		case('fraud3'):
			showDiv('div3','mainDivs');
			break;
		case('fraud4'):
			showDiv('div4','mainDivs');
			break;
		case('fraud5'):
			showDiv('div5','mainDivs');
			break;
	}
	
	/**** 3rd party warning for links generated by JavaScript ********/
	for(i=0;i<document.links.length;i++){
		var lnk = document.links[i];
		if(lnk.href){
			// test every allowedDomain against every link with an href attrib.
			//alert(lnk.href);
			if(lnk.href == "http://cyseal.cyveillance.com/SiteSeal"){
					document.links[i].href= "javascript:showWarning('http://cyseal.cyveillance.com/SiteSeal');"
					document.links[i].target= "_self";
			}
			/* Doesn't work with VeriSign code: if(lnk.href == "https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=WWW.BANTERRABANK.COM&lang=en"){
					document.links[i].href= "javascript:showWarning('https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=WWW.BANTERRABANK.COM&lang=en'); return false;"
					document.links[i].target= "_self";
			}*/
			if(lnk.href == "http://turbotax.intuit.com/affiliate/banter"){
					document.links[i].href= "javascript:showWarning('http://turbotax.intuit.com/affiliate/banter');"
					document.links[i].target= "_self";
			}
		}
	}
	
});




// for Cool Menus
if(window.event + "" == "undefined") event = null;
function showMenu(){return false};
function mout(){return false};
function dummyObject() {this.mout=mout};
oM = new dummyObject();
function stopError() {
 // return true;
}

var imgdir = "diFiles/skins/default/images/";

//window.onerror = stopError;

function makeNavImage(name,width,height){
this.name_on="nav_" + name +"_on.gif";
this.name_off="nav_" + name +"_off.gif";
this.width=width;
this.height=height;
this.newimage_on = new Image(width,height);
this.newimage_on.src = dir + '/images/' + this.name_on;
this.newimage_off = new Image(width,height);
this.newimage_off.src = dir + '/images/' + this.name_off;
}


function img_act(imgName){

document[imgName].src =  navitems[imgName].newimage_on.src;
}

function img_inact(imgName){
window.status = "";
document[imgName].src =  navitems[imgName].newimage_off.src;
}


document.write('<img src="'+dir+'/images/wcscreenrez.gif?width='+screen.width+'&height='+screen.height+'" width="1" height="1">'); 

function wcInternalPopup(url, height, width){
    var wide=width;
    var tall=height;
    var halfwide = (wide/2);
    var halftall = (tall/2); 
    var pWidth = ( ((parseInt(screen.width) / 2)) - halfwide);
    var pHeight = (((parseInt(screen.height) / 2)) - halftall);
    var features = 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
    window.open(url,'internalpopup',features);
} 

function wcPopup(url, height, width, disclaimer){
    var wide=width;
    var tall=height;
    var halfwide = (wide/2);
    var halftall = (tall/2);
    var pWidth = ( ((parseInt(screen.width) / 2)) - halfwide);
    var pHeight = (((parseInt(screen.height) / 2)) - halftall);
    var features = 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
    window.open(url,'externalpopup',features);
} 

/************************************************************************************************************
* This function is used in the onclick of the a tag to display the external site warning. 
* @param msg - Integer specifying the which message to display.
* @param lk - The a link object
* Usage: <a href="http://wwww.mysite.com" onclick="return displayThirdPartyAlert(1,this);">My Site</a>
**************************************************************************************************************/
function displayThirdPartyAlert(msg,lk){
	var description = lk.innerHTML;
	if(description.indexOf('alt="') != -1){
		var x = description.indexOf('alt="')+5;
		var temp = description.substring(x);
		description = temp.substring(0,temp.indexOf("\""));
	}
	showWarning(lk.href, description, lk.target, msg)
	return false;
}

/************************************************************************************************************
* This function is used in the href of the a tag to display the external site warning. 
* @param lk - The url of the site to be opened
* @param desc - The description of the site to be opened, i.e. the name of the site.
* @param target - Allows for the window to opened in a new window
* @param msg - Integer specifying the which message to display.
* Usage: <a href="javascript:('http://wwww.mysite.com');">My Site</a>
**************************************************************************************************************/
/*

function showWarning(lk, desc, target, msg){
	desc = (desc) ? desc : "Third Party Site";
	target = (target) ? target : "";
	msg = (msg) ? msg : 0;
	
	var messages = new Array(6);
	messages[0] = '<h1 style="margin-left:100px;">Third Party Site Disclaimer</h1><br/>You are leaving Fidelity Federal Bank and Trust\'s website. Links that may be accessed via <strong>' +desc+ '</strong> are for the convenience of informational purposes only. Any products and services accessed through <strong>'+ lk +'</strong> are not provided or guaranteed by Central Valley Bank. The site you are about to visit may have a privacy policy that is different than Fidelity Federal Bank and Trust\'s. Please review their privacy policy. Central Valley Bank does not endorse the content contained in these sites, nor the organizations publishing those sites, and hereby disclaims any responsibility for such content.';
	
	messages[1] = '<h1 style="margin-left:100px;">Third Party Site Disclaimer</h1><br/>You are leaving Fidelity Federal Bank and Trust\'s website. Links that may be accessed via <strong>' +desc+ '</strong> are for the convenience of informational purposes only. Any products and services accessed through <strong>'+ lk +'</strong> are not provided or guaranteed by Central Valley Bank. The site you are about to visit may have a privacy policy that is different than Fidelity Federal Bank and Trust\'s. Please review their privacy policy. Central Valley Bank does not endorse the content contained in these sites, nor the organizations publishing those sites, and hereby disclaims any responsibility for such content.';
	
	messages[2] = '<h1 style="margin-left:100px;">Non-Secure Email Disclaimer</h1><br/>As a convenience to you and to provide additional means of communications between you and Central Valley Bank, you can use electronic mail (e-mail) to contact the bank regarding general inquiries and general access and maintenance issues. However communication via e-mail is not considered secure, and you agree that you will not use e-mail to transmit sensitive and/or confidential information such as account numbers, user IDs, or PINs, or to request or authorize any financial transaction.';
	
	messages[3] = '<h1>Third Party Site Disclaimer</h1><br/>You are leaving Fidelity Federal Bank and Trust\'s website. Links that may be accessed via <strong>' +desc+ '</strong> are for the convenience of informational purposes only. Any products and services accessed through <strong>'+ lk +'</strong> are not provided or guaranteed by Central Valley Bank. The site you are about to visit may have a privacy policy that is different than Fidelity Federal Bank and Trust\'s. Please review their privacy policy. Central Valley Bank does not endorse the content contained in these sites, nor the organizations publishing those sites, and hereby disclaims any responsibility for such content.';
	
	messages[4] = '<h1>Third Party Site Disclaimer</h1><br/>You are leaving Fidelity Federal Bank and Trust\'s website. Links that may be accessed via <strong>' +desc+ '</strong> are for the convenience of informational purposes only. Any products and services accessed through <strong>'+ lk +'</strong> are not provided or guaranteed by Central Valley Bank. The site you are about to visit may have a privacy policy that is different than Fidelity Federal Bank and Trust\'s. Please review their privacy policy. Central Valley Bank does not endorse the content contained in these sites, nor the organizations publishing those sites, and hereby disclaims any responsibility for such content.';
	
	messages[5] = '<h1>Third Party Site Disclaimer</h1><br/>You are leaving Fidelity Federal Bank and Trust\'s website. Links that may be accessed via <strong>' +desc+ '</strong> are for the convenience of informational purposes only. Any products and services accessed through <strong>'+ lk +'</strong> are not provided or guaranteed by Central Valley Bank. The site you are about to visit may have a privacy policy that is different than Fidelity Federal Bank and Trust\'s. Please review their privacy policy. Central Valley Bank does not endorse the content contained in these sites, nor the organizations publishing those sites, and hereby disclaims any responsibility for such content.';

	var content = new Array();
	var index = 0;
	content[index++] = messages[msg];
	content[index++] = '<br /><br /><br />';
	content[index++] = '<div align="center"><a href="'+lk+'" target="'+target+'" onclick="document.getElementById(\'ex_dis\').style.display = \'none\'">Continue</a>&#160;&#160;<a href="javascript:void(\'0\');" onclick="document.getElementById(\'ex_dis\').style.display = \'none\'">Decline</a></div></div>';	
	document.getElementById("ex_dis").innerHTML = content.join("");
	document.getElementById("ex_dis").style.display = "block";
	scrollTo(0,0);
}

*/



/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/

/*function openIB(){
    showMessage();
}
*/
function showMessage(){
    var content = new Array();
	var index = 0;
	content[index++] = '<h1>Coming Soon!!</h1><br/><p>You are attempting to access a page or product that is not yet available.</p>  <p>Please check back often. It will be available soon.</p><p>Thank you!</p>';
	content[index++] = '<br /><br /><br />';
	content[index++] = '<div align="center"><a href="javascript:void(\'0\');" onclick="document.getElementById(\'ex_dis\').style.display = \'none\'"><strong>Close</strong></a></div></div>';	
	document.getElementById("ex_dis").innerHTML = content.join("");
	document.getElementById("ex_dis").style.display = "block";
	scrollTo(0,0);
}





function open_apps(nameofapp)

{ self.location.href = "https://www.bankexcel.com/Forms/OnlineForm.cgi?onweb=true&form=" + nameofapp; }



function ib_open_apps(nameofapp)

{ self.location.href = "https://www.banterrabank.com/onlineserv/HB/Forms/OnlineForm.cgi?onweb=true&form=" + nameofapp; }

/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/



function doReplacement(str, link)
{
    var result = str;
    
    var tempLink = link;
    
    if (tempLink == '' || tempLink == ' ')
        tempLink = '#';

// Begin List of Tag Replacements

    result = result.replace(/_BR_/i, '<br/>');    // <br/>

    result = result.replace(/_SUP_/i, '<sup>');      // <sup>
    result = result.replace(/_!SUP_/i, '</sup>');    // </sup>

    result = result.replace(/_A_/i, '<a href="' + tempLink + '">');     // <a href="link">
    result = result.replace(/_!A_/i, '</a>');                                            // </a>

// End List of Tag Replacements

    return result;
}



/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
function testForDemo2(fileName)
{
	if(document.cookie.indexOf('demo')!=-1)
	{
		if(confirm("In order to register, you must first exit the demo. Would you like to exit the demo?"))
		{
			expireDate = new Date("January 1, 1970");
			var kill_string1 = "cookie_check=invalid;expires=" + expireDate.toGMTString() + "; path=/";
            document.cookie = kill_string1;
            var kill_string2 = "demo=stub;expires=" + expireDate.toGMTString() + "; path=/";
            document.cookie = kill_string2;
			document.location = "https://www.banterrabank.com/home/?pageLabel=home";
		}
		else
		{
			
			document.location = "https://www.banterrabank.com/home/?pageLabel=home&#38;demo";
		}
	}
	else
	{
		document.location = fileName; 
	}
	
	return false;
} //end testForDemo2


function openIB(type)
{
    if(type == "")
    {
        self.location.href="?pageLabel=home";
    }
    else if(type == "demo")
    {
        self.location.href="home?demo";
    }
    else if(type == "reg")
    {
        self.location.href="javascript:testForDemo2('https://www.banterrabank.com/onlineserv/HB/STDReg.cgi');";
    }
    else if(type == "password")
    {
        self.location.href="https://www.banterrabank.com/onlineserv/HB/ForgottenPW.html";
    }
    else if(type == "browser")
    {
        var newBrowserWin = window.open('','btwin','width=800,height=600,resizable,scrollbars');
        newBrowserWin.location.href="https://www.banterrabank.com/onlineserv/HB/BrowserTest.cgi";
    }
    else
    {
        self.location.href="?pageLabel=home";
    }
}

function openCM(type)
{
    if(type == "")
    {
        self.location.href="https://www.banterrabank.com/onlineserv/CM/";
    }
    else if(type == "demo")
    {
        self.location.href="http://www.cmdemo.com/customer_demo/index.html";
    }
    else
    {
        self.location.href="https://www.banterrabank.com/onlineserv/CM/";
    }
}

/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/



function showWarning(url)
{
var content = new Array();
var index = 0;
content[index++] = "<h2>You are leaving banterrabank.com...</h2> From time to time, we provide our visitors with links to other websites. These links have been compiled from internal and external sources. By clicking on the “Continue” button below, you will be leaving our website to visit one of these other websites. Although we reviewed the website prior to creating the link, we are not responsible for the content of the website. Information on linked website pages may become dated or change without notice and we do NOT represent or warrant that information contained on these linked pages is complete or accurate. We suggest that you always verify information obtained from a linked website before you act upon such information.<br /><br />This link is provided solely for your convenience and does not constitute an endorsement of any kind. We are NOT responsible for the accuracy and completeness of information, typographical errors, errors of omission, or the privacy practices and security of this website. We encourage you to read the privacy statement of all linked websites to become acquainted with their specific privacy policies.<br /><br />By your use of this information, you recognize and agree to hold us, our employees, agents, successors, and/or assignees harmless from any liability as a result of your using any information, materials, products or services listed at this website. ";
content[index++] = "<br /><br /><br />";
content[index++] = "<div align=\"center\"><a href="+url+">Continue</a>&nbsp;&nbsp;<a href=\"javascript:void('0');\" onclick=\"document.getElementById('ex_dis').style.display = 'none'\">Decline</a></div></div>";            
document.getElementById("ex_dis").innerHTML = content.join("");
document.getElementById("ex_dis").style.display = "block";
scrollTo(0, 0);
}

function showWarning_newWin(url)
{
var content = new Array();
var index = 0;
content[index++] = "<h2>You are leaving banterrabank.com...</h2> From time to time, we provide our visitors with links to other websites. These links have been compiled from internal and external sources. By clicking on the “Continue” button below, you will be leaving our website to visit one of these other websites. Although we reviewed the website prior to creating the link, we are not responsible for the content of the website. Information on linked website pages may become dated or change without notice and we do NOT represent or warrant that information contained on these linked pages is complete or accurate. We suggest that you always verify information obtained from a linked website before you act upon such information.<br /><br />This link is provided solely for your convenience and does not constitute an endorsement of any kind. We are NOT responsible for the accuracy and completeness of information, typographical errors, errors of omission, or the privacy practices and security of this website. We encourage you to read the privacy statement of all linked websites to become acquainted with their specific privacy policies.<br /><br />By your use of this information, you recognize and agree to hold us, our employees, agents, successors, and/or assignees harmless from any liability as a result of your using any information, materials, products or services listed at this website. ";
content[index++] = "<br /><br /><br />";
content[index++] = "<div align=\"center\"><a href=\"javascript:void('0');\" onclick=\"window.open('"+url+"');document.getElementById('ex_dis').style.display = 'none'\">Continue</a>&nbsp;&nbsp;<a href=\"javascript:void('0');\" onclick=\"document.getElementById('ex_dis').style.display = 'none'\">Decline</a></div></div>";            
document.getElementById("ex_dis").innerHTML = content.join("");
document.getElementById("ex_dis").style.display = "block";
scrollTo(0, 0);
}




function mail_warning(url)
{
var content = new Array();
var index = 0;
content[index++] = '<span class="header">E-mail Disclaimer</span><br />WARNING: E-mail is an unsecure method of communication.  Any information contained in your message could be viewed by a third party.  Sensitive information such as passwords or social security numbers should be omitted from e-mail messages.';
content[index++] = "<br /><br /><br />";
content[index++] = '<div align="center"><a href="' + url + '" onclick="document.getElementById(\'ex_dis\').style.display = \'none\'">Continue</a>&nbsp;&nbsp;<a href="javascript:void(\'0\');" onclick="document.getElementById(\'ex_dis\').style.display = \'none\' ">Decline</a></div></div>';
document.getElementById("ex_dis").innerHTML = content.join("");
document.getElementById("ex_dis").style.display = "block";
scrollTo(0, 0);
}


function checkSize()
{
    var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		myWidth = window.innerWidth;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth ) )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	}
	else if( document.body && ( document.body.clientWidth ) )
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
    return myWidth;
}

document.write('<div id="ex_dis" style="background-color: #ffffff; font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; color: #000000; text-align: left; position:absolute; top:50px; left:' + (parseInt(checkSize()/2)-175) + 'px; border: thin solid #1A448E; padding: 15px; display: none; z-index: 100000; width:350px;"></div>');

function open_apps(nameofapp)
{self.location.href = "https://www.banterrabank.com/Forms/OnlineForm.cgi?onweb=true&form=" + nameofapp +"&onweb=true"; }





function hideFooterLogos()
{
    document.getElementById("fdic_logo").style.visibility = "hidden";
}

function showFooterLogos()
{
    document.getElementById("fdic_logo").style.visibility = "visible";
}

/** simple show/hide div function **/
function showDiv(divID, divClass)
{
	// set up variables to be used in the jQuery
	//divID= "'#" + divID + "'";
	//divClass= "'." + divClass + "'";
	
	// hid all divs with the same class name
	$("." + divClass).hide();
	
	// show div with the given ID
	$("#" + divID).show();
}


/*::::::::::::::::::::::::::::::::::::::::::    Div Changing Div's            :::::::::::::::::::::::::::::::::::::::::::::::::::*/


/*   ***********************************************************    */

function getElementsByName_iefix(tag, name) {
     
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

/*   ***********************************************************    */

function Hide_rot_mult()
{ var array = getElementsByName_iefix("div","rot_mult"); for (var i=0; i<array.length;i++) { array[i].style.display="none"; }  }


function rot_div(choice)  
{
	Hide_rot_mult();
	document.getElementById(choice).style.display="inline";
	if(choice==3 && (document.location.href.indexOf('pageLabel=bb.bb_bu') > -1 || document.location.href.indexOf('pageLabel=bb.bb_fm')>-1))hideFooterLogos();
	else showFooterLogos(); 
}




function getPageNumber()
{
var url = document.URL;
var pageidx = url.indexOf("page=")

if  (pageidx > -1)
{
var pagestr = url.substring(pageidx+5,url.length);
var pageNumber = parseInt(pagestr);
rot_div(pageNumber);
}
}






/*::::::::::::::::::::::::::::::::::::::::::   Bank Locations   ::     Div Changing Div's            :::::::::::::::::::::::::::::::::::::::::::::::::::*/

function Hide_bnk_rot_mult()
{ var array = getElementsByName_iefix("div","bnk_rot_mult"); for (var i=0; i<array.length;i++) { array[i].style.display="none"; }  };

function bnk_rot_div(choice)  
{ 
Hide_bnk_rot_mult(); 
var item = document.getElementById(choice).style; item.display="inline"; 

if (choice >= 10  && choice <= 25)
{ document.getElementById(1).style.display="inline"; }

if (choice >= 30  && choice <= 39)
{ document.getElementById(2).style.display="inline"; }

if (choice >= 40  && choice <= 49)
{ document.getElementById(3).style.display="inline"; }

if (choice >= 50  && choice <= 59)
{ document.getElementById(4).style.display="inline"; }

if (choice == 200)
{document.getElementById(1).style.display="inline"; document.getElementById(2).style.display="inline";  document.getElementById(3).style.display="inline"; document.getElementById(4).style.display="inline";}
}






/*::::::::::::::::::::::::::::::::::::::::::   ATM Locations   ::     Div Changing Div's            :::::::::::::::::::::::::::::::::::::::::::::::::::*/

function Hide_atm_rot_mult()
{ var array = getElementsByName_iefix("div","atm_rot_mult"); for (var i=0; i<array.length;i++) { array[i].style.display="none"; }  };

function atm_rot_div(choice)  
{ 
Hide_atm_rot_mult(); 
var item = document.getElementById(choice).style; document.getElementById(201).style.display="inline"; item.display="inline"; 

if (choice >= 10  && choice <= 29)
{ document.getElementById(1).style.display="inline";}

if (choice >= 30  && choice <= 39)
{ document.getElementById(2).style.display="inline";}

if (choice >= 40  && choice <= 49)
{ document.getElementById(3).style.display="inline";}

if (choice >= 50  && choice <= 59)
{ document.getElementById(4).style.display="inline";}

if (choice == 200)
{ document.getElementById(1).style.display="inline"; document.getElementById(2).style.display="inline";  document.getElementById(3).style.display="inline"; document.getElementById(4).style.display="inline";}
}


/* ::::::::::::::::::::::::::::::::::::::::::    fix wc bug     :::::::::::::::::::::::::::::::::::::::::::::::::::*/


var url = document.location.href;
var eSign = url.indexOf('=');
if(eSign > -1){
    queryString = url.substring(eSign+1);
    rIsProblem = /^[^_\.]+_[^\.]+\./;
    if(rIsProblem.test(queryString)){
        rFixProblem = /^([^_]+)(.*)$/;
        parsedQueryString = rFixProblem.exec(queryString);
        newQueryString = parsedQueryString[1]+"."+parsedQueryString[1]+parsedQueryString[2];
        newURL = "/home/?pageLabel="+newQueryString;
        document.location.replace(newURL);
    }
}
