Lofunce0()
ma0=new tmenu16()
zak=zmenu18()
protra=new protrat16();
proprih=new prihlasaf16();
propredmaz=new predmazaf16();
rovnej=new prorovnej16();
navyk=new naklvykl16();
vstupz=new vstupaf16();
logiz=new prologiaf16();
inter=setInterval(tufun, 1000);// odpočet startu
ppodr=new ppodrobaf16();//pro tlačítka od schémat
adresary17();

tmenu16                       zmenu18                   protrat16  

prihlasaf16                 predmazaf16                   prorovnej16

naklvykl16                  vstupaf16

prologiaf16

function tufun() {
logiz.pocita--;
logiz.div1.innerHTML ="<font color='#00FF00' size='7'>"+logiz.pocita+"</font>";
if(logiz.pocita<=0){
clearInterval(inter);
logiz=null;
document.getElementById("logi").removeChild(document.getElementById("logi").firstChild);
document.getElementById("avy").value=2;
rych=2;
}
}

var ppodrobaf16 = function() {
this.div = document.createElement("div");
this.div.style.position="absolute";
this.div.style.top=-20+"px";
this.div.style.left=40+"px";
this.div.style.width=800+"px";
this.div.style.height=10+"px";
document.getElementById("podrob").appendChild(this.div);
}

function adresary17() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://www.fotokomfort.cz/"+adere+"/vypadr.php", false); 
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if(xmlhttp.responseText=="nic"){
document.getElementById('vystuprih').value="Složka neexistuje";
}else{
ulozi=document.getElementById('jmtext').value;
if(predav==0){
fsmazcan16();
}            
if(ulozi!="test"){
pokrocily=1;
}else{
pokrocily=0;
}
if(startuj==1){
document.getElementById('proprihlas').style.display = 'none';
document.getElementById('promenu').style.display = 'block';    
document.getElementById('vloz').style.display = 'block';

}
document.getElementById('prihlasen').innerHTML = "<font color='#FFFFFF'>Přihlášen k: </font><font color='#FFFF00' size='4'><u>"+ulozi+"<u></font>";
document.getElementById('vystuprih').value="Jste přihlášeni k "+ulozi+".";
tabul17(xmlhttp.responseText);
}
}
}
xmlhttp.send(document.getElementById('jmtext').value);
}

function fsmazcan16() { 
ciscan=0;
nahrejcan=0;
document.getElementById('kon').value="mazu";   
document.getElementById('cykl').value="mazano";   
var element = document.getElementById("procan");    
while (element.firstChild) {
element.removeChild(element.firstChild);
}
can=[];
var tabulka = document.getElementById('ttable');//nal, vyl, X, O, V
for (var tax = tabulka.rows.length-1; tax >=0; tax --) {
if(document.getElementById("iinput"+tax)!=null){
elem = document.getElementById("iinput"+tax); 
elem.parentElement.removeChild(elem);
}
tabulka.deleteRow(tax);
}
var t = document.getElementById('tablekol');//prehled koleji
for (var tax = t.rows.length-1; tax >=0; tax --) {

t.deleteRow(tax);
}
context10.clearRect(0, 0, elem10.width, elem10.height);

}

function tabul17(pol){
var pole1=new Array();
var pole2=new Array();
pole2=pol.split("\n");
for (var i in pole2) { 
if(pole2[i].indexOf("f")!=0&&pole2[i]!=""){
pole1.push(pole2[i]);
}
}
pole1.sort();
var elem;
var tabulka = document.getElementById('tabadr');//seznam příkazů
for (var tax = tabulka.rows.length-1; tax >=0; tax --) {
tabulka.deleteRow(tax);
}
for (var ta = 0; ta < pole1.length; ta ++) {
var radek = tabulka.insertRow(ta);
radek.style.background = "#ffffff";
var bunka0 = radek.insertCell(0);
bunka0.width = "25px";
var bunka1 = radek.insertCell(1);
bunka1.width = "90px";
var bunka2 = radek.insertCell(2);
var bunka3 = radek.insertCell(3);
bunka0.innerHTML = ta+1;
bunka1.innerHTML = pole1[ta];
bunka2.innerHTML = "<button onclick='tltabadr17(this)' id='hoja' style = ' font-size:10px;'  >spusti</button>";
bunka3.innerHTML = "<button onclick='smazdotaz17(this)' id='hoja' style = ' font-size:10px;'  >X</button>";
}
astanice17();
}

function astanice17() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://www.fotokomfort.cz/"+adere+"/vypstan.php", false); 
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
tabstan17(xmlhttp.responseText);

if(startuj==0){
startuj=1;
fcykldir16();
}
}
}
xmlhttp.send();
}
function tabstan17(pol){
var pole1=new Array();
var pole2=new Array();
pole2=pol.split("\n");
for (var i in pole2) { 
if(pole2[i]!=""){
pole1.push(pole2[i].substring(0,pole2[i].indexOf(".")));
}
}
pole1.sort();
var elem;
var tabulka = document.getElementById('ctabadr');
for (var tax = tabulka.rows.length-1; tax >=0; tax --) {
tabulka.deleteRow(tax);
}
for (var ta = 0; ta < pole1.length; ta ++) {
var radek = tabulka.insertRow(ta);
radek.style.background = "#ffffff";
var bunka0 = radek.insertCell(0);
bunka0.width = "30px";
var bunka1 = radek.insertCell(1);
bunka1.width = "110px";
var bunka2 = radek.insertCell(2);
bunka0.innerHTML = ta+1;
bunka1.innerHTML = pole1[ta];
bunka2.innerHTML = "<button onclick='tltabstan17(this)' id='hoja' style = ' font-size:10px;'  >nahrej</button>";
}
if(predav==1){
fpredav16();
}else{
ccopy42();
}
}

