/* DW Functions */
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.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];}
}

/* My Functions */
MM_preloadImages('images/btn_go_ro.gif');

// if id is hidden, show it; else hide it.
function showHide(id) {
	var el = $(id);
	if (el) {
		if (el.style.display == 'none')
			el.style.display = '';
		else
			el.style.display = 'none';
	}
}
// if min icon is displayed, show max icon and vice-versa.
function minMax(id) {
	var el = $(id);
	if (el) {
		if (el.src.indexOf('ico_max.gif') == -1) {
			el.src = 'images/ico_max.gif';
			el.alt = el.title = 'Click to Maximize';
		} else {
			el.src = 'images/ico_min.gif';
			el.alt = el.title = 'Click to Minimize';
		}
	}
}
function toggleSlide(id) {
	if ($(id).style.display == '')
		new Effect.SlideUp(id);
	else 
		new Effect.SlideDown(id);
}
function toggleBlind(id) {
	if ($(id).style.display == '')
		new Effect.BlindUp(id);
	else 
		new Effect.BlindDown(id);
}
function toggleAppearFade(id) {
	if (id != 'events_nav')
		new Effect.Fade('events_nav');
	if (id != 'photos_nav')
		new Effect.Fade('photos_nav');
	if (id != 'contactus_nav')
		new Effect.Fade('contactus_nav');

	if ($(id).style.display == '')
		new Effect.Fade(id);
	else
		new Effect.Appear(id);
}

function shakeButton(id, repeat) {
	if ($(id)) {
		new Effect.Shake(id);
		if (repeat)
			setTimeout("shakeButton('"+id+"', true)",60000); // 60000 = 60 seconds
	}
}

function changeFontSize(id,action) {
	var curFontSize = $(id).style.fontSize=='' ? 12 : parseFloat($(id).style.fontSize);
	switch (action) {
		case('enlarge'):
			switch (curFontSize) {
				case(12): $(id).style.fontSize = '14px';
									$(id+'Enlarge').disabled = false;
									$(id+'Shrink').disabled  = true; break;
				case(14): $(id).style.fontSize = '16px'; break;
				case(16): $(id).style.fontSize = '18px'; break;
				case(18): $(id).style.fontSize = '20px';
									$(id+'Enlarge').disabled = true;
									$(id+'Shrink').disabled  = false;
			}
			break;
		case('shrink'):
			switch (curFontSize) {
				case(20): $(id).style.fontSize = '18px';
									$(id+'Enlarge').disabled = true;
									$(id+'Shrink').disabled  = false; break;
				case(18): $(id).style.fontSize = '16px'; break;
				case(16): $(id).style.fontSize = '14px'; break;
				case(14): $(id).style.fontSize = '12px';
									$(id+'Enlarge').disabled = false;
									$(id+'Shrink').disabled  = true;
			}
	}
	updateCookie('pref_font_size', $(id).style.fontSize);
}

