// JavaScript Document



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_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_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 doSearch() {

var what = document.getElementById('searchwhat').value;

if (what != "") {

MM_openBrWindow('http://www.google.com/search?ie=UTF-8&oe=UTF-8&q='+what+'&domains=www.joelsplacealaska.org&sitesearch=www.joelsplacealaska.org','mywindow','');
}

// window.open('http://www.google.com/search?ie=UTF-8&oe=UTF-8&q='+what+'&domains=www.joelsplacealaska.org&sitesearch=www.joelsplacealaska.org','mywindow');
}


var stop = 'no';

<!-- *************** Date Script ****************-->

	var months=new Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	var hrs=time.getHours();
	var mns=time.getMinutes();
	var ampm="AM";
	
	if (year < 2000)    // Y2K Fix, Isaac Powell
	year = year + 1900; // http://onyx.idbsu.edu/~ipowell

	date_str = lmonth + " " + date + ", " + year;
	
	
	if (hrs > 12) { 
		hrs = hrs - 12;
		ampm = "PM"; }
		
	if (mns.toString().length==1) { mns = "0" + mns; }
	
	if (hrs==0) { hrs=12; }
	
	time_str = hrs + ":" + mns + " " + ampm;


/*function doSearch() {

var what = document.getElementById('searchwhat').value;

var where = "http://www.google.com/search?ie=UTF-8&oe=UTF-8&q="+what+"&domains=www.doorofhopechurch.org&sitesearch=www.doorofhopechurch.org";

//window.open('http://www.google.com/search?ie=UTF-8&oe=UTF-8&q='+what+'&domains=www.doorofhopechurch.org&sitesearch=www.doorofhopechurch.org','DOH Site Search','status,menubar,scrollbars,resizable,height=600,width=800');

document.location = where;

// newWindow = window.open("someDoc.html","subWind","status,menubar,height=400,width=300");

}*/

// Image Randomizer
function randomImg(section) {

	
	if (section == "guest") { section = "welcome"; }
	if (section == "home") { section = "welcome"; }
	
	switch(section) {
		
		case "welcome"		: totalImgs = 13; break;
		case "about"		: totalImgs = 5; break;
		case "children"		: totalImgs = 7; break;
		case "youth"		: totalImgs = 6; break;
		case "adults" 		: totalImgs = 14; break;
		case "community" 	: totalImgs = 7; break;
		case "missions" 	: totalImgs = 25; break;
		case "giving"		: totalImgs = 3; break;		
		default			: totalImgs = 4; break;
		
	}
	
	// This is the randomizer for feature images
	var r = Math.round(Math.random()*totalImgs);
	if (r == 0) { r = 1; }
		
	
	var featureImg = "<img src='/" + section + "/images/photo_" + section + r + ".png' name='randimg' width='496' height='219' id='randimg' border='0' class='feature_img' alt='" +section + " header photo'>";
	
	
	if (navigator.appVersion.indexOf('Safari') != '-1') {
	// alert("this is Safari");
	}
	
	else
	
	{
	var img="";
	}
	

	return featureImg;
	
}


// QuickNav Machine for 'on this page' lists


var moved = "0";

function moveNav(direction) {

	if (direction == 'init') {
		document.getElementById('PageNavMenu').style.visibility='visible';
		document.getElementById('PageNavMenu').style.marginTop = "4px";  }
	
	if (direction == 'down' && moved == '0') { 
		document.getElementById('PageNavMenu').style.marginLeft = "-200px";
		document.getElementById('PageNavMenu').style.marginTop = "-280px";
		moved = "1"; }
		
	if (direction == 'up') { 
		document.getElementById('PageNavMenu').style.marginLeft = "0px";
		document.getElementById('PageNavMenu').style.visibility = "hidden";
		moved = "0"; }
		
}


function messagePop() {
	
	// alert("Note to registered subscribers of DOH newsletters: we are currently in transition to a new newsletter system and expect to be fully functional by the end of October. Thank you for your patience.");
		  
}


