//
// ChristianityToday.com JavaScript
// Version 1.1
// Copyright © 2006 Christianity Today International
//

// variables
	// user-agent identity
	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 isMac = (navigator.appVersion.indexOf('Macintosh') >= 0);
	var isWin = !isMac;
	var isAOL = (navigator.userAgent.indexOf('AOL') >= 0);

	// Flash detection; minimum: version 4.0
	var flashVersion = 0;
	for (var i = 4; i <= 10; i++)
	{
		if (isIE)
		{
			document.write('<script language="VBScript" type="text/vbscript">\n');
			document.write('On Error Resume Next\n');
			document.write('CreateObject("ShockwaveFlash.ShockwaveFlash." & i)\n');
			document.write('If Err = 0 Then\n');
			document.write('flashVersion = i\n');
			document.write('End If\n');
			document.write('</script>\n');
		}
		else
		{
			var plugin = navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin;
			if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf('.') - 1)) >= i)
			{
				flashVersion = i;
			}
		}
	}

	// events
	var clickURL;
	var mouseX = 0;
	var mouseY = 0;
	var pageWidth = 0;
	var pageHeight = 0;
	
	// settings
	var menuDelay = 100;
	var allowFrame = true;
	var menuDivArray = new Array('globalMenu', 'channelMenu');

	// page tools
	var windowArray = new Array();
	var pageURL = (window != top) ? document.referrer : location.href;
	var emailURL = 'email.html?title=%%title%%&url=%%url%%';
	var printURL = '/print.html?id=%%id%%';
	var similarURL = '/search.html?similar=%%url%%';
	var contextStyles =
	[
		['intro', 'cite', 'ital-off'],
		['bio', 'cite', 'ital-off']
	];

// Hover Ads
var ctiHovers = {
	// prevents conflicts with system.js
	notSystem: true,
	init: function() {
		var h = this.getSize().y,
			that = this,
			w = this.getSize().x,
			elems = [], kids, txt;

		this.body = document.getElementsByTagName('body')[0];
		this.closeLink = document.getElementById('closeHoverAd');
		this.hover = document.getElementById('hover');
		this.overlay = document.getElementById('overlay');

		kids = this.hover.childNodes;
		for (var i = 0, l = kids.length; i < l; i += 1) {
			if (kids[i].nodeType === 1) elems.push(kids[i]);
		}
		
		txt = this.hover.innerHTML.toLowerCase();
		if (this.hover && (txt.indexOf('empty hover ad') !== -1 || txt.indexOf('http://content.aimatch.com/cti/black_default.gif') !== -1 || elems.length <= 1)) {
			this.closeHover();
		} else {
			this.body.appendChild(this.hover);
			this.hover.style.left = (w/2) - (this.hover.clientWidth/2) + 'px';
			this.hover.style.visibility = 'visible';
	
			if (this.overlay) {
				this.body.appendChild(this.overlay);
				this.overlay.style.height = h + 'px';
				this.overlay.style.width = w + 'px';
			}
			
			this.timer = setTimeout(function() {
				that.closeHover();
			}, 15000);
			
			this.attach();
		}
	},
	attach: function() {
		var that = this,
			hoverForm = this.hover.getElementsByTagName('form')[0];
		
		if (hoverForm) {
			hoverForm.onsubmit = function() {
				that.hover.style.left = '-999em';
				setTimeout(function() {
					that.closeHover();
				}, 5000);
			};
		}
		this.hover.onclick = function(event) {
			var event = event || window.event,
				elem = event.target || event.srcElement;
			if (elem.nodeName === 'A' || elem.parentNode.nodeName === 'A' || elem.nodeName === 'OBJECT' || elem.nodeName === 'EMBED') {
				that.closeHover();
			}
		};
		this.hover.onmouseup = function() {
			var event = event || window.event,
				elem = event.target || event.srcElement;
			if (elem.nodeName === 'OBJECT' || elem.nodeName === 'EMBED') {
				setTimeout(function() {
					that.closeHover();
				}, 500);
			}
		};
		this.hover.onmouseover = function() {
			clearTimeout(that.timer);
		};
		this.closeLink.onfocus = function() {
			clearTimeout(that.timer);
		};
		this.closeLink.onclick = function() {
			that.closeHover();
			return false;
		};
		if (this.overlay) {
			this.overlay.onclick = function() {
				that.closeHover();
			};
		}
	},
	closeHover: function() {
		this.hover.parentNode.removeChild(this.hover);
		if (this.overlay) this.overlay.parentNode.removeChild(this.overlay);
		clearTimeout(this.timer);
	},
	getSize: function() {
		var doc = (!document.compatMode || document.compatMode === 'CSS1Compat') ? document.getElementsByTagName('html')[0] : document.body,
			m = window.ActiveXObject ? 'min': 'max';
		return {x: Math[m](doc.scrollWidth, doc.offsetWidth), y: Math.max(doc.scrollHeight, doc.offsetHeight)};
	}
};

// cookie management
	function readCookie(name)
	{
		var cookieArray = document.cookie.split('; ');
		for (var i = 0; i < cookieArray.length; i++)
		{
			var nameValueArray = cookieArray[i].split('=', 2);
			if (nameValueArray[0] == name) return(nameValueArray[1]);
		}
		return(null);
	}

	function writeCookie(name, value, expires)
	{
		if (expires)
		{
			document.cookie = name + '=' + value + '; expires=' + expires.toUTCString();
		}
		else
		{
			document.cookie = name + '=' + value;
		}
	}
	
