  $(document).ready(function(){
    $("textarea").each(function(){
      if (jQuery.trim($(this).val())=="") {
        $(this).val("");
      }
    });
    $("ul.rozcestnik li p.zvyrazneni").removeClass("zvyrazneni");
    
    $(".zvyrazneni").corner("8px");
    $("form.formular_standard").corner("8px");
    
    $("form.formular_standard").submit(function(){
      var allOK=true;
        var message="Bohužel jste nazadali všechny požadované údaje. Chybějící položky: ";
        $(":input.mandatory").each(function(){
          
          if ($(this).attr("value")=="") {
            message=message+", "+$(this).attr("title");
            allOK=false;
          } 
        });
        message = message + ". Doplňte je prosím";
        if (allOK) {
           var message="Bohužel některé položky neobsahují platnou emailovou adresu. Nesprávně zadané položky: ";
            $(":input.email").each(function(){
              if ($(this).attr("value")!="") {
                if (isEmail($(this).attr("value"))) {
                } else {
                  message=message+", "+$(this).attr("title");
                  allOK=false;
                }
              }
            });
            
            message = message + ". Opravte je prosím";
            if (allOK) {
              return true;
             } else {
              alert(message);
              return false;
             }
             
        } else {
          alert(message);
          return false;
        } 
  });
    
    
    //$("div#submenu_kalendar ul li a.active").each(function() {
      //if ( $("div#submenu_kalendar ul li:first a").attr("class")!="active"){
        $("div#submenu_kalendar ul li:first").attr("id","standard");
        //}
      //}
    //);
    
    //if ($("div#submenu_kalendar ul li:first a").attr("class")=="active"){
    // $("div#content div#maincontent  div.standard").attr("class","main");
    //};
    
    $("div#submenu_kalendar ul li#standard a").hover(
    
     function() {
     if ($(this).attr("class")!="active") {
      $("div#content div#maincontent  div.standard").attr("class","main");
      }
     },
     function() {
     if ($(this).attr("class")!="active") {
      $("div#content div#maincontent  div.main").attr("class","standard");
      }
     }
    );
    
    $("form.line_1k select").change(onChangeSelect1);
    $("form.line_1 select").change(onChangeSelect2);
    $("form.line_3l select").change(onChangeSelect3);
    function onChangeSelect1(){
      $("form.line_1k").submit();
    };
    function onChangeSelect2(){
      $("form.line_1").submit();
    };
     function onChangeSelect3(){
      $("form.line_3l").submit();
    };
    
    
    $("p.vyber a").each(function(){
      if ($(this).attr("class")=="active") {
        if ($(this).prev().attr("class")!="active") { 
          $(this).prev().attr("class","last-child");
        }
      }
      $(this).hover(
      function() {
        if ($(this).prev().attr("class")!="active") { 
          $(this).prev().attr("class","last-child");
        }
       },
      function() {
        if ($(this).prev().attr("class")!="active") { 
          if ($(this).attr("class")!="active") {
          $(this).prev().attr("class","");
          }
        }
       }
      );
    });
    
    $("p.vyber a:last-child").each(function(){
      if ($(this).attr("class")=="active") {
        $(this).attr("class", "last-child active");
      } else {
        $(this).attr("class", "last-child");
      }
    });
    
    $("p#seznam input:checkbox").change(onChangeCheckBox);
    
    function onChangeCheckBox(){
      var uri= $(this).attr("value");
      var nazev = $("p#seznam span label[for='" +uri+ "']").text();
      var text = "<input type=\"checkbox\" checked=\"checked\" id=\""+uri+"\"/>"+
			           "<label for=\""+uri+"\">"+nazev+"</label><br/>";
		 $("p#prehled").append(text);
    $(this).parent().next().remove();
		 $(this).parent().remove();
    };
     
    
    
    
    //$("table.kontaktypracovnici tr:last").attr("class", "detail show");
    
    $("#evropa_navi").hover(
      function() {
        $("#evropa").attr("class","hover");
      },
      function() {
      $("#evropa").attr("class","");
      }
    );
    $("#asie_navi").hover(
      function() {
        $("#asie").attr("class","hover");
      },
      function() {
      $("#asie").attr("class","");
      }
    );
    $("#afrika_navi").hover(
      function() {
        $("#afrika").attr("class","hover");
      },
      function() {
      $("#afrika").attr("class","");
      }
    );
    $("#amerika_navi").hover(
      function() {
        $("#amerika").attr("class","hover");
      },
      function() {
        $("#amerika").attr("class","");
      }
    );
    
    $("#evropa").hover(
      function() {
        $("#evropa_navi").attr("class","active");
         
      },
      function() {
        $("#evropa_navi").attr("class","");
      }
    );
    $("#asie").hover(
      function() {
        $("#asie_navi").attr("class","active");
        $("#asie_navi").prev().attr("class","last-child");
      },
      function() {
        $("#asie_navi").attr("class","");
        $("#asie_navi").prev().attr("class","");
      }
    );
    $("#afrika").hover(
      function() {
        $("#afrika_navi").attr("class","active");
        $("#afrika_navi").prev().attr("class","last-child");
      },
      function() {
      $("#afrika_navi").attr("class","");
      $("#afrika_navi").prev().attr("class","");
      }
    );
    $("#amerika").hover(
      function() {
        $("#amerika_navi").attr("class","active");
        $("#amerika_navi").prev().attr("class","last-child");
      },
      function() {
      $("#amerika_navi").attr("class","");
      $("#amerika_navi").prev().attr("class","");
      }
    );
  });

