/* Suckerfish dropdown menu
---------------------------------------------------------------------------- */
$(function() { 
    $('ul.sf-menu').superfish({ 
        delay:       100,                            // one second delay on mouseout 
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  false,                           // disable generation of arrow mark-up 
        dropShadows: false                            // disable drop shadows 
    }); 
    
    
/* Logo slider
---------------------------------------------------------------------------- */

    var aantal_logos = $('.logo_div').length;
    var breedte = -270;
    var current_logo = 0;
    var pauzetijd = 4500;
    $('.logo_div').fadeOut();
    
    slide = function(){
    	$('#logo_'+(current_logo+1)).fadeIn("slow");
    	$('#logo_slider').stop().animate({
    		left: current_logo * breedte
  		}, 2000);
 		if(current_logo == aantal_logos-1){
 			current_logo = 0;
 			$('.logo_div').delay(pauzetijd-1000).fadeOut();
 		} else {
 			current_logo++
 		}
    }
    $('#logo_1').fadeIn("slow");
    var playSlideshow = setInterval("slide()", pauzetijd );
	//alert(aantal_logos);
	
	
/* Video carrousel
---------------------------------------------------------------------------- */
	//video slider
	var aantal_videos = $('.video_div').length;
    var current_video = 1;
    $('#next').click(function() {
    	if(current_video == aantal_videos){
			$('#video_slider').stop().animate({left: 1}, 500);
			current_video = 1;
		}else{
			$('#video_slider').stop().animate({left: current_video * breedte}, 500);
			current_video++
		}
	});

	$('#previous').click(function() {
    	if(current_video == 1){
    		//ga naar laatste video
			$('#video_slider').stop().animate({left: (aantal_videos-1) * breedte}, 500);
			current_video = aantal_videos;
		}else{
			$('#video_slider').stop().animate({left: (current_video-2) * breedte}, 500);
			current_video--
		}
	});
	
	
/* Fancybox 
---------------------------------------------------------------------------- */
	/* Apply fancybox to multiple items */
	
	$("a.iframe").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'showCloseButton' : true,
		'speedIn'		:	600, 
		'type'			:	'iframe',
		'speedOut'		:	200, 
		'width'			:	800,
		'height'		: 	480,
		'scrolling'		: 	'no',
		'padding'		:	0,
		'autoScale'		:	true,
		'overlayShow'	:	true,
		'overlayColor'	:	'#333',
		'overlayOpacity' :	0.9,
		'hideOnContentClick' : true,
		'hideOnOverlayClick' : true
	});
	
	$("a.linkedin").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'showCloseButton' : true,
		'speedIn'		:	600, 
		'type'			:	'iframe',
		'speedOut'		:	200, 
		'width'			:	650,
		'height'		: 	300,
		'scrolling'		: 	'no',
		'padding'		:	0,
		'autoScale'		:	true,
		'overlayShow'	:	true,
		'overlayColor'	:	'#333',
		'overlayOpacity' :	0.9,
		'hideOnContentClick' : true,
		'hideOnOverlayClick' : true
	});


/* Extra classes aan downloads hangen
---------------------------------------------------------------------------- */
	// Add pdf icons to pdf links
	$("a[href$='.pdf']").addClass("pdf");
	
	$("a[href$='.mp3']").addClass("mp3");
 
	// Add txt icons to document links (doc, rtf, txt)
	$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft']").addClass("txt");
 
	// Add zip icons to Zip file links (zip, rar)
	$("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 
 
	// Add email icons to email links
	$("a[href^='mailto:']").addClass("email");
 
	//Add external link icon to external links - 
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external");
	//You might also want to set the _target attribute to blank
	/*
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external").attr("target", "_blank");
	*/
});



/* Popup window
---------------------------------------------------------------------------- */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function isValidEmailAddress(emailAddress) {
	var patroon = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return patroon.test(emailAddress);
};
/* 
	Uitleg:
	<a href="#" onclick="MM_openBrWindow('http://www.nu.nl','social','width=400,height=300')">popup</a> 
*/
