<!--
var LANG = new Array();
var PSID = '';

/* AJAX REGUEST
 * -------------------------------------------------------------------------- */
LANG['ajax_no_url']     = 'AJAX: parametr URL není nastaven!';
LANG['ajax_no_browser'] = 'AJAX: Lituji, ale váš prohlížeč nepodporuje objekt XmlHttpRequest :-(';
LANG['ajax_no_process'] = 'AJAX: Požadavek nelze zpracovat!';
LANG['ajax_no_error']   = 'AJAX: Nastala chyba v přenosu !';

function AJAX_makeRequest(url, param) 
{
  var url, param;
  this.request     = false;

  // když url neexistuje
  if (!url) {
    alert(LANG['ajax_no_url']);
    return false;
  }
  
  // parametry AJAX
  if (param) {
    param = param + '&_ajax=1' + (PSID ? '&' + PSID : '');
  }
  else {
    param = '_ajax=1' + (PSID ? '&' + PSID : '');  
  }  

  if (window.XMLHttpRequest) { // Mozilla, Safari, Opera, Konqueror...
    this.request = new XMLHttpRequest();
    if (this.request.overrideMimeType) {
        this.request.overrideMimeType('text/xml');
    }
  } 
  else if (window.ActiveXObject) { // Internet Explorer
    try {
      this.request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
          this.request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
    }
  }
    
  if (!this.request) {
    alert(LANG['ajax_no_browser']);
    return false;
  }
     
  this.request.open('POST', url, true);
  this.request.setRequestHeader('Content-Type', 
                                'application/x-www-form-urlencoded');
  this.request.send(param);
  
  return true;  
}
/* -------------------------------------------------------------------------- */
 


/* get_disable
 * -------------------------------------------------------------------------- */
function get_disabled(ido, tag, d) {
  var ido, tag, d;
  
  if (ido && tag) {
    var ido_p = ido.getElementsByTagName(tag);
    for(var a=0;a<ido_p.length;a++) {      
      ido_p[a].disabled = d;        
    }
    return true; 
  } 
  return false 
}
/* -------------------------------------------------------------------------- */


/* param_encode
 * -------------------------------------------------------------------------- */
