$(function()
{
	
	function Intro(e) {	
		if ($('body').attr('class') == 'frontpage') {
			$('.frontpage .intro').addClass('intro'+e.toString()+'');
			$('.intro-text-1').delay(100).fadeIn(1200, function() {
				$('.intro-text-2').fadeIn(1200)								   
			});
		} else {
			$('.main').addClass('sideimage'+e.toString()+'');
		}
	}
	
	$('.switch-two').click(function(e)
	{
		e.preventDefault();
		$(this).addClass('switch-selected');
		$('.switch-one').removeClass('switch-selected');
		$('.intro-vezalke').fadeOut(500);
		clearTimeout(t);
	});
	
	$('.switch-one').click(function(e)
	{
		e.preventDefault();	
		$(this).addClass('switch-selected');
		$('.switch-two').removeClass('switch-selected');
		$('.intro-vezalke').fadeIn(500);
		clearTimeout(t);
	});
	
	var t;
	 var timedCount = function() {

		 		$('.switch:not(.switch-selected)').click();
	 }
	 t=setInterval(timedCount,8000);
	
	
	Intro(Math.floor(Math.random()*3)+1);

	$(document).ready(function() {
		$('.form input.error').focus(function(){							   
			$(this).removeClass('error');
		});
		$('.partners a').click(function(e){
			e.preventDefault();								
		});
		$('.preview select, .preview input[readonly=readonly]').bind('blur focus focusin focusout click dblclick mousedown mouseup change select submit keydown keypress keyup error',function(e){
			e.preventDefault();
			e.stopImmediatePropagation();
			return false;
		});
		$('.image').fancybox({
			overlayOpacity 	: '0.7',
			overlayColor 	: '#001010',
			'titlePosition' 		: 'outside',
			titleFormat 	: function(title, currentArray, currentIndex, currentOpts){
								return '<span id="fancybox-title-over"><span>Slika ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '</span>' + title + '</span>' : '') + '</span>';
						  }
						 
		});
	});
	
	var domain = top.location.href.match(/(\/\/.*?)\/+/i)[1];
	$('a.external').live('click', (function(e){e.preventDefault();window.open($(this).attr('href'));}));
	$("a[href^='http']:not(a[href^='http:" + domain + "'])").addClass('external');	
});