// query extraction
	function getQueryVariable(name)
	{
		var query = window.location.search.substring(1);
		var vars = query.split('&');
		for (var i = 0; i < vars.length; i++)
		{
			var pair = vars[i].split('=');
			if (pair[0] == name)
			{
				return pair[1];
			}
		}
		return null;
	}

// event capturing
	if (isNS4)
	{
		window.captureEvents(Event.ONLOAD);
		window.onLoad = pageLoad;
		window.captureEvents(Event.ONUNLOAD);
		window.onUnload = pageUnload;
		document.captureEvents(Event.CLICK);
		document.onClick = mouseClick;
		document.captureEvents(Event.MOUSEMOVE);
		document.onMouseMove = mouseMove;
	}

	if (isNS5)
	{
		window.addEventListener('load', pageLoad, false);
		window.addEventListener('unload', pageUnload, false);
		document.addEventListener('click', mouseClick, false);
		document.addEventListener('mousemove', mouseMove, false);
	}

	if (isIE)
	{
		window.attachEvent('onload', pageLoad);
		window.attachEvent('onunload', pageUnload);
		document.attachEvent('onclick', mouseClick);
		document.attachEvent('onmousemove', mouseMove);
	}

// event handlers
	function pageLoad(evt)
	{
		// frame break
		if (window != top && allowFrame != true) top.location.replace(location.href);

		// create menu divs
		createMenuDivs();

		// display hover
		if (document.getElementById('hover')) ctiHovers.init();

		// set contextual styles
		setContextStyles();
		
		// set comment report button listeners
		cti.reportComments();
		
		// if multi-nl sign-up form, look up zip code
		var geoInputs = cti.getElementsByClass('newsletterGeoZipInput');
		if (geoInputs) {
			cti.visitorGeolocation = new Geolocate('cti.visitorGeolocation', true, false, function(geodata) {
				var zip = geodata['ZipPostalCode'], l = geoInputs.length, i;
				if (zip !== '') {
					for (i = 0; i < l; i += 1) geoInputs[i].value = zip;
				}
			});
			
			cti.visitorGeolocation.initialize();
		}

		if (window.channelLoad) channelLoad();
	}

	function pageUnload(evt)
	{
		// close child windows
		for (var i = 0; i < windowArray.length; i++)
		{
			if (typeof windowArray[i] == 'object' && !windowArray[i].closed) windowArray[i].close();
		}

		if (window.channelUnload) channelUnload();
	}

	function mouseOver(evt)
	{
		obj = (evt.target) ? evt.target : evt.srcElement;
		if (obj.over) obj.src = obj.over.src;
		if (obj.tip) showTip(obj);
		if (obj.menu) showMenu(obj, evt);
	}

	function mouseOut(evt)
	{
		obj = (evt.target) ? evt.target : evt.srcElement;
		if (obj.out) obj.src = obj.out.src;
		if (obj.tip) hideTip(obj);
		if (obj.menu) delayHideMenu();
	}

	function mouseClick(evt)
	{
		if (isNS4)
		{
			clickURL = evt.target.href;
		}
		else if (isNS5)
		{
			node = evt.target;
			while (node.tagName != 'A' && node.tagName != 'HTML')
			{
				node = node.parentNode;
			}
			clickURL = node.href;
		}
		else if (isIE)
		{
			element = evt.srcElement;
			while (element.tagName != 'A' && element.tagName != 'HTML')
			{
				element = element.parentElement;
			}
			clickURL = element.href;
		}

		if (clickURL == null) clickURL = '';
	}

	function getMousePosition(evt) {
		if (evt.pageX || evt.pageY) {
			mouseX = evt.pageX;
			mouseY = evt.pageY;
		} else if (evt.clientX || evt.clientY) {
			mouseX = evt.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			mouseY = evt.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
	}
	
	function getScroll() {
		if (window.innerWidth) {
			pageWidth = window.innerWidth;
			pageHeight = window.innerHeight;
		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			pageWidth = document.documentElement.clientWidth;
			pageHeight = document.documentElement.clientHeight;
		}  else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
			pageWidth = document.body.clientWidth;
			pageHeight = document.body.clientHeight;
		}
	}
	
	function mouseMove(evt) {
		if (tipVisible) {
			getMousePosition(evt);
			getScroll();
			moveTip();
		}
	}

	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);
		}
	}

// mouseovers; incompatible with NS4
	//
	// Usage:
	// <a href="LINK"><img src="IMAGE.EXT" onload="mouseLoad(this);" width="WIDTH" height="HEIGHT" title="ALT" /></a>
	// 
	// Note: mouseover image must be named IMAGE_over.EXT
	//
	function mouseLoad(obj)
	{
		if (isNS4 || obj.out) return;
		
		obj.out = new Image();
		obj.out.src = obj.src;
		obj.over = new Image();
		obj.over.src = obj.src.replace(/.gif$/, '_over.gif').replace(/.jpg$/, '_over.jpg');
		
		addMouseEvents(obj);
	}

