// JavaScript Document
var whereRequest;
var servicesRequest;
function httpRequestWhere(reqType,url,asynch){
    //Mozilla-based browsers
    if(window.XMLHttpRequest){
        whereRequest = new XMLHttpRequest(  );
    } else if (window.ActiveXObject){
        whereRequest=new ActiveXObject("Msxml2.XMLHTTP");
        if (! whereRequest){
            whereRequest=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    //the request could still be null if neither ActiveXObject
    //initialization succeeded
    if(whereRequest){
		// document.getElementById("events").innerHTML="Good browser";
		// return;
        initReqWhere(reqType,url,asynch);
    } else {
      //  alert("Your browser does not permit the use of all "+
              //"of this application's features!");
	  document.getElementById("solutionMatrix").innerHTML="Bad browser";

    }
}


function handleWhereResponse(){
    if(whereRequest.readyState == 4){
        if(whereRequest.status == 200){
            /* Grab the result as a string */
            var eventsDropDown = whereRequest.responseText;
            document.getElementById("solutionMatrix").innerHTML=eventsDropDown;
			//document.getElementById("personslabel").innerHTML="Select a person";
            
        } else {
            document.getElementById("solutionMatrix").innerHTML="Problem occured";
               //   "the XMLHttpRequest object and the server program.");
        }
    }//end outer if
	
	else
	{
		
	document.getElementById("solutionMatrix").innerHTML="&nbsp;&nbsp;Loading.....<img src='ajax/loading.gif'/>";
	}
	
}


function initReqWhere(reqType,url,bool){
    /* Specify the function that will handle the HTTP response */
    whereRequest.onreadystatechange=handleWhereResponse; 
    whereRequest.open(reqType,url,bool);
    whereRequest.send(null);
}


function getSolution(postVals)
{
		var url="getSolution.php?"+postVals;
        httpRequestWhere("GET",url,true);  
    
}


//services
function httpRequestService(reqType,url,asynch){
    //Mozilla-based browsers
    if(window.XMLHttpRequest){
        servicesRequest = new XMLHttpRequest(  );
    } else if (window.ActiveXObject){
        servicesRequest=new ActiveXObject("Msxml2.XMLHTTP");
        if (! servicesRequest){
            servicesRequest=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    //the request could still be null if neither ActiveXObject
    //initialization succeeded
    if(servicesRequest){
		// document.getElementById("events").innerHTML="Good browser";
		// return;
        initReqService(reqType,url,asynch);
    } else {
      //  alert("Your browser does not permit the use of all "+
              //"of this application's features!");
	  document.getElementById("servicesMatrix").innerHTML="Bad browser";

    }
}


function handleServiceResponse(){
    if(servicesRequest.readyState == 4){
        if(servicesRequest.status == 200){
            /* Grab the result as a string */
            var eventsDropDown = servicesRequest.responseText;
            document.getElementById("servicesMatrix").innerHTML=eventsDropDown;
			//document.getElementById("personslabel").innerHTML="Select a person";
            
        } else {
            document.getElementById("servicesMatrix").innerHTML="Problem occured";
               //   "the XMLHttpRequest object and the server program.");
        }
    }//end outer if
	
	else
	{
		
	document.getElementById("servicesMatrix").innerHTML="&nbsp;&nbsp;Loading.....<img src='ajax/loading.gif'/>";
	}
	
}


function initReqService(reqType,url,bool){
    /* Specify the function that will handle the HTTP response */
    servicesRequest.onreadystatechange=handleServiceResponse; 
    servicesRequest.open(reqType,url,bool);
    servicesRequest.send(null);
}


function getServices(postVals)
{
		var url="getServices.php?"+postVals;
        httpRequestService("GET",url,true);  
    
}

