/*
	   _____ ______
	  / ___// ____/
	  \__ \/ /_
	 ___/ / __/ (c) 2011
	/____/_/ sasaforic.com

*/

$(document).ready(function() {

	// Homepage rotate
	$('.slider .slides').each(function() {
		var fullClass = $(this).attr('class');
		var classes   = fullClass.split(' ');
		for (var c in classes) {
			if (/^time-.+/.test(classes[c])) {
				var duration = parseInt(classes[c].replace('time-', ''));
				$(this).data('duration', duration);
			}
		};
	});

	var timeOut;
	function rotate() {
		var $current = $('.slider .slides:visible');
		timeOut  = setTimeout(function() {
			$next = $('.slider .slides:visible').next();
		if ($next.length === 0) {
				$next = $('.slider .slides:first');
			}
			$current.fadeOut(500);
			$next.fadeIn(500);
			rotate();
		}, $current.data('duration') || 6000);
	}

	$('.slider').mouseenter(function() {
		clearTimeout(timeOut);
	}).mouseleave(function() {
		rotate();
	});
	
	rotate();

	// Images
	$('.images').tinycarousel({ pager: true, interval: true, controls: false  });
	
	
	//fancybox 
	$("#uvjeti").fancybox({
	'width'				: '50%',
	'height'			: '75%',
	'autoScale'     	: false,
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe'
	});			

});
