	var version = parseInt(navigator.appVersion);
	var isNS  = (navigator.appName.indexOf('Netscape') >= 0);
	var isNS4 = (isNS && version == 4);
	var isNS5 = (isNS && version > 4);
	var isFF  = (navigator.userAgent.indexOf('Firefox') >= 0);
	var isIE  = !isNS;
	var isIE4 = (isIE && version == 4);
	var isIE5 = (isIE && version > 4);
	var isIE6 = (isIE && version < 7);
	var isMac = (navigator.appVersion.indexOf('Macintosh') >= 0);
	var isWin = !isMac;
	var isAOL = (navigator.userAgent.indexOf('AOL') >= 0);

	function addMouseEvents(obj)
	{
		if (isNS5)
		{
			obj.addEventListener('mouseover', mouseOver, false);
			obj.addEventListener('mouseout', mouseOut, false);
		}

		if (isIE)
		{
			obj.detachEvent('onmouseover', mouseOver);
			obj.attachEvent('onmouseover', mouseOver);
			obj.detachEvent('onmouseout', mouseOut);
			obj.attachEvent('onmouseout', mouseOut);
		}
	}
	
function emailPage(page, id)
	{
		thisURL = "/utils/email.php?page=";
		thisURL += page;
		thisURL +="&id=";
		thisURL += id;
		mywindow = window.open(thisURL, 'EmailStory', 'width=480,height=560,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0');
	}

function showLayer(layerName, shadowLayerName)
  {
      if (document.getElementById) // Netscape 6 and IE 5+
      {
          var targetElement = document.getElementById(layerName);
          var shadowElement = document.getElementById(shadowLayerName);
          targetElement.style.top = shadowElement.style.top;
          targetElement.style.visibility = 'visible';
      }
  }


function hideLayer(layerName) {
    if (document.getElementById) 
    {
        var targetElement = document.getElementById(layerName);
        targetElement.style.visibility = 'hidden';
    }
}

var form_submitted = false;	
var message = 'There were errors in your form submission.  Please be sure to fill out the following:\n';

function checkBlankField(inputBox, inputDiv, errorMsg) {	
	var error = '';
	if (document.getElementById) {
		document.getElementById(inputDiv).style.visibility = 'hidden';
		if (inputBox.value == '') {
			error = errorMsg;
			message += error;
			document.getElementById(inputDiv).style.visibility = 'visible';
			return true;
		}
	} 
}
	
function checkCCnumberLength() {
	if (document.getElementById) {
		document.getElementById('idccNumber').style.visibility = 'hidden';
		if (document.forms.process.ccnum_from_posted_form.value.length < 16) {
			document.getElementById('idccNumber').style.visibility = 'visible';
			alert('The Credit Card number you entered is not valid.\nThere are too few numbers');
			return true;
		} else if (document.forms.process.ccnum_from_posted_form.value.length > 16) {
			document.getElementById('idccNumber').style.visibility = 'visible';
			alert('The Credit Card number you entered is not valid.\nThere are too many numbers');
			return true;
		} else {
			return false;
		}
	}
}	

function checkCCexpiration() {	
	if (document.getElementById) {
		var error = '';
		document.getElementById('idccExp').style.visibility = 'hidden';
		if ((document.forms.process.ccmm.value == '') || (document.forms.process.ccyy.value == '')) {
			error = 'Credit Card Expiration\n';
			message += error;
			document.getElementById('idccExp').style.visibility = 'visible';
			return true;
		}
	}
}	

function isValidEmail(str) {
	return (str.lastIndexOf(".") > 2) && (str.indexOf("@") > 0) && (str.lastIndexOf(".") > (str.indexOf("@")+1)) && (str.indexOf("@") == str.lastIndexOf("@"));
}

function checkCheckBoxes(inputEmail, box1, box2, inputDiv, reqBoxes) {	
	if (document.getElementById) {
		document.getElementById(inputDiv).style.visibility = 'hidden';
		
		if (reqBoxes) {
			if ((box1.checked === false) && (box2.checked === false)) {
				alert ('Please check at least one subscription');
				return true; 
			}
		}
		
		if (box1.checked || box2.checked) {		
			if (inputEmail.value === '') {
				alert ('You selected to receive our e-mail subscriptions,\nbut did not specify an email address');
				inputEmail.select();				
				document.getElementById(inputDiv).style.visibility = 'visible';
				window.scrollTo(0,0);
				return true;
			} else {
				if (!isValidEmail(inputEmail.value)) {
					alert ('The email address you entered is not valid.  Please try again.');
					document.getElementById(inputDiv).style.visibility = 'visible';
					inputEmail.select();
					window.scrollTo(0,0);
					return true;
				} else {
					document.getElementById(inputDiv).style.visibility = 'hidden';
					return false; }
			} 
		} else {
			return false; 
		}
	}	
}

