/* --------------------------------------------
Site:     Gateway 6
Author:   Bryan Sullivan
Version:  May 18, 2006
----------------------------------------------- */

/* =Base Functions
----------------------------------------------- */
function printCheck() {
	if (window.print) {
		window.print();
	} else { 
		alert("Your browser does not support this print function. Please hit CTRL-P if you are using windows, or APPLE/ALT-P if using a Mac.");
	}
}

function testBrowser() {
	window.open('https://www.banksafe.com/check.cfm','test','scrollbars=yes,resizable=yes,width=400,height=450');
}

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];}}
}

/* =Disclaimers
----------------------------------------------- */
function mailConfirm(passPrefix,passSuffix)
{
	if (confirm("Messages sent to this institution via e-mail are sent over the Internet and may not be transmitted in an encrypted or secure form. Caution is urged in the use of confidential information."))
	{
		if (passSuffix == "pesmail.com") passSuffix = "mybank.com";
		passedAddress = "mailto:" + passPrefix + "@" + passSuffix;
		window.location = passedAddress;
	}
}

function disclaimer(passedWebsite) {
	if(confirm("You are leaving this institution's web site.\r\rPlease be advised that this institution makes no endorsements or recommendations of the web site or its content and disclaims any responsibility for actions or transactions on the site.  This institution does not guarantee the accuracy, completeness, efficacy, or timeliness of the information contained therein.")) {
		window.open(passedWebsite,'NewWin','toolbar,status,resizable,location,scrollbars,menubar')
	}
}

/* =Online Banking FAQ Show/Hide Code
----------------------------------------------- */
function showFAQs(which){
	var container = document.getElementById("faqContainer");
	trigger = container.getElementsByTagName("dd").item(which).style.display;
	if (trigger=="block") trigger="none";
	else if (trigger=="" || trigger=="none") trigger="block";
	container.getElementsByTagName("dd").item(which).style.display=trigger;
}

function toggleAllFAQs(which,state) {
    var elemList=document.getElementById("faqSection" + which).getElementsByTagName("dd");
    for(i = 0; i < elemList.length; i++){
	    if (state == 1) { 
				elemList[i].style.display="block";
			} else {
				elemList[i].style.display="none";
			}
    }
	return false;
}

/* =Image Rotator
----------------------------------------------- */
/*
Other values (fadeTime, holdTime, and imageCount
are set in the coldfusion code since they are DB-driven

<img> tags are written by coldfusion based on images
that are set to "show".
*/

/*default parameters*/
oldImage = 0;
imagePos = 0;
/*controls speed of rotation and processor usage*/
stepsPerFade = 40;
var numSteps;
var intervalID;
/*multiplier used to determine opacity value at each step*/
fadeMult = 100/stepsPerFade;
i=0;

/*function to change counter for next image selection*/
function swapImages() {
	oldImage = imagePos;
	imagePos++;
	numSteps = stepsPerFade;
	if(imagePos == imageCount) imagePos = 0;
	setTimeout("fadeImages()", holdTime);
}
/*function to fade images based on step*/
function fadeImages() {
	intervalID = setInterval("fadeLoop()",fadeTime/stepsPerFade);	
}
function fadeLoop(){
	/*fade out old image*/
	changeOpacity(numSteps*fadeMult,"myImg" + oldImage);
	/*fade in new image*/
	changeOpacity(100-numSteps*fadeMult,"myImg" + imagePos);
	numSteps = numSteps - 1;
	if(numSteps==0){
		clearInterval(intervalID);
		void swapImages();
	}
}
/*function to modify styles (e.g. - change fade/opacity)*/
function changeOpacity(opacity, id) {
	var object = document.getElementById(id).style;
	/*if statement used to avoid flicker that occurs at first and last step*/
	if(opacity>0 && opacity<100){
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	}
} 
/*
----------------------------------------------- */
