var poziceMenu = 'right';

function prehoditMenu(){
  if(poziceMenu == 'right'){
    document.getElementById('leve-menu').className = "zmenaDoleva";
    document.getElementById('obsah').className = "zmenaDoprava";
    poziceMenu = 'left';
    return '';
  }
  
  if(poziceMenu == 'left'){
    document.getElementById('leve-menu').className = "zmenaDoprava";
    document.getElementById('obsah').className = "zmenaDoleva";
    poziceMenu = 'right';
  }
}

var poziceCitat = 1;

function prehoditCitaty(){
  if(poziceCitat == 1){
    document.getElementById('js-citat-1').style.display = "none";
    document.getElementById('js-citat-2').style.display = "block";
    poziceCitat = 2;
    return '';
  }
  if(poziceCitat == 2){
    document.getElementById('js-citat-1').style.display = "block";
    document.getElementById('js-citat-2').style.display = "none";
    poziceCitat = 1;
  }
}



/* PUVODNI JAA SCRIPT Z VERZE 1 */

function toolbar_box(akce){
  //akce: 0 = skryj, 1 = zobraz
  if(akce == 1){
    document.getElementById('hlavicka-toolbar-box').style.display = "block"; 
  }
  else{
    document.getElementById('hlavicka-toolbar-box').style.display = "none";
  }
}


//var loading = '<div class="jsloading"> Čekejte prosím...</div>';

function toolbar_login(){
  toolbar_box(1);
  return false;

}



kalendarNejvyssiId = 4;
function kalendarDalsiInput(){
  if(kalendarNejvyssiId == 11)
    alert('Více políček již nelze přidat, stiskněte tlačítko PŘIDAT DATUMY (poté můžete přidat další datumy)');
  else{
    document.getElementById('kal_obal_'+kalendarNejvyssiId).style.display = 'block';
    kalendarNejvyssiId = kalendarNejvyssiId + 1;
  }
}


function fotka_div_zmensit(){
  if(document.getElementById('fotka_div').style.position != "static"){
    document.getElementById('fotka_div').style.position = "static";
    document.getElementById('fotka_div').style.width = "100%";
    document.getElementById('fotka_div').style.height = "100%";
    document.getElementById('fotka_div').style.margin = "0";
    
    document.getElementById('fotka_div_in').style.width = "100%";
    document.getElementById('fotka_div_in').style.margin = "0";
    document.getElementById('fotka_div_in').style.height = "100%";
    document.getElementById('fotka_div_in').style.textAlign = "left";
    
    document.getElementById('velka_fotka').style.width = "600px";
    
    document.getElementById('levy_kalendar_roky').style.visibility = "visible";
    document.getElementById('levy_kalendar_mesice').style.visibility = "visible";
    document.getElementById('fotka_navigace').style.textAlign = "left";
  }
  else{
    document.getElementById('fotka_div').style.position = "absolute";
    document.getElementById('fotka_div').style.width = "1000px";
    document.getElementById('fotka_div').style.height = "1000px";
    document.getElementById('fotka_div').style.marginLeft = "-500px";
    
    document.getElementById('fotka_div_in').style.width = "950px";
    document.getElementById('fotka_div_in').style.margin = "0 auto";
    document.getElementById('fotka_div_in').style.marginTop = "50px";
    document.getElementById('fotka_div_in').style.height = "100%";
    document.getElementById('fotka_div_in').style.textAlign = "center";
    
    document.getElementById('velka_fotka').style.width = "auto";
    
    document.getElementById('levy_kalendar_roky').style.visibility = "hidden";
    document.getElementById('levy_kalendar_mesice').style.visibility = "hidden";
    document.getElementById('fotka_navigace').style.textAlign = "center";
    
  }

}

