function Checkmail()
{
var Email, Email2;

Email=document.getElementById("email_addy").value;
Email2=document.getElementById("reenter_email_addy").value;

if(Email==Email2)
	{
	return true;
	}
else
	{
	alert("Email addresses do not match. Please try again.");
	document.getElementById("email_addy").value="";
	document.getElementById("reenter_email_addy").value="";
	document.getElementById("email_addy").focus();
	return false;
	}
}



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; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function Q2ExternalLink(){
	if(confirm("You are about to leave Kitsap Bank's website. Third party websites are not covered by Kitsap Bank's Privacy Policy or security measures, nor does Kitsap Bank endorse, offer, guarantee or recommend any product or service offered on a third party website.")){
		return true;
	} else {
		return false;
	}
}

function Q2Email(){
	if(confirm("Electronic mail is not secure or confidential. Personal information should not be communicated in this manner.")){
		return true;
	} else {
		return false;
	}
}

function CheckBoxCheck(type){
	if(type == 0){
		if(document.Q2OnlineLogin.forgot_password[0].checked){
			document.Q2OnlineLogin.forgot_password[1].checked = false;
			document.Q2OnlineLogin.password.disabled = true;
			document.Q2OnlineLogin.password.style.backgroundColor = "#E5E5E5";
		} else {
			document.Q2OnlineLogin.password.disabled = false;
			document.Q2OnlineLogin.password.style.backgroundColor = "#FFFFFF";
		}
	} else if(type == 1){
		if(document.Q2OnlineLogin.forgot_password[1].checked){
			document.Q2OnlineLogin.forgot_password[0].checked = false;
			document.Q2OnlineLogin.password.disabled = true;
			document.Q2OnlineLogin.password.style.backgroundColor = "#E5E5E5";
		} else {
			document.Q2OnlineLogin.password.disabled = false;
			document.Q2OnlineLogin.password.style.backgroundColor = "#FFFFFF";
		}
	}
}

function KitsapLoginCheck(){
	if(isReturn(event)){loginSite(); return false;}
}

function setStartTimeNow()
{
 var d = new Date();
 var currYear = d.getFullYear();
 var currMonth = d.getMonth() + 1;
 var currDate = d.getDate();
 var currHour = d.getHours();
 var currMin = d.getMinutes();
 time = currYear + "-" +
     (currMonth < 10 ? "0" : "") + currMonth + "-" +
     (currDate < 10 ? "0" : "") + currDate + " " +
     (currHour < 10 ? "0" : "") + currHour + ":" +
     (currMin < 10 ? "0" : "") + currMin;
 
 theInput = document.getElementById("date");
 theInput.value = time;
}

function KitsapSearch(){
	if(isReturn(event)){searchSite('searchBox'); return false;}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function RateSelectProduct(t){
	if(t.value == "TC"){
		document.getElementById("RateSelectTerm").style.visibility = "visible";
	} else {
		document.getElementById("RateSelectTerm").style.visibility = "hidden";
		document.getElementById("RatesIframe").src = "default.aspx?v=" + t.value + "&t=blank";
	}
}

function TextCounter(field, cntfield, maxlimit) {
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    } else {
        cntfield.value = maxlimit - field.value.length;
    }
}

function RateSelectTerm(t){
	document.getElementById("RatesIframe").src = "default.aspx?v=" + t.value + "&t=blank";
}