function fpredav16() {
if(autominter==null){
pocet=0;
autominter=setInterval(fcykpred,10);
}else if(autominter!=null){
clearInterval(autominter);
autominter=null;
}
}
function fcykpred() {
if(fipr==0){
fipr=1;
if(popr>can.length-1){
popr=0;
clearInterval(autominter);
autominter=null;    
if(od!=""){
ccopy42();
}
}
fipredav16();
}
}
function fipredav16() {
var adar=document.getElementById('adr').value;
nazevstan=can[popr].nazevst;
var naz=ulozi+"/"+adar+"/_"+nazevstan+"_"+proul;
var plok="";
var pvozy="";
var pkoment="";
for (var jm in can[popr].jmeno) { 
plok+=can[popr].jmeno[jm]+";"+can[popr].loko[jm].join(",")+"|";
pvozy+=can[popr].jmeno[jm]+";"+can[popr].vozy[jm].join(",")+"|";
pkoment+=can[popr].jmeno[jm]+";"+can[popr].koment[jm].join(",")+"|";
}
var pridej=naz+"&"+plok+"&"+pvozy+"&"+pkoment;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://www.fotokomfort.cz/"+adere+"/predavka.php", false); 
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
popr++;
fipr=0;
}
}
xmlhttp.send(pridej);
}

function fcykldir16() { 
nahrejcan=0;
ciscan=0;
var pridej=ulozi+"/"+document.getElementById("adr").value;
var dirpo=new Array();
var dirpoo=new Array();
var dirtext="";
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://www.fotokomfort.cz/"+adere+"/isdir.php", false); 
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

dirtext=xmlhttp.responseText;

        if(dirtext.indexOf("_")!=-1){
dirtext=dirtext.substring(dirtext.indexOf("_"));
dirpo=dirtext.split("_");
for(b=0; b<dirpo.length;b++){
if(dirpo[b]!=""){
if(dirpo[b].indexOf("testik.xml")==-1){
dirpa.push(dirpo[b]);
}
}
}
//fsmazcan16();
if(autominter==null){
//var element = document.getElementById("procan");    
var element = ppodr.div;
while (element.firstChild) {
element.removeChild(element.firstChild);
}

clearInterval(autominter);
autominter=null; 
ciscan=0;
nahrejcan=0;
autominter=setInterval(nahdirschem16,10);
}
}
}
}
xmlhttp.send(pridej);
}

function nahdirschem16() { 
    if(nahrejcan==0){
nahrejcan=1;
test1(dirpa[ciscan]);
pridejtlac42(ciscan,dirpa[ciscan]);
ciscan++;
}
if(ciscan>=dirpa.length){
 clearInterval(autominter);
autominter=null;    
dirpa=[];
nahrejcan=0;
ciscan=0;
var okn=document.getElementById("okno").value;
if(okn==1){
fokno16();
}
if(okn==2){
foknoa16();
}
if(okn==3){
foknob16();
}
fnahpred16();   
}
}

function fnahpred16() {
ciscan=0;
nahrejcan=0;
if(autominter==null){
autominter=setInterval(spustipred16,10);
function spustipred16() {
if(nahrejcan==0){
nahrejcan=1;
ffnahpred16(ciscan);
}
}
}else if(autominter!=null){
clearInterval(autominter);
autominter=null;
}
}

function ffnahpred16(cisc) {
document.getElementById('adat').value=can[cisc].nazevst;
nazevstan=document.getElementById('adat').value;
var adar=document.getElementById('adr').value;
var naz=ulozi+"/"+adar+"/_"+nazevstan+"_"+proul;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if(ciscan<can.length){
if(xhttp.responseText!=""){
var parser, xmlDoc;
parser = new DOMParser();
xmlDoc = parser.parseFromString(xhttp.responseText,"text/xml");
//can[cisc].xmlDDoc=xmlDoc;
for (var tax =0 ; tax<can.length; tax ++) {
if(can[tax].nazevst==nazevstan){
can[tax].xmlDDoc=xmlDoc;
fpredavnah16(can[tax].xmlDDoc,tax);
}
}
}else{
document.getElementById('kon').value+="else\n";
}
}
if(ciscan>can.length-1){
document.getElementById('kon').value+="\nAAut11";
clearInterval(autominter);
autominter=null;
ciscan=0;
nahrejcan=0;
pocet=0;
AAut11();
}
}
};
//var adar=document.getElementById('adr').value;
reqListener16 (xhttp);
//xhttp.open("GET", "http://www.fotokomfort.cz/"+adere+"/uloz/"+adar+"/_"+can[cisc].nazevst+"_"+proul+".xml", true);
xhttp.open("POST", "http://www.fotokomfort.cz/"+adere+"/nahrej.php", true);
xhttp.send(naz); 
}

