// Corner Cafe homepage specials and galleries tabs

$(document).ready( function(){
	
	
	if ($('.gallery-container').length > 0)
	{
		
		$('.gallery-container:first').cycle({
			fx: 'fade',
			cleartype: true,
			cleartypeNoBg: true,
			startingSlide: 1,  // start on the slide that was in the markup
			timeout:  6000,
			speed:    900,
			prev:    '#prev',
			next:    '#next'
		});
		
	}
	
	$('.gallery-container:first').removeClass('hidden');
	
	$('.gallery-link a:first').addClass('selected',function() {
		
		Cufon.refresh();
		
	});
	
		$('.thumb').live('mouseover',function(){
											  
		$(this).animate({queue:false,duration:100});
		
			$(this).stop().animate({ opacity: 0.3 }, 100);
			
		}).live('mouseleave',function(){
		
			$(this).find('img.btn').animate({top:'0'},{queue:false,duration:100});
		
			$(this).stop().animate({ opacity: 1 }, 100);
			
		});
 
// determine time on users machine to display correct specials.
 
 		var currentTime = new Date()
  		var hours = currentTime.getHours()
        
			if (hours < 12) {
			   
				$('#breakfast-button').addClass('selected');
			   
				$('.lunch, .gallery-cover').hide();
				
				$('.soups').hide()
				
			} 
			
			else {
				
				$('#lunch-button').addClass('selected');
				
				$('.breakfast, .gallery-cover').hide();
				
				$('.soups').hide();

			}

			
		Cufon.refresh();

			
// hide the photo galleries tab
 
 	$('.photo-tab').hide();

	$('#prev').hide();
				
	$('#next').hide();

// main tabs and buttons

		$('#specials').html('<img src="http://www.cornercafecs.com//wp-content/themes/corner-cafe/images/todays-specialsRO.png" alt="Menu" />');

		$('#specials').click(function() {
				
				$('.specials-tab').fadeIn("slow");
				
				$('.photo-tab').hide();
				
				$('#prev').hide();
				
				$('#next').hide();
				
				$('.gallery-cover').hide();

				$(this).html('<img src="http://www.cornercafecs.com//wp-content/themes/corner-cafe/images/todays-specialsRO.png" alt="Menu" />');
				
				$('#photos').html('<img src="http://www.cornercafecs.com//wp-content/themes/corner-cafe/images/photo-galleries.png" alt="Menu" />');
				
				return false;
			
		});
		
		$('#photos').html('<img src="http://www.cornercafecs.com//wp-content/themes/corner-cafe/images/photo-galleries.png" alt="Menu" />');
		
		$('#photos').click(function() {
				
				$('.photo-tab').fadeIn("slow");
				
				$('#prev').show();
				
				$('#next').show();
				
				$('.gallery-cover').show();
				
				$('.specials-tab').hide();

				$('#specials').html('<img src="http://www.cornercafecs.com//wp-content/themes/corner-cafe/images/todays-specials.png" alt="Menu" />');
				
				$(this).html('<img src="http://www.cornercafecs.com//wp-content/themes/corner-cafe/images/photo-galleriesRO.png" alt="Menu" />');
				
				return false;
			
		});

// navigation for the specials tab

		$('#breakfast-button').click(function() {
			
			$(this).addClass('selected');
			
			$('.breakfast').fadeIn("slow");
			
			$('.lunch, .soups, .gallery-cover').hide();
			
			$('#lunch-button, #soups-button').removeClass('selected');
		
			Cufon.refresh();
			
			return false;
					
		});
			
		$('#lunch-button').click(function() {
			
			$(this).addClass('selected');
			
			$('.lunch').fadeIn("slow");
			
			$('.breakfast, .soups, .gallery-cover').hide();
			
			$('#breakfast-button, #soups-button').removeClass('selected');
		
			Cufon.refresh();
			
			return false;
			
		});
		  
		$('#soups-button').click(function() {
			
			$(this).addClass('selected');
			
			$('.soups').fadeIn("slow");
			
			$('.lunch, .breakfast, .gallery-cover').hide();
			
			$('#lunch-button, #breakfast-button').removeClass('selected');
		
			Cufon.refresh();
			
			return false;
			
		});
		
// navigation for the photo galleries tab

		$('.gallery-link a').click(function(event) {
			
			event.preventDefault();
			
			var id = this.id;
			
			$('.gallery-link a.selected').removeClass('selected');
			
			$(this).addClass('selected');
			
			$('.gallery-container').each(function() {
				
				if ($(this).hasClass('hidden') === false)
					$(this).addClass('hidden');
				
			});
			
			$('div#'+id).removeClass('hidden').cycle({
				fx: 'fade',
				cleartype: true,
				cleartypeNoBg: true,
				startingSlide: 0,  // start on the slide that was in the markup
				timeout:  6000,
				speed:    900,
				prev:    '#prev',
				next:    '#next'
			});
			
			Cufon.refresh();
			
			return false;
				
		});
		
});