function changeText(text){
	document.getElementById('EventPreview').innerHTML = text;
	document.getElementById('EventPreview2').innerHTML = text;
	document.getElementById('EventPreview3').innerHTML = text;
	//document.getElementById('EventPreview4').innerHTML = text;
	//document.getElementById('EventPreview5').innerHTML = text;
	
	if(text == "concern"){
		document.getElementById("Concern").style.visibility = "visible";
		document.getElementById("Concern").style.position = "relative";
		document.getElementById("ConcernDD").style.visibility = "visible";
		document.getElementById("ConcernDD").style.position = "relative";
		document.getElementById("ComplimentDD").style.visibility = "hidden";
		document.getElementById("ComplimentDD").style.position = "absolute";
	} else {
		document.getElementById("ComplimentDD").style.visibility = "visible";
		document.getElementById("ComplimentDD").style.position = "relative";
		document.getElementById("Concern").style.visibility = "hidden";
		document.getElementById("Concern").style.position = "absolute";
		document.getElementById("ConcernDD").style.visibility = "hidden";
		document.getElementById("ConcernDD").style.position = "absolute";
	}
}

     function updateDisclosures()
    {
        var disclosures = [{which:'a', show:false},
                           {which:'b', show:false},
                           {which:'c', show:false},
                           {which:'d', show:false},
                           {which:'e', show:false},
                           {which:'f', show:false}];
                           
        var application_type = $('application_type');
        //check Application Type
        if(application_type)
        {
            if(application_type.selectedIndex == 1 |
               application_type.selectedIndex == 2 |
               application_type.selectedIndex == 3)
               {
                disclosures[0].show = true;
                disclosures[1].show = true;
                disclosures[2].show = true;
               }
               
            //show secondary applicant
            var cosigner = $('cosigner');
            var questions_secondary = $('questions_secondary');
            if(cosigner && questions_secondary)
            {
                if(application_type.selectedIndex == 2 |
                   application_type.selectedIndex == 3)
                {
                    cosigner.show();
                    questions_secondary.show();
                }
                else
                {
                    cosigner.hide();
                    questions_secondary.hide();
                }
            }
            
        }
        
        var loan_type = $('loan_type');
        //check Loan Type
        if(loan_type)
        {
            if(loan_type.selectedIndex == 2)
            {
                disclosures[3].show = true;
            }
            if(loan_type.selectedIndex == 12)
            {
                disclosures[5].show = true;
            }
        }
        
        var loan_purpose = $('loan_purpose');
        //check Loan Purpose
        if(loan_purpose)
        {
           //show government monitoring questions
            var government_monitoring_questions = $('government_monitoring_questions');
            if(government_monitoring_questions)
            {
                if(loan_purpose.selectedIndex == 7 |
                   loan_purpose.selectedIndex == 10 |
                   loan_purpose.selectedIndex == 14)
                {
                    government_monitoring_questions.show();
                }
                else
                    government_monitoring_questions.hide();
            }
        }
        
        var payment_protection = $('payment_protection');
        //check Loan Purpose
        if(payment_protection)
        {
            if(payment_protection.selectedIndex == 1)
               {
                disclosures[4].show = true;
               }
        }
        
        $('disclosures_section').removeClassName('on');
        
        for(var i = 0; i < disclosures.length; i++)
        {
            var disc = $('disc_' + disclosures[i].which);
            if(disclosures[i].show)
            {
                disc.addClassName('on');
                $('disclosures_section').addClassName('on');
            }
            else
                disc.removeClassName('on');
        }
    }


function updateDocuments()
    {
        var type_of_business = $('type_of_business');
        if(type_of_business)
        {
            var which = $('biz_type_' + type_of_business.selectedIndex);
            if(which)
            {
                var parent = which.up(0);
                var list = parent.select('tr');
                list.each(function(s) {
                    s.hide();
                });
                which.show();
                which.addClassName('no_border');
            }
            else
            {
                //show all documents
                var list = $$('table#documents tr');
                list.each(function(s) {
                    s.removeClassName('no_border');
                    s.show();
                });
            }
        }
    }

function moresignatures()
{
$('more_signers_form').hide();
}

var imageInfo = [
            {img: 1, caption: 'Kitsap County Bank, circa 1908.<br/>Located on the corners of Bay and Frederick Streets in Port Orchard, Washington.'},
            {img: 2, caption: 'The Bank\'s first branch location opened in 1961 on Wheaton Way in Bremerton, the site of Kitsap Bank\'s current East Bremerton branch.'},
            {img: 3, caption: 'Future site of Main Branch and Corporate Headquarters in Port Orchard. Landfill created north side of Bay Street circa 1947.'},
            {img: 4, caption: 'Frank E. Langer, Bank President 1930-1952<br/>The Langer family\'s involvement with Kitsap Bank spans from 1922 to present day.'},
            {img: 5, caption: 'Kitsap County Bank in 1955.'},
            {img: 6, caption: 'Famous Lawrence Welk Champagne Lady, Norma Zimmer, pictured with Hannah Langer at the grand opening of Kitsap Bank\'s Main Branch and Corporate Headquarters in Port Orchard in 1977.'},
            {img: 7, caption: 'Main Branch Grand Opening, Port Orchard (1977)'},
            {img: 8, caption: 'Historic downtown Port Orchard during a parade circa 1910.'},
            {img: 9, caption: 'Hannah Langer, Bank President 1952-1972'},
            {img: 10, caption: 'Hannah Langer, President; Helen Langer Smith, Board Member; and Clarence Largis, Executive Vice President, pictured at the Bank\'s 50th Anniversary in 1958.'},
            {img: 11, caption: 'Kitsap County Bank Employee Christmas Party in 1957.'},
            {img: 12, caption: 'Helen Langer, Board Member; John Williams, Manager East Bremerton Branch, and Hannah Langer, Chairman of the Board, pictured at the Bank\'s 80th Anniversary celebration in 1988.'},
            {img: 13, caption: 'Directors of Kitsap County Bank circa 1909, gathered in original Kitsap County Bank location.'},
            {img: 14, caption: 'Inside Kitsap County Bank\'s original location on the corner of Bay and Frederick Streets in Port Orchard. Pictured:  Frank E. Langer (left) and Roy Noyes (right) circa 1928.'} ];

