
/*
	Slideshow for Sociable theme
	Author: BDQWorks/BDQThemes/Jason Saeho Lee
	Version: 1.0.1
	Updated: May 20th, 2011
	Description: This is a very simple jQuery slideshow that acts like the circular carousel slideshow, created for the Sociable WordPress theme.
*/

$(document).ready(function() {
  $('a.disable').click(function(e) {
	  e.preventDefault();
  });
	
  $('.s-up').click(function() {
    if (!$(this).parent().children().is(':animated')) {
	  var top = parseInt($('#slideshow-scroll').css('margin-top').replace("px", ""));
	  var target = parseInt($('#slideshow-scroll').attr('name'));
	  
	  if(top>target) {
	  	$('#slideshow-scroll').stop().animate({
          marginTop: '-=320px'
        }, 480);
	  } else {
		$('#last-slide').html('');
		$('.first-slide').clone().prependTo('#last-slide');  
		$('#slideshow-scroll').stop().animate({
    	  marginTop: '-=320px'
          }, 480, function() {
			$('#slideshow-scroll').css('marginTop', '-320px');
		  });
	  }
	}
			
  });	
		
  $('.s-down').click(function() {
    if (!$(this).parent().children().is(':animated')) {
	  var top = parseInt($('#slideshow-scroll').css('margin-top').replace("px", ""));
	  var target = parseInt($('#slideshow-scroll').attr('name'));
	  
	  if (top<-320) {
		$('#slideshow-scroll').stop().animate({
    	  marginTop: '+=320px'
          }, 480);
	  } else {
		$('#first-slide').html('');  
		$('.last-slide').clone().prependTo('#first-slide');  
		$('#slideshow-scroll').stop().animate({
    	  marginTop: '+=320px'
          }, 480, function() {
			$('#slideshow-scroll').css('marginTop', target+'px');
		  });
	  }
	}
  });
});