function validateDonateForm() {
	if (form_submitted) {
		alert ('Your form has already been submitted. Please wait...');
		return false;
	} else {		
		errors = false;
			if (checkBlankField(document.forms.process.donate_name, 'idName', 'Name\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.donate_phone, 'idPhone', 'Phone Number\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.donate_address, 'idAddress', 'Address\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.donate_city, 'idCity', 'City\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.donate_state, 'idState', 'State\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.donate_zip, 'idZip', 'Zip Code\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.donate_country, 'idCountry', 'Country\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.setamount, 'idccAmount', 'Gift Amount\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.cctype, 'idccType', 'Credit Card Type\n' )) { errors = true; }
			if (checkBlankField(document.forms.process.ccnum_from_posted_form, 'idccNumber', 'Credit Card Number\n' )) { 
				errors = true; 
			} else {				
				if (checkCCnumberLength()) { return false; }
			}		
			if (checkBlankField(document.forms.process.cccode, 'idccSecurity', 'Credit Card Security Number\n' )) { errors = true; }
			if (checkCCexpiration()) { errors = true; }			
			if (checkBlankField(document.forms.process.ccname, 'idccName', 'Name on Credit Card\n' )) { errors = true; }
			
			if (errors) {
				alert (message);
				window.scrollTo(0,0);
				message = '';
				message = 'There were errors in your form submission.  Please be sure to fill out the following:\n';
				return false;
			} else { 
				return true; 
			}		
		
		form_submitted = true;
		return false; 
	}
}

function subDonateForm() {
	if (validateDonateForm()) {
		document.forms.process.submit();
	}
}

function validEmailInput() {
			if (document.forms.process.eUser_email.value === '') {
				alert ('You selected to receive our e-mail subscriptions,\nbut did not specify an email address');
				return false;
			} else {
				if (!isValidEmail(document.forms.process.eUser_email.value)) {
					alert ('The email address you entered is not valid.  Please try again.');
					return false;
				} else {
					return true; }
			}		
}

function validEmailIn() {
			if (document.forms.process.email.value === '') {
				alert ('You selected to receive our e-mail subscriptions,\nbut did not specify an email address');
				return false;
			} else {
				if (!isValidEmail(document.forms.process.email.value)) {
					alert ('The email address you entered is not valid.  Please try again.');
					return false;
				} else {
					return true; }
			}		
}

function validateCommentForm() {
	if (form_submitted) {
		alert ('Your form has already been submitted. Please wait...');
		return false;
	} else {
		if (document.forms.captcha.commentname.value === '') {
				alert ('Please include your name');
				return false;
		}
		if (document.forms.captcha.commentemail.value === '') {
				alert ('Please specify an email address');
				return false;
		}
		if (!isValidEmail(document.forms.captcha.commentemail.value)) { 			
				alert ('The email address you entered is not valid.  Please try again.');
			return false; 
		}		
		if (document.forms.captcha.commentmessage.value === '') {
				alert ('You did not type a message');
				return false;
		} else {
			return true;
		}
		form_submitted = true;
		return false;
	}
}

function subCommentForm() {	
	if (validateEmailForm()) {
			document.forms.captcha.submit();	
	}
}

function validateEmailForm(theForm) {
	if (form_submitted) {
		alert ('Your form has already been submitted. Please wait...');
		return false;
	} else {
		if (checkCheckBoxes(theForm.eUser_email, theForm.eUser_today, theForm.eUser_message, 'idEmail', true)) { 
			return false; 
		} else {
			return true;
		}
		form_submitted = true;
		return false;
	}
}

function subEmailForm(theForm) {	
	if (validateCommentForm(theForm)) {
			theForm.submit();	
	}
}

function violationconfirm() {	
	var answer = confirm ("Are you sure you want to report this comment to the moderator?")
	if (answer)
	 return true;
	else
		return false;
}

