/**
 * Public site singleton
 * 
 * @author Ollie Maitland
 * @copyright Byng Systems LLP
 */

var Public = 
{
	/**
	 * Start the page
	 * 
	 */
	start : function ()
	{
		if ($('tab_list')) {
			tabs = new mootabs('tab_list');
			var hash = window.location.hash.substring(1);
			tabs.activate(hash);
		}
		
		if ($('upcoming_events')) {
			var hash = window.location.hash.substring(1);
			// locate the active elements
			if (hash) {
				var firstElementsOpen = [];
				$ES('div.element',$('upcoming_events')).each(function(el,idx) {
					if (hash == el.getAttribute('accesskey'))  firstElementsOpen.push(idx);
				});
				setTimeout(function(){ window.location = '#'+hash },400);
			}		
			var accordion = new MultipleOpenAccordion($$('a.atStart'), $$('div.atStart'), 
														{ 'openAll': false, 'allowMultipleOpen' : true, 
														  'firstElementsOpen' : firstElementsOpen});
		}
		
		if ($('flashbody')) {
				swfobject.embedSWF("/html/flash/intro4.swf","flash", "958", "300", "8.0.0", false, false, {xi:"true", wmode:"transparent"}); 
		}

		if ($('links')) {
			var accordion = new MultipleOpenAccordion($$('a.atStart'), $$('div.atStart'), 
														{ 'openAll': false, 'allowMultipleOpen' : true});
		}

		if ($('blog')) {
			var readMore = new MultipleOpenAccordion($$('a.atStart'), $$('dd.atStart'), 
														{ 'openAll': false, 'allowMultipleOpen' : true});
		}


		// menu link effects
		$ES('#top_nav a.hover_over').each(function(element) {
			 	
			 	// enter effect
				var fx = new Fx.Styles(element, {duration:250, wait:false});
				element.addEvent('mouseenter', function() {
					fx.start({'padding-top': 7, 'color': '#666' });
				});
			 	
			 	// leave effect
				element.addEvent('mouseleave', function() {
					fx.start({'padding-top': 0, 'color': '#404040' });
				});
			 
			});
		
		// schedule link effects
		$ES('#top_nav a.hover_schedule').each(function(el) {
			
			 	// enter effect
				var fx = new Fx.Styles(el, {duration:250, wait:false});
				el.addEvent('mouseenter', function(){
					fx.start({ 'padding-top': 7, 'color': '#C8AF7C' });
				});
			 
			 	// leave effect
				el.addEvent('mouseleave', function(){
					fx.start({ 'padding-top': 0, 'color': '#996600' });
				});
			});
	}
	
}
// domread -> load the page
window.addEvent('domready', Public.start);