/* cookies.js */
/*
     Example File From "JavaScript and DHTML Cookbook"
     Published by O'Reilly & Associates
     Copyright 2003 Danny Goodman
*/

// utility function to retrieve a future expiration date in proper format;
// pass three integer parameters for the number of days, hours,
// and minutes from now you want the cookie to expire; all three
// parameters required, so use zeros where appropriate
function getExpDate(days, hours, minutes) {
    var expDate = new Date();
    if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
        expDate.setDate(expDate.getDate() + parseInt(days));
        expDate.setHours(expDate.getHours() + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
        return expDate.toGMTString();
    }
}

// utility function called by getCookie()
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}

// primary function to retrieve cookie by name
function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return null;
}

// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
// routines for displaying pictures in a series
//check to see if there's a cookie for whichImg
var whichImg = getCookie('whichImg');
	var cookieExp = getExpDate(365,0,0);
if (!whichImg) {
	setCookie('whichImg','0', cookieExp);
	whichImg = 0;
	whichImg = "0" + whichImg;	
}else{
	whichImg++;
	if (whichImg == 39) {
		whichImg = 0;
	}
	setCookie('whichImg',whichImg,cookieExp);
//		alert ('cookie value is: ' + whichImg);
	if(whichImg < 10) {
		whichImg = "0" + whichImg;
	}
//	alert ('whichImg = ' + whichImg);
}
//set image array

function getFHImage() {
	var output = "<img src='images/revolving/revolve-" + whichImg + ".jpg' alt='Founders Hall in Pictures' />";
	return output;
}
// routines for displaying pictures in a series on the 'About' page
//check to see if there's a cookie for whichImg
var whichImgA = getCookie('whichImgA');
	var cookieExpA = getExpDate(365,0,0);
if (!whichImgA) {
	setCookie('whichImgA','0', cookieExpA);
	whichImgA = 0;
}else{
	whichImgA++;
	if (whichImgA >= 2) {
		whichImgA = 0;
	}
	setCookie('whichImgA',whichImgA,cookieExpA);
//		alert ('cookie value is: ' + whichImgA);
}
//set image array
var imgLinksa = new Array("Founders-Hall.jpg", "Stairway-Chandellier.jpg");