function reportlink(cat, storyid, cid) {
	var newpage = "comments.php";
	newpage += "?cat=";
	newpage += cat;
	newpage += "&storyid=";
	newpage += storyid;
	newpage += "&cid=";
	newpage += cid;
	newpage += "&action=report";
	location.href = newpage;
}

function toggleBox(tabNum) {	
	var tabId = "top"+tabNum;
	var liId = "toptab"+tabNum;
	document.getElementById('top1').style.display = 'none';
	document.getElementById('toptab1').className = "inactive";
	document.getElementById('top2').style.display = 'none';
	document.getElementById('toptab2').className = "inactive";
	document.getElementById('top3').style.display = 'none';
	document.getElementById('toptab3').className = "inactiveRC";
	document.getElementById(tabId).style.display = 'inline';
	if (liId == 'toptab3') {
		document.getElementById(liId).className = "activeRC";
	} else {
		document.getElementById(liId).className = "active";
	}
}

function toggleComments() {	
	document.getElementById('commentfield').style.display = 'inline';
	document.getElementById('addcomment2').style.display = 'none';
}

/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

	// global dropdown menus
	// ENGLISH MINISTRIES menu
	menu1 = new Array();
	menu1[0] = '<a href="http://backtogodradio.com">The Back to God Hour Radio Program</a>';
	menu1[1] = '<a href="http://kidscorner.net">Kids Corner</a>';
	menu1[2] = '<a href="http://walktheway.net">Walk the Way</a>';
	menu1[3] = '<a href="http://thisistoday.net">TODAY</a>';
	menu1[4] = '<a href="http://spotlightradio.net">Spotlight</a>';
	menu1[5] = '<a href="http://thinkchristian.net">Think Christian</a>';
	menu1[6] = '<a href="http://radarradio.net">Under the Radar</a>';

	// INTERNATIONAL MINISTRIES menu
	menu2 = new Array();
	menu2[0] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=14">Arabic</a>';
	menu2[1] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=15">Chinese</a>';
	menu2[2] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=16">English</a>';
	menu2[3] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=17">French</a>';
	menu2[4] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=18">Indonesian</a>';
	menu2[5] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=19">Japanese</a>';
	menu2[6] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=20">Portuguese</a>';
	menu2[7] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=21">Russian</a>';
	menu2[8] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=22">Spanish</a>';

	// RESOURCES menu
	menu3 = new Array();
	menu3[0] = '<a href="http://backtogod.net/sub.php?cat_id=6&page_id=23">Why Christianity?</a>';
	menu3[1] = '<a href="http://backtogod.net/sub.php?cat_id=6&page_id=24">How to Become a Christian</a>';
	menu3[2] = '<a href="http://backtogod.net/sub.php?cat_id=6&page_id=25">Find a Church</a>';
	menu3[3] = '<a href="http://backtogod.net/sub.php?cat_id=6&page_id=26">Bible Study</a>';
	menu3[4] = '<a href="http://backtogod.net/sub.php?cat_id=6&page_id=27">Need Prayer?</a>';
	menu3[5] = '<a href="http://backtogod.net/sub.php?cat_id=3&page_id=33">Faithline</a>';
	menu3[6] = '<a href="http://backtogod.net/resources.php">Church Resources</a>';

	// CONTACT menu
	menu4 = new Array();
	menu4[0] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=82">United States Office</a>';
	menu4[1] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=83">Canadian Office</a>';
	menu4[2] = '<a href="http://backtogod.net/onlinecontact.php">Online Contact Form</a>';
	menu4[3] = '<a href="http://backtogod.net/onlinesupport.php">Technical Support</a>';
	menu4[4] = '<div>Ministry Contacts</div>';
	menu4[5] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=138">Arabic</a>';
	menu4[6] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=139">Chinese</a>';
	menu4[7] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=140">English</a>';
	menu4[8] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=84">French</a>';
	menu4[9] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=85">Indonesian</a>';
	menu4[10] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=141">Japanese</a>';
	menu4[11] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=142">Portuguese</a>';
	menu4[12] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=143">Russian</a>';
	menu4[13] = '<a href="http://backtogod.net/contact.php?action=Ministry&id=144">Spanish</a>';

	// ABOUT US menu
	menu5 = new Array();
	menu5[0] = '<a href="http://backtogod.net/about.php?cat_id=2&page_id=2">Mission</a>';
	menu5[1] = '<a href="http://backtogod.net/about.php?cat_id=2&page_id=12">Core Beliefs</a>';
	menu5[2] = '<a href="http://backtogod.net/about.php?cat_id=2&page_id=13">The CRC</a>';
	menu5[3] = '<a href="http://backtogod.net/whoweare.php">Who We Are</a>';
	menu5[4] = '<a href="http://backtogod.net/jobs.php">Job Opportunities</a>';
	menu5[5] = '<a href="http://backtogod.net/newname.php">Our New Name</a>';
			