// Extract current page file name to determine which menu to load


	function extractFileName(fullPath) {
	
		  var lastSlash // the position of the last slash in the path
		  var fileName  // the name of the file
		  lastSlash = fullPath.lastIndexOf("/")
		  fileName = fullPath.substring(lastSlash+1,fullPath.length-4)
		  return fileName
	} 





function browserSniff () {
	
	var browserName=navigator.appName;
	var navscript = "/script/dohmenu_var.js";
	 
	 if (browserName=="Microsoft Internet Explorer")
	 {
	  // alert(browserName);
	  // location.href="index_ie.html";
	  navscript = "/script/dohmenu_var_ie.js";
	 }
	
	}
	
	
// - - - - - - - - - INDEX.HTML FEATURED EVENTS RANDOMIZER - - - - - - - - - - - - - - - - >>

/*
This script called from intro page as <SCRIPT language="JavaScript" SRC="random_img.js"></SCRIPT> 

Instructions for script:
1. Try to keep text at 40 words or less for optimal layout.
2. Change "totalImgs" value if needed, to reflect actual number of possible images in folder. 
3. Images named "1.png", "2.png", etc. (use photoshop file to generate correct size)
4. Only single quotes allowed in text.

*/



var totalImgs = 5;		// INDEX event feature images

// This is the randomizer for feature photos
var p = Math.round(Math.random()*totalImgs);
if (p == 0) { p = 1; }

// - - - - - - - - - BEGIN EDITABLE AREA (please only make changes here) - - - - - - - - - - - - - - - - >>

images = new Array;
images[1] = new Image();
images[1].name = "garage_sale.png";
images[1].title = "Thank you!";
images[1].txt = "Thanks to everyone who donated items or bought items at REAP's annual garage sale!";
images[1].date = "<b>REAP raised $5,451!</b>";
images[1].notes = "";
images[1].link = "javascript:;";

images[2] = new Image();
images[2].name = "memorial.png";
images[2].title = "Memorial Day";
images[2].txt = "<b>may 28</b>";
images[2].date = "Thank you to all our veterans and those currently serving in the military!";
images[2].notes = "";
images[2].link = "javascript:;";

images[3] = new Image();
images[3].name = "sunday.png";
images[3].title = "Celebration Service";
images[3].txt = "Join us as DOH worship team leads us in celebration & Pastor Al Woods shares the word!";
images[3].date = " <b>sunday, may 27 :: 6:30pm</b>";
images[3].notes = "@ New Jerusalem (COGIC)";
images[3].link = "javascript:;";

images[4] = new Image();
images[4].name = "benjamins.png";
images[4].title = "Dick and Carol Benjamin";
images[4].txt = "<b>Founding pastors of Abbott Loop Community Church</b>";
images[4].date = "sat, june 9 :: 6pm <br> sun, june 10 :: 10am";
images[4].notes = "";
images[4].link = "javascript:;";

images[5] = new Image();
images[5].name = "athletes.png";
images[5].title = "Host Families Needed!";
images[5].txt = "Click the link to learn more information on hosting members of this Christian baseball team!";
images[5].date = "<b>june 22-july 25</b>";
images[5].notes = "<a href='/community/events.html'>click here</a>";
images[5].link = "javascript:;";




// - - - - - - - - - END OF EDITABLE AREA - - - - - - - - - - - - - - - - >>

var featureImg = new Array();

// var featureImg[p] ="<a href='" + images[p].link + "'><img src='/images/features/" + images[p].name + "' alt='" + images[p].title + "' width='197' height='128' border='0' /></a>";
featureImg[1] ="<a href='" + images[1].link + "'><img src='/images/features/" + images[1].name + "' alt='" + images[1].title + "' width='197' height='128' border='0' /></a>";
featureImg[2] ="<a href='" + images[2].link + "'><img src='/images/features/" + images[2].name + "' alt='" + images[2].title + "' width='197' height='128' border='0' /></a>";
featureImg[3] ="<a href='" + images[3].link + "'><img src='/images/features/" + images[3].name + "' alt='" + images[3].title + "' width='197' height='128' border='0' /></a>";
featureImg[4] ="<a href='" + images[4].link + "'><img src='/images/features/" + images[4].name + "' alt='" + images[4].title + "' width='197' height='128' border='0' /></a>";
featureImg[5] ="<a href='" + images[5].link + "'><img src='/images/features/" + images[5].name + "' alt='" + images[5].title + "' width='197' height='128' border='0' /></a>";

