var windowState = (function(){
var readScroll = {scrollLeft:0,scrollTop:0};
var readSize = {clientWidth:0,clientHeight:0};
var readScrollX = 'scrollLeft';
var readScrollY = 'scrollTop';
var readWidth = 'clientWidth';
var readHeight = 'clientHeight';

function otherWindowTest(obj){
if((document.compatMode)&&
(document.compatMode == 'CSS1Compat')&&
(document.documentElement)){
return document.documentElement;
}else if(document.body){
return document.body;
}else{
return obj;
}
};
if((typeof this.innerHeight == 'number')&&
(typeof this.innerWidth == 'number')){
readSize = this;
readWidth = 'innerWidth';
readHeight = 'innerHeight';
}else{
readSize = otherWindowTest(readSize);
}
if((typeof this.pageYOffset == 'number')&&
(typeof this.pageXOffset == 'number')){
readScroll = this;
readScrollY = 'pageYOffset';
readScrollX = 'pageXOffset';
}else{
readScroll = otherWindowTest(readScroll);
}
return {
getScrollX:function(){
return (readScroll[readScrollX]||0);
},
getScrollY:function(){
return (readScroll[readScrollY]||0);
},
getWidth:function(){
return (readSize[readWidth]||0);
},
getHeight:function(){
return (readSize[readHeight]||0);
}
};
})();
var viewPortWidth = windowState.getWidth();
var viewPortHeight = windowState.getHeight();
var horizontalScroll = windowState.getScrollX();
var verticalScroll = windowState.getScrollY();


<!--
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.0
  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 && document.getElementById) x=document.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 redirect(select) {
	var page = select.options[select.selectedIndex].value;
	document.location.href = page;
}