function param_encode(txt)
{
  var txt;
  txt = txt.replace(/\&/g, "%26");
  txt = txt.replace(/\@/g, "%40");
  txt = txt.replace(/\#/g, "%23");
  txt = txt.replace(/\+/g, "%2B");
  txt = txt.replace(/\//g, "%2F");
  txt = txt.replace(/\\/g, "%5C");
  txt = txt.replace(/\'/g, "%27");
  txt = txt.replace(/\"/g, "%22");
  return txt;
}
/* -------------------------------------------------------------------------- */


/* Send_Form
 * -------------------------------------------------------------------------- */
function send_form(ido, fact, fc, f_confirm, msg_loading)
{
  var ido, fact;  
  var ido_tagName;
  var f_confirm, msg_loading;
  var fc;
    
  // id objektu    
  if (ido.tagName.toLowerCase() != 'form') {
    ido = ido.parentNode['form'];
  }  
  
  if (!ido) {    
    return false;
  }
  
  // fact
  if (!fact) {    
    fact = ido.getAttribute('action');
  }
     
  if (fact) {
    // button disabled = true
    get_disabled(ido, 'button', true);
    
    // fconfirm
    if (f_confirm) {
      if (!confirm(f_confirm)) {
        return false;
      }
    }
    
    var param = '';
    
    // parametry
    ido_p = ido;
    for(var a=0;a<ido.length;a++) {
      ido_tag = ido[a].tagName.toLowerCase();
      if (ido_tag == 'input' || ido_tag == 'select' || ido_tag == 'textarea') {
        // jen formulářové prvky
        if (ido[a].type == 'checkbox' || ido[a].type == 'radio') {
          if (ido[a].checked == true) {
            param += ido[a].name + '=' + param_encode(ido[a].value) + '&';
          }            
        }
        else if (ido[a].multiple == true 
              && ido[a].getAttribute('multiple_send') == '1' 
              && ido_tag == 'select') {          
          if (ido[a].options) {
            for(var s=0;s<ido[a].options.length;s++) {              
              param += ido[a].name + '=' 
                               + param_encode(ido[a].options[s].value) + '&';                           
            }
          }            
        }
        else if (ido[a].multiple == true && ido_tag == 'select') {          
          if (ido[a].options) {
            for(var s=0;s<ido[a].options.length;s++) {              
              if (ido[a].options[s].selected == true) {
                param += ido[a].name + '=' 
                                 + param_encode(ido[a].options[s].value) + '&';  
              }             
            }
          }            
        }
        else {
          param += ido[a].name + '=' + param_encode(ido[a].value) + '&';
        } 
      }
    }
    
    var ajax = new AJAX_makeRequest(fact, param);
    
    if (ajax.request) {
      // onLoading
      // onLoading(msg_loading, 'send_form');
                            
      ajax.request.onreadystatechange = function() {
        // onLoading
        // onLoading(ajax.request.readyState, 'send_form');
        
        if (ajax.request.readyState == 4) {
          if (ajax.request.status == 200) {            
            // button disabled = false
            get_disabled(ido, 'button', false);
            eval(ajax.request.responseText);
            if (fc) {
              fc();
            }                                     
          } 
          else {
            alert(LANG['ajax_no_process']);
            // button disabled = false
            get_disabled(ido, 'button', false);
          }         
        }          
      };
    }    
  }
  
  return false;  
};
/* -------------------------------------------------------------------------- */


/* bimg_open
 * -------------------------------------------------------------------------- */
function bimg_open(event, dir) 
{
  // id objektu
  if (!event.target) {    
    event.target = event.srcElement;
  }
  var ido = event.target;
  var dir;
  if (ido && dir) {
    if (ido.tagName.toLowerCase() == 'img') {
      var tag_a = ido.parentNode;
      if (tag_a.tagName.toLowerCase() == 'a') {
        var url = tag_a.href;
        if (url) {
          event.returnValue = false;
          winlocat('bimg.php?url='+url + '&dir='+dir, '_top');
          return false;
        }  
      }
    }
  }
}
/* -------------------------------------------------------------------------- */

/* winlocat 
 * -------------------------------------------------------------------------- */
function winlocat(u, t) 
{
  var u, t;
  
  var obj = parent.frames[t];
  if (obj) {
    obj.location.href = u;  
  }
  else {
    window.open(u, t);
  }
}
/* -------------------------------------------------------------------------- */

/* bimg_set
 * -------------------------------------------------------------------------- */
function bimg_set(url, r) 
{
  var url, r;
  var ido = document.getElementById('bimg_body');
  
  if (url && ido) {
    var image = ido.getElementsByTagName('img');
    if (image) {
      image[0].src          = url;
      image[0].style.height = 'auto';
      image[0].id           = 'bimg['+r+']';
      //bimg_size();
    }
  }
}
/* -------------------------------------------------------------------------- */

/* bimg_set
 * -------------------------------------------------------------------------- */
function bimg_next(r) 
{
  var r;
  var idom = document.getElementById('bimg_menu');
      if (!idom) {
        return;
      }
      idom = idom.getElementsByTagName('img');
      
  var idob = document.getElementById('bimg_body');
      if (!idob) {
        return;
      }
      idob = idob.getElementsByTagName('img');
      if (!idob) {
        return;
      }
      idob = idob[0];
  
  var row = idom.length; var is = '';
  for (var i = 0; i < row; i++) {
    is = 'bimg['+i+']';

    if (is == idob.id) {
      if (r == 'b') {
        i = i-1;
      }
      if (r == 'n') {
        i = i+1;
      }
      if (i < row && i > -1) {
        idom[i].onclick();        
      }
      return;
    }      
  }
}
/* -------------------------------------------------------------------------- */

/* bimg_set
 * -------------------------------------------------------------------------- */
function bimg_size() 
{
  var ido = document.getElementById('bimg_body');
      ido = ido.getElementsByTagName('img');
      ido = ido[0];
      
  if (ido) {
    ido.style.width  = 'auto';
    
    var x = ido.offsetWidth*1;
   
    var ido_d = ido.parentNode;
    var dx    = ido_d.offsetWidth*1;

    if (dx < x) { 
      ido.style.width  = (dx-5) + 'px';
    } 
  }
}
/* -------------------------------------------------------------------------- */  
// -->
