$(document).ready(function() {
	$("a[rel='lightbox[a]']").colorbox({ transition: 'fade', speed : 600 });
	
	$().bind('cbox_open', function(){ 
		clearTimeout(header_timeout_rotace);
	}).bind('cbox_closed', function(){ 
		header_timeout_rotace = setTimeout("rotujHeaderObrazek()", header_delka_rotace);
	});
});

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function odeslatForm(){
   var chyby = 0;
   id = 'jmeno'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'mail'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'text'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   
   var text = document.getElementById('mail').value;
	var vyraz = new RegExp("^[_a-zA-Z0-9-]+([\.]{1}[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+([\.]{1}[a-zA-Z0-9-]+)*[\.]{1}[a-z]{2,3}$");
	var result = text.search(vyraz);
	if(result == -1){chyby += 1;}
   
   if(chyby == 0){document.forms.kontakt.submit();}else{alert('Vyplňte jméno, e-mailovou adresu a text.');}
}

function odeslatRezervaci(){
   var chyby = 0;
   id = 'jmeno'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'tel'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   
   if(chyby == 0){document.forms.rezervace.submit();}else{alert('Vyplňte povinné údeje - Vaše jméno, telefon a termín pobytu.');}
}

// submenu

var timer;

function showSubmenu(id){
   clearTimeout(timer);
   document.getElementById('submenu'+id).style.display = 'block';
   document.getElementById('m04_li').className = 'slc';
}

function hideSubmenuDo(id){
   document.getElementById('submenu'+id).style.display = 'none';
   document.getElementById('m04_li').className = '';
}

function hideSubmenu(id){
   clearTimeout(timer);
   timer = setTimeout("hideSubmenuDo('"+id+"')", 50);
}