function fpredavnah16(xmlddoc,cis) {
pocet=0;
var zkrat=xmlddoc.documentElement.getElementsByTagName("predav");
    if(zkrat.length!=0){
var plok=zkrat[0].childNodes[0].textContent.split("|");
var pvozy=zkrat[0].childNodes[1].textContent.split("|");
var pkoment=zkrat[0].childNodes[2].textContent.split("|");
var polejmen=[];
var ax;
var ay;
document.getElementById("adat").value=can[cis].nazevst;
can[cis].context4.clearRect(0, 0, can[cis].f4.width, can[cis].f4.height);
can[cis].context4.beginPath();

        for (var jm in can[cis].jmeno) {
polejmen.push(jm);
}
        for(c=0; c<polejmen.length;c++){
if(pkoment[c].substring(pkoment[c].indexOf(";")+1)!=""){
can[cis].koment[polejmen[c]]=pkoment[c].substring(pkoment[c].indexOf(";")+1).split(",");
ax=polejmen[c].substring(0,polejmen[c].indexOf(","));
ay=polejmen[c].substring(polejmen[c].indexOf(",")+1);
for (var bx = 0; bx < can[cis].koment[polejmen[c]].length; bx ++) {
malujvozy4(can[cis],ax,ay,bx,polejmen[c],pmez,ba,psir);
}
}

            if(plok[c].substring(plok[c].indexOf(";")+1)!=""){
if(plok[c].substring(plok[c].indexOf(";")+1).indexOf(",")!=-1){
can[cis].loko[polejmen[c]]=plok[c].substring(plok[c].indexOf(";")+1).split(",");
}else{
can[cis].loko[polejmen[c]].push(plok[c].substring(plok[c].indexOf(";")+1));    
}
}

            if(pvozy[c].substring(pvozy[c].indexOf(";")+1)!=""){
can[cis].vozy[polejmen[c]]=pvozy[c].substring(pvozy[c].indexOf(";")+1).split(",");
}

}
}

document.getElementById('kon').value+="predavnah\n";
ciscan++;
nahrejcan=0;
}
function malujvozy4(cani,ax,ay,bx,jm,pmez,ba,psir) { 
var indee;
var kam=cani.koment[jm][bx].split(";");
ax=Number(jm.substring(0,jm.indexOf(",")))-cani.prode[jm];
    if(cani.koment[jm][bx].indexOf(";")!=-1){
kam=cani.koment[jm][bx].split(";");
if(kam[1].indexOf("!")==-1){
indee=seznam.indexOf(kam[1]);
}else{
indee=seznam.indexOf(kam[1].substring(kam[1].indexOf("!")+1));
}
if(kam[4]!="praz"){
cani.context4.drawImage(odkazy[indee],0,15,40,15,(Number(ax)*cani.vx)-(Number(cani.koment[jm].length)*Number(pmez)/2)+(bx*Number(pmez)),Number(ay)+Number(ba),Number(psir),15);
}else{
cani.context4.drawImage(odkazy[indee],0,0,40,15,(Number(ax)*cani.vx)-(Number(cani.koment[jm].length)*Number(pmez)/2)+(bx*Number(pmez)),Number(ay)+Number(ba),Number(psir),15);
}
if(kam[1].indexOf("!")!=-1){
var jakaspr =odkazyspr[seznamspr.indexOf(kam[1].substring(0,kam[1].indexOf("!")))];
cani.context4.drawImage(jakaspr,0,0,10,10,(Number(ax)*cani.vx)-(Number(cani.koment[jm].length)*Number(pmez)/2)+(bx*Number(pmez))+15*(Number(pmez)/40),Number(ay)+Number(ba)+5,10*(Number(pmez)/40),10);
}
}else{
cani.context4.drawImage(odkazy[0],0,0,odkazy[1].width,15,(Number(ax)*cani.vx)-(Number(cani.koment[jm].length)*Number(pmez)/2)+(bx*Number(pmez)),Number(ay)+Number(ba),Number(psir),15);
}
}

function AAut11() {
autom=0;
poc=-1;
if(autominter==null){
ukladej=0;
SSpusti();
}else if(autominter!=null){
clearInterval(autominter);
autominter=null;
ukladej=1;
}
}
function SSpusti() {
if(autom==0){
autom=1;
OOpak("pridej");
}
}
function OOpak(jak) { 
if(poc==-1){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var parser, xmlDoc;
parser = new DOMParser();
xmlDoc = parser.parseFromString(xhttp.responseText,"text/xml");

//xmlDDoc=xhttp.responseXML;
xmlDDoc=xmlDoc;
pocet=xmlDDoc.documentElement.getElementsByTagName("prikazy").length;
if(pocet>0){
poc=0;
autom=0;
autominter=setInterval(nnahanim,10);
}
}else{
poc=0;
autom=0;
clearInterval(autominter);
autominter=null;
}
}
reqListener16 (xhttp);
var adar=document.getElementById('adr').value;
var naz=ulozi+"/"+adar+"/books"+proul;
//xhttp.open("GET", "http://www.fotokomfort.cz/"+adere+"/uloz/"+adar+"/books"+proul+".xml", true);
xhttp.open("POST", "http://www.fotokomfort.cz/"+adere+"/nahrej.php", true);

xhttp.send(naz); 
}else if(poc!=-1){
}
}

