// JavaScript Document
 $(function(){
  $('.play').hide();
  var currentPosition = 0;
  var slideWidth = 712;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
  .wrapAll('<div id="slideInner"></div>')
  // Float left to display horizontally, readjust .slides width
  .css({
    'float' : 'left',
    'width' : slideWidth
  });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert left and right arrow controls in the DOM
  // Hide left arrow control on first load
  manageControls(currentPosition);
var t;
var r=setTimeout(function(){animate()}, 1000);
  // Create event listeners for .controls clicks
     $('.play').bind('click', function(){
$('.play').hide();
$('.pause').show();
var t=setTimeout(function(){animate()}, 1000);
});
  $('.control')
    .bind('click', function(){
    // Determine new position
      currentPosition = ($(this).attr('id')=='rightControl')
    ? currentPosition+1 : currentPosition-1;

      // Hide / show controls
      manageControls(currentPosition);
      // Move slideInner using margin-left
      $('#slideInner').animate({
        'marginLeft' : slideWidth*(-currentPosition)
      }, 4000);
    });
function animate(){
$('.control').hide();
if(currentPosition==4){dir=-1;}
if(currentPosition==0){dir=1;}
if(dir==1){
currentPosition=currentPosition+1;}
if(dir==-1){
currentPosition=currentPosition-1;}

$('.pause').bind('click', function(){
if(currentPosition==4){$('#leftControl').show()}
else if(currentPosition==0){$('#rightControl').show()}
else{$('.control').show();}
clearTimeout(t);
$('.play').show();
$('.pause').hide();

});

 $('#slideInner').animate({
        'marginLeft' : slideWidth*(-currentPosition)
      },4000);
	   
	  var t=setTimeout(function(){animate()}, 6000);

}

  // manageControls: Hides and shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
    if(position==0){ $('#leftControl').hide() }
    else{ $('#leftControl').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() }
    else{ $('#rightControl').show() }
    }
  });
  $(function(){
$("div.btd-left a").click(function() {
var x=$(this).attr("className");
if(x=="btd1-s"){
$(".btd1-s").hide();
$('div#one').animate({
        'height' : "330px"
      },1500);
	  }
if(x=="btd1-h"){
$('div#one').animate({
        'height' : "125px"
      },1500);
$(".btd1-s").show();

	  }
if(x=="btd2-s"){
$(".btd2-s").hide();
$('div#two').animate({
        'height' : "250px"
      },1500);
	  }
if(x=="btd2-h"){
$('div#two').animate({
        'height' : "125px"
      },1500);
$(".btd2-s").show();
	  }
if(x=="btd3-s"){
$(".btd3-s").hide();
$('div#three').animate({
        'height' : "330px"
      },1500);
	  }
if(x=="btd3-h"){
$('div#three').animate({
        'height' : "125px"
      },1500);
$(".btd3-s").show();

	  }

return false;
});
return false;
});