// dropdown menu
	//
	// Usage:
	// <img src="IMAGE.EXT" onload="menuLoad(this, 'MENU_NAME', 'WIDTH', 'LEFT|RIGHT');" width="WIDTH" height="HEIGHT" title="ALT" />
	//
	// Note: create menu items in a separate JavaScript file
	//
	
	var menu = new Array();
	var menuTimeout;

	function createMenuDivs()
	{
		if (!isNS4)
		{
			for (var i = 0; i < menuDivArray.length; i++)
			{
				var newDiv = document.createElement('div');
				newDiv.setAttribute('id', menuDivArray[i]);
				newDiv.setAttribute('style', 'display: none; width: 0px;');
				if (isNS5)
				{
					newDiv.addEventListener('mouseover', clearHideMenu, false);
					newDiv.addEventListener('mouseout', delayHideMenu, false);
				}
				if (isIE)
				{
					newDiv.attachEvent('onmouseover', clearHideMenu);
					newDiv.attachEvent('onmouseout', delayHideMenu);
				}
				document.body.appendChild(newDiv);
			}
		}
	}

	function menuLoad(obj, name, width, align)
	{
		if (isNS4 || obj.menu) return;

		obj.menu = menu[name];
		obj.menuName = name;
		obj.menuWidth = width;
		obj.menuAlign = align;
		
		addMouseEvents(obj);
	}
	
	function showMenu(obj, evt)
	{
		var menuObject;
		if (isNS4 || ! obj.menu) return;

		if (window.event)
		{
			event.cancelBubble = true;
		}
		else if (evt.stopPropagation)
		{
			evt.stopPropagation();
		}
		clearHideMenu();

		var menuDiv = 'channelMenu';
		if (obj.menuName.indexOf('global_') == 0)
		{
			menuDiv = 'globalMenu';
		}
	  
		menuObject = document.getElementById ? document.getElementById(menuDiv) : document.all[menuDiv];
		
		if (menuObject)
		{
			menuObject.innerHTML = obj.menu.join('');

			menuObject.style.width = obj.menuWidth + 'px';
			if (evt.type == 'click' && obj.visibility == hidden || evt.type == 'mouseover')
			{
				menuObject.style.display = 'block';
			}
			else if (evt.type == 'click')
			{
				menuObject.style.display = 'none';
			}
	
			var horizontalOffset;
			var verticalOffset;
			if (obj.menuAlign == 'right')
			{
				horizontalOffset = obj.offsetLeft + obj.offsetWidth;
			}
			else
			{
				horizontalOffset = obj.offsetLeft;
			}
			verticalOffset = obj.offsetTop + obj.offsetHeight;
			
			var parentElement = obj.offsetParent;
			while (parentElement != null)
			{
				horizontalOffset = horizontalOffset + parentElement.offsetLeft;
				verticalOffset = verticalOffset + parentElement.offsetTop;
				parentElement = parentElement.offsetParent;
			}
			if (obj.menuAlign == 'right')
			{
				menuObject.x = horizontalOffset - obj.menuWidth;
			}
			else
			{
				menuObject.x = horizontalOffset;
			}
			menuObject.y = verticalOffset;
			menuObject.style.left = menuObject.x;
			menuObject.style.top = menuObject.y;
		}
	}

	function delayHideMenu()
	{
		if (isNS4) return;

		menuTimeout = setTimeout('hideMenu()', menuDelay);
	}

	function hideMenu()
	{
		if (isNS4) return;

		var menuObject;

		for (var i = 0; i < menuDivArray.length; i++)
		{
			menuObject = document.getElementById ? document.getElementById(menuDivArray[i]) : document.all[menuDivArray[i]];
			if (typeof menuObject != 'undefined')
			{
				menuObject.style.display = 'none';
			}
		}
	}

	function clearHideMenu()
	{
		if (typeof menuTimeout != 'undefined') clearTimeout(menuTimeout);
	}

	document.onclick = hideMenu;

// help tips
	//
	// Usage:
	// <img src="IMAGE.EXT" onload="tipLoad(this, 'MESSAGE', 'LEFT|RIGHT', WIDTH, OFFSET);" width="WIDTH" height="HEIGHT" title="ALT" />
	// <a href="LINK" onmouseover="showTip(this, 'MESSAGE', 'LEFT|RIGHT', WIDTH, OFFSET);" />
	//		the ALIGN, WIDTH, and OFFSET can be left out and they will be set to default values
	//		if ALIGN is right, the OFFSET should be set to ensure proper positioning
	//
	var tipVisible = false;
	
	function tipLoad(obj, message, align, width, offset)
	{
		if (isNS4) return;
		
		if (! obj.tip)
		{
			obj.tip = message;
			if (align == null)
			{
				align = 'left';
			}
			obj.tipAlign = align;
			if (width == null)
			{
				width = 200;
			}					
			obj.tipWidth = width;
			if (offset == null)
			{
				offset = 210;
			}	
			obj.tipRightOffset = offset;
			addMouseEvents(obj);
			if (obj.nodeName == "A")
			{
				showTip(obj);
			}
		}
	}
	
	function showTip(obj)
	{
		if (isNS4) return;

		tipVisible = true;
		
		var tipDiv = document.getElementById('tip');
		
		if (!tipDiv)
		{
			tipDiv = document.createElement('div');
			tipDiv.setAttribute('id', 'tip');
			document.body.appendChild(tipDiv);
		}

		if (tipDiv)
		{
			tipDiv.innerHTML = obj.tip;
			moveTip();
			tipDiv.style.width = obj.tipWidth + 'px';
			tipDiv.style.visibility = 'visible';
		}
	}

	function hideTip()
	{
		if (isNS4) return;

		tipVisible = false;

		var tipDiv = document.getElementById('tip');

		if (tipDiv)
		{
			tipDiv.style.visibility = 'hidden';
		}
	}
	
	function moveTip()
	{
		var tipDiv = document.getElementById('tip');	
		if (tipDiv)
		{
			if(obj.tipAlign == 'left')
			{	
				var tipX = (((mouseX) > pageWidth) ? (pageWidth) : mouseX) + 10;
			} else {
				var tipX = (((mouseX) > pageWidth) ? (pageWidth) : mouseX) - obj.tipRightOffset;
			}
			var tipY = mouseY + 25;
			
			if (isNS4)
			{
				tipDiv.left = tipX;
				tipDiv.top = tipY;
			}
			else
			{
				tipDiv.style.left = tipX;
				tipDiv.style.top = tipY;
			}
		}
	}