function getFHImage_about() {
	var outputA = "<img src='../images/revolving/revolve-" + whichImg + ".jpg' width='400' height='300' alt='Founders Hall in Pictures' />";
	return outputA;
}
//set facts array and create function to display them
var fhFacts = new Array(

"\"I love going to Founders Hall. There is so much going on.\"", 	

"\"It is Ridgefield\'s sparkling gem!\"",  

"\"We who are members are truly blessed.\"", 

"\"I call it my \'private club\'\"", 

"\"Founders Hall has become my extended family.\"", 

"\"A wonderful gift for the 60 and over crowd!\"",  

"\"This place is my Life!\"", 

"\"Home away from Home\"",  

"\"Founders Hall is the reason I still stay in Ridgefield.\"",  
 
"\"Founders Hall has kept me busy through a hard grieving time.\"",

"\"The kindness and friendliness of everyone has really sustained me.\"",  

"\"I have met a lot of wonderful people.\"", 

 "\"Founders Hall seems too good to be true!\"",

"\"I honestly don\'t know what I would have done without this fabulous place.\"", 

"\"I can\'t say enough wonderful things about Founders Hall.\"",  

"\"I could not consider moving from Ridgefield because of Founders Hall.\"", 

"\"We are so fortunate to have this outstanding facility in our community.\"", 

"\"The staff is warm, friendly and personal.\"", 

"\"This is a place to meet new friends as well as to pursue interests.\"",  

 "\"I am constantly stimulated and energized by Founders Hall both mentally & physically.\"", 

 "\"Founders Hall contributes greatly to the quality of life in the larger Ridgefield community.\"",  

"\"Love coming here – a home away from home. Good courses – good friends.\"", 

 "\"Founders Hall has changed life for seniors here in Ridgefield.\"",  

"\"I am very grateful to be a member of this energetic, curious and decidedly upbeat senior community.\"",

"\"A beautiful place to come for body and soul\"", 

"\"Founders Hall is a huge asset in the community\"", 

"\"It\'s a place to meet & greet others – especially wonderful to meet one\'s peer group.\"",

"\"Founders Hall is a gift to all who enter the front door.\"", 

"\"I feel blessed to live in a community that offers so much to its seniors.\"", 

 "\"If it wasn\'t for Founders Hall I would not get the exercise I need.\"", 

"\"It is a wonderful place for seniors to get together with each other.\"", 

"\"Without Founders Hall, seniors would be sitting home bored.\"",  

 "\"My husband and I have made many friends and expanded our interests.\"", 

"\"Everyone is always warm and friendly.\"",  

"\"Everything here is first class and done with perfection.\"",

 "\"It has been a great addition to our lives!\"",  

 "\"Founders Hall is a wonderful gathering place for seniors.\"", 

"\"The town is enriched because of its presence.\"", 

 "\"The staff makes brand new as well as longtime members feel right at home.\"",  

  "\"It is a wonderful place to hang out and I do most days.\"", 

 "\"Founders Hall is a wonderful, welcoming place for seniors.\"",  

"\"It allows us a place to meet new friends, and to bond with one another.\"", 

"\"It is a never ending source of wonderful activities which enhance one\'s life.\"", 

"\"We have gone on many wonderful trips to places we might not have gone to otherwise.\"", 

 "\"The trips we take are wonderful.\"",

"\"The classes we take keep us healthy and our minds functioning.\"", 

 "\"The exercise classes restored balance and strength.\"",

 "\"The courses and instructors are outstanding\"", 

"\"The arts, global issues, exercises, new friendships enrich my life.\"", 

 "\"Being able to take an affordable, wonderful yoga class has made a huge difference in my life – physically and spiritually.\"", 

"\"The instructors are great and the people in our class are great!\"", 

 "\"The variety of classes offered is a gift that keeps on giving.\"",  

"\"The exercise instructors are caring and knowledgeable people.\"",  

 "\"There are many classes to pick from ranging from Aerobics to Zumba –something for everyone!\"", 

 "\"Each course is facilitated by talented dedicated instructors.\"", 

"\"The picnic and teas are wonderful. Thank you!\"", 

 "\"The Fitness classes here are designed to be challenging, yet safe.\"", 

"\"The speakers, programs and social activities are a great way to keep seniors informed and engaged.\"", 

  "\"Founders Hall gives me the chance to stay fit and in the game.\"",

"\"Tai Chi has been as beneficial to my mind as it is to my physique.\"", 

 
"\"The instructors are of top quality and experience and appear to enjoy teaching.\"",  

"\"I am constantly stimulated and energized by Founders Hall both mentally & physically.\"", 

"\"...a multiple of opportunities to become involved in activities missed during younger days.\"", 

"\"We can update ourselves with computer skills, investment options, foreign policy.\"", 

"\"We can enjoy a large range of programs on travel, opera, film, classical music, history.\"", 

"\"Staying/getting in shape is great with aerobics, strength/flexibility, dance! All at affordable costs.\"", 

"\"Founders Hall is keeping me healthy & happy!\"", 

"\"I never knew I could paint until I joined the art class.\"", 

"\"Founders Hall has introduced me to so much.\"",

 "\"I\'ve been introduced to a vibrant group of people all in one place.\"", 

"\"The staff and teachers, the individuals I\'ve met have added a new dimension to my life.\"",  

 "\"A great place to spend time exercising my body & brain.\"", 

 "\"I come to Founders Hall to improve my mind, my body and my spirit.\"", 

 "\"I enjoy the Strength & Balance class. It has made me stronger. I feel better.\"", 

"\"I enjoy the history class. It is very informative, interesting and fun.\"",

 "\"I come for the yoga which is wonderful.\""




	);

// routines for displaying facts in a series
//check to see if there's a cookie for whichFact
function getfhFacts() {
var whichFact = getCookie('whichFact');
if (!whichFact) {
	var cookieExp = getExpDate(365,0,0);
	setCookie('whichFact','0', cookieExp);
	whichFact = 0;
	return fhFacts[whichFact];
//	document.getElementById("fhNote").firstChild.nodeValue = fhFacts[whichFact];
}else{
	whichFact++;
//	document.getElementById("fhNote").firstChild.nodeValue = fhFacts[whichFact];
	if (whichFact == 76) {
		whichFact = 0;
	}
	setCookie('whichFact',whichFact,cookieExp);
	return fhFacts[whichFact];
//		alert ('cookie value is: ' + whichFact);
}
}