var featureTitle = images[p].title;
var featureText = images[p].txt;
var featureDate = images[p].date;
var featureNote = images[p].notes;



// - - - - - - - - - END FEATURE EVENTS - - - - - - - - - - - - - - - - - - - - - - - - - - >>

function showFeature(num) {
	
	document.getElementById('group1').style.visibility='hidden';	
	document.getElementById('group2').style.visibility='hidden';	
	document.getElementById('group3').style.visibility='hidden';	
	document.getElementById('group4').style.visibility='hidden';	
	document.getElementById('group5').style.visibility='hidden';	
	
	MM_swapImage('o1','','/images/buttons/feature_oval1.png',1);
	MM_swapImage('o2','','/images/buttons/feature_oval1.png',1);
	MM_swapImage('o3','','/images/buttons/feature_oval1.png',1);
	MM_swapImage('o4','','/images/buttons/feature_oval1.png',1);
	MM_swapImage('o5','','/images/buttons/feature_oval1.png',1);
	
	MM_swapImage('o'+num,'','/images/buttons/feature_oval2.png',1)
	
	
	switch(num) {
		case "1":	
			document.getElementById('group1').style.visibility='visible';
			break;
		case "2":	
			document.getElementById('group2').style.visibility='visible';
			break;
		case "3":	
			document.getElementById('group3').style.visibility='visible';
			break;
		case "4":	
			document.getElementById('group4').style.visibility='visible';
			break;
		case "5":	
			document.getElementById('group5').style.visibility='visible';
			break;
			
	}
	
}


MM_swapImage('o2','','/images/buttons/feature_oval2.png',1)


// - - - - - - - - - SHOPPING CART SCRIPT - - - - - - - - - - - - - - - - - - - - - - - - - - >>



function addUp(myform) {
	 
	
var amt = new Array();
var limit = parseInt(myform.n_items.value);
var mytotal = 0;

for (var i = 1; i < limit+1; i++) {
	var item = eval("myform.amt_" + i + ".value");
	amt[i] = parseFloat(item);
	mytotal = mytotal + amt[i];
}

/*	var amt1 = parseFloat(myform.amount_1.value);
	var amt2 = parseFloat(myform.amount_2.value);
	var amt3 = parseFloat(myform.amount_3.value);
	var amt4 = parseFloat(myform.amount_4.value);
	var amt5 = parseFloat(myform.amount_5.value);
	
	
	var mytotal = amt1 + amt2 + amt3 + amt4 + amt5;*/

	myform.theTotal.value = mytotal.toFixed(2);

}


function SimpleAddUp(myform) {
	 
	
var amt = new Array();
var limit = parseInt(myform.n_items.value);
var mytotal = 0;

for (var i = 1; i < limit+1; i++) {
	var item = eval("myform.amount_" + i + ".value");
	amt[i] = parseFloat(item);
	mytotal = mytotal + amt[i];
}

/*	var amt1 = parseFloat(myform.amount_1.value);
	var amt2 = parseFloat(myform.amount_2.value);
	var amt3 = parseFloat(myform.amount_3.value);
	var amt4 = parseFloat(myform.amount_4.value);
	var amt5 = parseFloat(myform.amount_5.value);
	
	
	var mytotal = amt1 + amt2 + amt3 + amt4 + amt5;*/

	myform.theTotal.value = mytotal.toFixed(2);

}

