$(document).ready(function() {
	
	
	//FORM VALIDACIA
	$('form').submit(function(){
		var povol = true;
		$('form input').each(function(intIndex){
			if($(this).attr('type')!='radio' && $(this).attr('type')!='hidden' && $(this).hasClass('povinne')==true) {
				if($(this).val()==''){
					alert('Povinné údaje musia byť vyplnené!');
					$(this).focus();
					$(this).addClass('highlighted');
					povol = false;
					return false;
				}
				else {
					$(this).removeClass('highlighted');
				}
			}
		})
		if(!povol){
			return false;
		}
	});
	
	
	/* This is basic - uses default settings */	
	$("a.single_image").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'hideOnContentClick': true,
		'overlayColor' : 'black'
	});

	/* Apply fancybox to multiple items */	
	$("a.grouped_elements").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'hideOnContentClick': true,
		'overlayColor' : 'black'
	});
	
	
	$('#search').focus(function(){
		if($(this).val()=='Hľadať') {
			$(this).val('');
		} 
		$(this).removeClass('grey')
	});
	
	$('#search').blur(function(){
		if($(this).val()==''){
			$(this).val('Hľadať'); 
			$(this).addClass('grey')
		}
	});
	
	$('#search-match').focus(function(){
		if($(this).val()=='Číslo stretnutia') {
			$(this).val('');
		} 
		$(this).removeClass('grey')
	});
	
	$('#search-match').blur(function(){
		if($(this).val()==''){
			$(this).val('Číslo stretnutia'); 
			$(this).addClass('grey')
		}
	});
	
	var otvorene_kola = false;
	$('#otvor-kola').click(function(){
		if(otvorene_kola){
			$('.liga-zapasy').hide();
			otvorene_kola = false;
		} else {
			$('.liga-zapasy').show();
			otvorene_kola = true;
		}
	});
	
	
	
	//PARTNERI2
	var current_znacka = 0;
	var spolu_znaciek = $('.partneri_in img').size();
	var posun_znacku_o = 145;
	
	$('#left-arrow').click(function(){
		if(current_znacka>0) {
			$('.partneri_in').animate({
				left:'+='+posun_znacku_o
			});
			current_znacka--;
		}
	});	
	$('#right-arrow').click(function(){
		if(current_znacka < spolu_znaciek-6) {
			$('.partneri_in').animate({
				left:'-='+posun_znacku_o
			});
			current_znacka++;
		}
	})
})