function nnahanim() {
if(autom==0){
autom=1;
var kou=xmlDDoc.documentElement.getElementsByTagName("prikazy").length;
var zkrat=xmlDDoc.documentElement.getElementsByTagName("prikazy");
var proinde =zkrat[poc].getAttribute("stan");
document.getElementById("adat").value=zkrat[poc].getAttribute("stan");
document.getElementById("cisvl").value=zkrat[poc].childNodes[0].textContent;
document.getElementById("bbv").value=zkrat[poc].getAttribute("datum");
document.getElementById("ccvy").value=zkrat[poc].childNodes[1].textContent;
document.getElementById('nazev3').value=zkrat[poc].childNodes[2].textContent;
document.getElementById('nazev4').value=zkrat[poc].childNodes[3].textContent;
pocet=kou;
document.getElementById('cykl').value=kou+"/"+(poc+1);
        for (var jm in can) { 
if(can[jm].nazevst==proinde){
if(inde!=jm){
inde=jm;   
for(b=0; b<can.length;b++){
can[b].div.childNodes[0].style.backgroundColor = 'rgba(158, 167, 184, 1)';
for(d=0; d<can[b].div.childNodes.length;d++){
can[b].div.childNodes[d].style.border ="1px solid #0F0";
}
}
can[inde].div.childNodes[0].style.backgroundColor = 'rgba(168, 177, 194, 1)';
for(c=0; c<can[inde].div.childNodes.length;c++){
can[inde].div.childNodes[c].style.border ="1px solid #F00";
}
for(cb=0; cb<document.getElementById("procan").childNodes.length;cb++){
document.getElementById("procan").childNodes[cb].childNodes[0].style.zIndex=cb;
document.getElementById("procan").childNodes[cb].childNodes[1].style.zIndex=cb;
document.getElementById("procan").childNodes[cb].childNodes[2].style.zIndex=cb;
document.getElementById("procan").childNodes[cb].childNodes[3].style.zIndex=cb;
//document.getElementById("procan").childNodes[cb].texta.style.zIndex=cb;
//document.getElementById("probut").childNodes[cb].style.zIndex=cb;
}
document.getElementById("procan").childNodes[inde].childNodes[0].style.zIndex=document.getElementById("procan").childNodes.length;
document.getElementById("procan").childNodes[inde].childNodes[1].style.zIndex=document.getElementById("procan").childNodes.length;
document.getElementById("procan").childNodes[inde].childNodes[2].style.zIndex=document.getElementById("procan").childNodes.length;
document.getElementById("procan").childNodes[inde].childNodes[3].style.zIndex=document.getElementById("procan").childNodes.length;

}
break;
}
}
        if(zkrat[poc].childNodes[2].textContent=="svet"){
cesta2();
opprijezd(zkrat,poc);
//cykltrat41(1);
}else{
            if(zkrat[poc].childNodes[7].textContent==""){
if(zkrat[poc].childNodes[2].textContent!=zkrat[poc].childNodes[3].textContent){
avyhybky42();
cesta2();
opprestaveni(zkrat,poc);
}else{
opzmena(zkrat,poc);
nal_vyl_nah42();

}
}else{
avyhybky42();
cesta2();
castprestaveni(zkrat,poc);
}
//cykltrat41(1);
tabul5(bfix,bfiy);
context10.clearRect(0, 0, elem10.width, elem10.height);
var roz=new Array();
roz.push(bfix);
roz.push(bfiy);
var kam;
var indee;
prodeset4(bfix+","+bfiy);
//cesta2();
//vystupkolejiste41(inde);
}
tabulvyskol18();
//vystupkolejiste41(inde);
poc++;
if(poc>kou-1){
if(opakuj==0){
poc=-1;
clearInterval(autominter);
autominter=null;
}
if(opakuj==1){
poc=0;
clearInterval(autominter);
autominter=null;
fnahpredvym16();
fnahpred16();
}
}
}
}

function cesta2() {
bbfix=0;
var ppe1 = new Array();
var jma = document.getElementById('nazev3').value;
var jmb = document.getElementById('nazev4').value;
can[inde].context3.clearRect(0, 0,can[inde].f3.width, can[inde].f3.height);
can[inde].context3.beginPath();
can[inde].context3.lineWidth=1.7;
//if(afix<bfix){
if(can[inde].cesta[jma+","+jmb]!=null){
stopa=true;
for (var bx = 0; bx < can[inde].cesta[jma+","+jmb].length; bx ++) {
ppe1=can[inde].cesta[jma+","+jmb][bx].split(";");
if(bx==0){
can[inde].context3.moveTo(ppe1[0]*can[inde].vx,ppe1[1]);
}else{
can[inde].context3.lineTo(ppe1[0]*can[inde].vx,ppe1[1]);
if(bx==1){
bbfix=ppe1[0];
}

}
}
}else{
if(can[inde].cesta[jmb+","+jma]==undefined){
stopa=false;
}else{
stopa=true; 
for (var bx = 0; bx < can[inde].cesta[jmb+","+jma].length; bx ++) {
ppe1=can[inde].cesta[jmb+","+jma][bx].split(";");
if(bx==0){
can[inde].context3.moveTo(ppe1[0]*can[inde].vx,ppe1[1]);
}else{
can[inde].context3.lineTo(ppe1[0]*can[inde].vx,ppe1[1]);
if(bx==can[inde].cesta[jmb+","+jma].length-2){
bbfix=ppe1[0];
}
}
}

//}
}
}

/*if(afix>bfix){
if(can[inde].cesta[jmb+","+jma]!=undefined){
stopa=true; 
for (var bx = 0; bx < can[inde].cesta[jmb+","+jma].length; bx ++) {
ppe1=can[inde].cesta[jmb+","+jma][bx].split(";");
if(bx==0){
can[inde].context3.moveTo(ppe1[0]*can[inde].vx,ppe1[1]);
}else{
can[inde].context3.lineTo(ppe1[0]*can[inde].vx,ppe1[1]);
}
}
}else{
if(can[inde].cesta[jma+","+jmb]==undefined){
stopa=false;
}
}
}*/

if(jma=="svet"){
stopa=true;
}
can[inde].context3.strokeStyle = "#ffff00";
can[inde].context3.stroke();
can[inde].context3.closePath();
//document.getElementById("texta16").value+=stopa+"sto\n";
}

