var theImages = new Array() // 
theImages[0] = 'images/images1.jpg' 
theImages[1] = 'images/images2.jpg'  
theImages[2] = 'images/images3.jpg' 
theImages[3] = 'images/images4.jpg' 
theImages[4] = 'images/images5.jpg' 
// ======================================
// do not change anything below this line
// ======================================
var j = 0
var p = theImages.length;

var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
	document.write('<img src="'+theImages[whichImage]+'">');
}
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];}}
}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Non-destructive way to add new functions to the window.onload event
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload !== 'function') {
    window.onload = func;
  } else {
    window.onload = function () {
      oldonload();
      func();
    };
  }
}
function addUnLoadEvent(func) {
	var oldonload = window.onunload;
	if (typeof window.onunload !== 'function') {
		window.onunload = func;
	} else {
		window.onunload = function() {
			oldonunload();
			func();
		};
	}
}
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} else {
		elm['on' + evType] = fn;
	}
}

/* =Window Functions
----------------------------------------------- */
function windowFunctions() {
	if (!document.getElementsByTagName) { return false; }
	var links, i;
	links = document.getElementsByTagName("a");
	for (i = 0; i < links.length; i++) {
		if (links[i].className.match("extLink")) {
			links[i].onclick = function() {
				disclaimer(this.href);
				return false;
			};
		}
		if (links[i].className.match("emailLink")) {
			links[i].onclick = function() {
				mailConfirm(this.href);
				return false;
			};
		}
		if (links[i].className.match("testBrowser")) {
			links[i].onclick = function() {
				window.open(this.href,'securityAdvisor','scrollbars=yes,resizable=yes,width=400,height=450');
				return false;
			};
		}
		if (links[i].className.match("calcLink")) {
			links[i].onclick = function() {
				window.open(this.href,'calculators','scrollbars=yes,resizable=yes,width=640,height=480');
				return false;
			};
		}
		if (links[i].className.match("newWindow")) {
			links[i].onclick = function() {
				window.open(this.href);
				return false;
			};
		}
	}
}
addLoadEvent(windowFunctions);

/* =Disclaimers
----------------------------------------------- */
function mailConfirm(passedAddress) {
	if (confirm("You are about to send information over the internet that may not be transmitted in an encrypted or secure form. It might be possible for others to see what you are sending. For your protection, please do not send any personal information (i.e. Social Security Number, account number, date of birth, etc.) We cannot address account related or personal information through non-secure email.")) {
		window.location.href = passedAddress;
	}
}

function disclaimer(passedWebsite) {
	var oWin;
	if (confirm("You are leaving the Decatur State Bank web site. Please be advised that Decatur State Bank makes no endorsements or recommendations of the web site or its contents and disclaims any responsibility for actions or transactions on this site. Be aware that the privacy policy of the linked web site is not that of Decatur State Bank.")) {
		oWin = window.open(passedWebsite,"newWindow");
		if (oWin === null || typeof(oWin) === "undefined") {
			window.location.href = passedWebsite;
		} else {
			return true;
		}
	}
}
function evalLink(linkURL,linkTarget,disclaimerFlag,disclaimerText) {
	var regexp = /&quote;/g;
	disclaimerText = disclaimerText.replace(regexp,"\"");
	switch(linkTarget) {
		case 0: //Same window
			if(disclaimerFlag == 1) {
				if(confirm(disclaimerText)) window.location = linkURL;
			}
			else window.location = linkURL;		
		break;
		case 1: // New Window
			if(disclaimerFlag == 1) {
				if(confirm(disclaimerText)) window.open(linkURL);
			}
			else window.open(linkURL);		
		break;
		case 2: // Popup Window
			if(disclaimerFlag == 1) {
				if(confirm(disclaimerText)) void myOpen(linkURL,500,500);
			}
			else void myOpen(linkURL,500,500);
		break;
	}
}
function myOpen(page,width,height) {
	 if (navigator.appName == 'Netscape') {
		  adjWidth = width+10;
		  adjHeight = height+10;
	 } else {
		  adjWidth = width;
		  adjHeight = height;
	 }
	 window.open(page,'windowName','width=' + adjWidth + ',height=' + adjHeight + ',toolbar=no,location=no,directories=no,resizable=yes,status=yes,menubar=yes,scrollbars=yes');
}
