﻿// JScript File

function CategoryChanged()
{
	var strCategory;
	var strReturn;

	debugger;
	

	/* Get Selected Category */
	strCategory = 
	  document.all.Srcinfo_ddlCountry.options( 
	  document.all.Srcinfo_ddlCountry.selectedIndex).value
// alert(strCategory); // Step 1
	
	/* Setup call to Web Service */
	objCall = DOMService.createCallOptions();
	objCall.async = false;
	objCall.funcName = "GetArea"
//alert(strCategory); // Step 2

   /* Pass category */	
	objCall.params = new Array();
	objCall.params.intCountryId = strCategory;

	/* Call Web Service */
	strReturn = DOMService.Services.callService(objCall);
	
	// alert(strCategory); // Step 3
// alert(strReturn); // Step 4
	/* Pass delimited String to function to load Drop Down */
	/* String is in format "|Text:Value" */
	PopulateDropDown(strReturn, "Srcinfo_ddlArea");
	
	/*document.all.lblMsg.innerText = '';*/
}


function PopulateDropDown(ReturnString, DDLName)
{

	var i;
	var arrValues
	var arrValue

	arrValues = ReturnString.value.split("|");

   /* Clear old values */
	document.all[DDLName].length = 0;
	/* Add blank Option */
	document.all[DDLName].options[0] = new Option("","");

	for(i=0;i <= arrValues.length-1; i++) {
      /* Split String into each Option */	
		arrValue = arrValues[i].split(":");
		
		/* Load Option into Drop Down */
		document.all[DDLName].options[i] = 
		  new Option(arrValue[0], arrValue[1]);
		  document.all[DDLName].disabled = false;
		  
	}
}