function komentare(nazevElementu)
{
    $(document).ready(function(){                                                                      
        /*********komentare************/                                                                                                                 
        $("#editaceKomentare").hide();    
        $("#zrusitKomentovani").click(function(){
            $("#editaceKomentare").hide(500);
            $("#addKomentar").attr("value","");
            $("#predmetKomentare").attr("value","");
        });
        
        
        $("#editaceKomentareSpan").text("Komentovat příspěvek od: " + $("#"+nazevElementu).attr("jmeno"));
        $("#editaceKomentare").show(500);
        $("#addKomentar").attr("value",$("#"+nazevElementu).attr("idKomentare"));
        $("#predmetKomentare").attr("value","Re:" + $("#"+nazevElementu).attr("nazev"));
        /*********komentare/************/
    });    
}
function vojedCheckboxy(rodic)
{
    $(document).ready(function(){
        $("input:checkbox").parents(rodic).css("background-color", "");
        $("input:checkbox:checked").parents(rodic).css("background-color", "#f4d7a6");
    });
}

function formek(data)
{
    alert(data.value);
}

//$(document).ready(function(){ $.post(\'/admin/index.php?page='.$_GET['page'].'\', { ukon: \'addPoznamka\', id: \''.$vypis['id'].'\' }, function(data){ vlozdo(\'#notes\',data); } );  }); return false;

