
// Cebuco.nl javascript
// By Andre Brocatus
// http://www.brocatus.com
// Uses Jquery 1.5.2
// 10 mei 2011


// Font detection script: // http://remysharp.com/2008/07/08/how-to-detect-if-a-font-is-installed-only-using-javascript/

// Documentready function

$(document).ready(function () {

    // TOOLKIT NAVIGATION START

      var toolscounter = 1;
      // marginleft is wat we gebruiken voor positie van de tools
      var ml = 0;
      var $tools = $('#toolall');

      $tools.css('marginLeft',ml);    // init op 0 pixels; was oorspronkelijk -3

      var realtoolstotal = $("#toolswidth > div").size()

      // verdubbel de tools zodat we kunnen loopen
      $toolsinnerhtml = $('#toolswidth').html();
      $('#toolswidth').append($toolsinnerhtml);

      // verdubbelen aangepast zodat alleen de tools verdubbeld zijn en niet de div met id="toolall"

      // navigatie en animatie
      $('div#toolkit div.knoprechts').click( function(event) {

           // deactivate auto-scrolling
           if(event.originalEvent){
               window.clearInterval(intervalId);
           }

           // kijken of we moeten loopen:
           if (toolscounter == realtoolstotal) {
               toolscounter = 0;           
           }

           // stapje naar links
           ml = ml - 185;
           $tools.animate({
                   marginLeft: ml
               },1000, function() {
               // Animation complete.

               if( ml == (realtoolstotal * -185) )
               {
                   ml = 0;
                   $tools.css('marginLeft',ml);
               }
           });

           toolscounter = toolscounter + 1;

           $("#debug").html( 'R tc: ' + toolscounter + ' | ml: ' + ml );
           return false;
       });

       $('div#toolkit div.knoplinks').click( function() {

           // deactivate auto-scrolling
           window.clearInterval(intervalId);

           toolscounter = toolscounter - 1;    // eerst counter updaten

           // kijken of we moeten loopen:

           if (toolscounter == 0) {
               ml = (realtoolstotal * -185);
               $tools.css('marginLeft',ml);
               toolscounter = realtoolstotal;
           }

           // stapje naar rechts
           ml = ml + 185;
           $tools.animate({
               marginLeft: ml
           },1000);

           $("#debug").html( 'L tc: ' + toolscounter + ' | ml: ' + ml );
           return false;
       });

       function autoslide(){
           $('div#toolkit div.knoprechts').click();
       }

       // Auto scroll every 4 seconds
       var intervalId = window.setInterval(autoslide, 7000);


      // TOOLKIT NAVIGATION END		
	// LEGACY JAVASCRIPT VAN VORIGE SITE

	// Uitklapinfo: togglelinks tonen en infoblokjes intrekken dan klikfunctie toevoegen
	$("a.show").css({'display' : 'block'});
	$("dd.slide").hide();
	$("a.show").click(function(){
		$(this).parent().toggleClass("titlebold");
		$(this).parent().next("dd").slideToggle("slow");
		return false;
	});

	// Print link
	$("li.print").prepend( "<a href=\"#\" id=\"print\" title=\"Print deze pagina\">Print</a>" );
	$("li.print").mousedown(function () { 
		window.print(); 
	});

	// Slideshow
	$("p.slide").parent().removeClass("smallimg").addClass("artimages");
	$("div.artimages").cycle(	{ 
		fx:    'fade', 
		speed:  500, 
		timeout: 5000 
	});

	// Interactieve grafiek
	$('div.invisible div.igraph').hide();
	$('div.interactivegraphs div.itable:first').toggleClass('invisible').toggleClass('visible').find('div.igraph').show();
	$('div.idata').live('mouseover', function() {
	    $this = $(this);
	    $thisgraph = $this.parent('div.itable').find('div.igraph');
	    $othergraphs = $this.closest('div.interactivegraphs').find('div.itable').find('div.igraph').not($thisgraph);
	    $thisgraph.fadeIn(function(){
	        $othergraphs.fadeOut();
	        $this.closest('div.interactivegraphs').find('div.itable').addClass('invisible').removeClass('visible');
	        $this.parent('div.itable').addClass('visible').removeClass('invisible').find('div.igraph');
	    });
	});

}); //end document.ready