function akce_obarvit(akce){
  if(akce == 1){
    document.getElementById('menu-planovane-akce').style.fontWeight = "bold";
    document.getElementById('menu-uplynule-akce').style.fontWeight = "bold";
    document.getElementById('menu-kalendar-akci').style.fontWeight = "bold";
    document.getElementById('menu-mapa-akci').style.fontWeight = "bold";
  }
  else{
    document.getElementById('menu-planovane-akce').style.fontWeight = "normal";
    document.getElementById('menu-uplynule-akce').style.fontWeight = "normal";
    document.getElementById('menu-kalendar-akci').style.fontWeight = "normal";
    document.getElementById('menu-mapa-akci').style.fontWeight = "normal";
  }

}

LOGO = "velky";

function zmenlogo(){
  if(LOGO == "velky")
    LOGO = "maly";
  else
    LOGO = "velky";
  document.getElementById('odkaz_logo').innerHTML = '<img src="/styly/savici-'+LOGO+'-panacci.gif" alt="logo" />';
  
  return false;
}


function vloz_do_formu(text, misto) {
  text = ' '+text+' ';
  if(misto == undefined)
    misto = 'js_vkladani';
  kam = document.getElementById(misto);
  kam.value += text;
  kam.focus();
}

function vloz_odkaz(misto) { 
  var adresa = window.prompt('Napiš adresu odkazu','http://'); 
  var nazev = window.prompt('Napiš text odkazu', ''); 
  vloz_do_formu('"'+nazev+'":'+adresa, misto);  
}



function vloz_obrazek(misto) { 
  var adresa = window.prompt('Napiš adresu obrázku','http://'); 
  vloz_do_formu('[* '+adresa+' *]', misto);  
}

function vytvorit_akce(typ) { 
  if(typ == 0){
    document.getElementById('akce_nazev').value = "";
    document.getElementById('form_datum_akce').style.visibility = "hidden";
  }
  if(typ == 1){
    document.getElementById('akce_nazev').value = "Spolčo";
    document.getElementById('form_datum_akce').style.visibility = "visible";
  }
    
}

function akce_ucast(typ) { 
  document.getElementById('akce_ucast_nastaveni').style.display = "block";
  document.getElementById('akce_ucast_nastaveni_odkaz').style.visibility = "hidden";
}


/* AJAX AJAX AJAX AJAX AJAX AJAX AJAX  */

var loading = '<img src="/styly/loading.gif" /> ';
var loading2 = '<img src="/styly/loading_2.gif" /> ';

/* Funkce pro zobrazeni akci na den */
function ajax_kalendar_den(den) {
  var http_request = false;
  var request1 = "ajaxakce=kalendar-den";
  var request2 = "den="+den;


  if (window.XMLHttpRequest)
    http_request = new XMLHttpRequest();
  else
    if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (eror) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
    } 
  http_request.onreadystatechange = function() { zpracuj_ajax_kalendar_den(http_request); };
  http_request.open('POST', '/ajax.php', true);
  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http_request.send(request1+"&"+request2);
  return false;
}
   
function zpracuj_ajax_kalendar_den(http_request) {
  document.getElementById('ajax-kalendar-den-menu').innerHTML = "<p> "+loading2+" Načítání akcí</p>";
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      document.getElementById('ajax-kalendar-den-menu').innerHTML = http_request.responseText;
    } 
    else 
      document.getElementById('ajax-kalendar-den-menu').innerHTML = "<p>Kalendář se nepodařilo načíst. Zkuste to znovu :-)</p>";
  }
}


/* Funkce pro zobrazeni kalendare v menu */


function ajax_kalendar_menu(den) {
  var http_request = false;
  var request1 = "ajaxakce=kalendar-menu";
  var request2 = "den="+den;


  if (window.XMLHttpRequest)
    http_request = new XMLHttpRequest();
  else
    if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (eror) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
    } 
  http_request.onreadystatechange = function() { zpracuj_ajax_kalendar_menu(http_request); };
  http_request.open('POST', '/ajax.php', true);
  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http_request.send(request1+"&"+request2);
  return false;
}
   
function zpracuj_ajax_kalendar_menu(http_request) {
  document.getElementById('ajax-kalendar-menu').innerHTML = "<p>"+loading+"Čekejte prosím</p>";
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      document.getElementById('ajax-kalendar-menu').innerHTML = http_request.responseText;
    } 
    else 
      document.getElementById('ajax-kalendar-menu').innerHTML = "<p>Kalendář se nepodařilo načíst. Zkuste to znovu :-)</p>";
  }
}


