//onerror = return true;

var xmlhttp;

function showResult(country, str, L, start, page_length) {
  if (str.length<=2) {
    document.getElementById("therapists_result").innerHTML="";
    document.getElementById("therapists_result").className="hidden_therapists_result";
    return;
  }
  xmlhttp=GetXmlHttpObject()
  if (xmlhttp==null) {
    alert ("Your browser does not support XML HTTP Request");
    return;
  }
  var url="fileadmin/templates/scripts/therapists_sess.php";
  url=url+"?c="+country;
  url=url+"&q="+encodeURIComponent(str);
  url=url+"&L="+L;
  url=url+"&start="+start;
  url=url+"&pl="+page_length;
  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged ;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

function deleteTherapist(id, l) {
  if(l == '1') {
    confirmMessage = 'Wollen Sie diesen Therapeuten wirklich löschen?';
  } else {
    confirmMessage = 'Do you really want to delete this therapist?';
  }
  var check = confirm(confirmMessage);
  if (check == true) {
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null) {
	alert ("Your browser does not support XML HTTP Request");
	return;
	}
	var url="fileadmin/templates/scripts/therapists_sess.php";
	url=url+"?id="+id;
	url=url+"&delete=true";
	url=url+"&L="+l;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged ;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
  }
}

function restoreTherapist(id, l) {
  xmlhttp=GetXmlHttpObject()
  if (xmlhttp==null) {
    alert ("Your browser does not support XML HTTP Request");
    return;
  }
  var url="fileadmin/templates/scripts/therapists_sess.php";
  url=url+"?id="+id;
  url=url+"&restore=true";
  url=url+"&L="+l;
  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged ;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

function editTherapist(id, l) {
  xmlhttp=GetXmlHttpObject()
  if (xmlhttp==null) {
    alert ("Your browser does not support XML HTTP Request");
    return;
  }
  var url="fileadmin/templates/scripts/therapists_sess.php";
  url=url+"?id="+id;
  url=url+"&edit=true";
  url=url+"&L="+l;
  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged ;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

function insertTherapist(l) {
  xmlhttp=GetXmlHttpObject()
  if (xmlhttp==null) {
    alert ("Your browser does not support XML HTTP Request");
    return;
  }
  var url="fileadmin/templates/scripts/therapists_sess.php";
  url=url+"?insert=true";
  url=url+"&L="+l;
  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged ;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

function saveTherapist(id, title, firstname, lastname, job, praxis, street, country, zip, city, phone, fax, email, web, special, l) {
  xmlhttp=GetXmlHttpObject()
  if (xmlhttp==null) {
    alert ("Your browser does not support XML HTTP Request");
    return;
  }
  var url="fileadmin/templates/scripts/therapists_sess.php";
  url=url+"?id="+id;
  url=url+"&save=true";
  url=url+"&title="+title;
  url=url+"&firstname="+firstname;
  url=url+"&lastname="+lastname;
  url=url+"&job="+job;
  url=url+"&praxis="+praxis;
  url=url+"&street="+street;
  url=url+"&country="+country;
  url=url+"&zip="+zip;
  url=url+"&city="+city;
  url=url+"&phone="+phone;
  url=url+"&fax="+fax;
  url=url+"&email="+email;
  url=url+"&web="+web;
  url=url+"&special="+special;
  url=url+"&L="+l;
  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged ;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}


function insertsaveTherapist(title, firstname, lastname, job, praxis, street, country, zip, city, phone, fax, email, web, special, l) {
  xmlhttp=GetXmlHttpObject()
  if (xmlhttp==null) {
    alert ("Your browser does not support XML HTTP Request");
    return;
  }
  
  if (l=="1") {
	  var msgfirstname = "Bitte Vornamen angeben.";
	  var msglastname = "Bitte Nachnamen angeben.";
	  var msgpraxis = "Bitte Praxis angeben.";
	  var msgstreet = "Bitte Straße angeben.";
	  var msgcountry = "Bitte Land angeben.";
	  var msgzip = "Bitte PLZ angeben.";
	  var msgcity = "Bitte Stadt angeben.";
  } else {
	  var msgfirstname = "Please fill in firstname.";
	  var msglastname = "Please fill in lastname.";
	  var msgpraxis = "Please fill in praxis.";
	  var msgstreet = "Please fill in street.";
	  var msgcountry = "Please fill in country.";
	  var msgzip = "Please fill in zip.";
	  var msgcity = "Please fill in city.";
  }
  
  
  //if (firstname==null||firstname=="") { alert(msgfirstname); return; }
  //if (lastname==null||lastname=="") { alert(msglastname); return; }
  //if (praxis==null||praxis=="") { alert(msgpraxis); return; }
  //if (street==null||street=="") { alert(msgstreet); return; }
  if (country==null||country=="") { alert(msgcountry); return; }
  if (zip==null||zip=="") { alert(msgzip); return; }
  if (city==null||city=="") { alert(msgcity); return; }
  
  
  
	  var url="fileadmin/templates/scripts/therapists_sess.php";
	  url=url+"?insertsave=true";
	  url=url+"&title="+title;
	  url=url+"&firstname="+firstname;
	  url=url+"&lastname="+lastname;
	  url=url+"&job="+job;
	  url=url+"&praxis="+praxis;
	  url=url+"&street="+street;
	  url=url+"&country="+country;
	  url=url+"&zip="+zip;
	  url=url+"&city="+city;
	  url=url+"&phone="+phone;
	  url=url+"&fax="+fax;
	  url=url+"&email="+email;
	  url=url+"&web="+web;
	  url=url+"&special="+special;
	  url=url+"&L="+l;
	  url=url+"&sid="+Math.random();
	  xmlhttp.onreadystatechange=stateChanged ;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.send(null);
 
}

function hideResult() {
  document.getElementById("therapists_result").innerHTML="";
  document.getElementById("therapists_result").className="hidden_therapists_result";
}

function stateChanged() {
  if (xmlhttp.readyState!=4) {
    document.getElementById("therapists_result").innerHTML='<img src="fileadmin/templates/media/loading.gif" width="48" />';
    document.getElementById("therapists_result").className="visible_therapists_result";
  }
  if (xmlhttp.readyState==4) {
    document.getElementById("therapists_result").innerHTML=xmlhttp.responseText;
    document.getElementById("therapists_result").className="visible_full_therapists_result";
  }
}

function GetXmlHttpObject() {
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    return new XMLHttpRequest();
  }
  if (window.ActiveXObject) {
    // code for IE6, IE5
    return new ActiveXObject("Microsoft.XMLHTTP");
  }
  return null;
}


