
// declare a global  XMLHTTP Request object
//var XmlHttpObj;
// create an instance of XMLHTTPRequest Object, varies with browser type, try for IE first then Mozilla
// called from onChange or onClick event of the continent dropdown list
function DSStateOnChange(thisForm) 
{
//alert(thisForm);
    var DSCategory = document.getElementById("DSStates");
    
    // get selected continent from dropdown list
    var selectedContinent = 0;
	// alert(thisForm.DSStates.selectedIndex);
    // url of page that will send xml data back to client browser
//	SelectedContinent = 0;
	len = thisForm.DSStates.length;
	i = 0;
	chosen = 0;


	if (thisForm.DSStates[0].selected == false)
	{
		
		for (i = 0; i < len; i++) 
		{
			if (thisForm.DSStates[i].selected) 
			{ chosen = chosen + 1; } 
		}
		if (chosen == 1 )
		{ 
			thisForm.DSDistricts.disabled = false; 
			selectedContinent = DSCategory.options[DSCategory.selectedIndex].value;
		}
		else
		{ 
			thisForm.DSDistricts.disabled = true; 
			selectedContinent = 0;
		}

	}	



    var requestUrl;
    // use the following line if using asp
    requestUrl = "xml_districts_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
    // use the following line if using php
    // requestUrl = "xml_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
	
//  alert(requestUrl);
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
//		alert("XmlHttpObj");
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandler1;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}


// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandler1()
{
//	alert("readystate " + XmlHttpObj.readyState);
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
//		alert("readystate " + XmlHttpObj.status);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
//			alert("in 200:"+XmlHttpObj.responseXML.documentElement);
			PopulateDSDistricts(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}

// populate the contents of the country dropdown list
function PopulateDSDistricts(countryNode)
{
//	alert("countryNode"+countryNode);
    var DSSubCategory = document.getElementById("DSDistricts");
//	alert("DSSubCategory: "+DSSubCategory);
	// clear the country list 
	for (var count = DSSubCategory.options.length-1; count >-1; count--)
	{
		DSSubCategory.options[count] = null;
	}

	var countryNodes = countryNode.getElementsByTagName('country');
	var idValue;
	var textValue; 
	var optionItem;
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < countryNodes.length; count++)
	{
		textValue = GetInnerText(countryNodes[count]);
//		alert(textValue);
		idValue = countryNodes[count].getAttribute("id");
		//alert(idValue);
		if(count==0)
		{
			optionItem = new Option( textValue, idValue,  true, true);
			}
		else
		{
			optionItem = new Option( textValue, idValue,  false, false);
			}
		
		DSSubCategory.options[DSSubCategory.length] = optionItem;
	}
}

// returns the node text value 
/* Background state dropdown start*/

function bgDSStateOnChange(thisForm) 
{
    var DSCategory = document.getElementById("bgDSStates");
    
    // get selected continent from dropdown list
    var selectedContinent = 0;
	// alert(thisForm.bgDSStates.selectedIndex);
    // url of page that will send xml data back to client browser
//	SelectedContinent = 0;
	len = thisForm.bgDSStates.length;
	i = 0;
	chosen = 0;


	if (thisForm.bgDSStates[0].selected == false)
	{
		
		for (i = 0; i < len; i++) 
		{
			if (thisForm.bgDSStates[i].selected) 
			{ chosen = chosen + 1; } 
		}
		if (chosen == 1 )
		{ 
			thisForm.bgDSDistricts.disabled = false; 
			selectedContinent = DSCategory.options[DSCategory.selectedIndex].value;
		}
		else
		{ 
			thisForm.bgDSDistricts.disabled = true; 
			selectedContinent = 0;
		}

	}	



    var requestUrl;
    // use the following line if using asp
    requestUrl = "xml_districts_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
    // use the following line if using php
    // requestUrl = "xml_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
	
//  alert(requestUrl);
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
//		alert("XmlHttpObj");
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandlerbgState;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}


// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandlerbgState()
{
//	alert("readystate " + XmlHttpObj.readyState);
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
//		alert("readystate " + XmlHttpObj.status);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
//			alert("in 200:"+XmlHttpObj.responseXML.documentElement);
			PopulatebgDSDistricts(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}

// populate the contents of the country dropdown list
function PopulatebgDSDistricts(countryNode)
{
//	alert("countryNode"+countryNode);
    var DSSubCategory = document.getElementById("bgDSDistricts");
//	alert("DSSubCategory: "+DSSubCategory);
	// clear the country list 
	for (var count = DSSubCategory.options.length-1; count >-1; count--)
	{
		DSSubCategory.options[count] = null;
	}

	var countryNodes = countryNode.getElementsByTagName('country');
	var idValue;
	var textValue; 
	var optionItem;
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < countryNodes.length; count++)
	{
		textValue = GetInnerText(countryNodes[count]);
//		alert(textValue);
		idValue = countryNodes[count].getAttribute("id");
		//alert(idValue);
		if(count==0)
		{
			optionItem = new Option( textValue, idValue,  true, true);
			}
		else
		{
			optionItem = new Option( textValue, idValue,  false, false);
			}
		
		DSSubCategory.options[DSSubCategory.length] = optionItem;
	}
}
/* Background state dropdown end*/


/* Hospital state dropdown start*/

function hDSStateOnChange(thisForm) 
{
    var DSCategory = document.getElementById("hDSStates");
    
    // get selected continent from dropdown list
    var selectedContinent = 0;
	// alert(thisForm.hDSStates.selectedIndex);
    // url of page that will send xml data back to client browser
//	SelectedContinent = 0;
	len = thisForm.hDSStates.length;
	i = 0;
	chosen = 0;


	if (thisForm.hDSStates[0].selected == false)
	{
		
		for (i = 0; i < len; i++) 
		{
			if (thisForm.hDSStates[i].selected) 
			{ chosen = chosen + 1; } 
		}
		if (chosen == 1 )
		{ 
			thisForm.hDSDistricts.disabled = false; 
			selectedContinent = DSCategory.options[DSCategory.selectedIndex].value;
		}
		else
		{ 
			thisForm.hDSDistricts.disabled = true; 
			selectedContinent = 0;
		}

	}	



    var requestUrl;
    // use the following line if using asp
    requestUrl = "xml_districts_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
    // use the following line if using php
    // requestUrl = "xml_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
	
//  alert(requestUrl);
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
//		alert("XmlHttpObj");
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandlerhState;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}


// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandlerhState()
{
//	alert("readystate " + XmlHttpObj.readyState);
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
//		alert("readystate " + XmlHttpObj.status);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
//			alert("in 200:"+XmlHttpObj.responseXML.documentElement);
			PopulatehDSDistricts(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}

// populate the contents of the country dropdown list
function PopulatehDSDistricts(countryNode)
{
//	alert("countryNode"+countryNode);
    var DSSubCategory = document.getElementById("hDSDistricts");
//	alert("DSSubCategory: "+DSSubCategory);
	// clear the country list 
	for (var count = DSSubCategory.options.length-1; count >-1; count--)
	{
		DSSubCategory.options[count] = null;
	}

	var countryNodes = countryNode.getElementsByTagName('country');
	var idValue;
	var textValue; 
	var optionItem;
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < countryNodes.length; count++)
	{
		textValue = GetInnerText(countryNodes[count]);
//		alert(textValue);
		idValue = countryNodes[count].getAttribute("id");
		//alert(idValue);
		if(count==0)
		{
			optionItem = new Option( textValue, idValue,  true, true);
			}
		else
		{
			optionItem = new Option( textValue, idValue,  false, false);
			}
		
		DSSubCategory.options[DSSubCategory.length] = optionItem;
	}
}
/* Hospital state dropdown end*/


