$(document).ready(function(){
	$('.gallery_select li').click(function(){
		$('#galleryImage').attr({src: $(this).children('img').attr('alt')});
		$('.caption').html($(this).children('img').attr('title'));

		$('.gallery_select li img').removeClass('active');
		$(this).children('img').addClass('active');
		// alert($(this).attr('alt'));
	});
	
	var currentLoaded = 0;
	var images = $('.gallery_select li img');


	$('.back').click(function(){
		currentLoaded--;
		if (currentLoaded < 0)
			currentLoaded = images.length -1;

		$("#galleryImage").attr({src: $(images[currentLoaded]).attr('alt')});
		$('.gallery_select li img').removeClass('active');
		$(images[currentLoaded]).addClass('active');
		//$("#titleImage").html($(images[currentLoaded]).children('.title').html());
		$('.caption').html($(images[currentLoaded]).attr('title'));
		//console.log(currentLoaded);
		return false;
	});

	$('.next').click(function(){
		currentLoaded++;
		if (currentLoaded >= images.length)
			currentLoaded = 0;

		$("#galleryImage").attr({src: $(images[currentLoaded]).attr('alt')});
		$('.gallery_select li img').removeClass('active');
		$(images[currentLoaded]).addClass('active');
		//$("#titleImage").html($(images[currentLoaded]).children('.title').html());
		//console.log(currentLoaded);
		$('.caption').html($(images[currentLoaded]).attr('title'));
		return false;
	});
	
		
	$('#departments-landscaping').click(function(){
		window.open("http://www.salisburylandscaping.ca");
		return false;
	});


});
