var xmlhttp;

function getLekarze() {
	document.getElementById("hdiv").style.height='5000px';
	document.getElementById("wyszList").style.display='block';
	document.getElementById("wyszDoc").style.display='none';
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getLekarze.php";

	var data = document.getElementById("data").value;
/*
	if (document.forms[0].dt1.checked) { var dtNd = 1; } else { var dtNd = 0; }
	if (document.forms[0].dt2.checked) { var dtPn = 1; } else { var dtPn = 0; }
	if (document.forms[0].dt3.checked) { var dtWt = 1; } else { var dtWt = 0; }
	if (document.forms[0].dt4.checked) { var dtSr = 1; } else { var dtSr = 0; }
	if (document.forms[0].dt5.checked) { var dtCz = 1; } else { var dtCz = 0; }
	if (document.forms[0].dt6.checked) { var dtPt = 1; } else { var dtPt = 0; }
	if (document.forms[0].dt7.checked) { var dtSo = 1; } else { var dtSo = 0; }
	var dt = new Array(dtNd, dtPn, dtWt, dtSr, dtCz, dtPt, dtSo);
*/
	//var loc = document.getElementById("loc").value;
	var loc = document.forms[0].loc.value;
	var suid = document.forms[0].suid.value;
	if (suid==43) {
    if (loc=='3' || loc=='4' || loc=='19' || loc=='3,4,19') {
      window.location.href='http://www.luxmedonline.pl/index.php?mod=res_sp5c&sto=1'
    }
	}

	var hourLength = document.forms[0].hour.length;
	for (var i=0; i<hourLength; i++) {
		if(document.forms[0].hour[i].checked) {
			var hour = document.forms[0].hour[i].value;
		}
	}

	url=url+"?loc="+loc+"&data="+data+"&hour="+hour+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function getLekarzHarm(l,d,h,id) {
	document.getElementById("hdiv").style.height='5000px';
	document.getElementById("wyszList").style.display='block';
	document.getElementById("wyszDoc").style.display='none';
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getLekarze.php";

	url=url+"?loc="+l+"&data="+d+"&hour="+h+"&p="+id+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function getAllLekarzHarm(l,d,h,id) {
	document.getElementById("hdiv").style.height='5000px';
	document.getElementById("wyszList").style.display='block';
	document.getElementById("wyszDoc").style.display='none';
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getAllLekarze.php";

	url=url+"?loc="+l+"&data="+d+"&hour="+h+"&p="+id+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function getLekarz(id, s) {
	document.getElementById("hdiv").style.height='0px';
	document.getElementById("wyszList").style.display='none';
	document.getElementById("wyszDoc").style.display='block';
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getLekarz.php";

	url=url+"?p="+id+"&st="+s+"&sid="+Math.random();

	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function getLekarzDays(id, uid) {
	document.getElementById("hdiv").style.height='1000px';
	document.getElementById("wyszList").style.display='none';
	document.getElementById("wyszDoc").style.display='block';
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getLekarz.php";

	url=url+"?p="+id+"&uid="+uid+"&sid="+Math.random();

	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function getLekarzHours(id, uid, data) {
	document.getElementById("hdiv").style.height='1000px';
	document.getElementById("wyszList").style.display='none';
	document.getElementById("wyszDoc").style.display='block';
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getLekarz.php";

	url=url+"?p="+id+"&uid="+uid+"&data="+data+"&sid="+Math.random();

	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function getLekarzHoursSet(id, uid, data, hour) {
	document.getElementById("hdiv").style.height='1000px';
	document.getElementById("wyszList").style.display='none';
	document.getElementById("wyszDoc").style.display='block';
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getLekarz.php";

	url=url+"?p="+id+"&uid="+uid+"&data="+data+"&hours="+hour+"&sid="+Math.random();

	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
/*
function getLekarzHoursSetSub(id, uid, data, hour) {
	document.getElementById("hdiv").style.height='1000px';
	document.getElementById("wyszList").style.display='none';
	document.getElementById("wyszDoc").style.display='block';
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getLekarz.php";

  var rw = '';
  var rb = '';

  if (uid=='1983' || uid=='1344') {
    if (document.getElementById("rodzaj_wizyty" + 0).checked == true) {
      rw = '&rw=0'
    } else if (document.getElementById("rodzaj_wizyty" + 1).checked == true) {
      rw = '&rw=1'
    }
    if (document.getElementById("rodzaj_badania").value=='') {
      alert('Proszę dokładnie przepisać ze skierowania rodzaj badania');
      return;
    } else {
      rb = '&rb='+document.getElementById("rodzaj_badania").value;
    }
  }

	url=url+"?p="+id+"&uid="+uid+"&data="+data+"&hours="+hour+"&sid="+Math.random();

	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
*/
function getLekarzFiltr(s) {
	document.getElementById("hdiv").style.height='1000px';
	document.getElementById("wyszList").style.display='none';
	document.getElementById("wyszDoc").style.display='block';

	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="source/output/getLekarz.php";
	
	var loc = document.forms[1].loc.value;
	//var loc = document.getElementById("loc").value;
	
	var hourLength = document.forms[1].hour.length;
	for (var i=0; i<hourLength; i++) {
		if(document.forms[1].hour[i].checked) {
			var hour = document.forms[1].hour[i].value;
		}
	}

	url=url+"?st="+s+"&loc="+loc+"&hour="+hour+"&sid="+Math.random();

	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged() {
	if (xmlhttp.readyState==(0||1||2||3)){
		document.getElementById("doctors").innerHTML='Wczytywanie danych...<br><img src="images/loader.gif">';
	}
	else if (xmlhttp.readyState==4 && xmlhttp.status==200 ){
		document.getElementById("doctors").innerHTML=xmlhttp.responseText;
	}
}

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;
}
