$(document).ready(function(){
	/** HOME **/
	$('#partner-slider').tinycarousel({
		interval: true,
		duration: 1000,
		intervaltime: 2500
	});

	$('.partner. a').tipsy({fade: true, gravity: 's'});
	$('.tooltip.n').tipsy({fade: true, gravity: 's'});
	$('.tooltip.s').tipsy({fade: true, gravity: 'n'});
	$('.tooltip.e').tipsy({fade: true, gravity: 'w'});
	$('.tooltip.w').tipsy({fade: true, gravity: 'e'});


	/* TOOLS OVERVIEW **/
	$('.full #teaser-slider').tinycarousel({
		interval: true,
		animation: false,
		start: 2,
		duration: 0,
		intervaltime: 5500,
		callback: function(element, index){
			toggleText(index);
		}
	});
	function toggleText(index) {
		$('.teaser .content[rel!="'+index+'"]').fadeOut('fast');
		$('.teaser .content[rel="'+index+'"]').fadeIn('slow');
	}

	/* LANGUAGE SWITCHER **/
	/*
	$("a[id*='language_']").click(function(event) {
		event.preventDefault();
		var click_id = $(this).attr('id');
		var id_split = click_id.split('_');
		var lang = id_split[1] + '_' + id_split[2];
		var clickable = id_split[3];
		if (clickable != 'disabled') {
			$("input[name=session_language]").val(lang);
			$('#language_form').submit();
		}
	});
	*/

	/* QUOTES **/
    if(randomNumber=== undefined) var randomNumber = 0;

	$('#index_quotes').tinycarousel({
		interval: true,
		pager: true,
		start: randomNumber,
		duration: 1000,
		intervaltime: 10000
	});

	/* TOOLS SUBPAGE **/
	$('.small #teaser-slider').tinycarousel({
		interval: true,
		pager: true,
		duration: 1000,
		intervaltime: 5500
	});

	/** Notification Animations **/
	$('.notification').hide().append('<span class="close" title="Dismiss"></span>').fadeIn('slow');
	$('.notification .close').hover(
		function () {
			$(this).addClass('hover');
		}, function () {
			$(this).removeClass('hover');
	});
	$('.notification .close').click(function () {
		$(this).parent().fadeOut('slow', function () {
			$(this).remove();
		});
	});
});
