// JavaScript Document

var undefined;



function LinkAlert(URL,target)

	{

	BankName = "United Bank of Iowa"
	MSG = "The " + BankName + " web site provides links to other web sites ";
	MSG = MSG + "for convenience and informational purposes only. Users should ";
	MSG = MSG + "be aware that when you select a link on the " + BankName + "'s web ";
	MSG = MSG + "site to an external web site, they are leaving " + BankName + "'s site.";
	MSG = MSG + "\n\n";
	MSG = MSG + "Linked sites are not under the control of " + BankName + ". ";
	MSG = MSG + BankName + " is not responsible for the contents of any linked site ";
	MSG = MSG + "or any link contained in a linked site, or any changes or updates ";
	MSG = MSG + "to such sites. The inclusion of a link does not imply endorsement ";
	MSG = MSG + "by " + BankName + " of the site, its content, advertisers or sponsors. ";
	MSG = MSG + "External sites may contain information that is copyrighted with ";
	MSG = MSG + "restrictions on reuse. Permission to use copyrighted materials must ";
	MSG = MSG + "be obtained from the original source and cannot be obtained ";
	MSG = MSG + "from " + BankName + ".";
	
	myTarget = "_blank";
	if (target!=undefined) myTarget = target;
	if (confirm(MSG)) window.open(URL,myTarget);
	}

function EmailAlert() {
	email_msg = "This email address is not secure. DO NOT send sensitive personal or financial information (such as SSNs, PIN, account numbers, etc.) using this email address. To send a SECURE message, please log into online banking. If you wish to proceed, click OK.";
	if (confirm(email_msg)) return true;
	return false;
	}

function LaunchCalcs(URL)
    	{
    	window.open(URL,'myCalculator','width=590,height=400,status=no,scrollbars=yes,toolbar=no,directories=no,resizable=yes');
    	}


	images = new Array();
	images[0] = "images/photos/Arthur.jpg";
	images[1] = "images/photos/Carroll.jpg";
	images[2] = "images/photos/CharterOak.jpg";
	images[3] = "images/photos/Churdan.jpg";
	images[4] = "images/photos/Denison.jpg";
	images[5] = "images/photos/FortDodge.jpg";
	images[6] = "images/photos/Glidden.jpg";
	images[7] = "images/photos/Harlan.jpg";
	images[8] = "images/photos/IdaGrove-Branch.jpg";
	images[9] = "images/photos/IdaGrove-MainOffice.jpg";
	images[10] = "images/photos/Kiron.jpg";
	images[11] = "images/photos/LakeCity.jpg";
	images[12] = "images/photos/Lohrville.jpg";
	images[13] = "images/photos/Odebolt.jpg";
	images[14] = "images/photos/RockwellCity.jpg";
	images[15] = "images/photos/Schleswig.jpg";
	images[16] = "images/photos/StormLake.jpg";

	
	
RotationType = 1; // 0 = random, 1=in the same order as images array 
var NowShowing = 0;
var SwitchTo = 0

function RandomImage() 
	{ 
	if (RotationType==0)
    	{
		seed = (images.length);
		SwitchTo = Math.floor(Math.random()*seed);
		}
	if (RotationType==1)
		{
		SwitchTo = NowShowing;
		NowShowing++;
		if (NowShowing==images.length) NowShowing=0;
		}
	document.splash.src = images[SwitchTo];
    setTimeout('RandomImage()',2500);
    }
	
function OpenWindow(URL,target,attributes)
	{
	if (target=="" || target==undefined) target="_self";
	if (attributes=="" || attributes==undefined) attributes = "width=450,height=350";
	window.open(URL,target,attributes);
	}

function date_stamp(format) {
	today = new Date();
	switch(format) {
		case "m/d/Y":
			today = update(0);
			break;
		default:
			today = update(0);
			break;
		}
	document.write(today);
	}

function update(num,element,xmonth)
	{
	// ******************************************
	// Generate a date based on an offset of today's date and return a MM/DD/YYYY formatted string.
	// This script is used for placing a current date in an HTML page without a form.
	// ******************************************

	now = new Date();
	date = now.getDate();
	if (isNaN(xmonth)) xmonth = 0;
	month = now.getMonth()+1+xmonth;
	lastMonth = month-1;
	year= now.getYear();
	date = (date - eval(num));
	if (month<=0)
		{
		if (month==0)
			{
			month = "12";
			year = year - 1;
			}
		else
			{
			month = month+12;
			year = year -1;
			}
		}
	if (date<=0)
		{
		month = month-1;
		if (month==0)
			{
			month = "12";
			year = year - 1;
			}
		if (month==2)
			{
			date = 28 + date;
			}
		if (month=="4" || month=="6" || month=="9" || month=="11")
			{
			date = 30 + date;
			}
		else
			{
			date = 31 + date;
			}
		}
		if (month>12)
			{
			month = "1";
			year = year + 1;
			}
	if (month==2 && date>28)
		{
		month = month + 1;
		date = date - 28;
		}
	if ((month=="4" || month=="6" || month=="9" || month=="11") && date>30)
		{
		month = month + 1;
		date = date - 30;
		}
	else
		{
		if (date>31)
			{
			month = month + 1;
			date = date - 31;
			}
		}
	if (year < 1000) year += 1900;
	//Building varchar date.
	if (month == "1") monthName="January";
	if (month == "2") monthName="February";
	if (month == "3") monthName="March";
	if (month == "4") monthName="April";
	if (month == "5") monthName="May";
	if (month == "6") monthName="June";
	if (month == "7") monthName="July";
	if (month == "8") monthName="August";
	if (month == "9") monthName="September";
	if (month == "10") monthName="October";
	if (month == "11") monthName="November";
	if (month == "12") monthName="December";
	myFullDate = monthName + " " + date + ", " + year;


	// Building numerical date.
	if (date<10)
		{
		date = "0" + date;
		}
	if (month<10)
		{
		dateStr= "0" + month + "/" + date + "/" + year;
		}
	else
		{
		dateStr = month + "/" + date + "/" + year;
		}
	myDate = dateStr;
	

	// Writing date to specified field.
	if (element == undefined) element=-1;
	if (element >= 0) document.dateform.elements[element].value = dateStr;
	return dateStr;
	}
