/************************************************************/
/****                 Het AJAX Script                     ***/
/************************************************************/
var xmlHttp;
var xmlHttpSD;

var whichLink = "";
var whichElement = "";
var whatLink = "";
var whatElement = "";

function showPrijsTest()
{ 
	var whichLink = "haalprijs.asp";
	var whichElement = "opleidingskosten";
	document.getElementById(whichElement).innerHTML = "opletten";
}
function showPrijs()
{ 

whichLink = "haalprijs.asp";
whichElement = "opleidingskosten";

//this shows the "working" graphic when the query page is retrieving data
//document.getElementById(whichElement).innerHTML = "<div align=center><b>Working....</b><br><br><img src='workingBar.gif'></div>"
document.getElementById(whichElement).innerHTML = "even geduld a.u.b....";
//by setting these values to "" it prevents an undefined error. Also defining these outside of the function will add existing data to the variable which will cause an error.
var theElement = "";
var daString = "";
xmlHttp=GetXmlHttpObject();

//this for block creates the string with all the data in the url. The loop goes through each element and assigns the form name and the value to the string creating a "first=brian&last=collier' string if the form contains a 'first' field and a 'last' field.
//for (i=0; i<howManyElement; i++){	
 theElement = document.getElementById("opleiding_pulldown");
 if (!(theElement.options[theElement.selectedIndex].id == ""))
	{
	daString = "opleidings_id="+theElement.options[theElement.selectedIndex].id+"&";	
	}
 else 
	{
	daString = "opleidings_id=32&";
	}
//}
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
 
//the 'whichLink' variable is assigned on the page making the request. 
var url=whichLink;
url=url+"?"+daString;
url=url+"sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

//alert(url)//this is used to view the URL being sent to the query page.
}


function showStartData()
{ 
//whatLink = "ajax/haalStartData.asp";
whatLink = "getlocations.aspx";
//whatLink = "http://imkosvr/ajax/getlocations.aspx";
whatLink = "ajax/getsourcecode.asp";
whatElement = "gewStart";
document.getElementById("gewStartDatum").innerHTML = "<select disabled='true' name='gewensteStartDatum' id='gewensteStartDatum' ><option selected='selected' value='(nog) geen plaats gekozen'> &nbsp; </option>";
//this shows the "working" graphic when the query page is retrieving data
//document.getElementById(whichElement).innerHTML = "<div align=center><b>Working....</b><br><br><img src='workingBar.gif'></div>"
//document.getElementById(whatElement).innerHTML = "even geduld a.u.b....";
document.getElementById(whatElement).innerHTML = "<select disabled='true' name='gewensteStartPlaats' id='gewensteStartPlaats' ><option selected='selected' value='(nog) geen plaats gekozen'> - even geduld a.u.b. - </option>";
//by setting these values to "" it prevents an undefined error. Also defining these outside of the function will add existing data to the variable which will cause an error.
var theElement = "";
var daString = "";
xmlHttpSD=GetXmlHttpObject();	
 theElement = document.getElementById("opleiding_pulldown");
 //alert (theElement.options[theElement.selectedIndex].className).substr(1));
 if (!((theElement.options[theElement.selectedIndex].className).substr(11) == ""))
	{	daString = "K5_code="+ (theElement.options[theElement.selectedIndex].className).substr(11)+"&";		}
 else 
	{	daString = "K5_code=3322&";	}
 //alert (daString);
//}
if (xmlHttpSD==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
 
var url=whatLink;
url=url+"?"+daString;
url=url+"sid="+Math.random();
//xmlHttpSD.onreadystatechange=stateChangedStartData;
//alert(whatElement);
xmlHttpSD.onreadystatechange=stateChangedStartData;
xmlHttpSD.open("GET",url,true);
xmlHttpSD.send(null);

//alert(url)//this is used to view the URL being sent to the query page.
}
function showStartDatums()
{ 
//whatLink = "ajax/haalStartData.asp";
whatLink = "getlocations.aspx";
//whatLink = "http://imkosvr/ajax/getlocations.aspx";
whatLink = "ajax/getsourcecode.asp";
whatElement = "gewStartDatum";

//this shows the "working" graphic when the query page is retrieving data
//document.getElementById(whichElement).innerHTML = "<div align=center><b>Working....</b><br><br><img src='workingBar.gif'></div>"
//document.getElementById(whatElement).innerHTML = "even geduld a.u.b....";									 
//by setting these values to "" it prevents an undefined error. Also defining these outside of the function will add existing data to the variable which will cause an error.
var theElement = "";
var theOtherElement = "";
var daString = "";
xmlHttpSD=GetXmlHttpObject();	
 theElement = document.getElementById("opleiding_pulldown");
 theOtherElement = document.getElementById("gewensteStartPlaats");
 if (!((theElement.options[theElement.selectedIndex].className).substr(11) == ""))
	{	daString = "K5_code="+(theElement.options[theElement.selectedIndex].className).substr(11)+"&plaatsnaam="+theOtherElement.options[theOtherElement.selectedIndex].value+"&";		}
 else 
	{	daString = "K5_code=666"+(theElement.options[theElement.selectedIndex].className).substr(11)+"&plaatsnaam="+theOtherElement.options[theOtherElement.selectedIndex].value+"&";	
		daString = "K5_code=3322"+(theElement.options[theElement.selectedIndex].className).substr(11)+"&plaatsnaam="+theOtherElement.options[theOtherElement.selectedIndex].value+"&";	}
 //alert (daString);
//}
if (xmlHttpSD==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
 
var url=whatLink;
url=url+"?"+daString;
url=url+"sid="+Math.random();
xmlHttpSD.onreadystatechange=stateChangedStartData;
xmlHttpSD.open("GET",url,true);
xmlHttpSD.send(null);

// alert(url)//this is used to view the URL being sent to the query page.
}
function stateChanged() 
{ 
	//if (xmlHttp.readyState==4)
		if (xmlHttpSD.readyState==4)
	{ 	
	document.getElementById(whichElement).innerHTML=xmlHttp.responseText;
	//alert(wElement);
	//document.getElementById(wElement).innerHTML=xmlHttp.responseText;
	}
}

function stateChangedStartData() 
{ 
	if (xmlHttpSD.readyState==4)
	{ 
	//alert ("state changed");
	//alert (xmlHttpSD.responseText);
	document.getElementById(whatElement).innerHTML=xmlHttpSD.responseText;
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}

