  var objekt="";
  var ang="";
  var dir="";
  var mess="";
  var zobraz="";
  var obraz=",,";
  var sezurl=',,';
  
  function zmenStatus(id,idkat) {
    //alert(id);
    //oEvent = event;
    objekt=id;
    var http_request = false;
    var request = '&t_idzaz='+id+'&c_idkat='+idkat;

    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
          http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (error) {
          http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }

    http_request.onreadystatechange = function() { zpracuj(http_request); };
    http_request.open('GET', 'index.php?poi=zazna1&akce=zmenstatus'+request, true);
    http_request.send(null);

  }
  function zmenUhly(angle,direction,message,idkat) {
    //alert(id);
    //oEvent = event;
    ang = angle;
    dir = direction;
    mess = message;
    document.getElementById(mess).innerHTML ='';
    var http_request = false;
    var request = '&t_idzaz='+angle+'&c_idkat='+idkat+'&c_angle='+document.getElementById(ang).value+'&c_direction='+document.getElementById(dir).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() { zpracuj2(http_request); };
    http_request.open('GET', 'index.php?poi=zazna1&akce=nastavuhly'+request, true);
    http_request.send(null);

  }
  function zpracuj(http_request) {
      if (http_request.readyState == 4) {
          if (http_request.status == 200) {
            var odpoved = http_request.responseText;
            //alert (odpoved);
            if (odpoved==1) {
              document.getElementById(objekt).checked = 'checked';
            }
            else  {
              document.getElementById(objekt).checked = '';
            }
          } else {
              alert('Chyba');
          }
      }
  }
  
  function zpracuj2(http_request) {
      if (http_request.readyState == 4) {
          if (http_request.status == 200) {
            var odpoved = http_request.responseText;
            //alert (odpoved);
            document.getElementById(mess).innerHTML = "&nbsp; "+odpoved;
            
          } else {
              alert('Chyba');
          }
      }
  }
  
  function showTip(even, pole, text)  {
    if (pole=="nazev")  doTooltip(even,'[b]<?php echo SP_nazev_bodu; ?>:[/b] '+text,'','','',250);
    else if (pole=="adresa")  doTooltip(even,'[b]<?php echo SP_adresa; ?>:[/b] '+text,'','','',150);
    else if (pole=="mesto")  doTooltip(even,'[b]<?php echo SP_mesto; ?>:[/b] '+text,'','','',150);
    else if (pole=="psc")  doTooltip(even,'[b]<?php echo SP_psc; ?>:[/b] '+text,'','','',150);
    else if (pole=="tel")  doTooltip(even,'[b]<?php echo SP_telefon; ?>:[/b] [br][font color="red"]'+
    '<?php echo SP_vlozte_devitimistne; ?>: [b]+420[/b][/font][br][br]'+text,'','','',240);
    else if (pole=="popis")  doTooltip(even,'[b]<?php echo SP_popis_bodu; ?>:[/b] '+text,'','','',250);
    else if (pole=="nazev_tt")  doTooltip(even,'[b]<?php echo SP_nazevTT; ?>:[/b][br][font color="red"]'+
    '<?php echo SP_nevyplniteli_pole; ?>[/font][br][br]'+text,'','','',250);
    else if (pole=="web")  doTooltip(even,'[b]WWW:[/b] '+text,'','','',150);
    else if (pole=="nenalezeno")  doTooltip(even,'Doplní text "nenalezeno" do pole web.','','','',150);
    else if (pole=="nenalezeno2")  doTooltip(even,'Doplní text "nenalezeno" do pole TEL.','','','',150);
  }

