$(document).ready(function(){
  $("#divPrev").click(function(){
    clearInterval(slideshowTimer);
    leftPos = Math.round($("#slideShow").position().left / 643) * 643;
    maxRight = 0;
		if(leftPos < maxRight){
  		$("#slideShow").animate({ 
        left: "+=643px"}, 1000, function() {
        $("#divNext").show();
        $("#divPrev").show();
      });
      $("#divNext").hide();
      $("#divPrev").hide();
    }
  });

  $("#divNext").click(function(){
    clearInterval(slideshowTimer);
    leftPos = Math.round($("#slideShow").position().left / 643) * 643;
    maxLeft = ($("#slideShow").width() - 643) * -1;
		if(leftPos > maxLeft){
  		$("#slideShow").animate({ 
        left: "-=643px"}, 1000, function() {
        $("#divNext").show();
        $("#divPrev").show();
      });
      $("#divNext").hide();
      $("#divPrev").hide();
    }
  });
  
  
  function moveNext(){
    leftPos = Math.round($("#slideShow").position().left / 643) * 643;
    maxLeft = ($("#slideShow").width() - 643) * -1;
		if(leftPos > maxLeft){
  		$("#slideShow").animate({ 
        left: "-=643px"}, 1000, function() {
        $("#divNext").show();
        $("#divPrev").show();
      });
      $("#divNext").hide();
      $("#divPrev").hide();
      slideshowTimer = setTimeout(moveNext, 4000);
    }
  }
  
  slideshowTimer = setTimeout(moveNext, 3000);


  
	$("#bottomItem1,#bottomItem2,#bottomItem3,#bottomItem4").hover(function(){
		var height = $(".divBottomItemText",$(this)).height();
		var top = 0;
		$(".divBottomItemText",$(this)).animate({ 
      top: top+"px",
      opacity: 0.85
    }, 300 );
	},function(){
		$(".divBottomItemText",$(this)).animate({
      top: "112px",
      opacity: 1
    }, 300 );		
	}); 
	
	$(".divSlideshow").hover(function(){
		$(".divTafHolder").css('display', 'block');
	},function(){
		$(".divTafHolder").css('display', 'none');	
	}); 
	
  $("#divTafNext").click(function(){
    if(document.getElementById("frmYourName").value != "Uw naam:" && document.getElementById("frmYourName").value != "" && document.getElementById("frmYourMail").value != "Uw e-mailadres:" && document.getElementById("frmYourMail").value != ""){
      $("#tafStep1").css('display', 'none');
      $("#tafStep2").css('display', 'block');
    } else {
      $("#frmYourName").css('color', 'red');
      $("#frmYourMail").css('color', 'red');
    
    }
  });	
  $("#divTafLast").click(function(){
    if(document.getElementById("frmFriendName").value != "Naam vriend:" && document.getElementById("frmFriendName").value != "" && document.getElementById("frmFriendMail").value != "E-mailadres vriend:" && document.getElementById("frmFriendMail").value != "" && document.getElementById("frmFriendMail").value != document.getElementById("frmYourMail").value){
      $("#tafStep2").css('display', 'none');
      $("#tafStep3").css('display', 'block');
      $(".divTafHolder").css('backgroundImage', "url('/images/tafMessage.jpg')");      
      
    } else {
      $("#frmFriendName").css('color', 'red');
      $("#frmFriendMail").css('color', 'red'); 
    }
  });  
	
});
