
/** 
 * schovávač políčok - šup 
 */
function showHide(elementid, hideClass, type) {

  if (type !== undefined && type == 'click') {
    showHide_click(elementid, hideClass);

  } else {
    showHide_slide(elementid, hideClass);

  }
}
  
function showHide_click(elementid, hideClass) {

  // skryje vsetky objekty ktore maju triedu class="[hideClass]"
  if (hideClass != undefined && hideClass != "") {
    $("."+hideClass).slideUp("fast");
  }

  // otvori/zatvori konkretny prvok id="[elementid]"
  if ($("#"+elementid).is(":hidden")) {
    $("#"+elementid).slideDown("fast");
  } else {
    $("#"+elementid).slideUp("fast");
  }
};

function showHide_click2(elementid, hideClass) {
if (document.getElementById(elementid).style.display == 'none'){
  // skryje vsetky objekty ktore maju triedu class="[hideClass]"
  if (hideClass != undefined && hideClass != "") {
    $("."+hideClass).slideUp("fast");
  }

  // otvori/zatvori konkretny prvok id="[elementid]"
  if ($("#"+elementid).is(":hidden")) {
    $("#"+elementid).slideDown("fast");
  } else {
    $("#"+elementid).slideUp("fast");
  }
}
};

function showHide_slide(elementid, hideClass) {

  // skryje vsetky objekty ktore maju triedu class="[hideClass]"
  if (hideClass != undefined && hideClass != "") {
    $("."+hideClass).slideUp("fast");
  }

  // otvori/zatvori konkretny prvok id="[elementid]"
  if ($("#"+elementid).is(":hidden")) {
    $("#"+elementid).slideDown("fast");
  } else {
    $("#"+elementid).slideUp("fast");
  }
};

/** 
 * schovávač políčok - blik 
 */
function showHide2(elementid){
  if (document.getElementById(elementid).style.display == 'none'){
    document.getElementById(elementid).style.display = '';
  } else {
    document.getElementById(elementid).style.display = 'none';
  }
};

/** 
 * zmena class-y pre HNTV 
 */
function shine(elementid) {
  document.getElementById("tv01").setAttribute("className", "");
  document.getElementById("tv02").setAttribute("className", "");
  document.getElementById("tv03").setAttribute("className", "");
  document.getElementById("tv04").setAttribute("className", "");
  document.getElementById("tv05").setAttribute("className", "");
  document.getElementById("tv06").setAttribute("className", "");
  document.getElementById("tv07").setAttribute("className", "");
  document.getElementById("tv08").setAttribute("className", "");
  document.getElementById(elementid).setAttribute("className", "current");
};

// tieto operacie sa inicializuju az po nacitani stranky
$(document).ready(function() {
  
  /**
   * Nazov podstranky musi byt zabaleny v <div> boxe headline spravy.
   * Kedze headline sa vykresluje suborom sablony, v ktorom nemozno menit dynamicky popisky, ako nazvy a podobne.
   * robime tak prostrednictvom JS.
   * 
   */            
  if ($("#top-udalost").length > 0) {
    var content = $("#top-udalost .lajnapodstr").html();
    var imgW = $("#top-udalost .image img").width() + 20; 
    $("#top-udalost .lajnapodstr").remove();
    $("#top-udalost #headline-tema .content").prepend('<div class="lajnapodstr" style="margin-left: '+imgW+'px;">'+content+'</div>');
    $("#top-udalost .content ul").css("padding-left", (imgW + 4) + "px");   
  }
  
  /**
   * Prida triedu .thickbox ku vsetkym odkazom na obrazky.
   * Tym zabezpeci, ze pri kliknuti na odkaz sa inicializuje objekt Thickbox.
   * Obrazok sa zobrazi v inline okne priamo na stranke a uzivatelovi sa neotvori nove okno prehliadaca.
   * 
   */              
  $(".detail-text a[href^='http://img.ihned.cz/']").addClass("thickbox").attr("rel", "gallery-plants");
  
});


/**
 * pokus na AJAX, zobrazovanie formularov na webe
 **/
 
function loadFragmentInToElement(fragment_url, element_id) {   
    var element = document.getElementById(element_id);   
    element.innerHTML = '<iframe src="http://labs.hnonline.sk/finweb_napiste/index.php" width="270" height="206" frameborder="0" scrolling="no">Your browser does not support iframes.</iframe>';   
    xmlhttp.open("GET", fragment_url);   
    xmlhttp.onreadystatechange = function() {   
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {   
            element.innerHTML = xmlhttp.responseText;   
        }   
    }   
     xmlhttp.send(null);   
 } 
 
function loadFragmentInToElement2(fragment_url, element_id) {   
    var element = document.getElementById(element_id);   
    element.innerHTML = '<iframe src="http://labs.hnonline.sk/finweb_napiste/index2.php" width="270" height="206" frameborder="0" scrolling="no">Your browser does not support iframes.</iframe>';   
    xmlhttp.open("GET", fragment_url);   
    xmlhttp.onreadystatechange = function() {   
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {   
            element.innerHTML = xmlhttp.responseText;   
        }   
    }   
     xmlhttp.send(null);   
 } 
