﻿function testEnterKey(buttonToClick, evt) {
	if (navigator.appName == 'Netscape' && navigator.appVersion.substring(0,1) >= 4) {
		if (evt.which == 13) {
			document.Form1[buttonToClick].focus();
			document.Form1[buttonToClick].click();
		}
	}
	
	if (window.event.keyCode == 13) {
		event.cancelBubble = true;
		event.returnValue = false;
		document.Form1[buttonToClick].click();
	}
}
	
var win=null;
			
function NewWindow(mypage,myname,w,h,scroll,pos,displayall)
{
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location='+displayall+',directories='+displayall+',status=yes,menubar='+displayall+',toolbar='+displayall+',resizable='+displayall;
	win=window.open(mypage,myname,settings);
}	

function NewWindowWithFeatures(mypage,myname,w,h,scroll,pos)
{
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes';
	win=window.open(mypage,myname,settings);

}	

function NewWindowWithFeaturesCloseWindow(mypage,myname,w,h,scroll,pos)
{
    window.close();  // close confirmation window
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes';
	win=window.open(mypage,myname,settings);

}	

function autoAdvance(input,len, e)
{
	var keyCode = e.keyCode; 
	var filter = [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsCode(filter,keyCode))
	{
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
}

function containsCode(arr, ele)
{
	var found = false, index = 0;
	while(!found && index < arr.length)
	{
		if(arr[index] == ele)
			found = true;
		else
			index++;
	}
	return found;
}

function getIndex(input)
{
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
	{
		if (input.form[i] == input)
			index = i;
		else
			i++;
	}
	return index;
}

var exit=true;
function exit_popup_console() {
	if (exit)
	{
		var w = window.screen.availWidth;
		var h = window.screen.availHeight;
		var win = window.open('exitconsole.aspx', 'new_window','resizable=1,status=0,menubar=0,toolbar=0,location=0,scrollbars=1');

		win.moveTo(0, 0);
		win.resizeTo(window.screen.availWidth, window.screen.availHeight);
		
	}
}

var preloadFlag = false;
function preloadImages() { 
	imgNames = new Array(
		"images/accountservices.gif",
		"images/acctinfo.gif",
		"images/applynow.gif",
		"images/body_bckgrnd.gif",
		"images/bttn_viewaccount.gif",
		"images/cardholderasst.gif",
		"images/close.jpg",
		"images/close_over.jpg",
		"images/console_closewindow.gif",
		"images/contactus.gif",
		"images/cvv.gif",
		"images/demo.jpg",
		"images/demo_over.jpg",
		"images/enroll.jpg",
		"images/enroll_over.jpg",
		"images/envelope.gif",
		"images/forgotPass.jpg",
		"images/forgotPass_over.jpg",
		"images/forgotusername.jpg",
		"images/forgotusername_over.jpg",
		"images/login.jpg",
		"images/login_over.jpg",
		"images/FPB Logo 1.jpg",
		"images/logoff.gif",
		"images/monetaryservices.gif",
		"images/moreinfo.gif",
		"images/mystatements.gif",
		"images/otherproducts.gif",
		"images/paymybill.gif",
		"images/pers_chk_info.jpg",
		"images/sep.gif",
		"images/shadow.gif",
		"images/sidefade.gif",
		"images/thanksforvisiting.gif",
		"images/topfade.gif",
		"images/whitepix.gif",
		"images/xmark.gif"
	)

	loadImgs = new Array()

	for(i=0; i < imgNames.length; i++) {
	loadImgs[i] = new Image;
	loadImgs[i].src = imgNames[i];
	}
	preloadFlag = true;
}

function changeImages() {
	for (var i=0; i<changeImages.arguments.length; i+=2) {
		document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
	}
}

function OpenMsgBox(cURL) { 
    var w = 900, h = 350;
    if (document.all || document.layers) {
       w = screen.availWidth;
       h = screen.availHeight;
    }

    var popW = 450, popH = 175;

    var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	MsgBox = window.open(cURL,'ChildForm','width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ',status=no,toolbar=no,menubar=no,titlebar=no,location=no,resizable=no,scrollbars=no');
}

function OpenMsgBox2(cStatus, cURL, cTrack) { 
    // lThrdPtyDisc logical field to determine whether or not we need to show the third party disclosure message
    // ctrack string field to determine whether or not to add record to transactionhistory table
    var w = 900, h = 350;
    var url = 'msgbox2.aspx';
    
    if (document.all || document.layers) {
       w = screen.availWidth;
       h = screen.availHeight;
    }
    var popW = 450, popH = 175;

    var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	MsgBox = window.open(url + '?lcFormName='+ document.forms['Form1'].name + '&lcStatus=' + cStatus + '&cTrack=' + cTrack + '&lcURL=' + cURL,'ChildForm','width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ',status=no,toolbar=no,menubar=no,titlebar=no,location=no,resizable=no,scrollbars=no');
	window.open('','_self','');
    window.close();
}

var t2;
var win2;
function popup_window() {
		var w = 730; //window.screen.availWidth;
		var h = 330; //window.screen.availHeight;
		var sw = (window.screen.availWidth-720)/2;
		var sh = (window.screen.availHeight-300)/2;
		win2 = window.open('popup.aspx', 'popup','resizable=0,status=0,menubar=0,toolbar=0,location=0,scrollbars=0');

		win2.moveTo(sw, sh);
		win2.resizeTo(w, h);
				
		if (window.focus) {win2.focus()}
		t2=win2.setTimeout(function(){if(window.focus)win2.focus()},2000);
	    return false;

}

var t
function popunder_window() {
		var w = 730; //window.screen.availWidth;
		var h = 330; //window.screen.availHeight;
		var sw = (window.screen.availWidth-720)/2;
		var sh = (window.screen.availHeight-300)/2;
		win = window.open('popunder.aspx', 'popunder','resizable=0,status=1,menubar=0,toolbar=0,location=0,scrollbars=0');

		win.moveTo(sw, sh);
		win.resizeTo(w, h);
		
        t=win.setTimeout(function(){if(win.closed==false)win.blur();window.focus();},2000);

}