var prom1 = 0;
function zobrdiv(idzaz,obrazek,url)  {
  if (obraz.indexOf(','+idzaz+':1')>0) {
    obrazek = 1;
  }
  else if (obraz.indexOf(','+idzaz+':0')>0) {
    obrazek = 0;
  }
  var poma = sezurl.indexOf(','+idzaz+':');
  if (poma>0) {
    var pomurl = sezurl.substr(poma+1);
    poma = pomurl.indexOf(':');
    url = pomurl.substr(poma+1, pomurl.indexOf(',')-poma-1);
  }
  
  if (obrazek==1) {
    var newtext = '<dl><input type="text" style="width: 300px;" id="url'+idzaz+'" name="url'+idzaz+'" class="inputbox" value="'+(url==""?"http://":url)+'" /><a href="#" onclick="nastavurl('+idzaz+', \'nastav\')"> nastav www</a> &nbsp;'+
    ' | <a href="#" onclick="nastavurl('+idzaz+', \'vymaz\')">vymaž www</a> &nbsp;<span id="url2'+idzaz+'"></span><br />'+
    '<br /><img src="<?php echo $cestapoi; ?>itemimage/'+idzaz+'.png?time='+Math.random()*1000+'" /> &nbsp; <input type="button" style="margin-top: -175px;" class="button2" name="B1" '+
    'value="Odstranit obrázek\nze systému" onclick="odstranim('+idzaz+');" /></dl>';
    if (zobraz!='') {
      document.getElementById("photo"+zobraz).innerHTML = "";
      document.getElementById("photo"+zobraz).style.display = "none";
    }
    zobraz = idzaz;
    document.getElementById("photo"+idzaz).innerHTML = newtext;
    document.getElementById("photo"+idzaz).style.display = "";
    
  }
  else  {
    var newtext = '<dl><input type="text" style="width: 300px;" id="url'+idzaz+'" name="url'+idzaz+'" class="inputbox" value="'+(url==""?"http://":url)+'" /><a href="#" onclick="nastavurl('+idzaz+', \'nastav\')"> nastav www</a> &nbsp;'+
    ' | <a href="#" onclick="nastavurl('+idzaz+', \'vymaz\')">vymaž www</a> &nbsp;<span id="url2'+idzaz+'"></span><br />'+
    '<form action="index.php?poi=zazna1&amp;c_uploadim='+idzaz+'" method="post" enctype="multipart/form-data" id="form-demo">'+
      '<fieldset id="demo-fallback">'+
            '<label for="demo-photoupload">'+
                'Zvolte soubor s fotkou pro nahrání na server: <input type="file" name="photoupload" id="demo-photoupload" />'+
            '</label>'+
        '</fieldset>'+
        '<div id="demo-status" class="hide">'+
                '<a href="#" id="link-1"></a><a href="#" id="link-2">Procházet fotky na disku...</a><a href="#" id="link-3"></a> |'+
                '<a href="#" id="link-4" style="margin-right: 25px;">Nahrát</a>'+
            '<span style="display: none;">'+
                '<strong class="overall-title">Overall progress </strong>'+
                '<img src="newpoi1/myjs/bar.gif" class="progress overall-progress" />'+
            '</span>'+
            '<span>'+
                '<strong class="current-title">Postup nahrávání fotky </strong>'+
                '<img src="newpoi1/myjs/bar.gif" class="progress current-progress" style="margin-left: 10px; margin-right: 10px;" />'+
            '</span>'+
            '<span class="current-text"> &nbsp; &nbsp; Pro úspěšný upload je nutný Flash Player 9 - <a target="_new" href="http://www.adobe.com/products/flashplayer/">odkaz</a>.</span>'+
        '</div>'+
        '<ul id="demo-list"></ul>'+
    '</form>'+
    '</dl>';
    if (zobraz!='') {
      document.getElementById("photo"+zobraz).innerHTML = "";
      document.getElementById("photo"+zobraz).style.display = "none";
    }
    zobraz = idzaz;
    document.getElementById("photo"+idzaz).innerHTML = newtext;
    document.getElementById("photo"+idzaz).style.display = "";
    zamen();
  }
}

