/* Author: 

*/



$(window).ready(function() {
 Galleria.loadTheme('/galleria/themes/twelve/galleria.twelve.min.js');
Galleria.debug = true; 
$('#gallery').galleria({
        width:960,
        height:500,
        transition: "pulse",
    	transitionSpeed: 500,
    	imageCrop: false,
    	thumbCrop: true,
    	carousel: false
    });
    
    $('#gallery-used').galleria({
        width:440,
        height:290,
        transition: "pulse",
    	transitionSpeed: 500,
    	imageCrop: false,
    	thumbCrop: true,
    	carousel: false
    });
   $("a[ href ^= '#' ]").each(function() {
        var href = window.location + $(this).attr('href').replace('/#.*/i','');
        $(this).attr('href',href);
    });

	$('a.prevent').click(function (event) 
	{ 
	     event.preventDefault(); 
	     //here you can also do all sort of things 
	});
	
	var total = $('#main-slider img').length;
var rand = Math.floor(Math.random()*total);

    $('#main-slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:10, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:300, // Slide transition speed
        pauseTime:4000, // How long each slide will show
        startSlide:rand, // Set starting Slide (0 index)
        directionNav:false, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNavThumbs:true,
        controlNavThumbsReplace: '_thumb.png',
        controlNav:true // 1,2,3... navigation
        

    });
    
    $('#new-boat-slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:10, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:1000, // Slide transition speed
        pauseTime:9000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:false, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:false // 1,2,3... navigation

    });
    
    $("#brands a").hover(function() {
        $(this).stop().animate({bottom: "-120"}, 460);
    }, function() {
        $(this).stop().animate({bottom: "0"}, 200);
    });
    
    $(".search .open").click(function() {
        $(".searchbox").fadeIn(220);
        $(".searchbox input[type=text]").select();
    });
    
    $(".search .close").click(function() {
        $(".searchbox").fadeOut(150);
        $(".specs-close").fadeOut(150);
        $(".specs").fadeOut(150);
        $("#close-all").hide();
    });
    
    $("a.specs-open").click(function() {
        $(".specs-close").fadeIn(220);
        $(".specs").fadeIn(220);
        $("#close-all").fadeIn(220);
        
    });
    
    $("a.specs-close").click(function() {
        $(".specs-close").fadeOut(150);
        $(".specs").fadeOut(150);
        $("#close-all").hide();
    });
    
    $("#close-all").click(function() {
        $(".specs-close").fadeOut(150);
        $(".specs").fadeOut(150);
        $(this).hide();
    });
    
    $('.fade').mosaic();
    
    $("a.video").click(function() {
	$.fancybox({
			'padding'		: 10,
			'overlayColor'	: '#f4f4f4',
			'overlayOpacity': 0.6,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});
    
    $("#charters li").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});

	$("#newboats li").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});

	$("#sales-list li").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});

	$(".brands-roids li").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});

	$("#commentForm").validate({
				submitHandler: function() {
				var naam     = $('#cname').attr('value');  
				var smail     = $('#cemail').attr('value');
				var curl   = $('#curl').attr('value');
				var telefoon  = $('#cphone').attr('value');
				var opmerking = $('#ccomment').attr('value');
                var adres =  $('#cadress').attr('value');
				
				$.ajax({  
						type: "POST",  
						url: "/include/contactsend.php",  
						data: "naam="+ naam +"&smail="+ smail+"&curl="+ curl+"&telefoon="+ telefoon+"&opmerking="+ opmerking+"&adres="+ adres,  
						success: function(){  
							$('form#commentForm').hide(function(){$("#succes").show("fast");});
							
								 }  
						 });return false; 
				}
			});
			
	$("#shareForm").validate({
				submitHandler: function() {
				var email     = $('#shareemail').attr('value');  
				var mess     = $('#sharecomment').attr('value');
							
				$.ajax({  
						type: "POST",  
						url: "/include/sharesend.php",  
						data: "email="+ email +"&mess="+ mess,  
						success: function(){  
							$('.close-reveal-modal').trigger('click');
							
								 }  
						 });return false; 
				}
			});
			
    $('#myButton').click(function(e) {
          e.preventDefault();
	  $('#myModal').reveal();
     });
    
    /*$('#moreLess .less').hide();
	$("#moreLess .more").click(function(){
    	$('.slidedown').slideDown(400);
    	$(this).hide();
    	$('#moreLess .less').show();
    });
    $("#moreLess .less").click(function(){
    	$('.slidedown').slideUp(400);
    	$(this).hide();
    	$('#moreLess .more').show();
    });  */
    
    
    
    
});






