function saf_addUp(myform) {
	 
	
	var amt1 = parseFloat(myform.amount_1.value);
	var amt2 = parseFloat(myform.amount_2.value);
	var amt3 = parseFloat(myform.amount_3.value);
	var amt4 = parseFloat(myform.amount_4.value);
	var amt5 = parseFloat(myform.amount_5.value);
	
	var amt6 = parseFloat(myform.amount_6.value);
	var amt7 = parseFloat(myform.amount_7.value);
	var amt8 = parseFloat(myform.amount_8.value);
	var amt9 = parseFloat(myform.amount_9.value);
	var amt10 = parseFloat(myform.amount_10.value);
	var amt11 = parseFloat(myform.amount_11.value);
	
	
	var mytotal = amt1 + amt2 + amt3 + amt4 + amt5 + amt6 + amt7 + amt8 + amt9 + amt10 + amt11;

	myform.theTotal.value = mytotal.toFixed(2);

}


function enableField(myField)
{
myField.disabled=false;
}

function processFrm(frm) {



if (frm.amount_1.value=="") { frm.amount_1.value='0'; }

return true;
	
}


function checkValue(currField) {
	
/*	var userEntry = currField.value;
	var oneChar;
	var problem = 'no';
	
	for (var i = 0; i < userEntry.length; i++) {
		oneChar = userEntry.charAt(i);
		if (oneChar < "0" || oneChar > "9") { problem = 'yes' }
	}
	
	if (problem == 'yes') {
		alert("The entry must be numerals only.");
		currField.value = '0';
	}*/
		
	if (currField.value == "") { currField.value = '0'; }
	
	var curr = parseFloat(currField.value);
	
	currField.value = curr.toFixed(2);	

}

function finalize(myfrm) {
	
myfrm.action="https://www.paypal.com/cgi-bin/webscr";


// testing whether if I send "" to the server will it still list the item

var amt = new Array();
var limit = parseInt(myfrm.n_items.value-2);
var count = 1;

for (var i = 1; i < limit+1; i++) {
	var item = eval("myfrm.amt_" + i + ".value");
	amt[i] = parseFloat(item);
	
	if (amt[i] != 0) { 
		var currName=eval("myfrm.it_name_" + i + ".value");
		var currAmt =eval("myfrm.amt_" + i + ".value");	
		// alert(currName+currAmt);
		myfrm.eval("it_name_"+count).name ="item_name_" + count;
		myfrm.eval("amt_" + count).name = "amount_" + count;
		myfrm.eval("item_name_" + count).value = currName;
		myfrm.eval("amount_" + count).value = currAmt;
		count = count + 1;
		}
}

// if (count == 0) { count = 1; }

if (myfrm.xtra_name1.value != "") { 
	myfrm.xtra_name1.name = "item_name_" + count; 
	myfrm.amt_12.name =  "amount_" + count;
	count = count + 1;
	}

if (myfrm.xtra_name2.value != "") { 
	myfrm.xtra_name2.name = "item_name_" + count; 
	myfrm.amt_13.name =  "amount_" + count; 
	}

return true;

}



function SimpleFinalize(myfrm) {
	
// var allok = "yes";

myfrm.action="https://www.paypal.com/cgi-bin/webscr";

if (myfrm.amount_12.value != "0.00") { 
	if (myfrm.item_name_12.value == "") {  
		alert("Please enter a name for this payment of " + myfrm.amount_12.value);
		// allok="no";
		myfrm.item_name_12.focus();
		return false;
		}
	}
	
if (myfrm.amount_13.value != "0.00") { 
	if (myfrm.item_name_13.value == "") {  
		alert("Please enter a name for this payment of " + myfrm.amount_13.value );
		// allok="no";
		myfrm.item_name_13.focus();
		return false;
		}
}

if (myfrm.theTotal.value == "0.00" | myfrm.theTotal.value == "" | myfrm.theTotal.value == 0) {
	alert("All amounts are curerntly 0.00");
	myfrm.amount_1.focus();
	return false; // allok = "no";
}

/*if (allok == "yes") { 
	alert("returning true. AllOK value = " + allok);
	myfrm.action="https://www.paypal.com/cgi-bin/webscr";
	return true; 
	}
	
else { 
	alert("returning false. AllOK value = " + allok);
	return false; 
	}*/
	
return true;

}




