function printerfriendly() {
	url=frames['main_iframe'].location.href;
	document.location.href=url;
}
function init_width() {
	if (document.location.href.lastIndexOf("narrow") ==-1) {
		if (screen.width<870) document.location.href="index.php?narrow";
	}
}
function change_cursor(which){
	document.getElementById(which).style.cursor="pointer";
}
function main_menus(ref,menu) {
	parent.document.getElementById("which_page_var").value=menu;
	pages_with_nav="about_us,home,meetings,ministries";
	if (pages_with_nav.indexOf(menu)!=-1){
		document.location.href="#";
		menu+="_nav.html";
		parent.frames['sidenav_iframe'].location.href=menu;
	}
	ref.blur();
	window.focus();
}
function sub_menus(ref,menu) {
	parent.document.getElementById("which_page_var").value=menu;
	document.location.href="#";
	pages_with_nav="articles,media";
	if (pages_with_nav.indexOf(menu)!=-1){
		if (menu=="articles") menu+="_nav_2007.html";
		else menu+="_nav.html";
		parent.frames['sidenav_iframe'].location.href=menu;
	} else parent.frames['sidenav_iframe'].location.href="home_nav.html";
	ref.blur();
	window.focus();
}
function check_menu(page,Id){
	if (parent.document.getElementById('which_page_var').value==page) {
		Id.style.cursor="default";
		return;
	} else Id.className='tints_off';
}
function validate_mailinglist(name,email,message) {
	error="";
	if (name=="") error+="Name is required.\n";
	if (email!="") {
		emailFilter=/^.+@.+\..{2,3}$/;
	    if (!(emailFilter.test(email))) { 
	       error+= "The email address you have entered does not appear to be a valid one.\n";
	    }
	    else {
		//test email for illegal characters
	       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
	         if (email.match(illegalChars)) {
	          error+= "The email address contains illegal characters.\n";
	       }
	    }
    } else {
		if (message==""||message=="[Type postal address here to receive our newsletter by post]") {
			error+="Please type an email address and/or a postal address.\n";
		}
	}
    if (error!="") {
    	alert(error);
    	return false;
    }
    return true;
}
function validate(name,email,phone,message) {
	error="";
	if (name=="") error+="Name is required.\n";
	
	if (email=="") error+="Email address is required.\n";
	else {
		emailFilter=/^.+@.+\..{2,3}$/;
	    if (!(emailFilter.test(email))) { 
	       error+= "The email address you have entered does not appear to be a valid one.\n";
	    }
	    else {
		//test email for illegal characters
	       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
	         if (email.match(illegalChars)) {
	          error+= "The email address contains illegal characters.\n";
	       }
	    }
    }
	/*
	if (phone!="") {
		stripped = phone.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	    if (isNaN(parseInt(stripped))) {
	       error+= "The phone number contains illegal characters.\n";
	    }
	    if (!(stripped.length > 10)) {
		error+= "The phone number should be at least 11 numbers. Please make sure you included an area code.\n";
	    }
    }
    */
	if (message=="") error+="The message field is empty.\n";

    if (error!="") {
    	alert(error);
    	return false;
    }
    
    return true;
}
function swap_event_img() {
	// allow original pic to stay in page full term
	if (document.getElementById("events_pic_swapped").value=="0") {
		document.getElementById("events_pic_swapped").value="1";
		setTimeout("swap_event_img()", 4000);
		return;
	}
	//alert("in swap event");
	numPics=EventsPicArray.length;
	// if less than 2 pics don't continue
	if (numPics<2) return;
	// get the array index of the current displayed pic
	currentPic=eval(document.getElementById("events_pic_var").value);
	//alert("current pic="+currentPic);
	// increment the array index
	newPicNum=currentPic+1;
	//alert("new pic num="+newPicNum);
	/* if the new increment exceeds the length of the array, start again from the beginning of the array
	*/
	if (newPicNum>=numPics) newPicNum=0;
	/* only needed for swaping actual jpg files
	newPic="images/events_imgs/";
	newPic+=EventsPicArray[newPicNum];
	document.getElementById("events_pic").src=newPic;
	//alert("about to write new pic num to html:"+newPicNum);
	document.getElementById("events_pic_var").value=newPicNum;
	*/
	for (i=0; i<numPics; i++) {
		document.getElementById("image"+i).style.visibility='hidden';
	}
	document.getElementById("image"+newPicNum).style.visibility='visible';
	// store the array index
	document.getElementById("events_pic_var").value=newPicNum
	setTimeout("swap_event_img()", 3000);
}