//set donor facts array and create function to display them
var donorFacts = new Array(
"\"I love going to Founders Hall. There is so much going on. I have good friends now. We dance together.\"",
"\"It is Ridgefield's sparkling gem!\"",
"\"We who are members are truly blessed.\"",
"\"Outstanding staff support this wonderful place.  I call it my 'private club'.\"",
"\"Founders Hall has become my extended family. I have met some wonderful new friends as well as reconnected with others in the community.\"",
"\"A wonderful gift for the 60 and over crowd!\"",
"\"This place is my Life!\"",
"\"Home away from Home\"",
"\"Founders Hall is the reason I still stay in Ridgefield.\"",
"\"Founders Hall has kept me busy through a hard grieving time and I am so thankful. The kindness and friendliness of everyone has really sustained me.\"",
"\"I have met a lot of wonderful people. THANK YOU  xoxoxoxo\"",
"\"Founders Hall seems too good to be true!  I honestly don't know what I would have done without this fabulous place.\"",
"\"I can't say enough wonderful things about Founders Hall.  It fills days with all kinds of wonderful fun and learning experiences.\"",
"\"I could not consider moving from Ridgefield because of Founders Hall.\"",
"\"We are so fortunate to have this outstanding facility in our community.\"",
"\"The staff is warm, friendly and personal.\"",
"\"This is a place to meet new friends as well as to pursue interests.\"",
"\"I am constantly stimulated and energized by Founders Hall both mentally & physically.\"",
"\"I feel part of a community.  In fact, Founders Hall contributes greatly to the quality of life in the larger Ridgefield community.\"",
"\"Love coming here - a home away from home. Good courses - good friends.\"",
"\"Founders Hall has changed life for seniors here in Ridgefield.\"",
"\"I am very grateful to be a member of this energetic, curious and decidedly upbeat senior community. Many Thanks.\"",
"\"The exercise classes restored balance and strength, the people and staff are welcoming and the facilities are spotless.\"",
"\"A beautiful place to come for body and soul\"",
"\"Founders Hall is a huge asset in the community\"",
"\"It's a place to meet & greet others - especially wonderful to meet one's peer group.\"",
"\"Founders Hall is a gift to all who enter the front door.\"",
"\"I feel blessed to live in a community that offers so much to its seniors.\"",
"\"If it wasn't for Founders Hall I would not get the exercise I need.\"",
"\"It is a wonderful place for seniors to get together with each other.\"",
"\"Without Founders Hall seniors would be sitting home bored.  Thank you for all you do for us.\"",
"\"My husband and I have made many friends and expanded our interests.\"",
"\"Everyone is always warm and friendly.\"",
"\"Everything here is first class and done with perfection.  It has been a great addition to our lives!\"",
"\"Founders Hall is a wonderful gathering place for seniors.\"",
"\"The town is enriched because of its presence.\"",
"\"The staff is extremely welcoming and makes brand new as well as longtime members feel right at home.\"",
"\"It is a wonderful place to hang out and I do most days.\"",
"\"Founders Hall is a wonderful, welcoming place for seniors.\"",
"\"It allows us a place to meet new friends, and to bond with one another.\"",
"\"It is a never ending source of wonderful activities which enhance one's life.\""
	);