function nastavurl (idzaz3, priz) {
  var http_request = false;
  var url2 = document.getElementById("url"+idzaz3).value; 
  var request = '&t_url=' + url2;
  if (priz=='vymaz')  {
    request = '';
    url2 = '';
  }
  if (window.XMLHttpRequest) {
      http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (error) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
  }

  http_request.onreadystatechange = function() { zpracujurl(http_request, idzaz3, priz, url2); };
  http_request.open('GET', 'index.php?poi=zazna1&c_'+priz+'url='+idzaz3+request, true);
  http_request.send(null);

}

function zpracujurl(http_request, ident, priz, url2) {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          var odpoved = http_request.responseText;
          //alert (odpoved);
          document.getElementById("url2"+ident).innerHTML = odpoved;
          //if (priz=="vymaz")  {
            document.getElementById("url"+ident).value = (url2==""?"http://":url2);
            if (sezurl.indexOf(','+ident+':')>0) {
              var reg = new RegExp(','+ident+':\\S*?,');
              sezurl = sezurl.replace(reg, ','+ident+':'+url2+',');
            }
            else  {
              sezurl += ident+':'+url2+',';
            }
          /*}
          else  {
            document.getElementById("url"+ident).value = url2;
            if (sezurl.indexOf(','+odpoved+':')>0) {
            var reg = new RegExp(','+ident+':+,');
              sezurl = sezurl.replace(reg, ','+ident+':'+url2+',');
            }
            else  {
              sezurl += ident+':,';
            }
          }*/
        } else {
            alert('Chyba');
        }
    }
}

function odstranim (idzaz2) {
  var http_request = false;
  var request = '&t_del=true';

  if (window.XMLHttpRequest) {
      http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (error) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
  }

  http_request.onreadystatechange = function() { zpracujods(http_request); };
  http_request.open('GET', 'index.php?poi=zazna1&c_uploadim='+idzaz2+request, true);
  http_request.send(null);

}

function zpracujods(http_request) {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          var odpoved = http_request.responseText;
          //alert (odpoved);
          document.getElementById("photo"+odpoved).innerHTML = "";
          document.getElementById("photo"+odpoved).style.display = "none";
          if (obraz.indexOf(','+odpoved+':')>0) {
            var reg = new RegExp(','+odpoved+':.,');
            obraz = obraz.replace(reg, ','+odpoved+':0,');
          }
          else  {
            obraz += odpoved+':0,';
          }
        } else {
            alert('Chyba');
        }
    }
}
  
function zamen() {

	var swiffy = new FancyUpload2($('demo-status'), $('demo-list'), {
		'url': $('form-demo').action,
		'fieldName': 'photoupload',
		'path': '<?php echo $cestaphp; ?>myjs/Swiff.Uploader.swf',
		'onLoad': function() {
			$('demo-status').removeClass('hide');
			$('demo-fallback').destroy();
		}
	});

	/**
	 * Various interactions
	 */

	/*$('link-1').addEvent('click', function() {
		swiffy.browse();
		return false;
	});*/

	$('link-2').addEvent('mousedown', function() {
		swiffy.removeFile();
		return false;
	});

	$('link-2').addEvent('click', function() {
		swiffy.browse({'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png'});
		return false;
	});
	
  /*$('link-3').addEvent('click', function() {
		swiffy.removeFile();
		return false;
	});*/

	$('link-4').addEvent('click', function() {
		swiffy.upload();
		return false;
	});

};
		/* ]]> */

function zobrcerpacky(idzaz)  {
  var request = '&c_idzaz='+idzaz;
  
  if (window.XMLHttpRequest) {
      http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (error) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
  }

  http_request.onreadystatechange = function() { zpracujcerpacky(http_request); };
  http_request.open('GET', 'index.php?poi=zazna1&t_cerp=true'+request, true);
  http_request.send(null);

}

