var TEMPLATE = {};

$(function() {
	TEMPLATE.mainNav();
	TEMPLATE.showHeaderHours();
	TEMPLATE.showFooterHours();
	TEMPLATE.addCommentButton();
});

TEMPLATE = {

	mainNav : function()
	{
		$('#navigation').find('ul').find('ul').addClass('level_2');
		$('#navigation').find('ul').find('ul').find('ul').addClass('level_3');
		
		$('.level_1').find('a').each(function(){
			if( $(this).attr('href').split('/')[4] == '#'){ // 3 FOR LIVE SITE, 4 FOR LOCAL
				$(this).css('cursor', 'default').click(function(){
					return false;
				});
			}
		});
		
		$('#navigation').find('ul:first').find('li').hover(function(){
			$(this).children('ul').css({display: 'block'});
		}, function() {
			$(this).children('ul').css({display: 'none'});
		});
	},

	showHeaderHours : function()
	{
		$('#locations').find('a.hoursLink').click(function(){
			$('#locations').find('h5').css({opacity: '0.3'});
			$(this).parent('h5').css({opacity: '1'}).addClass('selected').next('div').slideDown('slow');	
			$('html').click(function(){
					$('#locations').find('h5.selected').removeClass('selected').next('div').slideUp('slow');	
					$('#locations').find('h5').css({opacity: '1'});			   
			});
			return false;
		});
	},
	
	showFooterHours : function()
	{
		$('#footer').find('a.hoursLink').click(function(){
			$('.f-locationHours:visible').slideUp('slow').end();
			$('#footer').find('p.selected').removeClass();
			$(this).parent('p').addClass('selected').next('div.f-locationHours:hidden').slideDown('slow');	
			$('html').click(function(){
				$('.wraplocation').find('p').css({opacity: '1'}).removeClass('selected');
				$(this).find('div.f-locationHours:visible').slideUp('slow');		   
			});
			return false;
		});
	},

	addCommentButton : function()
	{
		$('.addCommentButton').click(function(){
			$('#comments_form_container').slideToggle('slow', function(){
				$(this).find('#name').focus();
			});
		});
	}
	
}