function hideNotes(){ $(document).ready(function(){$("#notes").fadeOut(300); $("#addNote").fadeOut(300); }); }
function hideAddNote(){ $(document).ready(function(){$("#addNote").fadeOut(300); }); }
function showAddNote(){ $(document).ready(function(){$("#addNote").fadeIn(300); });  }
function showNotes(){ $(document).ready(function(){$("#notes").fadeIn(300); }); }
function vlozdo(kam,data){ $(document).ready(function(){$(kam).html(data); }); }


 
/*********jQuery************/
$(document).ready(function(){
    $("#showRightsButton").click(function(){$("#showRights").toggle();});
     
     
     $("#hromadnaAkceOznacVse1").click(function(){
        if ($("#hromadnaAkceOznacVse1").attr("checked")) $(".hromadnaAkce1").attr("checked","true")
        else $(".hromadnaAkce1").attr("checked","");
     });
     $("#hromadnaAkceOznacVse2").click(function(){
        if ($("#hromadnaAkceOznacVse2").attr("checked")) $(".hromadnaAkce2").attr("checked","true")
        else $(".hromadnaAkce2").attr("checked","");
     });
     $("#hromadnaAkceOznacVse3").click(function(){
        if ($("#hromadnaAkceOznacVse3").attr("checked")) $(".hromadnaAkce3").attr("checked","true")
        else $(".hromadnaAkce3").attr("checked","");
     });
      
     $("#loaddStrom").hide();
     $("#loaddStrom").slideDown(600);
     
     $("#add1").show();
     $("#add2").hide();
     $("#add3").hide();
     $("#add4").hide();
     $("#add5").hide();
     $("#add6").hide();
     $("#add7").hide();
                                                                                                                     
                                                                                                                     
    /*********komentare************/                                                                                                                 
    $("#editaceKomentare").hide();    
    $("#zrusitKomentovani").click(function(){
        $("#editaceKomentare").hide(500);
        $("#addKomentar").attr("value","");
        $("#predmetKomentare").attr("value","");
    });
    
    $("#pridatKomentarKeKomentari").click(function(){
        $("#editaceKomentare").prepend("Komentovar příspěvek od: " + $("#pridatKomentarKeKomentari").attr("jmeno"));
        $("#editaceKomentare").show(1000);
        $("#addKomentar").attr("value",$("#pridatKomentarKeKomentari").attr("idKomentare"));
        $("#predmetKomentare").attr("value","Re:" + $("#pridatKomentarKeKomentari").attr("nazev"));
    });
    /*********komentare/************/
    
    
     
     $("#menuTopIn1").click(
        function() {$("#add1").slideDown(500);$("#add2").hide();$("#add3").hide(); $("#add4").hide(); $("#add5").hide(); $("#add6").hide(); $("#add7").hide();
        $(this).addClass("curent"); $("#menuTopIn2").removeClass("curent"); $("#menuTopIn3").removeClass("curent"); $("#menuTopIn4").removeClass("curent"); $("#menuTopIn5").removeClass("curent"); $("#menuTopIn6").removeClass("curent"); $("#menuTopIn7").removeClass("curent");} );
     $("#menuTopIn2").click(
        function() {$("#add1").hide();$("#add2").slideDown(500);$("#add3").hide(); $("#add4").hide(); $("#add5").hide(); $("#add6").hide(); $("#add7").hide();  
        $(this).addClass("curent"); $("#menuTopIn1").removeClass("curent"); $("#menuTopIn3").removeClass("curent"); $("#menuTopIn4").removeClass("curent"); $("#menuTopIn5").removeClass("curent"); $("#menuTopIn6").removeClass("curent"); $("#menuTopIn7").removeClass("curent");} );
     $("#menuTopIn3").click(
        function() {$("#add1").hide();$("#add2").hide();$("#add3").slideDown(500); $("#add4").hide(); $("#add5").hide(); $("#add6").hide(); $("#add7").hide(); 
        $(this).addClass("curent"); $("#menuTopIn1").removeClass("curent"); $("#menuTopIn2").removeClass("curent"); $("#menuTopIn4").removeClass("curent"); $("#menuTopIn5").removeClass("curent");$("#menuTopIn6").removeClass("curent"); $("#menuTopIn7").removeClass("curent");} );
     $("#menuTopIn4").click(
        function() {$("#add1").hide();$("#add2").hide();$("#add3").hide(); $("#add4").slideDown(500); $("#add5").hide(); $("#add6").hide(); $("#add7").hide();
        $(this).addClass("curent"); $("#menuTopIn1").removeClass("curent"); $("#menuTopIn2").removeClass("curent"); $("#menuTopIn3").removeClass("curent"); $("#menuTopIn5").removeClass("curent"); $("#menuTopIn6").removeClass("curent"); $("#menuTopIn7").removeClass("curent");} );
     $("#menuTopIn5").click(
        function() {$("#add1").hide();$("#add2").hide();$("#add3").hide(); $("#add4").hide(); $("#add5").slideDown(500); $("#add6").hide(); $("#add7").hide();
        $(this).addClass("curent"); $("#menuTopIn1").removeClass("curent"); $("#menuTopIn2").removeClass("curent"); $("#menuTopIn3").removeClass("curent"); $("#menuTopIn4").removeClass("curent"); $("#menuTopIn6").removeClass("curent"); $("#menuTopIn7").removeClass("curent");} );
     $("#menuTopIn6").click(
        function() {$("#add1").hide();$("#add2").hide();$("#add3").hide(); $("#add4").hide(); $("#add5").hide(); $("#add6").slideDown(500); $("#add7").hide();
        $(this).addClass("curent"); $("#menuTopIn1").removeClass("curent"); $("#menuTopIn2").removeClass("curent"); $("#menuTopIn3").removeClass("curent"); $("#menuTopIn4").removeClass("curent"); $("#menuTopIn5").removeClass("curent"); $("#menuTopIn7").removeClass("curent");} );
     $("#menuTopIn7").click(
        function() {$("#add1").hide();$("#add2").hide();$("#add3").hide(); $("#add4").hide(); $("#add5").hide(); $("#add6").hide(); $("#add7").slideDown(500); 
        $(this).addClass("curent"); $("#menuTopIn1").removeClass("curent"); $("#menuTopIn2").removeClass("curent"); $("#menuTopIn3").removeClass("curent"); $("#menuTopIn4").removeClass("curent"); $("#menuTopIn5").removeClass("curent"); $("#menuTopIn6").removeClass("curent"); } ); 
});

/*********jQuery/************/ 