// page tools
	//
	// email this page
	// Usage:
	// <a href="javascript:emailPage();">LINK</a>
	//
	function emailPage(url)
	{
		if (url != null)
		{
			windowArray[windowArray.length] = window.open(url);
		}
		else
		{			
			thisURL = emailURL.replace('%%title%%', escape(document.title)).replace('%%url%%', escape(pageURL));
			windowArray[windowArray.length] = window.open(thisURL, 'emailWindow', 'width=520,height=350,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0');
		}
	}

	//
	// print this page
	// Usage:
	// <a href="javascript:printPage(ID);">LINK</a>
	//
	function printPage(id)
	{
		windowArray[windowArray.length] = window.open(printURL.replace('%%id%%', id), 'printWindow', 'width=800,height=400,toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1');
	}
	
	//
	// bookmark this page (compatible with IE only)
	// Usage:
	// <a href="javascript:bookmarkPage();">LINK</a>
	//
	function bookmarkPage()
	{
		if (isMac || isAOL)
		{
			alert('Sorry, this feature is not supported by your browser.');
			return;
		}

		if (!isNS)
		{
			window.external.AddFavorite(this.location.href, document.title);
		}
		else
		{
			alert('Click "OK", then type CTRL-D to add this page to your list of bookmarks.');
		}
	}
	
	//
	// set as homepage (compatible with IE only)
	// Usage:
	// <a href="javascript:setHomepage();">LINK</a>
	//
	function setHomepage()
	{
		if (!isIE || isAOL)
		{
			alert('Sorry, this feature is not supported by your browser.');
			return;
		}
	
		document.body.style.behavior = 'url(#default#homePage)';
		document.body.setHomePage(pageURL);
	}

	//
	// find similar pages
	// Usage:
	// <a href="javascript:findSimilar();">LINK</a>
	//
	function findSimilar()
	{
		top.location.href = similarURL.replace('%%url%%', pageURL);
	}

	//
	// adjust font size (incompatible with NS4)
	// Usage:
	// <a href="javascript:fontSize(-1|+1);">LINK</a>
	//
	function fontSize(amt)
	{
		if (isNS4)
		{
			alert('Sorry, this feature is not supported by your browser.');
			return;
		}

		if (amt == 1)
		{
			
		}
		else if (amt == -1)
		{
			
		}
	}

	//
	// toggle highlighting (incompatible with NS4)
	// Usage:
	// <a href="javascript:toggleHighlight();">LINK</a>
	//
	function toggleHighlight()
	{
		if (isNS4)
		{
			alert('Sorry, this feature is not supported by your browser.');
			return;
		}

		var elementList = document.getElementsByTagName('*');
		for (i = 0; i < elementList.length; i++)
		{
			elementList[i].className = (elementList[i].className == 'highlight') ? 'highlight_disabled' : 'highlight';
		}
		writeCookie('highlight', ((readCookie('highlight') != 'false') ? 'false' : 'true'));
	}

// page load routines
	// set contextual styles (incompatible with NS4)
	function setContextStyles()
	{
		if (isNS4) return;

		var elementList = document.getElementsByTagName('*');
		for (i = 0; i < elementList.length; i++)
		{
			for (j = 0; j < contextStyles.length; j++)
			{
				if (elementList[i].className == contextStyles[j][0])
				{
					currentNode = elementList[i].firstChild;
					while (currentNode)
					{
						if (currentNode.className == contextStyles[j][1])
						{
							switch (contextStyles[j][2])
							{
								case 'ital-off':
									currentNode.style.fontStyle = 'normal';
									break;
								case 'ital-on':
									currentNode.style.fontStyle = 'italic';
									break;
								case 'bold-off':
									currentNode.style.fontWeight = 'normal';
									break;
								case 'bold-on':
									currentNode.style.fontWeight = 'bold';
									break;
								default:
									break;
							}
						}
						currentNode = currentNode.nextSibling;
					}
				}
			}
		}
	}
	
