$(document).ready(function() {

    $("#objekt_zeme").change(function() {
		$.get("./js/data_pro_ajax.asp", {"_co":"zeme","id":this.value}, function(data) {
            $("#objekt_kraj").html(data);
            $("#objekt_kraj").change();
        });
    });

    $("#objekt_kraj").change(function() {
        $.get("./js/data_pro_ajax.asp", {"_co":"kraj","id":this.value}, function(data) {
            $("#objekt_okres").html(data);
            $("#objekt_okres").change();
        });
    });

    $("#objekt_okres").change(function() {
        $.get("./js/data_pro_ajax.asp", {"_co":"okres","id":this.value}, function(data) {
            $("#objekt_obec").html(data);
        });
    });

});

function nums(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;
}

function doFilter() {
	document.getElementById('filter_count').innerHTML='vyhledávám <span>...</span>';

	var parametry = "";
	var form=document.forms['form_filter'];
	for(i=0; i<form.elements.length; i++) {
		el = form.elements[i];
		if (el.type != "button" && el.type != "reset" && el.type != "submit" && el.name != "")
		{
			if (el.type == "radio" || el.type == "checkbox") {
				if (el.checked) {
					parametry += el.name + "=" + encodeURIComponent(el.value) + "&";
				}
			}
			else if(el.type == "select-one") {
				x = 0;
				while (op = el.options[x]) {
					if (op.selected) {
						parametry += el.name + "=" + encodeURIComponent(el.options[x].value) + "&";
					}
					x++;
				}
			}
		}
	}

	$.get('pages/filtruj.asp?'+parametry,function(result){
			pole=result.split('@oddelovac@')
			document.getElementById('filter_count').innerHTML=pole[0];
			document.getElementById('filter_list').innerHTML=pole[1];
    });
}




  $(document).ready(function() {
     $('input.score').click(function(){ // překlikávání mezi radio buttony
        var name = $(this).attr('name');        
        $('.' + name + ' span').removeClass('bg2');
        $(this).parent().addClass('bg2');
     });
     $('.answers input.radio').click(function(){
      $('.answers input.text').css('visibility', 'hidden');
     });
     
     $('.text_visible').click(function(){ // textová pole v otázce 10      
      $('.answers input.text').css('visibility', 'hidden');
      $('.answers input.text').val('');
      $(this).parent().find('input.q10_text').css('visibility','visible');
     });
     
     $('.q11').click( function(){ //otázka 11 - zobrazení po kliknutí
        $('table.voucher').slideDown();
     });
    $('.q11hide').click( function(){ 
        $('table.voucher').slideUp();
        $('table.voucher textarea').val('');
     });
     
     
    $("textarea.flexible").keypress(function(e){ //natahování textarea podle textu    
       var code = (e.keyCode ? e.keyCode : e.which);
       if(code == 13) {         
        var countLines = $(this).val().split("\n").length
        if (countLines > 4){          
          var height = 90 + ((countLines - 4)  * 16);                  
          $(this).css('height', height + 'px');    
          }    
       }            
    });
    
    // POPUP začátek
	 $('a.popup-close').click(function(){       
       window.location.href="http://www.ckregio.cz";
    });   
    // POPUP konec
    
  });
