var index = 0;
var xmlhttp = new Array();

function change_banner(){
	if(window.XMLHttpRequest){
     	xmlhttp.push(new XMLHttpRequest());
	}
	else if(window.ActiveXObject){
	     xmlhttp.push(new ActiveXObject("Microsoft.XMLHTTP"));
	}
	index = xmlhttp.length - 1;
     if(xmlhttp[index]){
     	var obj = document.getElementById("banner_place");
          xmlhttp[index].open("GET", "./inc/mainbanner.inc", true);
          xmlhttp[index].onreadystatechange = function() {
               if(xmlhttp[index].readyState == 4 && xmlhttp[index].status == 200){
                    obj.innerHTML = xmlhttp[index].responseText;
               }
          }
          xmlhttp[index].send(null);
     }
}

/*====================================AJAX==========================================*/
 function VerifyCareerForm(careerForm) {
  var why = "";

  if((careerForm.jmeno.value == "") && (careerForm.prijmeni.value == "")){
    why += "Před odesláním zadejte své jméno a příjmení.\n";
  }
  if((careerForm.ulice.value == "") && (careerForm.obec.value == "") && (careerForm.psc.value == "")){
  	why += "Před odesláním zadejte svoji adresu.\n";
  }
  if((careerForm.telefon.value == "") && (careerForm.email.value == "") && (careerForm.gsm.value == "")){
    why += "Prosím zadejte Váš telefon nebo e-mailovou adresu nebo mobil, abychom Vás mohli kontaktovat.\n";
  }
  if(careerForm.vzdelani_nazev.value == ""){
  	why += "Prosím vyplňte před odesláním Vaše nejvýše dosažené vzdělání.\n";
  }
  if(careerForm.podminky_pozice.value == ""){
    why += "Před odesláním zadejte o jaké pracovní místo máte zájem.\n";
  }
  if(careerForm.podminky_nastup.value == ""){
  	why += "Prosím zadejte možný nástup do nového zaměstnání.\n";
  }
  if (careerForm.email.value != ""){
       why += checkEmail(contactForm.email.value);
  }

  if (why != ""){
    alert(why);
    return false;
  }

  return true;
}

function checkEmail (strng) {
  var error = "";

  var emailFilter=/^.+@.+\..{2,4}$/;
  if (!(emailFilter.test(strng))) {
    error += "Zadaná e-mailová adresa nemá platný formát.\n";
  }

  var illegalChars= /[\(\)\<\>\,\;\:\\\\[\]]/
  if (strng.match(illegalChars)) {
    error += "Zadaná e-mailová adresa obsahuje nepovolené znaky.\n";
  }
  return error;
}