// global dropdown menus
	// CHRISTIANITY TODAY menu
	menu['global_christianitytoday'] = new Array();
	menu['global_christianitytoday'][0] = '<a href="http://www.christianitytoday.com/ct/" target="_parent">Christianity Today</a>';
	menu['global_christianitytoday'][1] = '<a href="http://www.booksandculture.com/" target="_parent">Books &amp; Culture</a>';
	menu['global_christianitytoday'][2] = '<a href="http://www.christianitytoday.com/ch/" target="_parent">Christian History</a>';
	menu['global_christianitytoday'][3] = '<a href="http://blog.christianitytoday.com/ctmovies/" target="_parent">CT Entertainment Blog</a>';
	menu['global_christianitytoday'][4] = '<a href="http://www.ctlibrary.com/" target="_parent">CT Library</a>';
	menu['global_christianitytoday'][5] = '<a href="http://blog.christianitytoday.com/ctliveblog/" target="_parent">CT Liveblog</a>';
	menu['global_christianitytoday'][6] = '<a href="http://blog.christianitytoday.com/ctpolitics/" target="_parent">CT Politics Blog</a>';
	menu['global_christianitytoday'][7] = '<a href="http://blog.christianitytoday.com/women/" target="_parent">Her.meneutics (Women&#39;s) Blog</a>';
	menu['global_christianitytoday'][8] = '<a href="http://www.christianitytoday.com/international/" target="_parent">International Christianity</a>';
	menu['global_christianitytoday'][9] = '<a href="http://www.christianitytoday.com/globalconversation/" target="_parent">The Global Conversation</a>';
	
	// PASTORAL LEADERSHIP menu
	menu['global_pastoralleadership'] = new Array();
	menu['global_pastoralleadership'][0] = '<a href="http://www.christianitytoday.com/le/" target="_parent">Leadership Journal</a>';
	menu['global_pastoralleadership'][1] = '<a href="http://www.catalystleadershipdigital.com/" target="_parent">Catalyst Leadership</a>';
	menu['global_pastoralleadership'][2] = '<a href="http://www.giftedforleadership.com/" target="_parent">Gifted for Leadership</a>';
	menu['global_pastoralleadership'][3] = '<a href="http://www.outofur.com/" target="_parent">Out of Ur Blog</a>';
	menu['global_pastoralleadership'][4] = '<a href="http://www.preachingtoday.com/" target="_parent">Preaching Today</a>';
	menu['global_pastoralleadership'][5] = '<a href="http://media.preachingtoday.com/" target="_parent">Preaching Today Media Store</a>';
	
	// CHURCH MANAGEMENT menu
	menu['global_churchmanagement'] = new Array();
	menu['global_churchmanagement'][0] = '<a href="http://www.churchlawandtax.com/" target="_parent">Church Law and Tax</a>';
	menu['global_churchmanagement'][1] = '<a href="http://www.churchlawandtax.com/ctainfo.php" target="_parent">Church Finance Today</a>';
	menu['global_churchmanagement'][2] = '<a href="http://store.yahoo.com/cgi-bin/clink?yhst-78230354700659+u6MRfC+index.html" target="_parent">Your Church Resources Store</a>';
	menu['global_churchmanagement'][3] = '<a href="http://www.churchsafety.com/" target="_parent">Church Safety</a>';
	menu['global_churchmanagement'][4] = '<a href="http://www.christianitytoday.com/cbg/" target="_parent">Church Buyer&#39;s Guide</a>';
	menu['global_churchmanagement'][5] = '<a href="http://www.reducingtherisk.com/" target="_parent">Reducing the Risk</a>';
	menu['global_churchmanagement'][6] = '<a href="http://blog.yourchurch.net/" target="_parent">Managing Your Church Blog</a>';

	// LEADER TRAINING menu
	menu['global_leadertraining'] = new Array();
	menu['global_leadertraining'][0] = '<a href="http://www.buildingchurchleaders.com/" target="_parent">Building Church Leaders</a>';
	menu['global_leadertraining'][1] = '<a href="http://www.seminarygradschool.com/" target="_parent">Seminary/Grad School Guide</a>';
	menu['global_leadertraining'][2] = '<a href="http://www.smallgroups.com/" target="_parent">Small Groups</a>';

	// DISCIPLESHIP menu
	menu['global_discipleship'] = new Array();
	menu['global_discipleship'][0] = '<a href="http://www.christianitytoday.com/biblestudies/" target="_parent">Christian Bible Studies</a>';
	menu['global_discipleship'][1] = '<a href="http://www.christiancollegeguide.net/" target="_parent">Christian College Guide</a>';
	menu['global_discipleship'][2] = '<a href="http://www.christianitytoday.com/workplace/" target="_parent">Faith in the Workplace</a>';
	menu['global_discipleship'][3] = '<a href="http://www.giftedforleadership.com/" target="_parent">Gifted for Leadership</a>';
	menu['global_discipleship'][4] = '<a href="http://www.christianitytoday.com/holidays/" target="_parent">Holidays</a>';
	menu['global_discipleship'][5] = '<a href="http://www.christianitytoday.com/iyf/" target="_parent">Ignite Your Faith (Teens)</a>';
	menu['global_discipleship'][6] = '<a href="http://www.kyria.com/" target="_parent">Kyria (Women)</a>';
	menu['global_discipleship'][7] = '<a href="http://kyria.com/topics/marriagefamily/marriage/" target="_parent">Marriage Partnership</a>';
	menu['global_discipleship'][8] = '<a href="http://www.christianitytoday.com/moi/" target="_parent">Men of Integrity</a>';
	menu['global_discipleship'][9] = '<a href="http://kyria.com/topics/marriagefamily/parenting/" target="_parent">ParentConnect</a>';
	menu['global_discipleship'][10] = '<a href="http://www.christianitytoday.com/shopping/" target="_parent">Shopping</a>';
	menu['global_discipleship'][11] = '<a href="http://www.kyria.com/" target="_parent">Women (Kyria)</a>';

	// MAGAZINES menu
	menu['global_magazines'] = new Array();
	menu['global_magazines'][0] = '<a href="http://www.christianitytoday.com/ct/" target="_parent">Christianity Today</a>';
	menu['global_magazines'][1] = '<a href="http://www.booksandculture.com/" target="_parent">Books &amp; Culture</a>';
	menu['global_magazines'][2] = '<a href="http://www.catalystleadershipdigital.com/" target="_parent">Catalyst Leadership Digital</a>';
	menu['global_magazines'][3] = '<a href="http://www.churchlawandtax.com/" target="_parent">Church Law &amp; Tax Report</a>';
	menu['global_magazines'][4] = '<a href="http://www.churchlawandtax.com/ctainfo.php" target="_parent">Church Finance Today</a>';
	menu['global_magazines'][5] = '<a href="http://www.kyria.com/digital/" target="_parent">Kyria Digital</a>';
	menu['global_magazines'][6] = '<a href="http://www.christianitytoday.com/le/" target="_parent">Leadership</a>';
	menu['global_magazines'][7] = '<a href="http://www.christianitytoday.com/moi/" target="_parent">Men of Integrity</a>';
	menu['global_magazines'][8] = '<a href="http://www.christianitytoday.com/free/features/magazines.html" target="_parent">Free Trial Offers</a>';
	menu['global_magazines'][9] = '<a href="http://www.christianitytoday.com/myaccount/?page=magazines" target="_parent">Customer Care</a>';
	menu['global_magazines'][10] = '<a href="http://www.ctiadvertising.com/" target="_parent">Advertise with Us</a>';

	// SHOPPING menu
	menu['global_shopping'] = new Array();
	menu['global_shopping'][0] = '<a href="http://store.yahoo.com/cgi-bin/clink?biblestudies+TtWdCB+index.html" class="external">Bible Studies</a>';
	menu['global_shopping'][1] = '<a href="http://www.christianbook.com/bibles/?p=1029826" class="external">Bibles</a>';
	menu['global_shopping'][2] = '<a href="http://www.christianbook.com/html/static/home_page.html?p=1029826" class="external">Books</a>';
	menu['global_shopping'][3] = '<a href="http://www.christianitytoday.com/cbg/" class="external">Church Buyer&#39;s Guide</a>';
	menu['global_shopping'][4] = '<a href="http://cticlassifieds.com/" class="external">Classifieds</a>';
	menu['global_shopping'][5] = '<a href="http://www.christianbook.com/dvds/?p=1029826" class="external">DVDs</a>';
	menu['global_shopping'][6] = '<a href="http://www.christianbook.com/gifts/?p=1029826" class="external">Gifts</a>';
	menu['global_shopping'][7] = '<a href="http://www.buildingchurchleaders.com/" class="external">Leader Training</a>';
	menu['global_shopping'][8] = '<a href="http://www.christianbook.com/html/static/music.html?p=1029826" class="external">Music</a>';
	menu['global_shopping'][9] = '<a href="http://www.preachingtoday.com/" class="external">Sermons</a>';
	menu['global_shopping'][10] = '<a href="http://www.smallgroups.com/" class="external">Small Groups</a>';
	menu['global_shopping'][11] = '<a href="http://store.yahoo.com/cgi-bin/clink?yhst-52795328905550+MaaJVL+index.html" class="external">Women&#39;s Ministry</a>';

	// FREE menu
	menu['global_free'] = new Array();
	menu['global_free'][0] = '<a href="http://www.christianitytoday.com/free/features/magazines.html" target="_parent">Magazines</a>';
	menu['global_free'][1] = '<a href="http://store.yahoo.com/biblestudies/freesamples.html" target="_parent">Bible Studies</a>';
	menu['global_free'][2] = '<a href="http://www.christiancollegeguide.net/" target="_parent">ChristianCollegeGuide.net</a>';
	menu['global_free'][3] = '<a href="http://www.christianitytoday.com/ecards/" target="_parent">E-cards</a>';
	menu['global_free'][4] = '<a href="http://buildingchurchleaders.com/store/freesamples.html" target="_parent">Leader Training</a>';
	menu['global_free'][5] = '<a href="http://www.christianitytoday.com/free/features/newsletters.html" target="_parent">Newsletters</a>';
	menu['global_free'][6] = '<a href="http://www.preachingtoday.com/store/free.html" target="_parent">Preaching Resources</a>';
	menu['global_free'][7] = '<a href="http://www.christianitytoday.com/help/features/rss.html" target="_parent">RSS Feeds</a>';
	menu['global_free'][8] = '<a href="http://www.seminarygradschool.com/" target="_parent">SeminaryGradSchool.com</a>';

