// JavaScript Document
var clicked = 0;
var currImage = 1;
var prevImage = 1;
var count = 0;
$(document).ready(function() {
	$('#image-rotation img').each(function(index) {
		count = count+1;
	});

	$('#opening-times').css({
		'border-bottom':'none'
	});

	$('#opening-times img').click(function() {
		if (clicked == '0') {
			$('#opening-times').stop().animate({
				'height':'195px'
			});
			$('#opening-times').css({
				'border-bottom':'solid 1px #c4c4c4'
			});
			clicked = 1;
		} else {
			$('#opening-times').stop().animate({
				'height':'34px'
			});
			$('#opening-times').css({
				'border-bottom':'none'
			});
			clicked = 0;
		}
	});
	
	if(count>1){
		setInterval(nextImage,4000);
	}
	
	function nextImage() {
		if(currImage == count) {
			currImage = 0;
		}
		currImage ++;
		$('#image-'+prevImage).fadeOut();
		$('#image-'+currImage).fadeIn();
		prevImage = currImage;
	}
	
});