function opprijezd(zk,csi) { 
//var psir = document.getElementById('sirka').value;
var pmez = document.getElementById('mezera').value;
var ba = -15;
can[inde].f4.style.visibility='visible';
var anxy=new Array();
var bnxy=new Array();
var ax="";
var ay="";
for (var jm in can[inde].jmeno) {
if(can[inde].jmeno[jm]==zk[csi].childNodes[2].textContent)
{
anxy=jm.split(",");
afix=anxy[0];
afiy=anxy[1];
}
if(can[inde].jmeno[jm]==zk[csi].childNodes[3].textContent)
{
bnxy=jm.split(",");
bfix=bnxy[0];
bfiy=bnxy[1];
}
}
opvypocet(zk,csi,8,bfix+","+bfiy,0);
for (var jm in can[inde].koment) { 
ax=jm.substring(0,jm.indexOf(","));
ay=jm.substring(jm.indexOf(",")+1);
if(can[inde].koment[jm]!=""){
for (var bx = 0; bx < can[inde].koment[jm].length; bx ++) {
malujvozy4(can[inde],ax,ay,bx,jm,pmez,ba,psir);
}
}
}
autom=0;
}

function avyhybky42() {

var delik=can[inde].xmlDoc.documentElement.getElementsByTagName("pole2").length;

//document.getElementById("texta16").value=delik;
    if(delik>0){
    var jma = document.getElementById('nazev3').value;
var jmb = document.getElementById('nazev4').value;
var odkaz=can[inde].xmlDoc.documentElement.getElementsByTagName("pole2")[0];
var pol1=new Array();
var pol2=new Array();
var pol3=new Array();

        for(c=0; c<odkaz.childNodes.length; c++ ) {

            if (odkaz.childNodes[c].nodeType === 1) {
if (odkaz.childNodes[c].textContent!==""){
if(odkaz.childNodes[c].getAttribute("jm")==(jma+","+jmb)||odkaz.childNodes[c].getAttribute("jm")==(jmb+","+jma)){
can[inde].context0.clearRect(0, 0,can[inde].f3.width, can[inde].f3.height);
pol1=odkaz.childNodes[c].textContent.split(",");
for(d=0; d<pol1.length; d++ ) {
pol2=pol1[d].split("/");
vyhstav[pol2[0]]=pol2[1];

}
can[inde].context0.beginPath();
                        
can[inde].context0.font = '80px serif';
can[inde].context0.fillStyle='rgba(148, 157, 174, 0.4)';
//this.context0.textBaseline = 'hanging';
can[inde].context0.fillText('waglook@volny.cz', 50, 100);
can[inde].context0.fillText('waglook@volny.cz', 750, 100);
can[inde].context0.fillStyle='rgba(255, 255, 255, 1)';
can[inde].context0.font = '15px serif';                       
                        for (var jum in vyhstav) {
   pol3=vyhmisto[jum].split(",");
    can[inde].context0.fillText(jum+vyhstav[jum], pol3[0], pol3[1]);
                        }
                       can[inde].context0.closePath();
can[inde].context0.stroke(); 
//document.getElementById("texta16").value=odkaz.childNodes[c].textContent;
//document.getElementById("texta16").value+=this.odkaz.childNodes[c].textContent;
}
}
}
}
}
//var ade=can[inde].xmlDoc.documentElement.getElementsByTagName("pole2")[0].getElementsByTagName(jma+","+jmb).textContent;
//document.getElementById("texta16").value="del "+delik+"  "+ade;
}

function opprestaveni(zk,csi) { 
var aretez="";
var bretez="";
var sleduj=0;
var kolik=0;
var anxy=new Array();
var bnxy=new Array();
var ax="";
var ay="";
//var psir = document.getElementById('sirka').value;
var pmez = document.getElementById('mezera').value;
var ba = -15;
document.getElementById('nazev3').value=zk[csi].childNodes[2].textContent;
document.getElementById('nazev4').value=zk[csi].childNodes[3].textContent;
for (var jm in can[inde].jmeno) {
if(can[inde].jmeno[jm]==zk[csi].childNodes[2].textContent)
{
anxy=jm.split(",");
afix=Number(anxy[0]);
afiy=Number(anxy[1]);
}
if(can[inde].jmeno[jm]==zk[csi].childNodes[3].textContent)
{
bnxy=jm.split(",");
bfix=Number(bnxy[0]);
bfiy=Number(bnxy[1]);
}
}
can[inde].proanim3=[];
can[inde].zproanim3=[];
can[inde].apredkoment=[];
can[inde].bpredkoment=[];
can[inde].proanim2=[];
can[inde].zproanim2=[];
can[inde].proanim1=[];
can[inde].zproanim1=[];
if(can[inde].koment[afix+","+afiy].length>0){
for (var jm in can[inde].koment[afix+","+afiy]) { 
can[inde].apredkoment.push(can[inde].koment[afix+","+afiy][jm]);
can[inde].proanim1.push(can[inde].apredkoment[jm])
can[inde].zproanim1.push(can[inde].apredkoment[jm])
}
}
can[inde].koment[afix+","+afiy].splice(0,can[inde].koment[afix+","+afiy].length);
for (var bt = 0; bt< can[inde].koment[bfix+","+bfiy].length; bt ++) {
can[inde].bpredkoment.push(can[inde].koment[bfix+","+bfiy][bt]);
can[inde].proanim3.push(can[inde].koment[bfix+","+bfiy][bt]);
can[inde].zproanim3.push(can[inde].koment[bfix+","+bfiy][bt]);
}
opvypocet(zk,csi,7,afix+","+afiy,0);
opvypocet(zk,csi,8,bfix+","+bfiy,1);
can[inde].cislo[afix+","+afiy]=0;
can[inde].cislo[bfix+","+bfiy]=document.getElementById('cisvl').value;
tlacobr4(0,inde);
if(zk[csi].childNodes[3].textContent!="svet"){
if(Number(afix)<Number(bbfix)){
can[inde].afanim6();
}else{
can[inde].fanim8();
}
}else{
can[inde].obrat=0;
autom=0;
}
}