//GLOBAL MULTI NL SIGNUP TOOL FUNCTIONS

function get_checked_items() {
var c_value = "";
var c_text = "";
var s_email = "";
for (var i=0; i < document.subscribeform.list.length; i++)
   {
   if (document.subscribeform.list[i].checked)
      {
      c_value = c_value + document.subscribeform.list[i].value + " ";
      
	      switch(document.subscribeform.list[i].value) {
					case "booksandculture-html":
	      		c_text = c_text + "Books & Culture (weekly) \n";
	      		break;
					case "buildingsmallgroups-html":
	      		c_text = c_text + "Building Small Groups (monthly) \n";
	      		break;
					case "biblestudies-html":
	      		c_text = c_text + "Christian Bible Studies (weekly) \n";
	      		break;
					case "history-html":
	      		c_text = c_text + "Christian History & Biography Newsletter (weekly) \n";
	      		break;
					case "ctlibrary-html":
	      		c_text = c_text + "CT Library Newsletter -- ChristianityTodayLibrary.com (semimonthly) \n";
	      		break;
					case "visionproject":
	      		c_text = c_text + "The Christian Vision Project (monthly) \n";
	      		break;
					case "churchlaughs-html":
	      		c_text = c_text + "Church Laughs (weekly) \n";
	      		break;
					case "churchplaza-html":
	      		c_text = c_text + "Church Plaza Newsletter (monthly) \n";
	      		break;
					case "collegeguide":
	      		c_text = c_text + "College Guide (monthly) \n";
	      		break;
					case "connection-html":
	      		c_text = c_text + "The Connection -- HTML (weekly) \n";
	      		break;
					case "connection":
	      		c_text = c_text + "The Connection -- Text-only (weekly) \n";
	      		break;
					case "ctdirect-html":
	      		c_text = c_text + "CTDirect (daily) \n";
	      		break;
					case "ctweekly-html":
	      		c_text = c_text + "CTWeekly \n";
	      		break;
					case "movies-html":
	      		c_text = c_text + "CT at the Movies (weekly) \n";
	      		break;
					case "e-cards-html":
	      		c_text = c_text + "E-Cards (Holiday Reminder) \n";
	      		break;
					case "workplace-html":
	      		c_text = c_text + "Faith in the Workplace Newsletter (biweekly) \n";
	      		break;
					case "hottopics":
	      		c_text = c_text + "Hot Topics Newsletter (monthly) \n";
	      		break;
					case "campuslife-html":
	      		c_text = c_text + "Ignite Your Faith Connection (weekly) \n";
	      		break;
					case "ctcourses-html":
	      		c_text = c_text + "Interactive Training Courses \n";
	      		break;
	      		case "womenleaders":
	      		c_text = c_text + "Gifted for Leadership \n";
	      		break;	      		
					case "leadership-html":
	      		c_text = c_text + "Leadership Weekly \n";
	      		break;
					case "marriage-html":
	      		c_text = c_text + "Marriage Connection (biweekly) \n";
	      		break;
					case "men-html":
	      		c_text = c_text + "Men in the Word (weekly) \n";
	      		break;
					case "music-html":
	      		c_text = c_text + "Music Connection (weekly) \n";
	      		break;
					case "outreach-html":
	      		c_text = c_text + "Outreach & Evangelism Newsletter (biweekly) \n";
	      		break;
					case "ptaudio-html":
	      		c_text = c_text + "Preaching Today Audio (monthly) \n";
	      		break;
					case "ptsermons":
	      		c_text = c_text + "Preaching Today Sermons (weekly) \n";
	      		break;
					case "wiu-html":
	      		c_text = c_text + "Preaching Connection (weekly) \n";
	      		break;
					case "singles-html":
	      		c_text = c_text + "The Singles Channel Newsletter (weekly) \n";
	      		break;
					case "childrensministry-html":
	      		c_text = c_text + "Today's Children's Ministry (monthly) \n";
	      		break;
					case "tctoolbox-html":
	      		c_text = c_text + "Today's Christian Toolbox (bimonthly) \n";
	      		break;
					case "todayschristian-html":
	      		c_text = c_text + "Today's Christian Weekly \n";
	      		break;
					case "women-html":
	      		c_text = c_text + "Women's Connection (weekly) \n";
	      		break;
					case "yourchurch-html":
	      		c_text = c_text + "Your Church (biweekly) \n";
	      		break;
					case "churchsafety":
	      		c_text = c_text + "ChurchSafety.com Newsletter (monthly) \n";
	      		break;
	      		case "buildingchurchleaders":
	      		c_text = c_text + "Building Church Leaders (weekly) \n";
	      		break;
	      		case "reducingtheriskquicktip":
	      		c_text = c_text + "Reducing the Risk Quick Tip (weekly) \n";
	      		break;
	      }
      }
   }
   
   if (c_text != "") {
	   s_email = document.subscribeform.email.value;
	   document.subscribeform.checkedboxes.value = c_value;
	   c_text = "The email address " + s_email + " has been subscribed to the following Newsletters:\n" + c_text;
	   alert(c_text);
	   return true;
	} else {
		c_text = "Please select at least one Newsletter";
	  alert(c_text);
	  return false;
	}
}
	emailre = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	function check_email(theForm){
		if (emailre.test(theForm.email.value)) {
			return true;
		}				
			alert("Please enter a valid Email address");
			theForm.email.focus();
			theForm.email.select();
			return false;
	}
	
