//$(document).ready(function() {
	
	var images = $('#slideshow1 img'),
		index = 0,
		maxHeight = 0;
	
	var p = $('#slideshow1').attr('class').indexOf('height-') + 7;
	var h = $('#slideshow1').attr('class').substr(p,3) + 'px';
	$('#slideshow1').css('height', h);
	
	// hide all images initially
	images.each(function(i){
		$(this).hide();
		if (this.height > maxHeight)
			maxHeight = this.height;
		
		// show next image on image click
		$(this).click(function(){
			$(images.get(index++)).hide();
			if (index == images.length)
				index = 0;
			$(images.get(index)).show();
			return false;
		});
	});
	
	$('#slideshow1 div').css('height', (25 + maxHeight) + 'px');
	
	// show first image
	$(images.get(index)).show();
	
	// add slideshow control links
	$('#slideshow1').prepend('<p></p>');
	$('#slideshow1 p').append('<a href="#" class="prev_image">Previous Image</a> | <a href="#" class="next_image">Next Image</a>')
					  .append('<br /><span class="count"></span>');
	$('#slideshow1 .count').html("Showing image: 1 / " + images.size());
	
	// show previous image
	$('.prev_image').click(function(){
		$(images.get(index--)).hide();
		if (index < 0)
			index = images.length - 1;
		$(images.get(index)).show();
		$('#slideshow1 .count').html("Showing image: " + (index+1) + " / " + images.size());
		return false;
	});
	
	// show next image
	$('.next_image').click(function(){
		$(images.get(index++)).hide();
		if (index == images.length)
			index = 0;
		$(images.get(index)).show();
		$('#slideshow1 .count').html("Showing image: " + (index+1) + " / " + images.size());
		return false;
	});
//});
