﻿$(document).ready(function() {
    //Slider op homepage
    $('#slider').cycle({
        fx: "scrollDown",
        randomizeEffects: false,
        timeout: 6000,
        speed: 1000,
        containerResize: 1
    });
    
    $('#slider-image').jqFancyTransitions({ 
        width: 960, 
        height: 240,
        effect: 'wave', // wave, zipper, curtain
        width: 960, // width of panel
        height: 240, // height of panel
        strips: 20, // number of strips
        delay: 5000, // delay between images in ms
        stripDelay: 50, // delay beetwen strips in ms
        titleOpacity: 0, // opacity of title
        titleSpeed: 0, // speed of title appereance in ms
        position: 'random', // top, bottom, alternate, curtain
        direction: 'fountainAlternate', // left, right, alternate, random, fountain, fountainAlternate
        navigation: false, // prev and next navigation buttons
        links: false // show images as links
    });
     
     //Click functie voor bel mij terug
     $("div.btn-call-detail").hide(); 
     $("div.btn-call").toggle(function(){;
            $("div.btn-call-detail").stop().animate({height:"toggle"},{duration:300}); 
     }, function() {
            $("div.btn-call-detail").stop().animate({height:"toggle"}, {duration:300});
     });
     
    //Click functie voor Uitklap teksten
    $(".toggle_container").hide();

	$("h3.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle(100);
	});
	
	$(".klantcases").mouseover(function(){
		$(this).css({background: "url(img/bg-klantcases-hover.jpg)"});
	});
	$(".klantcases").mouseout(function(){
		$(this).css({background: "url(img/bg-klantcases.jpg)"});
	});
    
    //Fancybox
    $("a.fancybox-small").fancybox({
	    'transitionIn':'elastic',
	    'transitionOut':'elastic',
	    'speedIn':200, 
	    'speedOut':200, 
	    'overlayShow':false,
	    'hideOnOverlayClick':true,
	    'overlayShow':true,
	    'centerOnScroll':true,
	    'overlayOpacity':0.8
	}); 

    var totalscore = 0;
    var totalstars = 0;
    var totalreviews = 0;

    function roundToHalf(value) {
        var converted = parseFloat(value); // Make sure we have a number
        var decimal = (converted - parseInt(converted, 10));
        decimal = Math.round(decimal * 10);
        if (decimal == 5) { return (parseInt(converted, 10) + 0.5); }
        if ((decimal < 3) || (decimal > 7)) {
            return Math.round(converted);
        } else {
            return (parseInt(converted, 10) + 0.5);
        }
    }

    for (i = 0; i < $('div.block-referenties').length; i++) {
        $('#fixed' + i).raty({
            readOnly: true,
            half: true,
            start: $('#rating' + i).text()
        });
    }
    $('#total').raty({
        readOnly: true,
        half: true,
        start: $('#totalrating').text()
    });
});