var menuwidth='165px' //default menu width
var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top="-500px"
	if (menuwidth!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible
	else if (e.type=="click")
		obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
		if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
			edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
}

function populatemenu(what){
	if (ie4||ns6)
		dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)

	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}

	return clickreturnvalue()
}

function clickreturnvalue(){
	if (ie4||ns6) return false
	else return true
}

function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
		return true;
	return false;
}

function dynamichide(e){
	if (ie4&&!dropmenuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu()
}

function hidemenu(e){
	if (typeof dropmenuobj!="undefined"){
		if (ie4||ns6)
			dropmenuobj.style.visibility="hidden"
	}
}

function delayhidemenu(){
	if (ie4||ns6)
		delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
	document.onclick=hidemenu


	function charCount(what, maxCount) {
		var str = new String(what.value);
		var len = str.length;
		var limitSpan = document.getElementById("limitText");		

		len = maxCount - len;		

		if (document.getElementById) {	
			if (len < 0) {
				what.value = what.value.substring(0, maxCount);
			} else if (len > 1) {
				limitSpan.innerHTML = "<strong>" + len + "</strong> characters remaining";
			} else {
				limitSpan.innerHTML = "<strong>" + len + "</strong> character remaining";
			}
		}
	}

	function validateMessageBox() {
		var my_textarea = document.getElementById("commentmessage");
		if (my_textarea && my_textarea.value.length > 1000) {
			alert("Please limit your response to 1000 characters maximum.");
			return false;
		} else {
			return true;
		}
	}
	

function refreshList(sort, filter, direction, start, end) {	
	var newpage = "commentlist.php";
	if ((sort != 'none') || (filter != 'none') || (direction != 'none')) {	
		newpage += "?";
	}
	if (sort != 'none') {	
		newpage += "displayorder=";
		newpage += sort;
	}
	if ((sort != 'none') && ((filter != 'none') || (direction != 'none'))) {
		newpage += "&";
	}
	if (filter != 'none') {
		newpage += "action=category&cat=";
		newpage += filter;
	}
	if ((filter != 'none') && ((sort != 'none') || (direction != 'none'))) {
		newpage += "&";
	}
	if (direction != 'none') {
		newpage += "direction=";
		newpage += direction;	
	}
	if (start != '') {	
		newpage += "&start=";
		newpage += start;
	}
	if (end != '') {	
		newpage += "&end=";
		newpage += end;
	}
	location.href = newpage;
}

if(ap_instances == undefined) {
	var ap_instances = new Array();
	var ap_clearID = setInterval( ap_registerPlayers, 100 );
}

function ap_registerPlayers() {
	var objectID;
	var objectTags = document.getElementsByTagName('object');
	for(var i=0;i<objectTags.length;i++) {
		objectID = objectTags[i].id;
	if(objectID.indexOf('audioplayer') == 0) {
			ap_instances[i] = objectID.substring(11, objectID.length);
		}
	}
}

function ap_stopAll(playerID) {
	for(var i = 0;i<ap_instances.length;i++) {
		try {
			if(ap_instances[i] != playerID) { 
				document.getElementById('audioplayer' + ap_instances[i].toString()).SetVariable('closePlayer', 1);
			}	else {
				document.getElementById('audioplayer' + ap_instances[i].toString()).SetVariable('closePlayer', 0);
			}
		} catch( errorObject ) {
			// stop any errors
		}
	}
}

function showPage(dateid){
	var newpage = "index2.php";
	newpage += "?dateid=";
	newpage += dateid;
	location.href = newpage;
}

function canManipulateImages() {
if (document.images)
return true;
else
return false;
}

// loadPosterImage

function loadPosterImage(imageURL) {
if (gImageCapableBrowser) {
document.imagePoster.src = imageURL;
return false;
}
else {
return true;
}
}