function doSlide(direction) {

	switch(direction) {
		case 'left':
			$('#goLeft').click();
			break;
		case 'right':
			$('#goRight').click();
			break;
	}
	
}

(function($) {
	$.fn.toggleFade = function(settings)
	{
		if(settings==undefined) {
			settings={ speedIn : 'slow'};
		}
		
		settings = jQuery.extend(
				{
					speedIn: "normal",
					speedOut: settings.speedIn
				}, settings
		);
		return this.each(function()
				{
			var isHidden = jQuery(this).is(":hidden");
			jQuery(this)[ isHidden ? "fadeIn" : "fadeOut" ]( isHidden ? settings.speedIn : settings.speedOut);
				});
	};
})(jQuery);

function initSlideshow() {

    if ($(".slideshow")) {
        $('.slideshow').divSlideShow({ 'width': 960, 'height': 340, controlActiveClass: "dssControlActive", controlHoverClass: "dssControlHover" });

        $('.tooltipOpener').hide();

        // alleen initten voor mobiele devices
        var isDevice = false;

        if (DetectIpad() || DetectMobileQuick()) {
            $(".slide").touchwipe({
                wipeLeft: function() { doSlide("right"); },
                wipeRight: function() { doSlide("left"); },
                min_move_x: 20,
                preventDefaultEvents: true
            });
            isDevice = true;
        }

        // listen for tooltip mouseovers
        if (isDevice) {


            $('.tooltipOpener').click(function() {
                $(this).next().toggleFade('slow');
            });
        } else {
            var locked = false;
            $('.tooltipOpener').mouseenter(function() {

                if ($.browser.msie) {
                    $(this).next().show();
                } else {
                    $(this).next().fadeIn('slow');
                }


                $(this).next().mouseenter(function() {
                    locked = true;
                });
                $(this).next().mouseleave(function() {
                    locked = false;
                    if ($.browser.msie) {
                        $('.tooltip').hide();
                    } else {
                        $('.tooltip').fadeOut('slow');
                    }
                });
            });

            $('.tooltipOpener').mouseleave(function() {
                setTimeout(function() {
                    if (!locked) {
                        if ($.browser.msie) {
                            $('.tooltip').hide();
                        } else {
                            $('.tooltip').fadeOut('slow');
                        }
                    }
                }, 100);
            });
        }
    }
}



jQuery(document).ready(function() {

	initSlideshow();

});
