/* Author: 

*/

$(document).ready(function(){ 
var position = 0
var numberOfPhotos = $('#webSites img').length;
var scrollAmount = $('#siteWindow').width();

$('#leftbutton').click(function(){
  if(position < numberOfPhotos-1){ 
    //had scope problem here, why?
    var currentTitle = $('#slideTitle .show, #slideDesc .show')
    if(currentTitle.next().length){
      currentTitle.removeClass('show').addClass('hide');
      currentTitle.next().removeClass('hide').addClass('show');    
    }
    $('#webSites').animate({left:'-=' + scrollAmount}, 'slow');
    position++;
    
  // }else{
  //   $('#webSites').animate({left:0}, 'fast');
  //   position = 0
   }

});

$('#rightbutton').click(function(){
  //if it's not the first one slide right
  if(position > 0){ 
    var currentTitle = $('#slideTitle .show, #slideDesc .show')
    if(currentTitle.prev().length){
      currentTitle.removeClass('show').addClass('hide');
      currentTitle.prev().removeClass('hide').addClass('show');
    }
    $('#webSites').animate({left:'+=' + scrollAmount}, 'slow');
    position--;
    //if it's the first one zip to the full right and set it to last position
  // }else if(position ==0){
  //   $('#webSites').animate({left:'-=' + scrollAmount * (numberOfPhotos-1) }, 'fast');
  //   position = numberOfPhotos
   }

});


});//ready



// var currentTitle = $("#slideTitle h1:eq("+position+")");
// $('#leftbutton').click(function(){
//   if(position < numberOfPhotos-1){ 
//     //if(currentTitle.next().length){
//       currentTitle.hide();
//       currentTitle.next().show();
//   //  } 
//     $('#webSites').animate({left:'-=' + scrollAmount}, 'slow');
//     position++;
//   // }else{
//   //   $('#webSites').animate({left:0}, 'fast');
//   //   position = 0
//    }
// 
// });
// 
// $('#rightbutton').click(function(){
//   //if it's not the first one slide right
//   if(position > 0){ 
//     var currentTitle = $('#slideTitle .show, #slideDesc .show')
//     if(currentTitle.prev().length){
//       currentTitle.removeClass('show').addClass('hide');
//       currentTitle.prev().removeClass('hide').addClass('show');
//     }
//     $('#webSites').animate({left:'+=' + scrollAmount}, 'slow');
//     position--;
//     //if it's the first one zip to the full right and set it to last position
//   // }else if(position ==0){
//   //   $('#webSites').animate({left:'-=' + scrollAmount * (numberOfPhotos-1) }, 'fast');
//   //   position = numberOfPhotos
//    }
// 
// });






