var cti = {};
cti.getElementsByClass = function(theClass) {
	var elems = (document.all) ? document.all : document.getElementsByTagName('*'),
		pattern = new RegExp('(^| )' + theClass + '( |$)'),
		matched = [], l = elems.length, i = 0;
	while (i < l) {
		if (pattern.test(elems[i].className)) matched.push(elems[i]);
		i += 1;
	}
	return matched;
};
// Courtesy of PPK @ quirksmode.org
cti.getPosition = function(elem) {
	var l = t = 0;
	if (elem.offsetParent) {
		l = elem.offsetLeft;
		t = elem.offsetTop;
		while (elem = elem.offsetParent) {
			l += elem.offsetLeft;
			t += elem.offsetTop;
		}
	}
	return {x: l, y: t};
}
cti.reportComments = function() {
	var elems = cti.getElementsByClass('reportComment'),
		l = elems. length, i;
	for (i = 0; i < l; i += 1) {
		elems[i].onclick = function(i) {
			return function(e) {
				var elem = elems[i],
					pos = cti.getPosition(elem),
					comment = elem.id.replace('report', ''),
					container = document.getElementById('whyReport'),
					createContainer = function() {
						container = document.createElement('div');
						container.id = 'whyReport';
						container.innerHTML = '<h3>I am reporting this comment because*: <span>(check all that apply)</span></h3><form method="get" action="/system/comments/report.html"><fieldset class="inline"><div><input type="checkbox" id="spam" class="checkbox" name="reason" value="spam" /><label for="spam">It is spam or advertising</label></div><div><input type="checkbox" id="vulgarity" class="checkbox" name="reason" value="vulgarity" /><label for="vulgarity">It contains vulgarities</label></div><div><input type="checkbox" id="inflammatory" class="checkbox" name="reason" value="inflammatory" /><label for="inflammatory">It is inflammatory or attacks another person</label></div><div><input type="checkbox" id="offtopic" class="checkbox" name="reason" value="offtopic" /><label for="offtopic">It is completely off-topic</label></div><div><input type="hidden" id="reportedComment" name="id" value="" /><input type="submit" value="Submit" /><input type="button" id="cancelReport" value="Cancel" /></div></fieldset></form><p class="disclaimer">*We will only consider removing comments for the reasons listed above. Comments will not be removed because of disagreement of opinion.</p>';
						
						document.body.appendChild(container);
						return container;
					},
					commentForm;
					
				if (!container) {
					container = createContainer();
					document.getElementById('cancelReport').onclick = function() {
						container.style.cssText = 'position: absolute; top: 0; left: -999em; visibility: hidden;';
					};
					commentForm = container.getElementsByTagName('form')[0];
					commentForm.onsubmit = function() {
						var inputs = container.getElementsByTagName('input'),
							reason = '', l = inputs.length, i;
						for (i = 0; i < l; i += 1) {
							if (inputs[i].name === 'reason' && inputs[i].checked) reason += inputs[i].value;
						}
						
						if (reason === '') {
							alert('Please specify why you are reporting this comment.');
							return false;
						}
					};
				}
				
				document.getElementById('reportedComment').value = comment;
				container.style.cssText = 'position: absolute; top: ' + (pos.y + 20) + 'px; left: ' + pos.x + 'px; visibility: visible;';
				return false;
			}
		}(i);
	}
};

