// JavaScript Document
 var li = jQuery("#carouselUl").find("li");
    var commonWidth = jQuery("#carouselUl li").outerWidth();
    var width = li.length*commonWidth;
    
    jQuery("#carouselUl").css("width",width);
    
jQuery(".carousel-prev").click(
  function(){
   /*  var margin = width-commonWidth;
   if(jQuery("#carouselUl").css("margin-left") == "-" + margin + "px"){
      jQuery("#carouselUl").css("margin-left","0px");
    }
    else{*/
  //alert(margin);
  var margin = -1*(parseInt(parseInt(width)-parseInt(commonWidth*11)));
  if(parseInt(jQuery("#carouselUl").css("margin-left")) < 0){
     jQuery("#carouselUl").animate({
      marginLeft:"+=" + commonWidth + "px"
      },500);
    }
  else {
  jQuery("#carouselUl").animate({
      marginLeft: margin + "px"
      },500);
  }
  })
  

jQuery(".carousel-next").click(
  function(){
  var margin = -1*(parseInt(parseInt(width)-parseInt(commonWidth*11)));
  var margin_int = parseInt(jQuery("#carouselUl").css("margin-left"));
  var margin_left = margin_int + parseInt(commonWidth);
  if(margin_left<margin){
    jQuery("#carouselUl").animate({marginLeft:"0px"},500);
  }else{
     jQuery("#carouselUl").animate({
      marginLeft:"-=" + commonWidth + "px"
      },500);
  }})



