// JavaScript Document

$(document).ready(function() {
  
	// Cycle homepagina
	if($('.home-cycle li').length > 0) {
		$('.home-cycle')
			.after('<div id="sliderNav">')
			.cycle({
			timeout: 7000,
			speed: 1000,
			pager:  '#sliderNav'
		});
	}
	
	// Cycle banner vervolgpagina's
	if($('#banner-image img').length > 0) {
		$('#banner-image').cycle({
			timeout: 7000,
			speed: 2000
		});
	}
  
	//--- Fotogalerij Fancybox ---
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
		return '<div id="foto-title">' +(title && title.length ? '<b>' + title + '</b><br />' : '' ) + 'Afbeelding ' + (currentIndex + 1) + ' van ' + currentArray.length + '</div>';
	}
    
	$("a.fancybox").fancybox({
		'autoScale'        : true,
		transitionIn       : 'none',
		transitionOut      : 'none',
		'titlePosition'    : 'inside',
		'titleFormat'      : formatTitle
	});

	//--- Video Fancybox  ---
	function formatVideoTitle(title, currentArray, currentIndex, currentOpts) {
		return '<div id="video-title">' +(title && title.length ? '<b>' + title + '</b>' : '' ) + '</div>';
	}
  
	$(".btn-play").click(function() {
		$.fancybox({
			'padding'          : 0,
			'autoScale'        : false,
			'transitionIn'     : 'none',
			'transitionOut'    : 'none',
			'title'            : this.title,
			'titlePosition'    : 'inside',
			'titleFormat'      : formatVideoTitle,
			'width'            : 680,
			'height'           : 495,
			'href'             : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'             : 'swf',
			'swf'              : {
				'wmode'            : 'transparent',
				'allowfullscreen'  : 'true'
			}
		});
		return false;
	}); 
  
	$(".play").click(function() {
		$.fancybox({
			'padding'          : 0,
			'autoScale'        : false,
			'transitionIn'     : 'none',
			'transitionOut'    : 'none',
			'title'            : this.title,
			'titlePosition'    : 'inside',
			'titleFormat'      : formatVideoTitle,
			'width'            : 680,
			'height'           : 495,
			'href'             : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'             : 'swf',
			'swf'              : {
				'wmode'            : 'transparent',
				'allowfullscreen'  : 'true'
			}
		});
		return false;
	});
  
	$("[rel=play]").click(function() {
		$.fancybox({
			'padding'          : 0,
			'autoScale'        : false,
			'transitionIn'     : 'none',
			'transitionOut'    : 'none',
			'title'            : this.title,
			'titlePosition'    : 'inside',
			'titleFormat'      : formatVideoTitle,
			'width'            : 680,
			'height'           : 495,
			'href'             : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'             : 'swf',
			'swf'              : {
				'wmode'            : 'transparent',
				'allowfullscreen'  : 'true'
			}
		});
		return false;
	});
	
	//wysiwyg editor blogformulier
	$('.fldInhoud').wysiwyg({
		controls: {
			strikeThrough: { visible: false },
			underline: { visible: false },
			justifyLeft: { visible: false },
			justifyCenter:{ visible: false },
			justifyRight: { visible: false },
			justifyFull: { visible: false },
			indent: { visible: false },
			outdent: { visible: false },
			subscript: { visible: false },
			superscript: { visible: false },
			undo: { visible: false },
			redo: { visible: false },
			insertOrderedList: { visible: false },
			insertUnorderedList: { visible: false },
			insertHorizontalRule: { visible: false },
			insertImage: { visible: false },
			h1: { visible: false },
			h2: { visible: false },
			h3: { visible: false },
			html: { visible: false },
			insertTable: { visible: false }
		},
		css: {
			font: '12px/1.5em Arial, Helvetica, sans-serif'
		},
		initialContent: '<p><br /></p>'
	});
	
});

function submitSearch(str) {
	if(str.length > 0) location.href = '/zoekresultaten/?query=' + str;
}
