////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// esomniac Javascript Functions
// This file includes a collection of functions for use on the Blu Zeus site
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$(function()
{
	// slideshow
	if($('#portfolio').length > 0) {
		$("#portfolio_previous").click(slideshow);
		$("#portfolio_next").click(slideshow);
	}

});


function slideshow()
{	
	var id = $(this).attr("id");
	var current_image = $('#portfolio img:visible');
	 
	if(id == "portfolio_next") {
   	var next_image = current_image.next().attr('tagName') != 'IMG' ? current_image.siblings('img:first') : current_image.next();
   	var url = next_image.attr('alt');
	} else {
		var next_image = current_image.prev().attr('tagName') != 'IMG' ? current_image.siblings('img:last') : current_image.prev();
		var url = next_image.attr('alt');
	}

   current_image.fadeOut(1000);
   next_image.fadeIn(1000);
   $("#portfolio_view_site").parent().attr('href',url);
}
