function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function setCookie(key, value, days, path, domain, secure) {
   value = encodeURIComponent(value);
   value+='; domain='+domain;
   value+='; path='+path;
   var date = new Date();
   date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
   value+='; expires=' + date.toGMTString();
   if (secure) value+='; secure';
   document.cookie = key + '=' + value;
}

function AddSmile(what){
   document.forms.gbook.text.focus();
   document.forms.gbook.text.value=
   document.forms.gbook.text.value+what;
}

function contact_send(){
   var chyby = 0;
   id = 'k_name'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'k_mail'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'k_text'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   
   var text = document.getElementById('k_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('Prosíme, vyplňte správně všechna povinná pole označená hvězdičkou.');}
}

function order_send(){
   var chyby = 0;
   id = 'k_name'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'k_mail'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'k_text'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   
   var text = document.getElementById('k_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('Prosíme, vyplňte správně všechna povinná pole označená hvězdičkou.');}
}

var header_changer;

function show_next_header(){
   clearInterval(header_changer);
   $(".header_img").css('display','none');
   $(".header_img_active").css('display','none');
   if($(".header_img_active").next("span").css('display') == 'none'){
      $(".header_img_active")
         .removeClass("header_img_active")
         .addClass("header_img")
      .next(".header_img")
         .fadeIn(500)
         .removeClass("header_img")
         .addClass("header_img_active")
      ;
   }
   else{
      $(".header_img_active")
         .removeClass("header_img_active")
         .addClass("header_img");
      $("#header_img_1")
         .fadeIn(500)
         .removeClass("header_img")
         .addClass("header_img_active")
      ;
   }
   if($(".header_button_active").next("a").css('display') != 'none'){
      $(".header_button_active")
         .removeClass("header_button_active")
      .next("a")
         .addClass("header_button_active")
      ;
   }
   else{
      $(".header_button_active")
         .removeClass("header_button_active")
      ;
      $("#header_button_1")
         .addClass("header_button_active")
      ;
   }
   header_changer = setInterval('show_next_header();', 8000);
}

function show_header(id){
   clearInterval(header_changer);
   $(".header_img").css('display','none');
   $(".header_img_active").css('display','none').removeClass("header_img_active").addClass('header_img');
   $("#header_img_"+id)
         .fadeIn(500)
         .removeClass("header_img")
         .addClass("header_img_active")
      ;
   $(".header_button_active").removeClass('header_button_active');
   $("#header_button_"+id).addClass('header_button_active');
   header_changer = setInterval('show_next_header();', 8000);
}
