
//Count down until any date script
//Parameters are: the count down date using the format year/month/day/
//the event name
//The start time hour/minute in 24 hour format  (13 = 2PM - so 2:30pm in the example below.)
//what to say on that day of the event
//the ID of a DIV you wish the countdown inserted into.
//				<div id="countdwn" class="redbold"></div>
//				<script>countdown(2010,06,23,13,30,"Quadrenial","Quadrenial Starts Today!","countdwn")</script>

function countdown(yr,m,d,hr,mi, before, current, divID){
	divEl = document.getElementById(divID);
	var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	theyear=yr;themonth=m;theday=d;thehour=hr;themin=mi;thebefore=before;thecurrent=current;thedivID=divID
	var today=new Date();
	var todayy=today.getYear();
	if (todayy < 1000)
		{
		todayy+=1900
		}
	var todaym=today.getMonth();
	var todayd=today.getDate();
	var todayh=today.getHours();
	var todaymin=today.getMinutes();
	var todaysec=today.getSeconds();
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
	futurestring=montharray[m-1]+" "+d+", "+yr+" "+hr+":"+mi;
	dd=Date.parse(futurestring)-Date.parse(todaystring);
	dday=Math.floor(dd/(60*60*1000*24)*1);
	dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
	dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
	dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
	if(dday==0)
		{
		divEl.innerHTML = current;
		return
		}
	if(dday<0)
		{
		dive1.innerHTML = "";
		return
		}
		
//		divEl.innerHTML = "Only "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" sec. left until "+before;
//		setTimeout("countdown(theyear,themonth,theday,thehour,themin,thebefore,thecurrent,thedivID)",1000)

		divEl.innerHTML = "Only "+dday+ " days, "+dhour+" hours, and "+dmin+" minutes left until "+before;
		setTimeout("countdown(theyear,themonth,theday,thehour,themin,thebefore,thecurrent,thedivID)",60000)

		
}

// To display a church map window call <a href='javascript:mapWndow(nn, 392)'>
// where nn is the congregation index number and 392 is the height of the window.

function mapWndow(cid, whi) {
	var h="http://www.gadisciples.org/main/Cong_map_one.asp?id=" + cid;
	window.open(h,null,"height=" + whi + ",width=304,status=no,toolbar=no,menubar=no,location=no");
}

// To display a church info window call <a href='javascript:infoWndow(nn, hh)'>
// where nn is the congregation index number and hh is the height of the window.
// Select hh to make enough room for the data - this is calculated when the map program calls
// this function - but if you call the function from another program - start with about 250.

function infoWndow(cid, wh) {
	var h="http://www.gadisciples.org/main/Cong_info.asp?id=" + cid;
	window.open(h,null,"height="+wh+",width=450,status=no,toolbar=no,menubar=no,location=no");
}

// To display a window explaining PayPal call <a href='javascript:PPWndow()'>

function ppWndow() {
	var h="http://www.gadisciples.org/main/PayPal_info.asp";
	window.open(h,null,"height=350,width=450,status=no,toolbar=no,menubar=no,location=no");
}

// Tests an E-mail address for reasonableness.
function isEmailValid(email) {
	return /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w{2,}$/.test(email);
	}
	
// Removes dangerous characters from input fields.
function trim(str){
     return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function jumpto(bn)
{
document.location=bn;
}

function helpto(bn)
{
window.open("documentation.asp#" + bn);
}
