/*destination loader added by amila*/
function loadResRegions()
{
	var topRegionArr = topRegionList2.split(",");
	var arrLength = topRegionArr.length;
	//var topRegion = document.form1.Country;

	var topRegionCode = "";
	var topRegionText = "";
    var count = -1;
	var selectedCountryIndex = 0;

	deleteAllOptions(document.form1.ResCountry);
	for (var i=0; i < arrLength; i++)
	{
		topRegionCode = topRegionArr[i];
		i++;
		topRegionText =  topRegionArr[i];

		var opt = new Option(topRegionText,topRegionCode);
		//topRegion.options[topRegion.options.length] = opt;		
		document.form1.ResCountry.options.add(opt);
        count++;
		/*if ( topRegionCode == document.form1.ResCountry.value)
		{
			selectedCountryIndex = count + 1;
		}*/  
  	}
	count++;
    document.form1.Country.selectedIndex = selectedCountryIndex;

/*	var topRegionArr = topRegionList.split(",");
	var arrLength = topRegionArr.length;
	//var topRegion = document.form1.Country;

	var topRegionCode = "";
	var topRegionText = "";
    var count = -1;
	var selectedCountryIndex = 0;

	for (var i=0; i < arrLength; i++)
	{
		topRegionCode = topRegionArr[i];
		i++;
		topRegionText =  topRegionArr[i];

		var opt = new Option(topRegionText,topRegionCode);
		//topRegion.options[topRegion.options.length] = opt;

        count++;
		if ( topRegionCode == document.form1.selectedCountry.value)
		{
			selectedCountryIndex = count + 1;
		}
  	}
	count++;
    document.form1.Country.selectedIndex = selectedCountryIndex;*/
	
}

function loadTopRegions()
{
/*	var topRegionArr = topRegionList.split(",");
	var arrLength = topRegionArr.length;
	//var topRegion = document.form1.Country;

	var topRegionCode = "";
	var topRegionText = "";
    var count = -1;
	var selectedCountryIndex = 0;

	for (var i=0; i < arrLength; i++)
	{
		topRegionCode = topRegionArr[i];
		i++;
		topRegionText =  topRegionArr[i];

		var opt = new Option(topRegionText,topRegionCode);
		//topRegion.options[topRegion.options.length] = opt;

        count++;
		if ( topRegionCode == document.form1.selectedCountry.value)
		{
			selectedCountryIndex = count + 1;
		}
  	}
	count++;
    document.form1.Country.selectedIndex = selectedCountryIndex;*/
	
}


function loadMiddleRegions()
{
    var sel = document.form1.Region;
	var sel2 = document.form1.RetRegion;
	//if(document.form1.Country.value != "")
	{
		var selectedTopRegionCode = replaceHifen(document.form1.Country.value);

		var pickIndex = 0;
		var dropIndex = 0;
		var count = 0;

		var temp = "";
		temp = eval(selectedTopRegionCode);

		if(temp != "")
		{
			deleteAllOptions(sel);
			deleteAllOptions(sel2);

			var middleRegionArr = temp.split(",");
			var middleRegionCode = "";
			var middleRegionText = "";
			var arrLength = middleRegionArr.length;

			for (var i=0; i < arrLength; i++)
			{
				middleRegionCode = middleRegionArr[i];
				i++;
				middleRegionText =  middleRegionArr[i];
				var opt1 = new Option(middleRegionText,middleRegionCode);
				var opt2 = new Option(middleRegionText,middleRegionCode);
				sel.options[sel.options.length] = opt1;
				sel2.options[sel2.options.length] = opt2;

				if (document.form1.selectedPickupRegion.value == middleRegionCode)
				{
					pickIndex = count;
				}
				if (document.form1.selectedDropoffRegion.value == middleRegionCode)
				{
					dropIndex = count;
				}

				count ++;
			}

			document.form1.Region.selectedIndex = pickIndex;
			document.form1.RetRegion.selectedIndex = dropIndex;
		}
		else
		{
			deleteAllOptions(sel);
			deleteAllOptions(sel2);
		}
	}
	//else
	//{
	//	var opt1 = new Option("Please Select","");
	//	var opt2 = new Option("Please Select","");
	//	sel.options[sel.options.length] = opt1;
	//	sel2.options[sel2.options.length] = opt2;
	//}

}

function setIndex()
{
    document.form1.RetRegion.selectedIndex = document.form1.Region.selectedIndex;
}
function replaceHifen(code)
{
    var tempCode = code.replace("-","_");
    return tempCode;
}

function deleteAllOptions (select)
{
  select.options.length = 0;
}



/*end*/
