
;(function($) {
	$.fn.featureList = function(options) {
		var tabs	= $(this);
		var output	= $(options.output);

		new jQuery.featureList(tabs, output, options);

		return this;	
	};

	$.featureList = function(tabs, output, options) {
		function slide(nr) {
			if (typeof nr == "undefined") {
				nr = visible_item + 1;
				nr = nr >= total_items ? 0 : nr;
			}

			tabs.removeClass('current').filter(":eq(" + nr + ")").addClass('current');

			output.stop(true, true).filter(":visible").fadeOut();
			output.filter(":eq(" + nr + ")").fadeIn(function() {
				visible_item = nr;	
			});
		}

		var options			= options || {}; 
		var total_items		= tabs.length;
		var visible_item	= options.start_item || 0;

		options.pause_on_hover		= options.pause_on_hover		|| true;
		options.transition_interval	= options.transition_interval	|| 5000;

		output.hide().eq( visible_item ).show();
		tabs.eq( visible_item ).addClass('current');

		tabs.click(function() {
			if ($(this).hasClass('current')) {
				return false;	
			}

			slide( tabs.index( this) );
		});

		if (options.transition_interval > 0) {
			var timer = setInterval(function () {
				slide();
			}, options.transition_interval);

			if (options.pause_on_hover) {
				tabs.mouseenter(function() {
					clearInterval( timer );

				}).mouseleave(function() {
					clearInterval( timer );
					timer = setInterval(function () {
						slide();
					}, options.transition_interval);
				});
			}
		}
	};
})(jQuery);


