	var xmlHttp;
	var form_id_global;
	var formular_global;
		
  function GetXmlHttpObject(){ 
    var objXMLHttp=null;
    if (window.XMLHttpRequest){
      objXMLHttp=new XMLHttpRequest();
    }else if (window.ActiveXObject){
      objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    return objXMLHttp;
  } 
  
  function check_data(form, webRoot){
  	xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
      alert ("Prohlížeč nepodporuje HTTP Request");
      return;
    }
    var data = '';
    var f_length = form.length;
    var form_id = 0;
    for(i=0;i<f_length;i++){
    	if(form.elements[i].name=="form_contact_id"){
    		form_id = form.elements[i].value;
    	}
    	data += form.elements[i].name + '=' + form.elements[i].value + '&';
    }
    var url= webRoot + "inc/contact_check_data.inc.php";
    xmlHttp.onreadystatechange=stateChangedCheckData;
    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(data);
    formular_global = form.id;
    form_id_global = form_id;
  } 
  
  
  function stateChangedCheckData(){ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
      var text = xmlHttp.responseText;
    	if(text == "ok"){
    		document.getElementById("error_contact_"+form_id_global).style.display="none";
      	document.getElementById("save_form["+form_id_global+"]").value="1";
      	document.getElementById(formular_global).submit();
      }else{
      	document.getElementById("error_contact_"+form_id_global).style.display="inline";
      	document.getElementById("error_contact_"+form_id_global).innerHTML=text;
      }
    } 
  }
  
  
  function changeImageAndText(fotoId,imgId, divId){
  	xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
      alert ("Prohlížeč nepodporuje HTTP Request");
      return;
    }
    var url="/inc/foto_big_change_foto.inc.php?foto_id="+fotoId;
    xmlHttp.onreadystatechange=stateChangedCheckDataImage;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    xmlHttp.imgId = imgId;
    xmlHttp.divId = divId;
  } 
  
  
  function stateChangedCheckDataImage(){ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
      var text = xmlHttp.responseText;
      document.getElementById("PhotoDetail").innerHTML=text;
    } 
  }
  
  
  function guestbook_check_data(form, webRoot){
  	xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
      alert ("Prohlížeč nepodporuje HTTP Request");
      return;
    }
    var data = '';
    var f_length = form.length;
    for(i=0;i<f_length;i++){
    	data += form.elements[i].name + '=' + form.elements[i].value + '&';
    }
    var url=webRoot + "inc/guestbook_check_data.inc.php";
    xmlHttp.onreadystatechange=stateChangedGuestbookCheckData;
    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(data);
  } 
  
  
  function stateChangedGuestbookCheckData(){ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
      var text = xmlHttp.responseText;
    	if(text == "ok"){
    		document.getElementById("error_guestbook").style.display="none";
      	document.getElementById("save_form").value="1";
      	document.getElementById("guestbookForm").submit();
      }else{
      	document.getElementById("error_guestbook").style.display="inline";
      	document.getElementById("error_guestbook").innerHTML=text;
      }
    } 
  }

