<script type="text/javascript" src="/include2012/analytics.js"></script>
// Slider functie
$(document).ready(function() { //perform actions when DOM is ready
  var z = 0; //for setting the initial z-index's
  var inAnimation = false; //flag for testing if we are in a animation

  $('#pictures img').each(function() { //set the initial z-index's
    z++; //at the end we have the highest z-index value stored in the z variable
    $(this).css('z-index', z); //apply increased z-index to <img>
  });

var swapFirstLast = function(isFirst) {
    if(inAnimation) return false; //if already swapping pictures just return
    else inAnimation = true; //set the flag that we process a image

    var processZindex, direction, newZindex, inDeCrease; //change for previous or next image

    if(isFirst == 'next') { processZindex = 1; direction = ''; newZindex = z; inDeCrease = -1; } //set variables for "previous" action
    else { processZindex = z; direction = '-'; newZindex = 1; inDeCrease = 1; } //set variables for "next" action

    $('#pictures img').each(function() { //process each image
      if($(this).css('z-index') == processZindex) { //if its the image we need to process
        $(this).animate({ 'top' : direction + $(this).height() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
          $(this).css('z-index', newZindex) //set new z-index
            .animate({ 'top' : '0' }, 'slow', function() { //animate the image back to its original position
              inAnimation = false; //reset the flag
            });
        });
      } else { //not the image we need to process, only in/de-crease z-index
        $(this).animate({ 'top' : '0' }, 'slow', function() { //make sure to wait swapping the z-index when image is above/under the gallery
          $(this).css('z-index', parseInt($(this).css('z-index')) + inDeCrease); //in/de-crease the z-index by one
        });
      }
    });

    return false; //don't follow the clicked link
  }


  var intervalTime = 5000;
  var swapInterval = setInterval(swapFirstLast, intervalTime);

  $('#next a').click(function() {
    clearInterval(swapInterval);
    swapFirstLast('previous'); //swap first image to last position
    swapInterval = setInterval(swapFirstLast, intervalTime);
    return false;
  });

  $('#slider img').click(function() {
    clearInterval(swapInterval);
    swapFirstLast('previous'); //swap first image to last position
    swapInterval = setInterval(swapFirstLast, intervalTime);
    return false;
  });

  $('#prev a').click(function() {
    clearInterval(swapInterval);
    swapFirstLast('next'); //swap last image to first position
    swapInterval = setInterval(swapFirstLast, intervalTime);
    return false;
  });

});

// Tooltip functie
$(document).ready(function() {
    $(".trigger1").mouseover(function() {
        $(".trigger1_show").show();
    }).mouseout(function(){
        $(".trigger1_show").hide();
    });
    $(".trigger2").mouseover(function() {
        $(".trigger2_show").show();
    }).mouseout(function(){
        $(".trigger2_show").hide();
    });
    $(".trigger3").mouseover(function() {
        $(".trigger3_show").show();
    }).mouseout(function(){
        $(".trigger3_show").hide();
    });
    $(".trigger4").mouseover(function() {
        $(".trigger4_show").show();
    }).mouseout(function(){
        $(".trigger4_show").hide();
    });

    $(window).resize(function() {
        if($(window).width() < '1215') {
            $("#header_img").parent("div").css({'margin': '0 auto', 'width': '960', 'overflow' : 'hidden'});
            $("#header_img").css("margin-left","-109");
        } else {
            $("#header_img").parent("div").removeAttr("style");
            $("#header_img").removeAttr("style");
        }
    });
    if($(window).width() < '1215') {
        $("#header_img").parent("div").css({'margin': '0 auto', 'width': '960', 'overflow' : 'hidden'});
        $("#header_img").css("margin-left","-109");
    }

});

// Font resize functie
$(document).ready(function() {
    var startSize = parseInt($.cookie('fontNew'));
    if(startSize == '') {
        var startSize = 11;
    }
    var fontItems = $('#content .left, #info p, .right, #footermenu ul');
    $(fontItems).css('font-size', startSize);
    $(".button").css('font-size', 11);

    if(startSize == 11) {
        $("#kleiner").css("color","#f17738");
        $("#normaal").css("color","#b0b0b0");
        $("#groter").css("color","#b0b0b0");
    }
    if(startSize == 14) {
        $("#kleiner").css("color","#b0b0b0");
        $("#normaal").css("color","#f17738");
        $("#groter").css("color","#b0b0b0");
    }
    if(startSize == 17) {
        $("#kleiner").css("color","#b0b0b0");
        $("#normaal").css("color","#b0b0b0");
        $("#groter").css("color","#f17738");
    }
    $('#fontsize ul li a').click(function() {
        var newFontSize = parseInt($(this).attr("rel"));
        $(fontItems).css('font-size', newFontSize);
        $(".button").css('font-size', 11);
        $.cookie('fontNew', newFontSize,{
            path: '/'
        });
        $("#fontsize ul li a").css("color","#b0b0b0");
        $(this).css("color","#f17738");
        return false;
    });
        
});

// Contact anti spam input
$(function() {
    $("#specialInput1").focus(function () {
         $("#submit").focus();
    });
});

// Fancybox
$(document).ready(function() {
    $("a[rel=producten]").fancybox({
        'overlayShow'	: false,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic',
        'titleShow'     : false
    });
    $("#show_popup").fancybox({
        'scrolling'		: 'no',
        'titleShow'		: false
    });
});