function checkCheckbox(id) 
{
    if(document.getElementById(id).checked!="checked") document.getElementById(id).checked="checked";
    else document.getElementById(id).checked="";     
}
function addFotoFromURL() 
{
  var ni = document.getElementById('kolonkyurl');
  var numi = document.getElementById('inkrurl');
  var num = (document.getElementById('inkrurl').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'kolonkaurl'+num;
  
  newdiv.setAttribute('id',divIdName);
  newdiv.setAttribute('class','kolony'); 
  newdiv.innerHTML = '<input type="text" size="60" name="fotoFromURL' + num + '" /> <input type="button" class="buttonClose" onclick=\'removeElementURL("'+divIdName+'")\'>';
  ni.appendChild(newdiv);
}
function addOption() 
{                                                                                                
  var ni = document.getElementById('kolonky');
  var numi = document.getElementById('inkr');
  var num = (document.getElementById('inkr').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'kolonka'+num;
  
  newdiv.setAttribute('id',divIdName);
  newdiv.setAttribute('class','kolony'); 
  newdiv.innerHTML = num +'. možnost&nbsp;&nbsp;&nbsp;<input type="text" size="50" name="option' + num + '" /> <input type="button" class="buttonClose" onclick=\'removeElement("'+divIdName+'")\'>';
  ni.appendChild(newdiv);
}
function addElement() 
{
  var ni = document.getElementById('kolonky');
  var numi = document.getElementById('inkr');
  var num = (document.getElementById('inkr').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'kolonka'+num;
  
  newdiv.setAttribute('id',divIdName);
  newdiv.setAttribute('class','kolony'); 
  newdiv.innerHTML = '<input type="file" size="50" name="foto_m' + num + '" /> <input type="button" class="buttonClose" onclick=\'removeElement("'+divIdName+'")\'>';
  ni.appendChild(newdiv);
}
function rozbalAdd(cis) 
{
  var ni = document.getElementById('polozka_'+cis);
  var numi = document.getElementById('inkr'+cis);
  var num = (document.getElementById('inkr'+cis).value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'kolonka'+cis+num;
  newdiv.setAttribute('id',divIdName);
  newdiv.setAttribute('class','kolony');
  newdiv.innerHTML = '<input type="text" size="30" name="add*' + cis + "*" + num + '" /> <input type="button" class="buttonClose" onclick=\'rozbalDel("'+divIdName+'","polozka_'+ cis+'")\'>';
  ni.appendChild(newdiv);
}
function rozbalDel(divNum,nameElement) 
{
  var d = document.getElementById(nameElement);
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}
function rozbalEdit(cis,val) 
{
  
  var ni = document.getElementById('polozka_' + cis);
  var newdiv = document.createElement('div');
  var divIdName = 'kolonka'+cis;
  if (document.getElementById('iff'+cis).value==0 )
  {
      newdiv.setAttribute('id',divIdName);
      newdiv.setAttribute('class','kolony');
      newdiv.innerHTML = '<input type="text" size="30" value="' + val + '" name="edit*' + cis + '" /> <input type="button" class="buttonClose" onclick=\'smazEdit("'+divIdName+'","'+ cis+'")\'>';
      ni.appendChild(newdiv);
      document.getElementById('iff'+cis).value=1;
  }
  else
  {
      var d = document.getElementById('polozka_' + cis);
      var olddiv = document.getElementById(divIdName);
      d.removeChild(olddiv);
      document.getElementById('iff'+cis).value=0;
  }
}
function smazEdit(divNum,cis) 
{
     var d = document.getElementById('polozka_'+cis);
     var olddiv = document.getElementById(divNum);
     d.removeChild(olddiv);
     document.getElementById('iff'+cis).value=0;
}
function addNextSlevaInput() 
{
  var ni = document.getElementById('slevy');
  var numi = document.getElementById('inkSlevy');
  var num = (document.getElementById('inkSlevy').value -1)+ 2;
  numi.value = num;
  var newtr = document.createElement('tr');
  var trIdName = 'slevaInput'+num;
  newtr.setAttribute('id',trIdName);
  newtr.innerHTML = '<td class="id">-</td><td class="slevy"><input type="text" name="od' + num + '" /></td><td class="slevy"><input type="text" name="do' + num + '" /></td><td class="slevyy"><input type="text" name="percent' + num + '" /></td><td class="aplik"><input type="checkbox" name="aplikovatNaNeregistrovane' + num + '" value="true" /></td><td class="delete"><input type="button" class="buttonClose" onclick=\'removeSlevaInput("'+trIdName+'")\';></td>';
  ni.appendChild(newtr);
}
function removeSlevaInput(trNum) 
{
  var d = document.getElementById('slevy');
  var oldtr = document.getElementById(trNum);
  d.removeChild(oldtr);
}
function removeElementURL(divNum) 
{
  var d = document.getElementById('kolonkyurl');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}
function removeElement(divNum) 
{
  var d = document.getElementById('kolonky');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}


function addNextDPHInput() 
{
  var ni = document.getElementById('DPHs');
  var numi = document.getElementById('inkDPH');
  var num = (document.getElementById('inkDPH').value -1)+ 2;
  numi.value = num;
  var newtr = document.createElement('tr');
  var trIdName = 'DPHInput'+num;
  newtr.setAttribute('id',trIdName);
  newtr.innerHTML = '<td class="id">-</td><td class="slevy"><input type="text" name="nazev' + num + '" /></td><td class="slevy"><input type="text" name="hodnota' + num + '" /></td><td class="delete"><input type="button" class="buttonClose" onclick=\'removeDPHInput("'+trIdName+'")\';></td>';
  ni.appendChild(newtr);
}
function removeDPHInput(trNum) 
{
  var d = document.getElementById('DPHs');
  var oldtr = document.getElementById(trNum);
  d.removeChild(oldtr);
}

 
function deleteQuestion(question,delUrl,otazka) 
{
    if(otazka != '0') pom = " Operace už se nedá vrátit !";  else pom="";
    var de = confirm(question + pom); 
    if (de) location=delUrl;
}

function stav (text,kam)
{
    document.getElementById(kam).innerHTML=text-1;    
}

function progress_bar (text,kam)
{
    document.getElementById(kam).innerHTML='<div style="border:1px solid black;font-size:20px;padding:10px 15px 5px 10px;height:30px;background-color:#FFFFFF;"><img style="float:left;margin:-6px 20px 0 0;" src="/admin/images/loading.gif" />' + text + '</div>';    
}

function vymaz(kde)
{
	document.getElementById(kde).innerHTML="";
}

function hide(id)
{
    $(document).ready(function() { $(id).hide(); });
}
function uav(co,kam,load,text,typ,pom)
{ 
  if (typ=="whisper")
  {
    document.getElementById(load).innerHTML='<img src="/admin/images/loadingmin.gif" />';
    $(document).ready(function() { $('#'+kam).hide(); $('#'+kam).fadeIn(400); });
  }  
  else document.getElementById(load).innerHTML='<div style="border:1px solid black;font-size:20px;padding:10px 15px 5px 10px;height:30px;background-color:#FFFFFF;"><img style="float:left;margin:-6px 20px 0 0;" src="/admin/images/loading.gif" />' + text + '</div>';
  
  var url=co;
  if (window.ActiveXObject)
  {
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else
  {
    httpRequest = new XMLHttpRequest();
  }
  httpRequest.open("GET", url, true);
  if(kam!="")
    httpRequest.onreadystatechange = function () {processsRequest(kam,load);};
  httpRequest.send(null);
}

function processsRequest(kam,load)
{
  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {
      var mistoZobrazeni = document.getElementById(kam);
      mistoZobrazeni.innerHTML = httpRequest.responseText;
      document.getElementById(load).innerHTML='';
    }
    else
    {
      alert("Chyba při načítání stránky, opakujte akci..."+ httpRequest.status +":"+ httpRequest.statusText);
      document.getElementById(load).innerHTML='';
    }
  }
}
tinyMCE.init({language: "cs", mode : "exact",elements : "tmSimple",theme : "simple"});
tinyMCE.init({language: "cs", mode : "exact",elements : "tmSimple1",theme : "simple"}); 
tinyMCE.init({language: "cs", mode : "exact",elements : "tmSimple2",theme : "simple"}); 
tinyMCE.init({language: "cs", mode : "exact",elements : "tmSimple3",theme : "simple"}); 
tinyMCE.init({language: "cs", mode : "exact",elements : "tmSimple4",theme : "simple"}); 
tinyMCE.init({
        // General options
        mode : "exact",
        elements : "tm1",
        language: "cs",
        theme : "advanced",
        plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",

        // Theme options
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,

        // Example content CSS (should be your site CSS)
        content_css : "css/content.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url : "lists/template_list.js",
        external_link_list_url : "lists/link_list.js",
        external_image_list_url : "lists/image_list.js",
        media_external_list_url : "lists/media_list.js",

        // Replace values for the template plugin
        template_replace_values : {
            username : "Some User",
            staffid : "991234"
        }
    });
tinyMCE.init({
        // General options
        mode : "exact",
        elements : "tm2",
        language: "cs",
        theme : "advanced",
        plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",

        // Theme options
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,

        // Example content CSS (should be your site CSS)
        content_css : "css/content.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url : "lists/template_list.js",
        external_link_list_url : "lists/link_list.js",
        external_image_list_url : "lists/image_list.js",
        media_external_list_url : "lists/media_list.js",

        // Replace values for the template plugin
        template_replace_values : {
            username : "Some User",
            staffid : "991234"
        }
    });
