﻿// JavaScript Document
/* update cursor on add/remove click event */
Element.Events.click = { 
	base:'click',
	onAdd: function() {
		if(this.setStyle) {
			this.store('original-cursor',this.getStyle('cursor'));
			this.setStyle('cursor','pointer');
		}
	},
	onRemove: function() {
		if(this.setStyle) {
			this.setStyle('cursor',this.retrieve('original-cursor'));
		}
	}
};


window.addEvent('domready', function() {

		
//the following line gets commented out when there isn't a special event
//be sure to find the same thing at the bottom of index.html to comment it out
milkbox.showGallery({ gallery:'gall1' })


	//We can use one Request object many times.

	var req = new Request.HTML({url:'sermon.php', 

		onSuccess: function(html)

		{

			//Clear the text currently inside the content div.

			$('sermoncontent').set('text', '');

			//Inject the new DOM elements into the content div.

			$('sermoncontent').adopt(html);

		},

		//Our request will most likely succeed, but just in case, we'll add an

		//onFailure method which will let the user know what happened.

		onFailure: function()

		{

			$('sermoncontent').set('text', 'The request failed.');

		}

	});
	
//	var cch = new Request.HTML({url:'cch.php', 
//
//		onSuccess: function(html)
//
//		{
//
//			//Clear the text currently inside the content div.
//
//			$('content').set('text', '');
//
//			//Inject the new DOM elements into the content div.
//
//			$('content').adopt(html);
//
//		},
//
//		//Our request will most likely succeed, but just in case, we'll add an
//
//		//onFailure method which will let the user know what happened.
//
//		onFailure: function()
//
//		{
//
//			$('content').set('text', 'The request failed.');
//
//		}
//
//	});
	
	var worshipReq = new Request.HTML({url:'worship.php', 

		onSuccess: function(html)

		{

			//Clear the text currently inside the content div.

			$('sermoncontent').set('text', 'Please check back.');

			//Inject the new DOM elements into the content div.

			$('sermoncontent').adopt(html);

		},

		//Our request will most likely succeed, but just in case, we'll add an

		//onFailure method which will let the user know what happened.

		onFailure: function()

		{

			$('sermoncontent').set('text', 'The request failed.');

		}

	});
	
	
	$('sermons').addEvent('click', function()

	{

		req.send();

	});
	
//	$('cch').addEvent('click', function()
//
//	{
//
//		cch.send();
//		$('connect').setStyles({display:'none'});
//
//	});

	$('worship').addEvent('click', function()

	{

		worshipReq.send();

	});

		$('connect').setStyles({

			display:'none'

		}).addEvents({'mouseenter': function(){$('connect').setStyles({display:'block'});
												$('sermoncontent').set('text', ''); 

		    }, 

		    'mouseleave': function(){ 

		      $('connect').setStyles({display:'none'}); 

		}

		});

		$('grow').setStyles({

			display:'none'

		}).addEvents({'mouseenter': function(){$('grow').setStyles({display:'block'});
												$('sermoncontent').set('text', '');
												$('ourmission').setStyles({display:'none'});
		    }, 

		    'mouseleave': function(){ 

		      $('grow').setStyles({display:'none'});
			  $('ourmission').setStyles({display:'block'}); 

		}

		});

		$('serve').setStyles({

			display:'none'

		}).addEvents({'mouseenter': function(){$('serve').setStyles({display:'block'});
												$('sermoncontent').set('text', '');
		    }, 

		    'mouseleave': function(){ 

		      $('serve').setStyles({display:'none'}); 
		}

		});



		$('cshow').addEvents({ 

		    'mouseenter': function(){ 

		      $('connect').setStyles({display:'block'}); 

		    }, 

		    'mouseleave': function(){ 

		      $('connect').setStyles({display:'none'}); 

		    } 

		});

		$('gshow').addEvents({ 

		    'mouseenter': function(){ 

		      $('grow').setStyles({display:'block'}); 

		    } 

		});

		$('sshow').addEvents({ 

		    'mouseenter': function(){ 

		      $('serve').setStyles({display:'block'}); 

		    }, 

		    'mouseleave': function(){ 

		      $('serve').setStyles({display:'none'}); 

		    } 

		});

  new Fx.Accordion($('accordion'), '#accordion li', '#accordion .content', { trigger:'mouseenter' });
  new Fx.Accordion($('accordion'), '#growaccord li', '#growaccord .content', { trigger:'mouseenter' });
});


