function showQuestion(nr, totalquestions) {
	$('#submit').hide();
	
	// console.log("showQuestion:"+nr);
	//$('.layoutvraag').hide();
 
	next_nr = nr + 1;

	if((next_nr > totalquestions && totalquestions != 0) || totalquestions == 1000) {
		$('.layoutvraag').show();
		$('#onderzoek_overzicht').show();
		$('.vraag_navigatie').hide();

		$('.onderzoeksvraag_aan').css('height', 'auto');
		$('.onderzoeksvraag_uit').css('height', 'auto');
		//$('.onderzoeksvraag_aan').css('background-color', '#ffffff');

		$('#submit').show();
	} else {
		$('#vraag_' + next_nr).show();
		//console.log($('#vraag_' + next_nr).height());
		$('#vraag_' + next_nr).parent().parent().height($('#vraag_' + next_nr).height()+200); 
	}


	var params = {
		vraagnummer: nr,
		onderzoek_uid: $('#onderzoek_uid').val(),
		deelnemer_uid: $('#deelnemer_uid').val()
	}


	// Laat de titel animeren..
	//$('#vraagback_'+next_nr).css('background-color', "#d9ed49"); // "#0f2863");
	//$('#vraagback_'+next_nr).css('opacity', 1); // "#0f2863");
	//$('#vraagback_'+next_nr).animate({ opacity: 0.01 }, 1500 );

    $('#vraag_' + next_nr +' a.onepixel').each(function() {
        var playerid="player_"+$(this).attr("id");
        $(this).after('<div class="mediaplayer"><div id="'+playerid+'"> </div></div>');
        var flashvars = {
            id: playerid,
            backcolor: "#CAE529",
            lightcolor: "#FFFFFF",
            frontcolor: "#000000",
            screencolor: "#FFFFFF",
            file: $(this).attr("href")
            //, skin: "/musicpanel/mediaplayer/minimal3.swf"
            // uncomment this line if a working custom player skin is present
        };
        var params = {
            allowfullscreen: "false",
            allowscriptaccess: "always"
        };

        swfobject.embedSWF('/musicpanel/mediaplayer/player.swf', playerid, "200", "20", "9.0.0","", flashvars, params, {});

        //console.log('made player: '+$(this).attr('id'), $("#"+$(this).attr('id')));
    });


	// Zet een random achtergrond..
	background++;
	if (background>6) { background = 1; }

	$('#contentholder').css('background-image', 'url(/musicpanel/images/image'+background+'.jpg)' );

	if(nr > 0) {
		$.get("includes/onderzoek_status.php", params, function(data){ });
	}
}

// when the DOM is ready...
function initSlider() {
    var panels = $('#vragen_slider .scrollcontainer > fieldset');
    var container = $('#vragen_slider .scrollcontainer');

    // if false, we'll float all the panels left and fix the width
    // of the container
    var horizontal = true;

    // float the panels left if we're going horizontal
    if(horizontal) {
      panels.css({
        'float' : 'left',
        'position' : 'relative' // IE fix to ensure overflow is hidden
      });

      // calculate a new width for the container (so it holds all panels)
      container.css('width', (panels[0].offsetWidth+50) * panels.length);
    }

    // collect the scroll object, at the same time apply the hidden overflow
    // to remove the default scrollbars that will appear
    var scroll = $('#vragen_slider .scroll').css('overflow', 'hidden');

    // apply our left + right buttons
    // scroll.before('<img class="scrollButtons left" src="/musicpanel/images/scroll_left.png" />').after('<img class="scrollButtons right" src="/musicpanel/images/scroll_right.png" />');

    // handle nav selection
    function selectNav(el) {
      $(el)
        .parents('ul:first')
          .find('a')
            .removeClass('selected')
          .end()
        .end()
        .addClass('selected');
      //alert('trigger3'+$(el).attr('href'));
      if(jQuery.browser.msie && jQuery.browser.version<7) {
          //alert('msie6 trigger');
          $('fieldset.panel').hide();
          $($(el).attr('href')).show();
      }
      return true;
    }

    $('#slider .navigation').find('a').click(selectNav);

    // go find the navigation link that has this target and select the nav
    function trigger(data) {
      var el = $('#vragen_slider .navigation').find('a[href$="' + data.id + '"]').get(0);
      //alert('trigger1');
      showQuestion($(el).text()-1, 0);
      //alert('trigger2');
      selectNav(el);
      return true;
    }

    if (window.location.hash) {
      trigger({ id : window.location.hash.substr(1) });
    } else {
      $('ul.navigation a:first').click();
    }

    // offset is used to move to *exactly* the right place, since I'm using
    // padding on my example, I need to subtract the amount of padding to
    // the offset.  Try removing this to get a good idea of the effect
    var offset = parseInt((horizontal ?
      container.css('paddingTop') :
      container.css('paddingLeft'))
      || 0) * -1;


    var scrollOptions = {
      target: scroll, // the element that has the overflow

      // can be a selector which will be relative to the target
      items: panels,

      //navigation: '.navigation a',

      // selectors are NOT relative to document, i.e. make sure they're unique
      //prev: 'img.left',
      //next: 'img.right',
      prev: 'input.left',
      next: 'input.right',

      // allow the scroll effect to run both directions
      axis: 'xy',
      onBefore: function(){$('.layoutvraag div.mediaplayer').remove().empty();},
      onAfter: trigger, // our final callback

      offset: offset,
      jump: false,

      // duration of the sliding effect
      duration: 500,

      // easing - can be used with the easing plugin:
      // http://gsgd.co.uk/sandbox/jquery/easing/
      easing: 'swing'
    };

    // apply serialScroll to the slider - we chose this plugin because it
    // supports// the indexed next and previous scroll along with hooking
    // in to our navigation.
    $('#vragen_slider').serialScroll(scrollOptions);

    // now apply localScroll to hook any other arbitrary links to trigger
    // the effect
    $.localScroll(scrollOptions);

    // finally, if the URL has a hash, move the slider in to position,
    // setting the duration to 1 because I don't want it to scroll in the
    // very first page load.  We don't always need this, but it ensures
    // the positioning is absolutely spot on when the pages loads.
    scrollOptions.duration = 1;
    $.localScroll.hash(scrollOptions);

}