function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function odeslat_objednavku(){
   var chyby = 0;
   id = 'jmeno'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'mail'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'tel'; 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.fans.submit();}else{alert('Vyplňte správně jméno, e-mailovou adresu a telefonní číslo.');}
}

var sn_actual = 1;
var timer;

$(document).ready(function(){
   
   $("#sn_box_2").hide();
   $("#sn_box_3").hide();
   $("#sn_box_4").hide();
   
   $("#sn_li_"+sn_actual).addClass('slc');
   
   timer = setInterval(function(){
      sn_show(sn_actual + 1);
   }, 6000);
   
});

function sn_show(id){
   
   clearInterval(timer);
   
   id = parseInt(id);
   
   if(id > 4) id = 1;
   
   $("#sn_li_"+sn_actual).removeClass('slc');
   $("#sn_li_"+id).addClass('slc');
   
   $("#sn_box_"+sn_actual).fadeOut(400);
   setTimeout(function(){$("#sn_box_"+id).fadeIn(400);}, 500);
   
   sn_actual = id;
   
   timer = setInterval(function(){
      sn_show(sn_actual + 1);
   }, 6000);
   
}

function online_report_refresh(id){
   
   if(id){
      
      var so_orr = new sack();
   	so_orr.requestFile = '/ajax/online_report_refresh.php';
   	so_orr.element = 'online_report_refresh_ajax_element';
   	so_orr.method = 'GET';
   	so_orr.setVar('id', id);
   	so_orr.runAJAX();
      
   }
   
}