function castprestaveni(zk,csi) { 
var aretez="";
var bretez="";
var sleduj=0;
var kolik=0;
var anxy=new Array();
var bnxy=new Array();
var ax="";
var ay="";
//var psir = document.getElementById('sirka').value;
var pmez = document.getElementById('mezera').value;
var ba = -15;
document.getElementById('nazev3').value=zk[csi].childNodes[2].textContent;
document.getElementById('nazev4').value=zk[csi].childNodes[3].textContent;
for (var jm in can[inde].jmeno) {
if(can[inde].jmeno[jm]==zk[csi].childNodes[2].textContent)
{
anxy=jm.split(",");
afix=Number(anxy[0]);
afiy=Number(anxy[1]);
}
if(can[inde].jmeno[jm]==zk[csi].childNodes[3].textContent)
{
bnxy=jm.split(",");
bfix=Number(bnxy[0]);
bfiy=Number(bnxy[1]);
}
}
can[inde].proanim3=[];
can[inde].zproanim3=[];
can[inde].apredkoment=[];
can[inde].bpredkoment=[];
can[inde].proanim2=[];
can[inde].zproanim2=[];
can[inde].proanim1=[];
can[inde].zproanim1=[];
var animkoment=new Array();
animkoment=zk[csi].childNodes[6].textContent.split(",");
for (var jm in animkoment) { 
can[inde].apredkoment.push(animkoment[jm]);
}
for (var jm in can[inde].apredkoment) { 
can[inde].proanim1.push(can[inde].apredkoment[jm]);
can[inde].zproanim1.push(can[inde].apredkoment[jm]);
}
var bnimkoment=new Array();
bnimkoment=zk[csi].childNodes[8].textContent.split(",");
var delnim=zk[csi].childNodes[6].textContent.length;
var dnim=zk[csi].childNodes[8].textContent.indexOf(zk[csi].childNodes[6].textContent);
var dnimkoment="";
if(Number(afix)<Number(bbfix)){
dnimkoment=zk[csi].childNodes[8].textContent.substring(delnim).split(",");
}else{
dnimkoment=zk[csi].childNodes[8].textContent.substring(0,dnim).split(",");
}
for (var jm in dnimkoment) { 
if(dnimkoment[jm]!=""){
can[inde].bpredkoment.push(dnimkoment[jm]);
}
}
for (var bt = 0; bt< bnimkoment.length; bt ++) {
can[inde].proanim3.push(bnimkoment[bt]);
can[inde].zproanim3.push(bnimkoment[bt]);
}
var cnimkoment=new Array();
cnimkoment=zk[csi].childNodes[7].textContent.split(",");
for (var jm in cnimkoment) { 
can[inde].proanim2.push(cnimkoment[jm]);
can[inde].zproanim2.push(cnimkoment[jm]);
}
opvypocet(zk,csi,7,afix+","+afiy,0);
opvypocet(zk,csi,8,bfix+","+bfiy,1);
for (var jm in can[inde].koment) { 
ax=jm.substring(0,jm.indexOf(","));
ay=jm.substring(jm.indexOf(",")+1);
}
tlacobr4(0,inde);
if(Number(afix)<Number(bbfix)){
can[inde].afanim6();
}else{
can[inde].fanim8();
}
}
function opzmena(zk,csi) { 
var bnxy=new Array();
var ax="";
var ay="";
//var psir = document.getElementById('sirka').value;
var pmez = document.getElementById('mezera').value;
var ba = -15;
can[inde].f4.style.visibility='visible';
for (var jm in can[inde].jmeno) {
if(can[inde].jmeno[jm]==zk[csi].childNodes[3].textContent)
{
bnxy=jm.split(",");
bfix=Number(bnxy[0]);
bfiy=Number(bnxy[1]);
afix=Number(bnxy[0]);
afiy=Number(bnxy[1]);
}
}
dotext3(can[inde].jmeno,bfix,bfiy);
opvypocet(zk,csi,8,bfix+","+bfiy,1); 
for (var jm in can[inde].koment) { 
ax=jm.substring(0,jm.indexOf(","));
ay=jm.substring(jm.indexOf(",")+1);
if(can[inde].koment[jm]!=""){
for (var bx = 0; bx < can[inde].koment[jm].length; bx ++) {
malujvozy4(can[inde],ax,ay,bx,jm,pmez,ba,psir);
}
}
}
tlacobr4(1,inde);
autom=0;
}

function tabul5(ax,ay){
var pole1=new Array();
var elem;
var tabulka = document.getElementById('ttable');
for (var tax = tabulka.rows.length-1; tax >=0; tax --) {
if(document.getElementById("iinput"+tax)!=null){
elem = document.getElementById("iinput"+tax); 
elem.parentElement.removeChild(elem);
}
tabulka.deleteRow(tax);
}
for (var ta = 0; ta < can[inde].koment[ax+","+ay].length; ta ++) {
pole1=can[inde].koment[ax+","+ay][ta].split(";");
var radek = tabulka.insertRow(ta);
radek.style.background = "#ffffff";
var bunka0 = radek.insertCell(0);
var bunka1 = radek.insertCell(1);
var bunka2 = radek.insertCell(2);
var bunka3 = radek.insertCell(3);
var bunka4 = radek.insertCell(4);
var bunka5 = radek.insertCell(5);
var bunka6 = radek.insertCell(6);
var bunka7 = radek.insertCell(7);
if(pole1.length>1){
bunka0.innerHTML = ta+1;
bunka1.innerHTML = pole1[0];
bunka2.innerHTML = pole1[1];
bunka3.innerHTML = pole1[2];
bunka4.innerHTML = pole1[3];
bunka5.innerHTML = pole1[4];
bunka6.innerHTML = "<input type='text' id='iinput"+ta+"' style='width: 30px;' value="+pole1[5]+">";
bunka7.innerHTML = "<button onclick='tltab(this)' id='hoja' style = ' font-size:10px;'  >edit</button>";
}else{
bunka0.innerHTML = ta+1;
bunka1.innerHTML = pole1[0];
bunka2.innerHTML = "";
bunka3.innerHTML = "";
bunka4.innerHTML = "";
bunka5.innerHTML = "";
bunka6.innerHTML = "";
bunka7.innerHTML = "<button onclick='tltab(this)' id='hoja' style = ' font-size:10px;'  >edit</button>";
}

var deldyn=500;
    if(tabulka.rows.length<25){
   deldyn=(tabulka.rows.length+1)*20;
       }
}
document.getElementById('tabuldyn').style.height=deldyn+'px';
}