/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function LTrim(str) {
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...
      var j=0, i = s.length;
      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

/*
==================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function RTrim(str) {
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...
      var i = s.length - 1;       // Get length of string
      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }
   return s;
}

/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(str){
   return RTrim(LTrim(str));
}

var timerId;

function divWait() {
	if (waitDiv.style.visibility == "visible") {
		waitDiv.style.visibility = "hidden";
	}
	else {
		waitDiv.style.visibility = "visible";
	}
	timerId = setTimeout("divWait()", 1000);
}

function checkEmail (what) {
    var strng = what.value;
    var error="";
    if (strng == "") {
       error = "You didn't enter an email address.\n";
    }
        var emailFilter=/^.+@.+\..{2,3}$/;
        if (!(emailFilter.test(strng))) {
           error = "Please enter a valid email address.\n";
        }
        else {
    //test email for illegal characters
           var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
             if (strng.match(illegalChars)) {
              error = "The email address contains illegal characters.\n";
           }
        }
    if (error != "") {
        alert(error);
        return false;
    }
    else {
        return true;
    }
}

// phone number - strip out delimiters and check for 10 digits
function checkPhone (what) {
	var strng = what.value;
	var error = "";
	if (strng == "") {
	   error = "You didn't enter a phone number.\n";
	}

	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
		if (isNaN(parseInt(stripped))) {
		   error = "The phone number contains illegal characters.";
		}
		if (!(stripped.length == 10)) {
		error = "The phone number is the wrong length. Make sure you included an area code.\n";
		}
	if (error != "") {
		alert(error);
	}
}

// password - between 6-8 chars, uppercase, lowercase, and numeral
function checkPassword (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a password.\n";
}
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    }
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
    }
return error;
}

// username - 4-10 chars, uc, lc, and underscore only.
function checkUsername (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a username.\n";
}
    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 10)) {
       error = "The username is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The username contains illegal characters.\n";
    }
return error;
}

// non-empty textbox
function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "The mandatory text area has not been filled in.\n"
  }
return error;
}

// was textbox altered
function isDifferent(strng) {
var error = "";
  if (strng != "Can\'t touch this!") {
     error = "You altered the inviolate text area.\n";
  }
return error;
}

// exactly one radio button is chosen
function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;
}

// valid selector from dropdown list
function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option from the drop-down list.\n";
    }
return error;
}

function required(what, label) {
	if (what.value == "") {
		alert(label + " is required!");
        return false;
	}
    return true;
}

function displayAbout() {
	if (aboutDiv.style.display == 'none') {
		aboutDiv.style.display = '';
	}
	else {
		aboutDiv.style.display = 'none';
	}
}

function displayHappenings() {
	if (happeningsDiv.style.display == 'none') {
		happeningsDiv.style.display = '';
	}
	else {
		happeningsDiv.style.display = 'none';
	}
}

function showDiv(theDiv) {
	var what = document.all[theDiv];
	if (what) {
		what.style.display = 'block';
	}
}

function hideDiv(theDiv) {
	var what = document.all[theDiv];
	if (what) {
		what.style.display = 'none';
	}
}

function displayDiv(whatStr) {
	var what = document.all[whatStr];
	if (what) {
		if (what.style.display == 'none') {
			what.style.display = 'block';
		}
		else {
			what.style.display = 'none';
		}
	}
}

function getMap() {
	var win = window.open(
		"http://www.mapquest.com/maps/map.adp?city=Fridley&state=MN&address=61%2BMississippi%2BWay%2BNE&zip=55432&country=us&zoom=8",
		"MAPQUEST",
		"height=600, width=600, resizable");
}

var estaff = new Array(
					"dn.glesne",
					"j.niewald",
					"s.nocton",
					"h.schmitt",
					"t.anderson",
					"a.beseman",
					"d.diederich",
					"p.diederich",
					"l.fitzgerald",
					"e.mcintyre",
					"l.antoine",
					"g.haggberg",
					"t.colby",
					"n.larson",
					"l.niewald",
					"l.fraser",
					"b.montague",
					"b.connor",
					"l.johnson",
					"m.rosa",
					"e.wegscheid",
					"e.stoney");

var staff = new Array(
				"dave",
				"john",
				"scott",
				"harley",
				"terri",
				"annette",
				"deb",
				"paul",
				"lynnae",
				"eric",
				"lynn",
				"gail",
				"tom",
				"nancy",
				"lynette",
				"luann",
				"brian",
				"bekky",
				"leah",
				"marcia",
				"eldon",
				"erin");

var hostName = "redeemerfridley.org";

function sendTo(who) {
	var em = "";
	for (var i = 0; i < staff.length; i++) {
		if (staff[i] == who) {
			em = estaff[i];
			break;
		}
	}
	
	document.write(
		"<a href=" + "mail" + "to:" + em +
		"@" + hostName + ">" + em + "@" + hostName + "</a>")
}

function loadNews() {
    var divId = document.getElementById("news");
    if (divId) {
        var newsCall = new net.ContentLoader(
            "/news/get_news.html",
            loadDiv,
            errorHandler,
            "html",
            "news",
            "POST");        
    }
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ) {
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y ) {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function delete_cookie ( cookie_name ) {
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function get_cookie ( cookie_name ) {
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

/**
 ** Used for lightbox effects
 **/
function loadFailure() {

}

function getWidthAndHeight() {
	var div = document.getElementById("light");
	div.style.width = (this.width) + "px";
	div.style.height = (this.height + 40) + "px";
	div.style.marginLeft = -((this.width) / 2) + "px";
	div.style.marginTop = -((this.height + 40) / 2) + "px";
}

function showLightbox(img) {
	//var myImage = new Image();
	//myImage.name = "Vision Night";
	//myImage.onload = getWidthAndHeight;
	//myImage.onerror = loadFailure;
	//myImage.src = img;
	var theDiv = findObj('light');
	var divW = parseInt(theDiv.style.width);
	var divH = parseInt(theDiv.style.height);
	var hPos = Math.round(horizontalScroll+((viewPortWidth-divW)/2));
	var vPos = Math.round(verticalScroll+((viewPortHeight-divH)/2));
	hPos = (hPos < 0)?0:hPos;
	vPos = (vPos < 0)?0:vPos;
	theDiv.style.top = vPos + "px";
	theDiv.style.left = hPos + "px";
	theDiv.style.display='block';		
	document.getElementById('fade').style.display='block';
}

function hideLightbox() {
	if (document.getElementById('light')) document.getElementById('light').style.display='none';
	if (document.getElementById('fade')) document.getElementById('fade').style.display='none'
}

function loadVideo() {
	hideLightbox();
	window.open("/resources/video/vision_night_video.jsp", null, "height=360,width=400,status=no,titlebar=no,toolbar=no,menubar=no,location=no");
}

function findObj(id){
	var obj = null;
	if(document.getElementById){
		obj = document.getElementById(id);
	}
	else if(document.all){
		obj = document.all[id];
	}
	else if(document.layers){
		obj = document.layers[id];
	}
	return obj;
}
