// Multi-slide - used to hide information on long pages. User clicks on heading to reveal the information.
function Enable_Multislide() { 	window.addEvent('domready',function() {
		multislide = new multislide('ms_container', 
				{	onExpand: function(el){
						el.addClass('arrow');
					},	
					onCollapse: function(el){
						el.removeClass('arrow');
					}
				});
		var hash = window.location.hash.substr(1); //strip off the leading #
		if (hash) {
			multislide.expand_ifcontains(hash);
			var hashEl = $(hash);
			if (hashEl) {
				var myFx = new Fx.Scroll(window).toElement(hashEl);
			}
		}
		$(document.body).getElements('a[href^=#]').each(function(item){
			href = item.getProperty('href').substr(1);
			item.addEvent('click', function(){
				this.expand_ifcontains(arguments[0]);
				var hashEl = $(arguments[0]);
				if (hashEl) {
					var myFx = new Fx.Scroll(window).toElement(hashEl);
					return false;
				}
				
			}.pass(href, multislide));
		});
	});
}

function playerButton(id)
{
   Element.replace('listen_button','<a href="#' + id + '" onclick="openPlayer(' + id + ');" id="listen_button"><img src="/stylesheets/images/customer/listen_full.jpg" /></a>')
}

function openPlayer(id)
{
   window.open('/player/for/'+ id, 'rejoicemusicplayer', "width=600,height=380,menubar=no,toolbar=no,location=no,scrollbars=no,status=no,resizable=no")
}

// Get the object used for callbacks
function GetXmlHttpObject()
{
	var XMLHttp = null

	try
	{
		XMLHttp = new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch (e)
	{
		try
		{
			XMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch (e)
		{
			XMLHttp = null
		}
	}

	if (XMLHttp == null)
		XMLHttp = new XMLHttpRequest()

	return XMLHttp
}

// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17212171-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

window.addEvent('domready', function()
{
	var elements, elementIndex, emailAddress, correctedEmailAddress;

	elements = $$('a[href]');
	for (elementIndex = 0; elementIndex < elements.length; elementIndex++)
	{
		if (elements[elementIndex].href.match(/^mailto:/))
		{
			emailAddress = elements[elementIndex].href.replace('mailto:', '');
			correctedEmailAddress = emailAddress.replace(/\*/g, '@').replace(/\|/g, '.');
			elements[elementIndex].set('href', elements[elementIndex].get('href').replace(emailAddress, correctedEmailAddress));
			elements[elementIndex].set('html', elements[elementIndex].get('html').replace(new RegExp(emailAddress.replace(/([*|])/g, '\\$1'), 'i'), correctedEmailAddress));
		}
	}

	elements = $$('.emailTransform');
	for (elementIndex = 0; elementIndex < elements.length; elementIndex++)
	{
		elements[elementIndex].set('text', elements[elementIndex].get('text').replace(/\*/g, '@').replace(/\|/g, '.'));
	}
});
