function Pop(url)
{
    link = window.open(url,"Home","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width=650,height=700,left=100,top=100");
}

// Demo Pop Up
function demopop(url)
{
    link = window.open(url,"Compare","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width=790,height=672,left=100,top=100");
}

// FAQ Pop Up
function faqpop(url) 
{
    link = window.open(url,"FAQ","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width=650,height=500,left=100,top=100");
}

// Ratios Pop Up
function ratiospop(url) {
	link = window.open(url, "Ratios", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width=900,height=500,left=100,top=100");
}

// Calc Pop Up
function calcpop(url)
{
    link = window.open(url,"Calc","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width=650,height=700,left=100,top=100");
}

// Forms & Disclosure Pop Up
function windowpop(url) {
link = window.open(url,"FormsNDisclosures","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=1,width=750,height=600,left=100,top=100");
}

// Go Code
function goUser(selected) {
	if (selected != "") {
		location.href = selected;
	}
}

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 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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/*********************************************************************************************************
Name: setFieldFormat
Desc: Add Format to a field
Param:
Input: intType - Element Type (0 - SSN, 1 - Phone Type 1, 2 - Phone Type 2), strFieldValue - Input value to add formatting
Output: new value with dashes
*********************************************************************************************************/
function setFieldFormat(intType, strFieldValue) {
	var strTemp = "";
	var bFlag = 0;
	var strHolder = "";

	//Get Key
	if(document.layers) { Key = e.which; }
    else { Key = window.event.keyCode; }
    
	//Check for Delete button pressed
	if(Key != 8)
	{
		//Load Array
		var arrType = loadFormatArray(intType);

		//Loop through and create formatted value
		for(i=0;i<strFieldValue.length;i++)
		{
	        strHolder = searchFormatArray(arrType, i)
			if(!isEmpty(strHolder))
			{
				if(i == 0)
				{
					if(strFieldValue.charAt(i) != strHolder) { strTemp += strHolder + strFieldValue.charAt(i); }
					else { strTemp += strFieldValue.charAt(i); }
				}
				else if(strFieldValue.charAt(i+1) != strHolder) { strTemp += strFieldValue.charAt(i) + strHolder; }
				else { strTemp += strFieldValue.charAt(i); }
			}
			else { strTemp += strFieldValue.charAt(i); }
		}
	}
	else { strTemp = strFieldValue; }

	//Return new formatted value
	return strTemp;
}
/*********************************************************************************************************
Name: searchFormatArray
Desc: Returns value if there is a match in the array
Param:
Input: arrToSearch - Array to Search, strValueToSearch - Value to search for
Output: Format Value
*********************************************************************************************************/
function searchFormatArray(arrToSearch, strValueToSearch) {
	for(x=0;x<arrToSearch[0].length;x++) 
	{ 
	    if(arrToSearch[0][x] == strValueToSearch)
	    {
	        return arrToSearch[1][x]; 
	    } 
	}
}
/*********************************************************************************************************
Name: loadFormatArray
Desc: Returns the correct Format Array to use
Param:
Input: intType - Format Type(0 - SSN, 1 - Phone Type 1, 2 - Phone Type 2)
Output: Array Value
*********************************************************************************************************/
function loadFormatArray(intType) {
		var arrType = new Array();

		//Formats Type and values
		//SSN 999-99-9999
		arrType[0] = new Array();
		arrType[0][0] = new Array(2, 5);
		arrType[0][1] = new Array("-", "-");
		//Phone Type 1 999-999-9999
		arrType[1] = new Array();
		arrType[1][0] = new Array(2, 6);
		arrType[1][1] = new Array("-", "-");
		//Phone Type 2 (999)999-9999
		arrType[2] = new Array();
		arrType[2][0] = new Array(0, 3, 7);
		arrType[2][1] = new Array("(", ")", "-");
		//RLN 07112003-155248-0906
		arrType[3] = new Array();
		arrType[3][0] = new Array(7, 14);
		arrType[3][1] = new Array("-", "-");
		return arrType[intType];
}
/*********************************************************************************************************
Name: isEmpty
Desc: Check to see if value has a value
Param:
Input: objEleVal - Item to check
Output: true - value is empty, false - value is not empty
*********************************************************************************************************/
function isEmpty(objEleVal) {
	if(objEleVal == "" || objEleVal == " " || objEleVal == null) { return true; }
	else { return false; }
}

function FormatPhone(control)
{
    if(control != null && control.value != null)
    {
        var value = control.value;
        value = value.replace(/[^0-9]/g, '');
        if(value.length >= 10)
        {
            value = value.substr(0, 10);
            value = value.substr(0, 3) + '-' + value.substr(3, 3) + '-' + value.substr(6, 4);
        }
        else if(value.length >= 7)
        {
            value = value.substr(0, 7);
            value = value.substr(0, 3) + '-' + value.substr(3, 4);
        }
       
        control.value = value;
    }
}
function expandJoke(jokeID)
{
	if (document.getElementById(jokePrefix + "jokeContent" + jokeID).style.display == "")
	{
		document.getElementById(jokePrefix + "jokeContent" + jokeID).style.display = "none";
	}
	else
	{
		for (var i = 0; i < jokeCount; i++)
		{
			document.getElementById(jokePrefix + "jokeContent" + i).style.display = "none";
		}
		document.getElementById(jokePrefix + "jokeContent" + jokeID).style.display = "";
	}
}

function alertLeavingSite() 
{
	return confirm("This link is provided as a convenience.  By clicking OK below, you will be leaving VirtualBank's website and connecting to a third-party website which is not affiliated with VirtualBank and may use a different privacy policy and security level than VirtualBank.");
}

function toggleVisibile(id) {
	var control = (typeof (id) == 'string') ? document.getElementById(id) : id;
	control.style.display = (control.style.display == 'none') ? '' : 'none';
}

function closeModalDialog(modalDalogResult) {
	if (parent.$ != null) //prevent error if page is not displayed in a modal popup.
	{
		parent.$.fancybox.modalDalogResult = modalDalogResult;
		parent.$.fancybox.close();
	}
}

function showModalDialog(url, width, height, onCloseHandler) {
	$.fancybox.modalDalogResult = LPBEnum.DialogResult.Cancel;

	var popupTrigger = $('#popupTrigger');
	if (popupTrigger.length == 0) {
		$('body').append('<a id="popupTrigger" href="ModalDlgHandler.axd?dlgPanel=' + url + '" />');
		popupTrigger = $('#popupTrigger');
	}
	else {
		popupTrigger.attr('href', 'ModalDlgHandler.axd?dlgPanel=' + url);
	}

	popupTrigger.fancybox({
		'width': (width != null) ? width : 400,
		'height': (height != null) ? height : 200,
		'autoScale': false,
		'padding': 4,
		'overlayOpacity': .8,
		'titleShow': true,
		'titlePosition': 'inside',
		'titleFormat': function() { return '<div id="fancybox-title-logo">&nbsp;</div>'; },
		'showCloseButton': true,
		'centerOnScroll': true,
		'transitionIn': 'none',
		'transitionOut': 'none',
		'type': 'iframe',
		'onComplete': function() {
			$('#fancybox-loading').show();

			$('#fancybox-frame').load(function() {
				$('#fancybox-loading').hide();
			});
		},
		'onClosed': function() { if (onCloseHandler != null) onCloseHandler($.fancybox.modalDalogResult); }
	}).click();

	return false;
}

//Begin LPBEnum construction.
function LPBEnum() { }
LPBEnum.DialogResult = { Ok: 0, Cancel: 1 };
//End LPBEnum construction.

var SWFStorage =
{
	storageId: 'SWFStorage',
	flashObject: null,

	ready: function(callback) {
		$(this).bind('readyEvt', callback);
	},

	init: function() {
		if (document.getElementById) {
			this.flashObject = document.getElementById(this.storageId);
		}

		$(this).trigger('readyEvt', this);
	},

	isEnabled: function() {
		if (this.flashObject != null) {
			return this.flashObject.isEnabled();
		}
		return false;
	},

	getValue: function(key) {
		if (this.isEnabled()) {
			return this.flashObject.getValue(key);
		}

		return null;
	},

	setValue: function(key, val) {
		if (this.isEnabled()) {
			this.flashObject.setValue(key, val);
		}
	},

	deleteValue: function(key) {
		if (this.isEnabled()) {
			this.flashObject.deleteValue(key);
		}
	}
};

function SWFStorageReady() {
	SWFStorage.init();
}

/* VB Banner BEGIN */
var bannerWidth = -900;

var vbanner = {

	getSlide: function(id) {
		var scootOver = bannerWidth * (id - 1) + "px";
		$('#slide_container').animate({
			'left': scootOver
		}, 800);
	}
}
/* VB Banner END */


