$(document).ready(function() {
    $('.flexslider').flexslider({
    	animation: "slide",              //Select your animation type (fade/slide)
		slideshow: true,                //Should the slider animate automatically by default? (true/false)
		slideshowSpeed: 4000,           //Set the speed of the slideshow cycling, in milliseconds
		animationDuration: 500,         //Set the speed of animations, in milliseconds
		directionNav: false,             //Create navigation for previous/next navigation? (true/false)
		controlNav: false,               //Create navigation for paging control of each clide? (true/false)
    });
    /*$('.slideshow').cycle({
		fx: 'scrollHorz' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	*/

	$('a[rel=gallery1]').fancybox({
		titlePosition:	'over',
		titleFormat:	formatTitle
	});
	$('a[rel=gallery2]').fancybox({
		titlePosition:	'over',
		titleFormat:	formatTitle
	});

	function formatTitle(title, currentArray, currentIndex, currentOpts){
		var url = currentArray[currentIndex];

		//alert(url);

		var html = '';
		html +=	'<div class="fancy-box-cust-title">';
		html +=		title;
		html +=		'<div class="share-photo">';
		html +=			'<a href="javascript:;" class="delen">Delen</a>';
		html +=			'<div class="networks">';
		html +=				'<iframe src="http://www.facebook.com/plugins/like.php?app_id=106423482797237&amp;href='+url+'&amp;send=false&amp;layout=button_count&amp;width=180&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>';
		html +=				'<span style="margin-right: 10px;"><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="test"></script></span>';
		html +=				'<iframe src="http://www.hyves.nl/respect/button?url='+url+'" style="border: medium none; overflow:hidden; width:102px; height:21px;" scrolling="no" frameborder="0" allowTransparency="true" ></iframe>';
		html +=				'<a href="http://twitter.com/share" class="twitter-share-button" data-url="'+url+'" data-count="none" data-via="huttencatering">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';
		html +=				'';
		html +=				'';
		html +=			'</div>';
		html +=		'</div>';
		html +=	'</div>';

		return html
	}


	$('.delen').live('click', function() {
		$('.networks').show();
	});


	// Validation
	$('#gastvrijheidsscan').validate();


	// start chat
	$('#chat-form').submit( function(){
		message = $('#message-from-me').val();

		window.open("http://178.18.84.191/~hutten/chat/index.php?message="+message, null, "height=500,width=330,status=yes,toolbar=no,menubar=no,location=no");
		return false;

		return false;
	});

	//Search
	$('#zoek-term').autocomplete({
		source: function(request, response){

			$.ajax({
				url: 	path+'front/ajax.php',
				type: 	'POST',
				data: 	{
					zoekterm: 	request.term,
					actie:		'zoek_paginas'
				},
				dataType: 'json',
				success: function(data){

					if(data){
						response( $.map( data, function( result ){
							return {
								label:	'&raquo; '+result.label,
								value:	result.label,
								url:	result.url
							}
						}));
					}
				}
			});
		},
		select: function(event, ui){
			location.href = ui.item.url;
			return false;
		}
	})
	
	$('#zoek-form').submit( function(event){ event.preventDefault(); return false;} );
});