function prodeset4(jm) {
var kam;
var indee;
context10.font = "9px sans-serif";
context10.clearRect(0, 0, elem10.width, elem10.height);
for (var ta = 0; ta < can[inde].koment[jm].length; ta ++) {
if(can[inde].koment[jm][ta].indexOf(";")!=-1){
kam=can[inde].koment[jm][ta].split(";");
if(kam[1].indexOf("!")==-1){
indee=seznam.indexOf(kam[1]);
}else{
indee=seznam.indexOf(kam[1].substring(kam[1].indexOf("!")+1));
}
if(kam[4]!="praz"){
context10.drawImage(odkazy[indee],0,15,40,15,20+(28*ta),23,23,15);
}else{
context10.drawImage(odkazy[indee],0,0,40,15,20+(28*ta),23,23,15);
}
if(kam[1].indexOf("!")!=-1){
var jakaspr =odkazyspr[seznamspr.indexOf(kam[1].substring(0,kam[1].indexOf("!")))];
context10.drawImage(jakaspr,0,0,10,10,20+(28*ta)+15*(28/40),25,10*(23/40),10);
}
context10.fillText(kam[0].substring(8), 20+(28*ta), 10);
context10.fillText(kam[5], 20+(28*ta), 48);
}else{
context10.drawImage(odkazy[0],0,0,40,15,20+(28*ta),23,23,15);
context10.fillText(can[inde].koment[jm][ta], 20+(28*ta), 10);
}
context10.fillText(ta+1+"/"+(can[inde].koment[jm].length-ta), 20+(28*ta), 20);
}
}

function tabulvyskol18(){
var r;
var c;
var pac=0;
var t = document.getElementById('tablekol');
for (var tax = t.rows.length-1; tax >=0; tax --) {

t.deleteRow(tax);
}

var votext="";
for (var jam in can[inde].vozy) { 
if(can[inde].loko[jam]!=""||can[inde].vozy[jam]!=""){
r = t.insertRow(pac); 
r.style.background = "#ffffff";
if(document.getElementById('nazev3').value==can[inde].jmeno[jam]){
r.style.background = "#ffff00";

}
c = r.insertCell(0);
c.innerHTML = can[inde].jmeno[jam];
c = r.insertCell(1);
        if(can[inde].loko[jam]!=""){
//votext+=can[inde].jmeno[jam]+"-"+can[inde].vozy[jam].join(",")+","+can[inde].loko[jam].join(",")+"\n";
c.innerHTML = can[inde].vozy[jam].join(" ")+" "+can[inde].loko[jam].join(" ");
}else{
if(can[inde].vozy[jam].length!=0){ 
//votext+=can[inde].jmeno[jam]+"-"+can[inde].vozy[jam].join(",")+"\n";
c.innerHTML = can[inde].vozy[jam].join(" ");
}
}
pac++;
}
}

    /*c = r.insertCell(0);
    c.innerHTML = 123;
    c = r.insertCell(1);
    c.innerHTML = 456;*/
    
}

function fnahpredvym16() {
var polejmen;
clearInterval(autominter);
clearInterval(cutominter); 
clearInterval(dutominter);
autominter=null;
promcutominter=0;
document.getElementById("onof").value="on";
document.getElementById('textrov').value+="\nSTOP";
funsmaznavyk42();
    for (var jim in can) { 
polejmen=[];
for (var jm in can[jim].jmeno) {
polejmen.push(jm);
}
for(c=0; c<polejmen.length;c++){
can[jim].koment[polejmen[c]]=[];
can[jim].loko[polejmen[c]]=[];
can[jim].vozy[polejmen[c]]=[];
}
can[jim].poslilok="";
can[jim].poslivuz="";
can[jim].posliinfp="";
can[jim].posliinfv="";
can[jim].posliinfk="";
can[jim].context4.clearRect(0, 0, can[jim].f4.width, can[jim].f4.height);
can[jim].context4.beginPath();
can[jim].context5.clearRect(0, 0, can[jim].f5.width, can[jim].f5.height);
can[jim].context5.beginPath();
can[jim].context6.clearRect(0, 0, can[jim].f6.width, can[jim].f6.height);
can[jim].context6.beginPath();
can[jim].context7.clearRect(0, 0, can[jim].f7.width, can[jim].f7.height);
can[jim].context7.beginPath();
}
}

function funsmaznavyk42(){
 document.getElementById("pronak42").innerHTML=""; 
 document.getElementById("provyk42").innerHTML=""; 
}

