$(document).ready(function() {
	init_hoverLoginform();
	init_trailerOverlay();
	init_autocomplete();
	init_tooltips();
	init_homeslideshow();
});



function addtext(tekst) {
 $('#slowchat-reactie').focus();
 var newtext = $('#slowchat-reactie').val() + tekst;
 $('#slowchat-reactie').val(newtext);
} 

function init_tooltips() {
	$('.tooltip-s').tipsy({
		gravity: 's',
		title: 'rel',
		html: true 
	});
}

function init_hoverLoginform() {
	$('#login-form').hoverIntent(function() {
		$(this).animate({opacity: 1});
	}, function() {
		$(this).animate({opacity: 0.4});
	});
}


function init_trailerOverlay() {
	/* prettyphoto */
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'});
}

function init_autocomplete() {
	if ($('input[name="zoekwoord"]').length >0)
	{
		var a = $('input[name="zoekwoord"]').autocomplete({ 
		serviceUrl:'http://www.arthouse.nl/reviews/autocomplete.php',
		minChars:2, 
		delimiter: /(,|;)\s*/, // regex or character
		maxHeight:400,
		width:275,
		zIndex: 9999,
		deferRequestBy: 0, //miliseconds
		noCache: false, //default is false, set to true to disable caching
		//onSelect: function(value, data){ alert('You selected: ' + value + ', ' + data); },
		onSelect: function(){ $('input[name="zoekwoord"]').parents('form').submit(); }
	  });
	}
}

function init_homeslideshow() {
if ($('#news-slideshow').length >0)
	{
	$('#news-slideshow') 
	.before('<div id="slideshow-nav">') 
	.cycle({ 
		fx:     'fade', 
		speed:  500, 
		timeout: 7000, 
		pager:  '#slideshow-nav',
		   // callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<a href="javascript:void(0);" onclick="this.blur();">&nbsp;</a>'; 
		} 
	});
	}
}
