	function slideSwitch() {
		var $active = $('#image_cycle img.active');
	
		if ( $active.length == 0 ) $active = $('#image_cycle img:last');
	
		var $next =  $active.next().length ? $active.next()
			: $('#image_cycle img:first');
		
		$active.addClass('last-active');
	
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 2000, function() {
				$active.removeClass('active last-active');
			});
	}
	
	$(function() {
		setInterval( "slideSwitch()", 4000 );
	});


	



$(document).ready(function(){
	ticker();
	
	
	function ticker() {
		var width_of_news = $('#news_ticker').width();
		$('#news_ticker').animate({
			left: '-='+width_of_news
		},width_of_news*10,'linear',function() {
			$('#news_ticker').css('left','80px');
			ticker();
		});
	}

	$('#news_ticker').hover(function(){$(this).stop();},function(){ticker();});
	
	// this corrects the short left column if the variable right column is taller
	var rightcolheight = $('#col_right').outerHeight();
	var leftcolheight = $('#col_left').outerHeight();

	if (rightcolheight>leftcolheight) {
		$('#col_left').css('height',rightcolheight+'px');
	}
	
	
	$('#feedbacklink').click(function(){
		$('#commentcardform_cont').show();
		$('body').append('<div id="overlay"></div>');
		var docHeight = $(document).height();
		$('#overlay').css('height',docHeight+'px').css('opacity','.75');
		
		var newX = ($(window).width() - $('#commentcardform_cont').width())/2;
		var newY = $(window).scrollTop()+100; // place form just 100px below top of window
		
		$('#commentcardform_cont').css('top',newY+'px').css('left',newX+'px');
		
		return false;
	});
	
	
	$('#overlay').live('click', function() {
  		$('#overlay').remove();
  		$('#message').remove();
  		$('#commentcardform_cont').children().show();
  		$('#commentcardform_cont').hide();
  		
	});
	
	// creates feedback sliders
	
	
	$('#slider_food').slider({
			value: 3,
			min: 1,
			max: 5,
			step: 1,
			animate: 'fast',
			slide: function(event, ui) {
				$("input[name=food_rating]").val(ui.value);
				$('#slider_food a').html(ui.value);
			}
	});
	
	$('#slider_service').slider({
			value: 3,
			min: 1,
			max: 5,
			step: 1,
			animate: 'fast',
			slide: function(event, ui) {
				$("input[name=service_rating]").val(ui.value);
				$('#slider_service a').html(ui.value);
			}
	});
	
	$('#slider_atmosphere').slider({
			value: 3,
			min: 1,
			max: 5,
			step: 1,
			animate: 'fast',
			slide: function(event, ui) {
				$("input[name=atmosphere_rating]").val(ui.value);
				$('#slider_atmosphere a').html(ui.value);
			}
	});
	
	$('#slider_food a').html('3');
	$('#slider_service a').html('3');
	$('#slider_atmosphere a').html('3');
	
	// capture form submission
	
	$('input[name=submit_comments_button]').click(function(){
		// attempt to submit via ajax
		$.ajax({
			type: 'POST',
			url: 'main/commentcard',
			data: $('#commentcardform').serialize(),
			success: function(html_resp) {
				if (html_resp=='success') {
					$('#commentcardform_cont').children().hide();
					$('#commentcardform_cont').append('<div id="message"><h2>Thanks for your feedback!</h2></div>');
					// reset the form
					$('input[name=food_rating]').val('3');
					$('#slider_food').slider( "option", "value", 3);
					$('#slider_food a').html('3');
					
					$('input[name=service_rating]').val('3');
					$('#slider_service').slider( "option", "value", 3);
					$('#slider_service a').html('3');
					
					$('input[name=atmosphere_rating]').val('3');
					$('#slider_atmosphere').slider( "option", "value", 3);
					$('#slider_atmosphere a').html('3');
					
					$('input[name=commenter_name]').val('');
					$('input[name=commenter_emailaddr]').val('');
					$('textarea[name=comments]').val('');
					
				} else {
					// an error occurred, show the error
					$('#commentcardform_cont').prepend('<div id="message"><p class="error">Sorry, an error occurred. Please try again.</p></div>');
					
				}
			}
		}); // add_form ajaxForm
					
		return false;
	});
	
});