<!-- AJAX -->
function createXMLHttpRequest() {
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	try { return new XMLHttpRequest(); } catch(e) {}
	alert("XMLHttpRequest not supported");
	return null;
}
function setSermon(id) {
	var MAXIMUM_WAITING_TIME = 20000; // 20 seconds
	var xhReq = createXMLHttpRequest();
	$('txtBody').innerHTML		= "Loading...<br /><img src='images/load_bar1.gif'>";
	xhReq.open("GET", "ajax/set_sermon.php?id=" + escape(id), true);
	xhReq.setRequestHeader("If-Modified-Since", "Mon, 1 Jan 2007 00:00:00 GMT");
	var requestTimer = setTimeout(function() {	// Handle timeout situation, e.g. Retry or inform user.
		$('txtBody').innerHTML	= "<div align='right'><span class='errors'>Sorry, we are experiencing heavy traffic - please try again.</span></div>";
		xhReq.abort();
	}, MAXIMUM_WAITING_TIME);
	xhReq.onreadystatechange = function() {
		if (xhReq.readyState != 4)  { return; }
		clearTimeout(requestTimer);
		if (xhReq.status != 200) { return; }	// Handle error, e.g. Display error message on page
		var results = xhReq.responseText;
		if (results!='') {
			$('txtBody').innerHTML = results;
		} else
			$('txtBody').innerHTML = "Sorry, this sermon was unable to load - please try again.";
	};
	xhReq.send(null);
}
function filterCalendar(id, category_id, month, year) {
	var MAXIMUM_WAITING_TIME = 20000; // 20 seconds
	var xhReq = createXMLHttpRequest();
	$(id).innerHTML		= "Loading...<br /><img src='images/load_bar1.gif'>";
	xhReq.open("GET", "ajax/filter_calendar.php?category_id=" + escape(category_id) + "&month=" + escape(month) + "&year=" + escape(year), true);
	xhReq.setRequestHeader("If-Modified-Since", "Mon, 1 Jan 2007 00:00:00 GMT");
	var requestTimer = setTimeout(function() {	// Handle timeout situation, e.g. Retry or inform user.
		$(id).innerHTML	= "<div align='right'><span class='errors'>Sorry, we are experiencing heavy traffic - please try again.</span></div>";
		xhReq.abort();
	}, MAXIMUM_WAITING_TIME);
	xhReq.onreadystatechange = function() {
		if (xhReq.readyState != 4)  { return; }
		clearTimeout(requestTimer);
		if (xhReq.status != 200) { return; }	// Handle error, e.g. Display error message on page
		var results = xhReq.responseText;
		if (results!='')
			$(id).innerHTML = results;
		else
			$(id).innerHTML = "Sorry, this calendar was unable to load - please try again.";
	};
	xhReq.send(null);
}
function updateCookie(cookie_name, value) {
	var MAXIMUM_WAITING_TIME = 20000; // 20 seconds
	var xhReq = createXMLHttpRequest();
	xhReq.open("GET", "ajax/update_cookie.php?cookie_name=" + escape(cookie_name) + "&value=" + escape(value), true);
	xhReq.setRequestHeader("If-Modified-Since", "Mon, 1 Jan 2007 00:00:00 GMT");
	var requestTimer = setTimeout(function() {	// Handle timeout situation, e.g. Retry or inform user.
		xhReq.abort();
	}, MAXIMUM_WAITING_TIME);
	xhReq.onreadystatechange = function() {
		if (xhReq.readyState != 4)  { return; }
		clearTimeout(requestTimer);
		if (xhReq.status != 200) { return; }	// Handle error, e.g. Display error message on page
	};
	xhReq.send(null);
}

<!-- AJAX using Prototype.js -->
function sendJoin() {
	first_name		= $('first_name').value;
	last_name			= $('last_name').value;
	email					= $('email').value;
	phone		 			= $('phone').value;
	pref_contact	= $('pref_contact').value;
	hear_about		= $('hear_about').value;
	comments			= $('comments').value;
	
	// check required fields
	if (first_name == '' || last_name == '' || email == '')
		alert('Oops! Please fill in required fields.');
	else {
		// show loading bar
		$('status_send').innerHTML = 'Sending...<br/><img src="images/load_bar1.gif">';

		new Ajax.Request('ajax/send_join.php', {
			method:'get',
			parameters: {first_name: first_name, last_name: last_name, email: email, phone: phone, pref_contact: pref_contact, hear_about: hear_about, comments: comments},
			onSuccess: function(transport){
				var response = transport.responseText;
				switch (response) {
					case('sent'): $('status_send').innerHTML = "Message sent.<br/>Thank you!"; break;
					default: $('status_send').innerHTML = "<span style='color:#ff0000'>Message did not send.<br/> Please try again.</span>";
				}
			},
			onFailure: function(){ alert('Message did not send, please try again.') }
		});
	}
}