// routines for displaying facts in a series
//check to see if there's a cookie for whichFact
function getDonorFacts() {
var donorFact = getCookie('donorFact');
if (!donorFact) {
	var cookieExp = getExpDate(365,0,0);
	setCookie('donorFact','0', cookieExp);
	donorFact = 0;
	return donorFacts[donorFact];
//	document.getElementById("fhNote").firstChild.nodeValue = fhFacts[whichFact];
}else{
	donorFact++;
//	document.getElementById("fhNote").firstChild.nodeValue = fhFacts[whichFact];
	if (donorFact == 40) {
		donorFact = 0;
	}
	setCookie('donorFact',donorFact,cookieExp);
	return donorFacts[donorFact];
//		alert ('cookie value is: ' + whichFact);
}
}
var programFacts = new Array(
"\"We have gone on many wonderful trips to places we might not have gone to otherwise.\"", 

"\"The trips we take are wonderful.\"",

"\"The classes we take keep us healthy and our minds functioning.\"", 

"\"The exercise classes restored balance and strength.\"",

"\"The courses and instructors are outstanding\"", 

"\"The arts, global issues, exercises, new friendships enrich my life.\"", 

"\"Being able to take an affordable, wonderful yoga class has made a huge difference in my life – physically and spiritually.\"", 

"\"The instructors are great and the people in our class are great!\"", 

"\"The variety of classes offered is a gift that keeps on giving.\"",  

"\"The exercise instructors are caring and knowledgeable people.\"",  

"\"There are many classes to pick from ranging from Aerobics to Zumba - something for everyone!\"", 

"\"Each course is facilitated by talented dedicated instructors.\"", 

"\"The picnic and teas are wonderful. Thank you!\"", 

"\"The Fitness classes here are designed to be challenging, yet safe.\"", 

"\"The speakers, programs and social activities are a great way to keep seniors informed and engaged.\"", 

"\"Founders Hall gives me the chance to stay fit and in the game.\"",

"\"Tai Chi has been as beneficial to my mind as it is to my physique.\"", 

 
"\"The instructors are of top quality and experience and appear to enjoy teaching.\"",  

"\"I am constantly stimulated and energized by Founders Hall both mentally & physically.\"", 

"\"...a multiple of opportunities to become involved in activities missed during younger days.\"", 

"\"We can update ourselves with computer skills, investment options, foreign policy.\"", 

"\"We can enjoy a large range of programs on travel, opera, film, classical music, history.\"", 

"\"Staying/getting in shape is great with aerobics, strength/flexibility, dance! All at affordable costs.\"", 

"\"Founders Hall is keeping me healthy & happy!\"", 

"\"I never knew I could paint until I joined the art class.\"", 

"\"Founders Hall has introduced me to so much.\"",

"\"I've been introduced to a vibrant group of people all in one place.\"", 

"\"The staff and teachers, the individuals I've met have added a new dimension to my life.\"",  

"\"A great place to spend time exercising my body & brain.\"", 

"\"I come to Founders Hall to improve my mind, my body and my spirit.\"", 

"\"I enjoy the Strength & Balance class. It has made me stronger. I feel better.\"", 

"\"I enjoy the history class. It is very informative, interesting and fun.\"",

"\"I come for the yoga which is wonderful. I love the others in my class and the instructors.\""

)
// routines for displaying facts in a series
//check to see if there's a cookie for whichFact
function getProgramFacts() {
var programFact = getCookie('programFact');
if (!programFact) {
	var cookieExp = getExpDate(365,0,0);
	setCookie('programFact','0', cookieExp);
	donorFact = 0;
	return programFacts[programFact];
//	document.getElementById("fhNote").firstChild.nodeValue = fhFacts[whichFact];
}else{
	programFact++;
//	document.getElementById("fhNote").firstChild.nodeValue = fhFacts[whichFact];
	if (programFact == 33) {
		programFact = 0;
	}
	setCookie('programFact',programFact,cookieExp);
	return programFacts[programFact];
//		alert ('cookie value is: ' + whichFact);
}
}
function getIFrameContent(whichPage) {
	document.getElementById("contentFrame").src = whichPage;
	return;
}
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}
function isEmpty(inputString) {
	if (inputString == null || inputString == "") {
		return true;
	}
	return false;
}
function checkFields(form) {
var errorMessage ="\n";
if (isEmpty(form.client_email.value)) {
errorMessage += "\nPlease enter your e-Mail address.";
}
if (form.client_email.value != "") {
	var holdemail = form.client_email.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!holdemail.match(re)) {
	errorMessage += "\nThe e-Mail address appears to be invalid, please re-enter it.";
	}
}
if (isEmpty(form.rvar_name.value)) {
errorMessage += "\nPlease enter your name.";
}
if (isEmpty(form.rvar_address.value)) {
errorMessage += "\nPlease enter your street address.";
}
if (isEmpty(form.rvar_cityState.value)) {
errorMessage += "\nPlease enter your city and state.";
}
if (isEmpty(form.rvar_zip.value)) {
errorMessage += "\nPlease enter your zip code.";
}
if (isEmpty(form.amount.value)) {
errorMessage += "\nPlease enter an amount.";
}

if (errorMessage == "\n") {
// After passing all edits, format currency amount field...
	form.amount.value = formatCurrency(form.amount.value);
//	alert("amount now is: " + form.amount.value);
	return true;
} else {
alert("We have noticed some missing information. Please complete the following and click the Login button to continue. Thank you." + errorMessage);
return false;
}
}