function zpracujcerpacky(http_request) {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          var odpoved = http_request.responseText;
          //alert (odpoved);
          var paramupd=0;
          if (odpoved.substring(0, 10)=='false_data')  {
            paramupd=1;
            var pol2 = odpoved.split(";");
            odpoved = pol2[1]+';'+pol2[1]+';;;;;;;;;;;;;;;;;;;;;;;';
          }
          var pol = odpoved.split(";");
          var newtext = '<dl>'+
'<table border="1">'+
'<tr>'+
  '<td>Natural 95:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c2" value="'+pol[2]+'" /></td>'+
  '<td>mycka1:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c12" value="'+pol[12]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>Natural 98:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c3" value="'+pol[3]+'" /></td>'+
  '<td>mycka2:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c13" value="'+pol[13]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>Special:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c4" value="'+pol[4]+'" /></td>'+
  '<td>mycka3:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c14" value="'+pol[14]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>Diesel:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c5" value="'+pol[5]+'" /></td>'+
  '<td>mycka4:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c15" value="'+pol[15]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>LPG:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c6" value="'+pol[6]+'" /></td>'+
  '<td>mycka5:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c16" value="'+pol[16]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>CNG:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c7" value="'+pol[7]+'" /></td>'+
  '<td>WC:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c17" value="'+pol[17]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>druh7:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c8" value="'+pol[8]+'" /></td>'+
  '<td>Sprcha:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c18" value="'+pol[18]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>druh8:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c9" value="'+pol[9]+'" /></td>'+
  '<td>Bankomat:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c19" value="'+pol[19]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>druh9:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c10" value="'+pol[10]+'" /></td>'+
  '<td>Restaurace:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c20" value="'+pol[20]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>druh10:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c11" value="'+pol[11]+'" /></td>'+
  '<td>Parkoviště:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c21" value="'+pol[21]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>Ubytování:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c22" value="'+pol[22]+'" /></td>'+
  '<td>Popis:</td>'+
  '<td><input type="text" id="pol'+pol[0]+'c23" value="'+pol[23]+'" /></td>'+
'</tr>'+
'<tr>'+
  '<td>Datum aktualizace:</td>'+
  '<td>'+pol[24]+'</td>'+
  '<td colspan="2"><span style="cursor: pointer; float: right;" onclick="schovejcerpacky('+pol[1]+')">x</span>'+
  '<span style="cursor: pointer;" onclick="nastavcerpacky('+pol[0]+','+paramupd+','+pol[1]+')">Uložit nastavení </span></td>'+
'</tr>'+
'</table>'+
          '</dl>';
          /*if (zobraz!='') {
            document.getElementById("photo"+zobraz).innerHTML = "";
            document.getElementById("photo"+zobraz).style.display = "none";
          }
          zobraz = idzaz;*/
          //alert ("photo"+pol[1]+" "+odpoved.substring(1, 10));
          document.getElementById("photo"+pol[1]).innerHTML = newtext;
          document.getElementById("photo"+pol[1]).style.display = "";

        } else {
            alert('Chyba');
        }
    }
}	

function nastavcerpacky (idpol,param,idzaz) {
  var http_request = false;
  var veta = idpol+';'+param+';';
  for (x=2; x<24; x++)  {
    veta = veta+document.getElementById("pol"+idpol+"c"+x).value+';';
  }
  var request = '&t_veta='+veta;

  if (window.XMLHttpRequest) {
      http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (error) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
  }
  //alert(request);
  http_request.onreadystatechange = function() { zpracujnastcerpacky(http_request,idzaz); };
  http_request.open('GET', 'index.php?poi=zazna1&t_cerp=set'+request, true);
  http_request.send(null);

}

function zpracujnastcerpacky(http_request,idzaz) {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          var odpoved = http_request.responseText;
          //alert (odpoved);
          if (odpoved=='OK')  {
            document.getElementById("photo"+idzaz).innerHTML = "";
            document.getElementById("photo"+idzaz).style.display = "none";
          }
        } else {
            alert('Chyba');
        }
    }
}
function schovejcerpacky(idzaz) {
  document.getElementById("photo"+idzaz).innerHTML = "";
  document.getElementById("photo"+idzaz).style.display = "none";
}

function entity (poma)  {
  var pomb = poma.replace('+', '~plus;');
  pomb = pomb.replace('&', '~amp;');
  return pomb;
}

function zmenitajaxpen(idzaz)  {
  prom1 = 1;
  zmenitajax(idzaz);
  prom1 = 0;
}
                          
