
function createIFrame() {
  var id = 'f' + Math.floor(Math.random() * 99999);
  var div = document.createElement('div');
  div.innerHTML = '<iframe style="display:none" src="about:blank" id="'+id+'" name="'+id+'" onload="sendComplete(\''+id+'\')"></iframe>';
  document.body.appendChild(div);
  return document.getElementById(id);
}

function sendForm(form, url, func, arg) {
  if (!document.createElement) return; // not supported
  if (typeof(form)=="string") form=document.getElementById(form);
  var frame=createIFrame();
  frame.onSendComplete = function() { func(arg, getIFrameXML(frame)); };
  form.setAttribute('target', frame.id);
  form.setAttribute('action', url);
  form.submit();
}

function sendComplete(id) {

  var iframe=document.getElementById(id);
  if (iframe.onSendComplete && typeof(iframe.onSendComplete) == 'function') iframe.onSendComplete();
}

function getIFrameXML(iframe) {
  var doc=iframe.contentDocument;
  if (!doc && iframe.contentWindow) doc=iframe.contentWindow.document;
  if (!doc) doc=window.frames[iframe.id].document;
  if (!doc) return null;
  if (doc.location=="about:blank") return null;
  if (doc.XMLDocument) doc=doc.XMLDocument;
  return doc;
}

var cnt=0;

function uploadComplete(element, doc) {
  if (!doc) return;
  if (typeof(element)=="string") element=document.getElementById(element);
  element.innerHTML=doc.documentElement.firstChild.nodeValue;

document.getElementById("divfoto").style.display = 'block';
document.getElementById("spanfoto").innerHTML = "<img src=/UserFiles/Image/photo/tn/"+doc.documentElement.firstChild.nodeValue+" border=0>";

 loadfoto(doc.documentElement.firstChild.nodeValue);

}


function loadfoto(user) {


var url = "ajax.pl?uprav=" + 53
  + "&user=" +  user
 + "&rnd="+Math.random();

// alert(url);

  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = function() {divloadfoto(user);};
  xmlHttp.send(null);}

function divloadfoto(divuser) {
        if(xmlHttp.readyState == 3 ) {}
        else {if(xmlHttp.readyState == 4) {



document.getElementById("divfotoall").style.display = 'block';
document.getElementById("spanfotoall").innerHTML = xmlHttp.responseText;

}}}