$(document).ready(function() {
						   
			$.featureList(
				$("#feature-tabs li a"),
				$("#feature-info li"), {
					start_item	:	1
				}
			);
						   
		
		if($("#leaderboard").height() < 30) {
			$("#promo-top").hide();
		}
		
		$('#column-right #select-container .title').height($('#column-left .block:first .title').height());
		
		$('#recent-items').cycle({
			fx:    'scrollHorz',
			speed:  1600,
			pause:   1,
			timeout:       6000,
			next:   '#cycle-next', 
			prev:   '#cycle-prev'	
		});
	

		$("#s").focus(function () { 
			if ($(this).val() == 'Trefwoord, Locatie of Toeleverancier') $(this).val('');	
		});
		$("#menu .inner").clone().prependTo("#footer-navigation .inner");

		
      function addMega(){

		 $(this).addClass("hovering");
		 $(this).children().children("#menu div.mega-container-content").dropShadow().bgiframe();
		// $(this).children(".mega-container-content").dropShadow();
		 //$(".mega-container-content").dropShadow();
        }

      function removeMega(){
		 $(this).children().children("#menu div.mega-container-content").removeShadow();		  
		$(this).removeClass("hovering");


        }
	
		var megaConfig = {
			 interval: 100,
			 sensitivity: 4,
			 over: addMega,
			 timeout: 500,
			 out: removeMega
		};
	
		$("#menu li.mega").hoverIntent(megaConfig)

  $("#comment-form").submit(function(){
  	if ($("#fldComment").val().indexOf("www.") >= 0 || $("#fldComment").val().indexOf("http") >= 0  ){
		alert('In uw reactie mag u helaas ivm misbruik geen website adressen gebruiken');
		return false;	
	}	
  });
 
  $("#btnPrint a").click(function(){
  	window.print();
	return false;	
  });
    // add a "rel" attrib if Opera 7+   
    if(window.opera) {   
        if ($("#btnBookmark a").attr("rel") != ""){ // don't overwrite the rel attrib if already set   
            $("#btnBookmark a").attr("rel","sidebar");   
        }   
    }   
  
    $("#btnBookmark a").click(function(event){   
        event.preventDefault(); // prevent the anchor tag from sending the user off to the link   
        var url = this.href;   
        var title = this.title;   
  
        if (window.sidebar) { // Mozilla Firefox Bookmark   
            window.sidebar.addPanel(title, url,"");   
        } else if( window.external ) { // IE Favorite   
            window.external.AddFavorite( url, title);   
        } else if(window.opera) { // Opera 7+   
            return false; // do nothing - the rel="sidebar" should do the trick   
        } else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)   
             alert('Unfortunately, this browser does not support the requested action,'  
             + ' please bookmark this page manually.');   
        }   
  
    });   
 
 			var onMouseOutOpacity = 0.50;
			$('#thumbs-adv ul.thumbs li').css('opacity', onMouseOutOpacity)
				.hover(
					function () {
						$(this).not('.selected').fadeTo('fast', 1.0);
					}, 
					function () {
						$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
					}
				);
				// Initialize Advanced Galleriffic Gallery
				if ( $('#gallery-adv').length > 0){				
					var galleryAdv = $('#gallery-adv').galleriffic('#thumbs-adv', {
						delay:                  4800,
						numThumbs:              5,
						preloadAhead:           8,
						enableTopPager:         false,
						enableBottomPager:      true,
						imageContainerSel:      '#slideshow-adv',
						controlsContainerSel:   '#controls-adv',
						captionContainerSel:    '#caption-adv',
						loadingContainerSel:    '#loading-adv',
						renderSSControls:       true,
						renderNavControls:      true,
						playLinkText:           '<img src="/images/controlbl_play.png" alt="Afspelen"/>',
						pauseLinkText:          '<img src="/images/controlbl_pause.png" alt="Pauseren"/>',
						prevLinkText:           '<img src="/images/controlbl_prev.png" alt="Vorige"/>',
						nextLinkText:           '<img src="/images/controlbl_next.png" alt="Volgende"/>',
						nextPageLinkText:       '| Volgende 5 &rsaquo;',
						prevPageLinkText:       '&lsaquo; Vorige 5 |',
						enableHistory:          true,
						autoStart:              false,
						onChange:               function(prevIndex, nextIndex) {
							$('#thumbs-adv ul.thumbs').children()
								.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
								.eq(nextIndex).fadeTo('fast', 1.0);
						},
						onTransitionOut:        function(callback) {
							$('#slideshow-adv, #caption-adv').fadeOut('fast', callback);
						},
						onTransitionIn:         function() {
							$('#slideshow-adv, #caption-adv').fadeIn('fast');
						},
						onPageTransitionOut:    function(callback) {
							$('#thumbs-adv ul.thumbs').fadeOut('fast', callback);
						},
						onPageTransitionIn:     function() {
							$('#thumbs-adv ul.thumbs').fadeIn('fast');
						}
					});
					
					if ( $('#contact').length > 0){
						galleryAdv.toggleSlideshow();
					}
				}				

 
 
  // Reset Font Size
  var originalFontSize = $('.article').css('font-size');
  $(".resetFont").click(function(){
  $('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  $(".increaseFont").click(function(){
  	var currentFontSize = $('.article').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
	if (newFontSize < 26 ){
		$('.article').css('font-size', newFontSize);
		$('.article').css('line-height', 1.5);	
		$('img.decreaseFont').attr('src','/images/icon-text-size-down.gif');
	} else{
		this.src = '/images/icon-text-size-up-inactive.gif';		
	}
	return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
  	var currentFontSize = $('.article').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum/1.2;	
	if (newFontSize > 6 ){
		$('.article').css('font-size', newFontSize);
		$('.article').css('line-height',1.5);	
		$('img.increaseFont').attr('src','/images/icon-text-size-up.gif');
	} else{
		this.src = '/images/icon-text-size-down-inactive.gif';
	}
	return false;
  });
      
    });

	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-15611959-1']);  
	_gaq.push(['_trackPageview']);  
	(function() {    
			  var ga = document.createElement('script'); 
			  ga.type = 'text/javascript'; 
			  ga.async = true;    
			  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';    
			  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);  
	})();

	var ord = Math.random()*10000000000000000;
