/*globals $ window document */

/* EASING */
$(document).ready(function(){
	$('.scrollto').click(function(){
		var position = $( $(this).attr("href") ).offset().top;
		$("body:not(:animated), html:not(:animated)").animate(
			{ scrollTop:position},
			1000,
			'easeInOutQuad');
		return false;
	});
});



/* NIVO SLIDER */
$(window).load(function() {
    $('#slider').nivoSlider({
        effect:'random', //Specify sets like: 'fold,fade,sliceDown'
        slices:15,
        animSpeed:600, //Slide transition speed
        pauseTime:8000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        keyboardNav:false, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
});



/* FANCYBOX */
$(document).ready(function() {
	$("a.work1").fancybox();

	$("a#work2").fancybox({
		'titlePosition'		: 'outside',
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.8
	});

	$("a[rel=work_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'outside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
});



/* VALIDATION */
$(document).ready(function() {
	// SUCCESS AJAX CALL, replace "success: false," by:     success : function() { callSuccessFunction() }, 
	$("#formID").validationEngine({
		ajaxSubmit: true,
		ajaxSubmitFile: "ajaxSubmit.php",
		ajaxSubmitMessage: "Thank you, we received your inscription!",
		success :  false,
		failure : function() {}
	})
});



/* TIPSY */
$('li.icons a').tipsy({
	gravity: 'n',
	fade: true
});
$('a.top').tipsy({
	gravity: 'w',
	fade: false
});



/* TWEET@ANYWHERE */
twttr.anywhere(function(T) {
	T(".tweet").hovercards();
	T(".tweet").linkifyUsers();
});



/* TWEETS */
$(document).ready(function(){
	$(".tweet").tweet({
		username: "fabienb",
		join_text: "auto",
		avatar_size: 0,
		count: 1,
		auto_join_text_default: "I said:",
		auto_join_text_ed: "I",
		auto_join_text_ing: "I was",
		auto_join_text_reply: "I replied to",
		auto_join_text_url: "I was checking out",
		loading_text: "loading tweets..."
	});
});



/* INSTAGRAM-EMBEDAGRAM 
$(document).ready(function() {
	$('#slidegram').embedagram({
		instagram_id: 431312,
		success: function (){ $('#slidegram').jcarousel() },
		limit: 12
	});
});
*/