function DSCountryOnChange()
{

var DSCountry = document.getElementById("DSCountry");
//alert(DSCountry.options[DSCountry.selectedIndex].value);
if(DSCountry.options[DSCountry.selectedIndex].value!=1)
{
	document.getElementById("DSStates").disabled = true;
	document.getElementById("DSDistricts").disabled = true;  

}
else
{
document.getElementById("DSDistricts").disabled = false;
document.getElementById("DSStates").disabled = false; 
}

}
function bgDSCountryOnChange()
{

var DSCountry = document.getElementById("bgDSCountry");
//alert(DSCountry.options[DSCountry.selectedIndex].value);
if(DSCountry.options[DSCountry.selectedIndex].value!=1)
{
	document.getElementById("bgDSStates").disabled = true;
	document.getElementById("bgDSDistricts").disabled = true;  

}
else
{
document.getElementById("bgDSDistricts").disabled = false;
document.getElementById("bgDSStates").disabled = false; 
}

}

function hDSCountryOnChange()
{

var DSCountry = document.getElementById("hDSCountry");
//alert(DSCountry.options[DSCountry.selectedIndex].value);
if(DSCountry.options[DSCountry.selectedIndex].value!=1)
{
	document.getElementById("hDSStates").disabled = true;
	document.getElementById("hDSDistricts").disabled = true;  

}
else
{
document.getElementById("hDSDistricts").disabled = false;
document.getElementById("hDSStates").disabled = false; 
}

}

//Validation district AJAX
function volunteerDSStateOnChange(thisForm,vtid) 
{
//alert(thisForm);
vtypeid=vtid;
vdsstatesid="vDSStates"+vtid;
vdsdistrictsid="vDSDistricts"+vtid;
    var DSCategory = document.getElementById(vdsstatesid);
    
    // get selected continent from dropdown list
    var selectedContinent = 0;
	// alert(vdsstatesid);
    // url of page that will send xml data back to client browser
//	SelectedContinent = 0;
/*
	len = thisForm.vdsstatesid.length;
    //alert(len);
	i = 0;
	chosen = 0;


	if (thisForm.vdsstatesid[0].selected == false)
	{
		
		for (i = 0; i < len; i++) 
		{
			if (thisForm.vdsstatesid[i].selected) 
			{ chosen = chosen + 1; } 
		}
		if (chosen == 1 )
		{ 
			thisForm.vdsdistrictsid.disabled = false; 
			selectedContinent = DSCategory.options[DSCategory.selectedIndex].value;
		}
		else
		{ 
			thisForm.vdsdistrictsid.disabled = true; 
			selectedContinent = 0;
		}

	}	
*/

selectedContinent = DSCategory.options[DSCategory.selectedIndex].value;
    var requestUrl;
    // use the following line if using asp
    requestUrl = "xml_districts_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
    // use the following line if using php
    // requestUrl = "xml_data_provider.php" + "?filter=" + encodeURIComponent(selectedContinent);
	
//  alert(requestUrl);
	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
//		alert("XmlHttpObj");
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = volunteerStateChangeHandler1;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
}


// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function volunteerStateChangeHandler1()
{
//	alert("readystate " + XmlHttpObj.readyState);
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
//		alert("readystate " + XmlHttpObj.status);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
//			alert("in 200:"+XmlHttpObj.responseXML.documentElement);
			volunteerPopulateDSDistricts(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}

// populate the contents of the country dropdown list
function volunteerPopulateDSDistricts(countryNode)
{
//	alert("countryNode"+countryNode);
    var DSSubCategory = document.getElementById("vDSDistricts"+vtypeid);
//	alert("DSSubCategory: "+DSSubCategory);
	// clear the country list 
	for (var count = DSSubCategory.options.length-1; count >-1; count--)
	{
		DSSubCategory.options[count] = null;
	}

	var countryNodes = countryNode.getElementsByTagName('country');
	var idValue;
	var textValue; 
	var optionItem;
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < countryNodes.length; count++)
	{
		textValue = GetInnerText(countryNodes[count]);
//		alert(textValue);
		idValue = countryNodes[count].getAttribute("id");
		//alert(idValue);
		if(count==0)
		{
			optionItem = new Option( textValue, idValue,  true, true);
			}
		else
		{
			optionItem = new Option( textValue, idValue,  false, false);
			}
		
		DSSubCategory.options[DSSubCategory.length] = optionItem;
	}
}

// returns the node text value 






