	/**
	 * getPageSize() by quirksmode.com
	 *
	 * @return Array Return an array with page width, height and window width, height
	 */
	function getPageSize() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth;
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = xScroll;
		} else {
			pageWidth = windowWidth;
		}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	};

	function onFocusSearchSearch() {
		if ( $("input[id='form_s_search']").val() == 'Search CNB' ) {
			$("input[id='form_s_search']").val('');
		}

		return false;
	};

	function onSubmitFormOnlineBankingLoginSubmit() {
		if ( $("input[name='loginTo']:checked").val() == 'ecorp' ) {
			if ( $("input[id='form_obl_access_id']").val() != '' ) {
				$("form[id='form_obl']").attr('action', 'https://web4.secureinternetbank.com/ebc_ebc1961/EBC1961.ASP?Rt=072402694&WCE=RemoteLogon&WCI=Process');
				$("input[id='form_obl_nmpwd']").val('');
				$("input[id='form_obl_nmrtn']").val('072402694');
				$("input[id='form_obl_nmuid']").val($("input[id='form_obl_access_id']").val());
				$("input[id='form_obl_access_id']").val('');

				return true;
			}
		} else {
			if ( $("input[id='form_obl_access_id']").val() != '' ) {
				$("form[id='form_obl']").attr('action', 'https://web4.secureinternetbank.com/pbi_pbi1961/pbi1961.asp?LogonBy=Connect3&PRMACCESS=Account&Rt=072402694&WCI=RemoteLogin');
				$("input[id='form_obl_nmpwd']").val('');
				$("input[id='form_obl_nmrtn']").val('');
				$("input[id='form_obl_nmuid']").val('');

				return true;
			}
		}

		return false;
	};

	function onSubmitFormSearchSubmit() {
		if ( $("input[id='form_s_search']").val() == 'Search CNB' ) {
			return false;
		}
	};

	$().ready(function() {
		$("#content").append('<div id="speedbump-panel"><h3>You are now leaving County National Bank\'s website.</h3><p>County National Bank does not provide, and is not responsible for, the product, service, or overall website content available at the site to which you are going. The privacy policy of the site to which you are going may differ from County National Bank\'s privacy policy. To remain at our site, click cancel. To leave our site for the link you selected, click ok.</p><p id="speedbump-url"></p><a class="button" href="#" id="speedbump-ok" target="_blank">Ok</a><a class="button" href="#" id="speedbump-cancel">Cancel</a></div>');
		$("#content").append('<div id="speedbump-background"></div>');

		$("a").click(function() {
			if ( this.id === 'speedbump-ok' ) {
				$("#speedbump-background, #speedbump-panel").fadeOut(300);

				return true;
			}

			var href = $(this).attr('href');
			var linkIndex = href.search('^/leaving');

			if ( linkIndex === 0 ) {
				var arrPageSize = getPageSize();
				href = unescape(href.substr(linkIndex + 13));

				$("#speedbump-ok").attr('href', href);
				$("#speedbump-url").html(href);
				$("#speedbump-background").css({
					height: arrPageSize[1],
					width: arrPageSize[0]
				});
				$("#speedbump-background, #speedbump-panel").fadeIn(300, function() {
					$("#speedbump-background").css("filter", "alpha(opacity=80)");
				});

				return false;
			}

			linkIndex = href.search('^/about/offices_atms/');
			var urlIndex = location.href.search('^h.*/about/offices_atms.*');

			if ( ( linkIndex === 0 ) && ( urlIndex === 0 ) ) {
				return false;
			}

			return true;
		});

		$("a#speedbump-cancel").click(function() {
			$("#speedbump-background, #speedbump-panel").fadeOut(300);
		});
	});

