var cparticipants = "";
   var cduration = "";
   var cbudget = "";
   var ctype = "";
   
   var http_request = false;
   function makePOSTRequest(url) {
      http_request = true;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
	   /* var objLoaderHolder = document.getElementById("loaderDiv");
		var objLoaderContentHolder = document.getElementById("loaderContent");
		var windowSize = getWindowSize();
		objLoaderHolder.style.height = windowSize.Y + 'px';
		objLoaderHolder.style.display = 'block';
		objLoaderContentHolder.style.top = (windowSize.Y/2 - objLoaderContentHolder.offsetHeight/2 ) + 'px';
		objLoaderContentHolder.style.left = (windowSize.X/2 - objLoaderContentHolder.offsetWidth/2 ) + 'px';*/
	  
      http_request.onreadystatechange = alertContents;
      http_request.open('GET', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      //http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(null);
   }

   function alertContents() {
	   if (http_request.readyState == 1) {
		   outputStr = "<span class='rightText'></span>";
		    var resultDiv = document.getElementById("result");
		   resultDiv.innerHTML = outputStr;
	   }
      if (http_request.readyState == 4) {
	     var objLoaderHolder = document.getElementById("loaderDiv");
	     //objLoaderHolder.style.display = 'none';
         if (http_request.status == 200) {
			//alert(http_request.responseXML.firstChild);
            //result = http_request.responseXML;
			displayResult(http_request.responseXML);
			//document.getElementById('contentspan').innerHTML = result;            
		 } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function getResult() {
	   //alert(document.myform.budget.length);
       makePOSTRequest('findConcept.php?cparticipants='+cparticipants+'&cduration='+cduration+'&cbudget='+cbudget+'&ctype='+ctype);
   }
   
   //Function to create xml object
   function displayResult(result){
	   var xmlResp = result.firstChild;
	   	   
	   var resultDiv = document.getElementById("result");
	      
	   	   
	   if(xmlResp.childNodes.length > 0){
		   outputStr="<ul id='results' class='inline'>";
		   for(j=0;j<xmlResp.childNodes.length;j++){
			  /* if(xmlResp.childNodes[j].childNodes[1].firstChild.data > 1)
			     dayStr = "days";
			   else
			     dayStr =  "day";*/
				 
			    //outputStr=outputStr + "<li><a href="+ xmlResp.childNodes[j].childNodes[2].firstChild.data +"><span>"+ xmlResp.childNodes[j].childNodes[0].firstChild.data + " - " + xmlResp.childNodes[j].childNodes[1].firstChild.data +" " + dayStr + "</span></a></li>";
				outputStr=outputStr + "<li><a href="+ xmlResp.childNodes[j].childNodes[2].firstChild.data +"><span>"+ xmlResp.childNodes[j].childNodes[0].firstChild.data + "</span></a></li>";
			}
			outputStr=outputStr + "</ul>";
	   }else{
		     	outputStr= "<span class='err'>Geen Resultaten Gevonden</span>";
	   }
	   
	   resultDiv.innerHTML = outputStr;
   }
   
   //----------------------------------------------------------------------------------------------
   function getWindowSize()	{
   
	  var myWidth = 0, myHeight = 0;
	 
	  if( typeof( window.innerWidth ) == 'number' )
	  {
		//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
	  }
	  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	  {
		   //IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth ;
			myHeight = document.documentElement.clientHeight;
	  }
	  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	  {
		//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
	  }
	 
	  var X= myWidth;
	  var Y= myHeight;
	 
	  return {X:X, Y:Y};
	}
	
// JavaScript Document
//document.getElementById("duration").onClick = getResult();

function makeactive(tab) { 
	document.getElementById("tab0").className = ""; 
	document.getElementById("tab1").className = ""; 
	document.getElementById("tab2").className = ""; 
	document.getElementById("tab3").className = "";
	document.getElementById("tab4").className = ""; 
	document.getElementById("tab5").className = ""; 
	document.getElementById("tab"+tab).className = "active";
	document.getElementById("step0").style.display = "none"; 
	document.getElementById("step1").style.display = "none"; 
	document.getElementById("step2").style.display = "none";
	document.getElementById("step3").style.display = "none"; 
	document.getElementById("step4").style.display = "none"; 
	document.getElementById("step5").style.display = "none"; 
	document.getElementById("step"+tab).style.display = "block"; 
	
	// get values after pressing result tab
	if(tab==5){
		cparticipants = "";
		cduration = "";
		cbudget = "";
		ctype = "";
   
		//To get participant no.
		if(document.getElementById("participants").value != ""){
			cparticipants = document.getElementById("participants").value
		}
				
		// To get duration		
		durationObj=document.myform.duration;
		var durationLength = durationObj.length;
		for(var i = 0; i < durationLength; i++) {
			if(durationObj[i].checked) {
				cduration=durationObj[i].value;
			}
		}
		
		//To get budget
		budgetObj=document.myform.budget;
		var budgetLength = budgetObj.length;
		for(var i = 0; i < budgetLength; i++) {
			if(budgetObj[i].checked) {
				cbudget=budgetObj[i].value;
			}
		}
		
		// To get type
		temp_cnt=0;
		typeObj=document.myform.type;
		var typeLength = typeObj.length;
		for(var i = 0; i < typeLength; i++) {
			if(typeObj[i].checked) {
				if(temp_cnt>0){
					ctype=ctype + ",";
				}
				//alert(ctype);
				ctype=ctype + typeObj[i].value;
				temp_cnt++;
			}
		}
	    //alert("cparticipants : " + cparticipants +" cduration : " + cduration +" cbudget : " + cbudget + " ctype : " + ctype);
		if(cparticipants == "" || cduration =="" || cbudget=="" || ctype==""){
			var resultDiv = document.getElementById("result");
			resultDiv.innerHTML = "<span class='err'>Gelieve alle stappen te doorlopen om de resultaten te zien.</span>";
		}else{
		 getResult();
		}
	}
} 	
	
function scrollhere(here){
	//scrollIntoView(where);
	
//alert(here);
	var mymsg = document.getElementById(here);
	mymsg.scrollIntoView();
}	
	
