var xmlHttp = createXmlHttpRequestObject();
var chyba = 'Nastala chyba.';
function createXmlHttpRequestObject(){	
	var xmlHttp;
	if ( window.ActiveXObject ){
	    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		xmlHttp = new XMLHttpRequest();
  }
  if ( !xmlHttp )
	  alert("Chyba při vytváření objektu.");
	else 
    return xmlHttp;
}
function preloader() {

}
function showBlock(id) {
  if (document.getElementById(id).className == "hidden") {
    document.getElementById(id).className="";
    document.getElementById("firma").checked=true;
    return false
  }
  if (document.getElementById(id).className != "hidden") {
    document.getElementById("firma").checked=false;
    document.getElementById(id).className="hidden";
    return false
  }
}
function showBlockDiv(id) {
  if (document.getElementById(id).className == "hidden") {
    document.getElementById(id).className="";
    return false
  }
  if (document.getElementById(id).className != "hidden") {
    document.getElementById(id).className="hidden";
    return false
  }
}

function checkInput(id) {
  if (document.getElementById(id).checked === true) {
    document.getElementById(id).checked=false;
  }
  else if (document.getElementById(id).checked === false) {
    document.getElementById(id).checked=true;
  }
}
/*
 * Zkontroluje platny format emailove adresy
 */
function validEmail(email)
{
  invalidChars = " /:,;"

  if(email == "")
  {
    return false
  }
  for(i=0; i < invalidChars.length; i++)
  {
    badChar = invalidChars.charAt(i)
    if (email.indexOf(badChar,0) > -1)
    {
      return false
    }
  }
  atPos = email.indexOf("@",1)
  if(atPos == -1)
  {
    return false
  }
  if(email.indexOf("@",atPos+1) > -1)
  {
    return false
  }
  periodPos = email.indexOf(".",atPos)
  if(periodPos == -1)
  {
    return false
  }
  if(periodPos+3 > email.length)
  {
    return false
  }
  return true
}
function validPhone(phonenumber) {
  vyraz = /^[+]?[()/0-9. -]{9,}$/
  if (vyraz.test(phonenumber)==true)
    return true;
  else 
    return false;
}