function zmenitajax(idzaz)  {
  document.getElementById("li" + idzaz).style.backgroundImage = 'url(/newpoi1/imageset/pozwork.gif)';
  var http_request = false;
  
  if (window.XMLHttpRequest) {
      http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (error) {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
  }
  var t_web = document.getElementById("web" + idzaz).value;
  var re = new RegExp("&"); 
  t_web = t_web.replace(re, "~");
  //alert (encodeURI(document.getElementById("web" + idzaz).value));
  var parameters = 't_nazev=' + encodeURI(entity(document.getElementById("nazev" + idzaz).value)) + 
  '&t_adresa=' + encodeURI(document.getElementById("adresa" + idzaz).value) +
  '&t_mesto=' + encodeURI(document.getElementById("mesto" + idzaz).value) +
  '&t_adresa=' + encodeURI(document.getElementById("adresa" + idzaz).value) +
  '&t_psc=' + encodeURI(document.getElementById("psc" + idzaz).value) +
  '&t_tel=' + encodeURI(document.getElementById("tel" + idzaz).value) +
  '&t_popis=' + encodeURI(document.getElementById("popis" + idzaz).value) +
  '&t_adresa=' + encodeURI(document.getElementById("adresa" + idzaz).value) +
  '&t_nazev_poi=' + encodeURI(document.getElementById("nazev_poi" + idzaz).value) +
  '&t_lat=' + encodeURI(document.getElementById("lat" + idzaz).value) +
  '&t_lon=' + encodeURI(document.getElementById("lon" + idzaz).value) +
  '&t_stat=' + encodeURI(document.getElementById("stat" + idzaz).value) +
  '&t_web=' + encodeURI(t_web) +
  '&c_idzaz=' + idzaz + '&ajax=true&z5=true';
  if (prom1 == 1) parameters += '&c_plustopenny=1';
  
  var nazev_poi = document.getElementById("nazev_poi" + idzaz).value;
  if (nazev_poi.trim() == '') {
    nazev_poi = document.getElementById("nazev" + idzaz).value + 
    (document.getElementById("mesto" + idzaz).value.trim()==''?'':', ' + document.getElementById("mesto" + idzaz).value) +
    (document.getElementById("adresa" + idzaz).value.trim()==''?'':', ' + document.getElementById("adresa" + idzaz).value) +
    (document.getElementById("popis" + idzaz).value.trim()==''?'':', ' + document.getElementById("popis" + idzaz).value);
    
    tel = document.getElementById("tel" + idzaz).value.replace(' ', '').trim();
    if (tel.substr(0, 2)=='00') tel = '+' + tel.substr(2);
    if (tel.length==9)  tel = '+420' + tel;
    tel = tel.replace('+', '>');
    
    nazev_poi = nazev_poi.substr(0, 127-tel.length) + tel;
    document.getElementById("nazev_poi" + idzaz).value = nazev_poi;
    //nazev_poi = $predpona.substr($t_nazev_poi,0,$maxpocetznaku-strlen($tel)-strlen($predpona)).$tel;
          
  }
  //alert(parameters);
  http_request.onreadystatechange = function() { zpracujzmenitajax(http_request,idzaz); };
  http_request.open('POST', 'index.php?poi=zazna1&upravzaz=true', true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);

}

function zpracujzmenitajax(http_request,idzaz) {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          var odpoved = http_request.responseText;
          //alert (odpoved);
          if (odpoved.substr(0, 2)=='OK')  {
            document.getElementById("li" + idzaz).style.backgroundImage = 'none';
            document.getElementById("upra" + idzaz).innerHTML = 'Upraveno: ' + odpoved.substr(2);
            document.getElementById("upra" + idzaz).style.color = '#FF0000';
            /*document.getElementById("photo"+idzaz).innerHTML = "";
            document.getElementById("photo"+idzaz).style.display = "none";*/
          }
        } else {
            alert('Chyba');
        }
    }
}
String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "")
};