// This function relies on the IPInfoDB api: http://ipinfodb.com
	var Geolocate = function Geolocate(objectVar, cityPrecision, timezone, callback) {
		var api = (cityPrecision) ? "ip_query.php" : "ip_query_country.php",
			timezone = (timezone) ? 'true' : 'false',
			apiKey = '5ae3767203f9b8299534e63b00127854d99d8aec28024d92e6e33a7bffb1cf6a',
			url = "http://api.ipinfodb.com/v2/" + api + "?key=" + apiKey + "&output=json&timezone=" + timezone + "&callback=" + objectVar + ".setGeoCookie",
			geodata,
			JSON = JSON || {};
	
		// implement JSON.stringify serialization
		JSON.stringify = JSON.stringify || function (obj) {
			var t = typeof (obj);
			if (t != "object" || obj === null) {
				// simple data type
				if (t == "string") obj = '"'+obj+'"';
				return String(obj);
			} else {
				// recurse array or object
				var n, v, json = [], arr = (obj && obj.constructor == Array);
				for (n in obj) {
					v = obj[n]; t = typeof(v);
					if (t == "string") v = '"'+v+'"';
					else if (t == "object" && v !== null) v = JSON.stringify(v);
					json.push((arr ? "" : '"' + n + '":') + String(v));
				}
				return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
			}
		};
	
		// implement JSON.parse de-serialization
		JSON.parse = JSON.parse || function (str) {
			if (str === "") str = '""';
			eval("var p=" + str + ";");
			return p;
		};
	
		//Check if cookie already exist. If not, query IPInfoDB
		this.initialize = function(callback) {
			var cache = readCookie('ctiGeolocation');
			if (!cache) {
				this.getGeolocation();
			} else {
				geodata = JSON.parse(cache);
				callback(geodata);
			}
		}
	
		//API callback function that sets the cookie with the serialized JSON answer
		this.setGeoCookie = function(response) {
			if (response['Status'] == 'OK') {
				var JSONString = JSON.stringify(response),
					d = new Date(),
					y = d.getFullYear();
				d.setFullYear(y + 1);
				writeCookie('geolocation', JSONString, d);
				geodata = response;
				callback(geodata);
			}
		}
	
		//Request to IPInfoDB
		this.getGeolocation = function() {
			var script = document.createElement('script');
			script.src = url;
			document.body.appendChild(script);
		}
	};