function fnahpred16() {
ciscan=0;
nahrejcan=0;
if(autominter==null){
autominter=setInterval(spustipred16,10);
function spustipred16() {
if(nahrejcan==0){
nahrejcan=1;
ffnahpred16(ciscan);
}
}
}else if(autominter!=null){
clearInterval(autominter);
autominter=null;
}
}

function ffnahpred16(cisc) {
document.getElementById('adat').value=can[cisc].nazevst;
nazevstan=document.getElementById('adat').value;
var adar=document.getElementById('adr').value;
var naz=ulozi+"/"+adar+"/_"+nazevstan+"_"+proul;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if(ciscan<can.length){
if(xhttp.responseText!=""){
var parser, xmlDoc;
parser = new DOMParser();
xmlDoc = parser.parseFromString(xhttp.responseText,"text/xml");
//can[cisc].xmlDDoc=xmlDoc;
for (var tax =0 ; tax<can.length; tax ++) {
if(can[tax].nazevst==nazevstan){
can[tax].xmlDDoc=xmlDoc;
fpredavnah16(can[tax].xmlDDoc,tax);
}
}
}else{
document.getElementById('kon').value+="else\n";
}
}
if(ciscan>can.length-1){
document.getElementById('kon').value+="\nAAut11";
clearInterval(autominter);
autominter=null;
ciscan=0;
nahrejcan=0;
pocet=0;
AAut11();
}
}
};
//var adar=document.getElementById('adr').value;
reqListener16 (xhttp);
//xhttp.open("GET", "http://www.fotokomfort.cz/"+adere+"/uloz/"+adar+"/_"+can[cisc].nazevst+"_"+proul+".xml", true);
xhttp.open("POST", "http://www.fotokomfort.cz/"+adere+"/nahrej.php", true);
xhttp.send(naz); 
}

function fpredavnah16(xmlddoc,cis) {
pocet=0;
var zkrat=xmlddoc.documentElement.getElementsByTagName("predav");
    if(zkrat.length!=0){
var plok=zkrat[0].childNodes[0].textContent.split("|");
var pvozy=zkrat[0].childNodes[1].textContent.split("|");
var pkoment=zkrat[0].childNodes[2].textContent.split("|");
var polejmen=[];
var ax;
var ay;
document.getElementById("adat").value=can[cis].nazevst;
can[cis].context4.clearRect(0, 0, can[cis].f4.width, can[cis].f4.height);
can[cis].context4.beginPath();

        for (var jm in can[cis].jmeno) {
polejmen.push(jm);
}
        for(c=0; c<polejmen.length;c++){
if(pkoment[c].substring(pkoment[c].indexOf(";")+1)!=""){
can[cis].koment[polejmen[c]]=pkoment[c].substring(pkoment[c].indexOf(";")+1).split(",");
ax=polejmen[c].substring(0,polejmen[c].indexOf(","));
ay=polejmen[c].substring(polejmen[c].indexOf(",")+1);
for (var bx = 0; bx < can[cis].koment[polejmen[c]].length; bx ++) {
malujvozy4(can[cis],ax,ay,bx,polejmen[c],pmez,ba,psir);
}
}

            if(plok[c].substring(plok[c].indexOf(";")+1)!=""){
if(plok[c].substring(plok[c].indexOf(";")+1).indexOf(",")!=-1){
can[cis].loko[polejmen[c]]=plok[c].substring(plok[c].indexOf(";")+1).split(",");
}else{
can[cis].loko[polejmen[c]].push(plok[c].substring(plok[c].indexOf(";")+1));    
}
}

            if(pvozy[c].substring(pvozy[c].indexOf(";")+1)!=""){
can[cis].vozy[polejmen[c]]=pvozy[c].substring(pvozy[c].indexOf(";")+1).split(",");
}

}
}

document.getElementById('kon').value+="predavnah\n";
ciscan++;
nahrejcan=0;
}

function malujvozy4(cani,ax,ay,bx,jm,pmez,ba,psir) { 
var indee;
var kam=cani.koment[jm][bx].split(";");
ax=Number(jm.substring(0,jm.indexOf(",")))-cani.prode[jm];
    if(cani.koment[jm][bx].indexOf(";")!=-1){
kam=cani.koment[jm][bx].split(";");
if(kam[1].indexOf("!")==-1){
indee=seznam.indexOf(kam[1]);
}else{
indee=seznam.indexOf(kam[1].substring(kam[1].indexOf("!")+1));
}
if(kam[4]!="praz"){
cani.context4.drawImage(odkazy[indee],0,15,40,15,(Number(ax)*cani.vx)-(Number(cani.koment[jm].length)*Number(pmez)/2)+(bx*Number(pmez)),Number(ay)+Number(ba),Number(psir),15);
}else{
cani.context4.drawImage(odkazy[indee],0,0,40,15,(Number(ax)*cani.vx)-(Number(cani.koment[jm].length)*Number(pmez)/2)+(bx*Number(pmez)),Number(ay)+Number(ba),Number(psir),15);
}
if(kam[1].indexOf("!")!=-1){
var jakaspr =odkazyspr[seznamspr.indexOf(kam[1].substring(0,kam[1].indexOf("!")))];
cani.context4.drawImage(jakaspr,0,0,10,10,(Number(ax)*cani.vx)-(Number(cani.koment[jm].length)*Number(pmez)/2)+(bx*Number(pmez))+15*(Number(pmez)/40),Number(ay)+Number(ba)+5,10*(Number(pmez)/40),10);
}
}else{
cani.context4.drawImage(odkazy[0],0,0,odkazy[1].width,15,(Number(ax)*cani.vx)-(Number(cani.koment[jm].length)*Number(pmez)/2)+(bx*Number(pmez)),Number(ay)+Number(ba),Number(psir),15);
}
}