JE$$.styledBox({
	id : 'whitebox',
	border: '0',
	bgColor : 'transparent',
	img : '/images/whitebox',
	ext : 'png',
	width : { top:10, right:10, bottom:10, left:10 },
	padding : '',
	minHeight : 120,
	minWidth : 120
});
JE$$.styledBox({
	id : 'whitebox_in',
	border: '0',
	bgColor : 'transparent',
	img : '/images/whitebox-in',
	ext : 'png',
	width : { top:10, right:10, bottom:10, left:10 },
	padding : '',
	minHeight : 120,
	minWidth : 120
});

function show_send_form(){
   if($("#send_form").css('display') == 'none'){
      $("#send_form").fadeIn(100);
   }
   else{
      hide_send_form();
   }
}

function hide_send_form(){
   $("#send_form").fadeOut(100);
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function link_send(link){
   var chyby = 0;
   id = 'l_mail'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   
   var text = document.getElementById('l_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){
      
      $("#send_form_msg_bad").hide(1);
      $("#send_form_msg_good").show(1);
      
      var mail = document.getElementById('l_mail').value;
      var text = document.getElementById('l_text').value;
      
      var so_l = new sack();
   	so_l.requestFile = '/ajax/odeslani-odkazu.php';
   	so_l.method = 'GET';
   	so_l.runAJAX('mail='+mail+'&text='+text+'&odkaz='+link);
      
      var mail = document.getElementById('l_mail').value = '';
      var text = document.getElementById('l_text').value = '';
      
      timer = setTimeout(function(){
         hide_send_form();
         $("#send_form_msg_good").hide(1);
      }, 2000);
   }
   else{
      $("#send_form_msg_good").hide(1);
      $("#send_form_msg_bad").show(1);
   }
}

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: Jméno, e-mail a text');}
}

function demand_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;}
   
   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.poptavka.submit();}else{alert('Prosíme, vyplňte správně všechna povinná pole: Jméno a e-mail');}
}

function demand_f_send(){
   var chyby = 0;
   id = 'f_k_name'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   id = 'f_k_mail'; if(trim(document.getElementById(id).value) == ''){chyby += 1;}
   
   var text = document.getElementById('f_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.poptavka_f.submit();}else{alert('Prosíme, vyplňte správně všechna povinná pole: Jméno a e-mail');}
}

function select_region(id_region){
   document.getElementById('select_region_'+id_region).selected = true;
}

function load_city(id_region){
   var so1 = new sack();
	so1.requestFile = '/ajax/load_city.php';
	so1.method = 'GET';
	so1.element = 'city';
	so1.runAJAX('id_region='+id_region);
}

function load_city_body(id_region){
   var so1 = new sack();
	so1.requestFile = '/ajax/load_city.php';
	so1.method = 'GET';
	so1.element = 'city_body';
	so1.runAJAX('id_region='+id_region);
}

function load_city_f(id_region){
   var so1 = new sack();
	so1.requestFile = '/ajax/load_city.php';
	so1.method = 'GET';
	so1.element = 'f_city';
	so1.runAJAX('id_region='+id_region);
}

function load_cats(id_type){
   var so2 = new sack();
	so2.requestFile = '/ajax/load_cats.php';
	so2.method = 'GET';
	so2.element = 'cats';
	so2.runAJAX('id_type='+id_type);
}

function load_cats_body(id_type){
   var so2 = new sack();
	so2.requestFile = '/ajax/load_cats.php';
	so2.method = 'GET';
	so2.element = 'cats_body';
	so2.runAJAX('id_type='+id_type);
}

function load_cats_demand(id_type){
   var so2 = new sack();
	so2.requestFile = '/ajax/load_cats_demand.php';
	so2.method = 'GET';
	so2.element = 'cats';
	so2.runAJAX('id_type='+id_type);
}

function load_properties(id_type){
   var so3 = new sack();
	so3.requestFile = '/ajax/load_properties.php';
	so3.method = 'GET';
	so3.element = 'properties';
	so3.runAJAX('id_type='+id_type);
}

function load_cats_select(id_type){
   var so2 = new sack();
	so2.requestFile = '/ajax/load_cats_select.php';
	so2.method = 'GET';
	so2.element = 'cats';
	so2.runAJAX('id_type='+id_type);
}

function load_cats_select_f(id_type){
   var so2 = new sack();
	so2.requestFile = '/ajax/load_cats_select_f.php';
	so2.method = 'GET';
	so2.element = 'f_cats';
	so2.runAJAX('id_type='+id_type);
}

function show_tab(id){
   to_hide = (id == '1') ? '2' : '1';
   document.getElementById('tab_box_'+to_hide).style.display = 'none';
   document.getElementById('tab_li_'+to_hide).className = '';
   document.getElementById('tab_box_'+id).style.display = '';
   document.getElementById('tab_li_'+id).className = 'slc';
}

function map_region_select(id){
   alert(id);
}
