/* Author: Jericho Coffee */

Jericho = {
	common: {
		init: function() {
			/* hack for iframe hover on IE */
			if($.browser.msie){
			 $(document).delegate('.upcomingevents li, .social', 'mouseenter',function() {
					$(this).addClass('hover');
			 });
			 $(document).delegate('.upcomingevents li, .social', 'mouseleave',function() {
					$(this).removeClass('hover');
			 });
			}
		} // end common init
	}, // end common
	
  /*------------------------------------------------
	 * Events page
	 *-----------------------------------------------*/
	events: {
		init: function() {
			$('#calendar').fullCalendar({
				aspectRatio: 1.6,
				header: {
					left: 'today prev,next',
					center: 'title',
					right: 'month,agendaWeek,agendaDay'
				},
				theme: true,
				weekMode: 'variable',
				minTime: 6,
				maxTime: 22,
				allDaySlot: false,
				allDayDefault: false,
				events: 'feeds/events.php',
				loading: function(isLoading, view) {
					if(isLoading) {
						$('#calendar').loading(true, { mask: true, effect: 'ellipsis', delay: 100, align: 'top-center', classname: 'loading', pulse: 'error' });
					}
					else {
						$('#calendar').loading(false);
					}
				},
				eventClick: function(event) {
					if (event.url) {
							window.open(event.url);
							return false;
					}
				},
				// eventColor: '#FFFFFF', // this is the background & border as one
				eventBackgroundColor: '#9D2D01',
				eventBorderColor: '#681818'
				//eventTextColor: '#000000' 
			});
		} // end events init
	}, // end events
	
	/*------------------------------------------------
	 * Menu page
	 *-----------------------------------------------*/
	menu: {
		init: function() {
			$('#drinkaccordion > li[data-role="list-divider"] > a').wrap('<div />')
			$('#drinkaccordion').accordion( { autoHeight: false, collapsible: true, active: false, header: 'li[data-role=list-divider] > div' } );
			$('#foodaccordion > li[data-role="list-divider"] > a').wrap('<div />')
			$('#foodaccordion').accordion( { autoHeight: false, collapsible: true, active: false, header: 'li[data-role=list-divider] > div' } );
			$('#menutabs').tabs({
				create: function(event, ui) { $('#menutabs').show(); }
			});
		} // end menu init
	} // end menu
} // end Jericho

UTIL = {
  exec: function( page) {
    var ns = Jericho;
    if ( page !== "" && ns[page] && typeof ns[page]['init'] == 'function' ) {
      ns[page]['init']();
    }
  },

  init: function() {
    var body = document.body,
        page = body.getAttribute( "data-page" );
        
    UTIL.exec( "common" );
    UTIL.exec( page );
  }
};

$(document).ready(UTIL.init);