function showCaption(img)
        {
            var mainImage = $('history_image');
            var caption = $('history_caption');
            //line below needs to be changed to the correct location of the images
            mainImage.src = 'Images/History/kitsap_pic_' + img + '.jpg';
            caption.update(imageInfo[img-1].caption);
        }

/**
 * SWFObject v1.4.2: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i=0; i < objects.length; i++) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = null;
			}
		}
	}
}
if (typeof window.onunload == 'function') {
	var oldunload = window.onunload;
		window.onunload = function() {
		deconcept.SWFObjectUtil.cleanupSWFs();
		oldunload();
	}
} else {
	window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;

function validateData(t){





	var checkMessage = "";
	var checkMessageField = "";
	var validateCount = 0;
	var requiredCount = 0;
	for (i=0; i<t.length; i++) {
		if (t[i].alt == undefined){
			Alt = "0";
		} else {
			Alt = t[i].alt;
		}
		if(t[i].value == "" && Alt.indexOf("req") != -1 && t[i].type != "checkbox"){
			t[i].className = "ReqField";
			requiredCount = requiredCount + 1;
		} else if(t[i].type == "checkbox" && Alt.indexOf("req") != -1){
			if(!t[i].checked){
				t[i].className = "ReqField";
				requiredCount = requiredCount + 1;
			} else {
				t[i].className = "";
			}
		} else if(Alt.indexOf("ssn") != -1 && t[i].value != ""){
			if(checkSSN(t[i].value)){
				t[i].className = "";
			} else {
				validateCount = validateCount + 1;
				checkMessageField = t[i];
				checkMessage = "The Social Security Number you entered does not appear to be valid.\n\nPlease enter it in the format: 000-00-0000";
			}
		} else if(Alt.indexOf("phone") != -1 && t[i].value != ""){
			if(checkPhone(t[i].value)){
				t[i].className = "";
			} else {
				validateCount = validateCount + 1;
				checkMessageField = t[i];
				checkMessage = "The Phone Number you entered does not appear to be valid.\n\nPlease enter it in the format: (000) 000-0000 x0000";
			}
		} else if(Alt.indexOf("email") != -1 && t[i].value != ""){
			if(checkEmail(t[i].value)){
				t[i].className = "";
			} else {
				validateCount = validateCount + 1;
				checkMessageField = t[i];
				checkMessage = "The Email Address you entered does not appear to be valid.\n\nPlease enter it in the format: johndoe@somewhere.com";
			}
		} else if(Alt.indexOf("zip") != -1 && t[i].value != ""){
			if(checkZip(t[i].value)){
				t[i].className = "";
			} else {
				validateCount = validateCount + 1;
				checkMessageField = t[i];
				checkMessage = "The Zip Code you entered does not appear to be valid.\n\nPlease enter it in the format: 00000 or 00000-0000";
			}
		} else {
			t[i].className = "";
		}
	}

	if(requiredCount != 0){
		alert("Please complete all required fields before submitting your application.");
		return false;
	} else if(validateCount != 0){
		checkMessageField.className = "ReqField";
		alert(checkMessage);
		return false;
	}else {
		return true;
	}
}


function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked == true) {cnt = i; i = -1;}
    }
    if (cnt > -1) {return true;}
    else {

alert('Please select an option.');
return false;}
}


function bigvalidate(t){
if( valButton(document.form1.radio) == false){ return false;}

return true;



}