function process_registration(myreg) {
	
myreg.action="https://www.paypal.com/cgi-bin/webscr";

var something = 0;

if (myreg.xtra_name1.value != "") { 
	myreg.xtra_name1.name = "item_name_1"; 
	something = 1;
	// myreg.amt_12.name =  "amount_" + count;

	}

if (myreg.xtra_name2.value != "") { 
	myreg.xtra_name2.name = "item_name_2"; 
	something = 1;
	// myreg.amt_13.name =  "amount_" + count; 

	}
	
if (myreg.xtra_name3.value != "") { 
	myreg.xtra_name3.name = "item_name_3";
	something = 1;
	// myreg.amt_13.name =  "amount_" + count; 

	}

if (something == 0) {
	alert('please specify the item name you are paying for');
	return false;
}
else {
return true;
}

}


function processRegBasic(myreg) {
	
myreg.action="https://www.paypal.com/cgi-bin/webscr";

// if (myreg.item_name_1.value == "") { myreg.item_name_1.value = "Item 1"; }
// if (myreg.item_name_2.value == "") { myreg.item_name_2.value = "Item 2"; }
// if (myreg.item_name_3.value == "") { myreg.item_name_3.value = "Item 3"; }

if (myreg.amount_1.value != "0.00" && myreg.amount_1.value != "0" && myreg.amount_1.value != 0) {
	if (myreg.item_name_1.value == "") { alert("Please enter a name for the amount of " + myreg.amount_1.value); myreg.item_name_1.focus(); return false; }
}

if (myreg.amount_2.value != "0.00" && myreg.amount_2.value != "0" && myreg.amount_2.value != 0) {
	if (myreg.item_name_2.value == "") { alert("Please enter a name for the amount of " + myreg.amount_2.value); myreg.item_name_2.focus(); return false; }
}

if (myreg.amount_3.value != "0.00" && myreg.amount_3.value != "0" && myreg.amount_3.value != 0) {
	if (myreg.item_name_3.value == "") { alert("Please enter a name for the amount of " + myreg.amount_3.value); myreg.item_name_3.focus(); return false; }
}

if (myreg.amount_1.value == "0.00" && myreg.amount_2.value == "0.00" && myreg.amount_3.value == "0.00") {
	alert("I see all values as 0.00 Please enter at least one value and designation.");
	myreg.amount_1.focus();
	return false;
}

return true;


}

function addUpReg(myform) {
	 
	
/*var amt = new Array();
var limit = parseInt(myform.n_items.value);
var mytotal = 0;

for (var i = 1; i < limit+1; i++) {
	var item = eval("myform.xtra_name" + i + ".value");
	amt[i] = parseFloat(item);
	mytotal = mytotal + amt[i];
}*/

	var amt1 = parseFloat(myform.amount_1.value);
	var amt2 = parseFloat(myform.amount_2.value);
	var amt3 = parseFloat(myform.amount_3.value);
	
	
	var mytotal = amt1 + amt2 + amt3;

	myform.theTotal.value = mytotal.toFixed(2);

}




function validate(frm) {

  var goodEmail = frm.Email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
  
  if (frm.Name.value=="") { 
  	alert("Please include your name"); 
	frm.Name.focus(); 
	frm.Name.select(); 
	return false; 
	}
	
  if (!goodEmail) { 
  	alert("Please check the formatting of your email address"); 
	frm.Email.focus(); 
	frm.Email.select(); 
	return false; 
	} 
	
  if (frm.Message.value=="") { 
  	alert("Please include your Message!"); 
	frm.Message.focus(); 
	frm.Message.select(); 
	return false; 
	} 
	  
  return true;
}




// This is the randomizer for feature images

var totalSideImgs = 12;

var r = Math.round(Math.random()*totalSideImgs);
if (r == 0) { r = 1; }

var sideimg = "<img src='../images/sidebar/photo" + r + ".gif' name='sideimg' width='201' height='144' id='pic" + r + "' border='0' class='sidebarphoto' alt='pic" + r + "'>";

var sideimg_contact = "<img src='images/sidebar/photo" + r + ".gif' name='sideimg' width='201' height='144' id='pic" + r + "' border='0' class='sidebarphoto' alt='pic" + r + "'>";