function ajax_kalendar_den_hlavni_stranka(id, akce){
  var pole = id.split(",");
  for(i=0; i<pole.length; i++){
    if(akce == 1){
      document.getElementById('kalendar-hlavni-stranka-id-akce-'+pole[i]).style.fontWeight = "bold";
      document.getElementById('kalendar-hlavni-stranka-id-akce-'+pole[i]).style.color = "#555555";
    }
    if(akce == 0){
      document.getElementById('kalendar-hlavni-stranka-id-akce-'+pole[i]).style.fontWeight = "normal";
      document.getElementById('kalendar-hlavni-stranka-id-akce-'+pole[i]).style.color = "#E45A49";
    }
  }
  return false;

}

function ajax_kalendar_den_hlavni_stranka_naKalendari(den, akce){
  var pole = den.split(",");
  for(i=0; i<pole.length; i++){
    if(akce == 1){
      document.getElementById('kalendar-hlavni-stranka-den-'+pole[i]).style.backgroundColor = "#8FB596";
    }
    if(akce == 0){
      document.getElementById('kalendar-hlavni-stranka-den-'+pole[i]).style.backgroundColor = "#eeeeee";
    }
  }
  return false;

}


/* Funkce pro zobrazeni kalendare na hlavni strance */


function ajax_kalendar_hlavnistranka(den) {
  var http_request = false;
  var request1 = "ajaxakce=kalendar-hlavnistranka";
  var request2 = "den="+den;


  if (window.XMLHttpRequest)
    http_request = new XMLHttpRequest();
  else
    if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (eror) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
    } 
  http_request.onreadystatechange = function() { zpracuj_ajax_kalendar_hlavnistranka(http_request); };
  http_request.open('POST', '/ajax.php', true);
  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http_request.send(request1+"&"+request2);
  return false;
}
   
function zpracuj_ajax_kalendar_hlavnistranka(http_request) {
  document.getElementById('kalendar-akce-hlavni-stranka-loading').innerHTML = "<p>"+loading2+"Probíhá načítání kalendáře</p>";
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      document.getElementById('kalendar-hlavnistranka-box').innerHTML = http_request.responseText;
    } 
    else 
      document.getElementById('kalendar-akce-hlavni-stranka-loading').innerHTML = "<p>Kalendář se nepodařilo načíst. Zkuste to znovu :-)</p>";
  }
}

/* Fotogalerie - Fotka */

/* Funkce pro zobrazeni akci na den */
function ajax_fotka(id, akce) {
  self.location.hash = id;
  var http_request = false;
  var request1 = "ajaxakce=fotogalerie-fotka";
  var request2 = "fotka="+id;
  var request3 = "akce="+akce;
  if(akce == 'popisek')
    var request4 = "popisek="+document.getElementById('js-fotka-popisek').value;

  if (window.XMLHttpRequest)
    http_request = new XMLHttpRequest();
  else
    if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (eror) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
    } 
  http_request.onreadystatechange = function() { zpracuj_ajax_fotka(http_request); };
  http_request.open('POST', '/ajax.php', true);
  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http_request.send(request1+"&"+request2+"&"+request3+"&"+request4);
  return false;
}
   
function zpracuj_ajax_fotka(http_request) {
  document.getElementById('fotka-popisek').innerHTML = loading+"Čekejte prosím";
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      document.getElementById('fotka_div_in').innerHTML = http_request.responseText;
    } 
    else 
      alert('Fotku se nepodařilo načíst. Zkus to znovu ;-)');
  }
}



function stinitko_text(text) {
  document.getElementById('stinitko').style.display = "block";
  document.getElementById('stinitko-in').innerHTML = text;
}


function stinitko() {
  document.getElementById('stinitko').style.display = "block";
}

function stinitko_zavrit() {
  document.getElementById('stinitko').style.display = "none";
}





