﻿//GRS.Distribution.GoRedSea.Client.WebApp.WebServices.SmartMask.GetLivingInCountries(currentLanguageCode, _onGetLivingInCountriesFeedbackReceived, _onGetLivingInCountriesFeedbackFailed, this);    
//var dropDownListAccommodationNames;
//function PrepareAccommodationNames(destinationListControl, accommodationListControl, isInnerMask){
//    
//    //----------------
//    //Extract Controls
//    dropDownListAccommodationNames = GetControl(accommodationListControl);
//    dropDownListDestinations = GetControl(destinationListControl);
//    
//    if(isInnerMask != true || ( isInnerMask == true && dropDownListAccommodationNames.options.length == 1 ))    
//    {    
//        //------------------------
//        //Reset AccommodationNames
//        dropDownListAccommodationNames.options.length = 1;
//        
//        //------------------------------------------------
//        //Call Web service to fill accommdation names data   
//        if(dropDownListDestinations.value != "0")
//        {
//            dropDownListAccommodationNames.options[1] = new Option("Loading...", "0");
//            var selectedDepartureLocation = selectedDepartureLocationValue = GetControl( "dropDownListDepartureLocations", 0, "select" ).value.split("-")[0];    
//            var productType = GetProductType();            
//            GRS.Distribution.GoRedSea.Client.WebApp.WebServices.SmartMask.GetAccommodationNames( dropDownListDestinations.value, productType, selectedDepartureLocation, _onGetAccommodationNamesFeedbackReceived, _onGetAccommodationNamesFeedbackFailed, this);    
//        }
//    }
//    else
//    {
//        GlobalPreSelectedAccName = GlobalPreSelectedAccName.toLowerCase();
//        
//        //-----------------------------
//        //Pre select accommodation name
//        for(var i = 0; i < dropDownListAccommodationNames.options.length; i++)
//        {
//           var accommodationCode = dropDownListAccommodationNames.options[i].value.toLowerCase();           
//           var AccCodeParts = accommodationCode.split("-");
//           if( String.format("{0}-{1}",AccCodeParts[1],AccCodeParts[2]) == GlobalPreSelectedAccName)
//           {
//                dropDownListAccommodationNames.selectedIndex = i;
//                break;
//           }
//        }
//    }
//    
//}

//function _onGetAccommodationNamesFeedbackReceived(results, context) {   
//   if(GlobalPreSelectedAccName == null)
//   {
//        dropDownListAccommodationNames.options.length = 1;
//        for(var i = 0; i < results.length; i++)                
//           dropDownListAccommodationNames.options[i+1] = new Option(results[i].split(":")[0],results[i].split(":")[1]);            
//   }
//   else
//   {
//         var selectedIndex = -1;
//         GlobalPreSelectedAccName = GlobalPreSelectedAccName.toLowerCase();
//         
//         var AccCodeToBeSelectedParts = GlobalPreSelectedAccName.split("-");
//         
//         //-----------------------------------
//         //Normal case used in the refine mask          
//         if(AccCodeToBeSelectedParts.length == 3)
//         {
//               for(var i = 0; i < results.length; i++)
//               {
//                   var accommodationCode = results[i].split(":")[1].toLowerCase();
//                   dropDownListAccommodationNames.options[i+1] = new Option(results[i].split(":")[0],accommodationCode);                   
//                   
//                   if( accommodationCode.toLowerCase() == GlobalPreSelectedAccName.toLowerCase())
//                        selectedIndex = i +1;        
//               }
//           }           
//           else
//           {
//                //--------------------------------------------------------------------
//                //Special case in case mapping the code from the CMS to the inner mask
//                for(var i = 0; i < results.length; i++)
//                {
//                   var accommodationCode = results[i].split(":")[1].toLowerCase();
//                   dropDownListAccommodationNames.options[i+1] = new Option(results[i].split(":")[0],accommodationCode);                   
//                   
//                   var AccCodeParts = accommodationCode.split("-");
//                    if( String.format("{0}-{1}",AccCodeParts[1],AccCodeParts[2]) == GlobalPreSelectedAccName)
//                        selectedIndex = i +1;        
//                }            
//           }      
//         
//         if(selectedIndex != -1)         
//            dropDownListAccommodationNames.selectedIndex = selectedIndex;
//            
//         GlobalPreSelectedAccName = null;              
//   }  
//        
//       
//}

//function _onGetAccommodationNamesFeedbackFailed(results) {
//}

var dropDownListLivingInCountries;
function PrepareLivingInCountries(livingInCountriesCountrol, languageCodeControl){
    
    //----------------
    //Extract Controls
    dropDownListLivingInCountries = GetControl(livingInCountriesCountrol);
    if(dropDownListLivingInCountries.options.length == 2)    
    {
        //------------------------------------------------
        //Call Web service to fill living in countries data   
        dropDownListLivingInCountries.options[2] = new Option("Loading...", "0");
        var currentLanguageCode = GetControl(languageCodeControl).value;
        GRS.Distribution.GoRedSea.Client.WebApp.WebServices.SmartMask.GetLivingInCountries( currentLanguageCode, _onGetLivingInCountriesFeedbackReceived, _onGetLivingInCountriesFeedbackFailed, this);    
    }
}

function _onGetLivingInCountriesFeedbackReceived(results, context) {
    dropDownListLivingInCountries.options.length = 2;
    for(var i = 0; i < results.length; i++)                
       dropDownListLivingInCountries.options[i+2] = new Option(results[i].split(":")[0],results[i].split(":")[1]);            
}

function _onGetLivingInCountriesFeedbackFailed(results) {
}

//var GlobalPreSelectedAccName = null;   
//function ChangeHeaderMode(imageControl)
//{
//	switch(imageControl)
//	{	
//		case "CreateYourHolliday":
//			var createYourHollidayControl = GetControl( "CreateYourHolliday",0,"img" );
//			var readyMadePackagesControl = GetControl( "ReadyMadePackages",0,"img" );
//			
//			var BookingProcessKind = GetControl( "BookingProcessKind",0,"table" );
//			var BookingProcessCategory = GetControl( "BookingProcessCategory",0,"input" );

//			BookingProcessKind.style.visibility = "hidden";
//			BookingProcessKind.style.display = "none";
//			
//			createYourHollidayControl.src = createYourHollidayControl.src.replace("create-inactive","create-active");
//			readyMadePackagesControl.src = readyMadePackagesControl.src.replace("search-active","search-inactive");
//			BookingProcessCategory.value = "CYH"
//			break;
//		case "ReadyMadePackages":
//			var createYourHollidayControl = GetControl( "CreateYourHolliday",0,"img" );
//			var readyMadePackagesControl = GetControl( "ReadyMadePackages",0,"img" );
//			
//			var BookingProcessKind = GetControl( "BookingProcessKind",0,"table" );
//			var BookingProcessCategory = GetControl( "BookingProcessCategory",0,"input" );
//			
//			BookingProcessKind.style.visibility = 'hidden';
//			BookingProcessKind.style.display = "none";
//					
//			createYourHollidayControl.src = createYourHollidayControl.src.replace("create-active","create-inactive");
//			readyMadePackagesControl.src = readyMadePackagesControl.src.replace("search-inactive","search-active");
//			BookingProcessCategory.value = "RMP"
//				
//			AdjustBookingProcessToFA();		
//			break;
//	}
//	
//		
//}

function AdjustBookingProcessToFA()
{
	var FADBookingProcess 	= GetControl( 'FARadio', 0,'input');
	currentBookingProcessKind = "FA";
	FADBookingProcess.checked = true;
	AdjustBookingProcessInterface();
}

function GetDepartureCountry()
{
	var selectedDepartureLocationValue = "";

    switch(GetBookingProcessKind())
    {    
        case "FA":
            selectedDepartureLocationValue = GetControl( "dropDownListDepartureLocations", 0, "select" ).value;
        break;
        case "AO":
            selectedDepartureLocationValue = GetControl( "dropDownListLivingInLocations", 0, "select" ).value;            
        break;
    }
    
    var firstDashIndex = selectedDepartureLocationValue.indexOf("-");
	var lastDashIndex = selectedDepartureLocationValue.lastIndexOf("-");
    var length = selectedDepartureLocationValue.length;	
	selectedCountryValue = selectedDepartureLocationValue.substring( lastDashIndex +1, length );
    
    
	    
//	if(GetBookingProcessKind() == "FA")
//	{
//	    selectedDepartureLocationValue = GetControl( "dropDownListDepartureLocations", 0, "select" ).value;
//	    var firstDashIndex = selectedDepartureLocationValue.indexOf("-");
//	    var lastDashIndex = selectedDepartureLocationValue.lastIndexOf("-");
//	    var length = selectedDepartureLocationValue.length;
//    	
//	    selectedCountryValue = selectedDepartureLocationValue.substring( lastDashIndex +1, length );
//	}
	return selectedCountryValue;
}
//function updateAccTypesDropDown( dropDownName )
//{
//    var selectedCountryValue = null;
//    
//    if(GetBookingProcessKind() == "AO")
//	    selectedCountryValue = "*";
//	else
//	    selectedCountryValue = GetDepartureCountry();
//	    
//	
//	var productType = GetProductType();
//	
//	var chosenAccTypes = accTypesMapping[productType][selectedCountryValue];
//    var dropDown = GetControl(dropDownName, 0, "select");
//	if(chosenAccTypes)
//	{
//	    dropDown.options.length = 1;
//	    for(var i = 0; i < chosenAccTypes.length; i++)
//	    {
//	        dropDown.options[dropDown.options.length] = new Option(accTypes[chosenAccTypes[i]], chosenAccTypes[i]);
//	    }
//	}
//}

//function updateAccCategoryDropDown( dropDownName )
//{

//	var selectedAccommodationTypeValue;
//	var productType = GetProductType();
//	var selectedCountryValue = null;

//	if (GetBookingProcessKind() == "AO")
//	    selectedCountryValue = "*";
//	else
//	    selectedCountryValue = GetDepartureCountry();
//	    
//	
//	selectedAccommodationTypeValue = GetControl( "dropDownListAccommodationType", 0, "select" ).value;
//	if(selectedAccommodationTypeValue == "")
//	    selectedAccommodationTypeValue = "*";

//	var chosenAccCategories = accCategoriesMapping[productType][selectedAccommodationTypeValue][selectedCountryValue];
//	
//	if (chosenAccCategories == null)
//	    chosenAccCategories = accCategoriesMapping[productType][selectedAccommodationTypeValue]["*"];
//    var dropDown = GetControl(dropDownName, 0, "select");
//	var accommodationCategoryDownList = GetControl( "dropDownListAccommodationCategory",0,"select" );
//	var lblAccommodationCategory = GetControl( "lblAccommodationCategory",0,"td" );
//	var selectAccommodationCategory = GetControl( "selectAccommodationCategory",0,"td" );
//    	
//	if(chosenAccCategories && chosenAccCategories.length > 1)
//	{
//	    accommodationCategoryDownList.style.visibility = "" 
//	    lblAccommodationCategory.style.visibility = "" 
//	    selectAccommodationCategory.style.visibility = "" 
//	    dropDown.options.length = 0;
//	    for(var i = 0; i < chosenAccCategories.length; i++)
//	    {
//	        dropDown.options[i] = new Option(accCategories[chosenAccCategories[i]], chosenAccCategories[i]);
//	    }
//	}
//	else if(chosenAccCategories.length == 1 && chosenAccCategories[0] == "None")
//	{
//	    accommodationCategoryDownList.selectedIndex = 0;
//	    accommodationCategoryDownList.style.visibility = "hidden" 
//	    lblAccommodationCategory.style.visibility = "hidden" 
//	    selectAccommodationCategory.style.visibility = "hidden" 
//    }
//}

function UpdateDurationPreselection(dropDownName)
{
    var selectedCountry = GetDepartureCountry();
    var dropDown = GetControl(dropDownName, 0, "select");
    dropDown.selectedIndex = durationsPreselectedIndexes[selectedCountry];
}

function GetProductType()
{
   
    var readyMadePackagesControl = GetControl("BookingProcessCategory", 0, "input");
    
	var productType = "";
	if (readyMadePackagesControl != null)
	    productType = GetControl("BookingProcessCategory", 0, "input").value;
	else
	    productType = "CYH";

	productType += "-" + GetBookingProcessKind();
	
	return productType;
}

function GetBookingProcessKind()
{
//	var FADBookingProcess = GetControl( 'FARadio', 0,'input');
//	var bookingProcessKind = "FA";
//	if ( FADBookingProcess != null )
//	{
//		if (FADBookingProcess.checked )
//			bookingProcessKind = "FA";
//		else
//		    bookingProcessKind = "AO";
//    }	
//	return bookingProcessKind;	

    return currentBookingProcessKind;
}

function AdjustBookingProcessInterface() {

    var bookingProcessKindControl = GetControl("BookingProcessKind", 0, "input");
    var bookingProcessKind = "";
    if (bookingProcessKindControl != null)
        bookingProcessKind = bookingProcessKindControl.value;
    else
        bookingProcessKind = "FA";
            
//	var FADBookingProcess 	= GetControl( 'FARadio', 0,'input');	
//	var RadioButtonChecked =  FADBookingProcess!= null?(FADBookingProcess.checked?"FA":"AO"):"AO";
	
	var tableFAD 	= GetControl( 'tableFAD', 0,'table');
	var tableAO 	= GetControl( 'tableAO', 0,'table');
	
	var tableFADInfo 	= GetControl( 'tableFADInfo', 0,'table');
	var tableAOInfo 	= GetControl( 'tableAOInfo', 0,'table');
		
	if( tableFAD != null && tableAO != null && tableFADInfo != null && tableAOInfo != null )	
	{	
		var rawFAD = document.getElementById("firstRowFAD");
		var rawAO = document.getElementById("firstRowAO");	
			
		var DepartureDateValidationCell = document.getElementById("DepartureDateValidationCell");	
		var CheckInDateValidationCell = document.getElementById("CheckInDateValidationCell");
		var CheckOutDateValidationCell = document.getElementById("CheckOutDateValidationCell");

		switch (bookingProcessKind)
		{
			case "FA":
				document.getElementById("tableAO").style.display = "none";
				document.getElementById("tableFAD").style.display = "block";
				
				document.getElementById("tableAOInfo").style.display = "none";
				document.getElementById("tableFADInfo").style.display = "block";				
			
				ChangeValidatorsState(rawFAD.cells[2],true);
				ChangeValidatorsState(DepartureDateValidationCell,true);
				ChangeValidatorsState(CheckInDateValidationCell,false);
				ChangeValidatorsState(CheckOutDateValidationCell,false);
				ChangeValidatorsState(rawAO.cells[2],false);
					
			break;
			
			case "AO":
				document.getElementById("tableFAD").style.display = "none";
				document.getElementById("tableAO").style.display = "block";
				
				document.getElementById("tableFADInfo").style.display = "none";
				document.getElementById("tableAOInfo").style.display = "block";				
			
				ChangeValidatorsState(rawFAD.cells[2],false);
				ChangeValidatorsState(DepartureDateValidationCell,false);
				ChangeValidatorsState(CheckInDateValidationCell,true);
				ChangeValidatorsState(CheckOutDateValidationCell,true);
				ChangeValidatorsState(rawAO.cells[2],true);
			
			break;		
		}
	}

}

function ShowAppropriateRooms( callerName )
{
	var caller = GetControl( callerName, 0, "select" );//alert( caller.value );
    var roomCount = parseInt( caller.value );//caller.options[caller.selectedIndex].text; //caller.selectedIndex + 1;//caller.options[caller.selectedIndex].text; 
    
    //--------------------------------
    //Enable and disable validators
    
    
	for ( var i=2;i<=3;i++ )
	{
	
		var tempTable = document.getElementById("tableRoom"+i);
		
		var cellAdultsR = document.getElementById("CellAdultsR"+i);
		var cellChildrenR = document.getElementById("CellChildrenR"+i);
		
		if ( i <= roomCount && roomCount != 4 )
		{
			ChangeValidatorsState(cellAdultsR,true);
			ChangeValidatorsState(cellChildrenR,true);
		}
		else
		{
			ChangeValidatorsState(cellAdultsR,false);
			ChangeValidatorsState(cellChildrenR,false);	
		}
		
	} 
    
    switch (roomCount)
	{
	    case 1:
	        if (document.getElementById("room1Title") != null)
	            document.getElementById("room1Title").style.display = "none";
	        document.getElementById("tableRoom1").style.display = "";
	        document.getElementById("tableRoom2").style.display = "none";
	        document.getElementById("tableRoom3").style.display = "none";

	        document.getElementById("tableRoom1Children").style.display = "none";
	        document.getElementById("tableRoom2Children").style.display = "none";
	        document.getElementById("tableRoom3Children").style.display = "none";

	        ResetDropDownLists("dropDownListAdultsR2", null);
	        ResetDropDownLists("dropDownListAdultsR3", null);
	        ResetDropDownLists("dropDownListChildrenR2", null);
	        ResetDropDownLists("dropDownListChildrenR3", null);
	        break;
	    case 2:
	        if (document.getElementById("room1Title") != null)
	            document.getElementById("room1Title").style.display = "";
	        document.getElementById("tableRoom1").style.display = "";
	        document.getElementById("tableRoom2").style.display = "";
	        document.getElementById("tableRoom3").style.display = "none";

	        document.getElementById("tableRoom1Children").style.display = "none";
	        document.getElementById("tableRoom2Children").style.display = "none";
	        document.getElementById("tableRoom3Children").style.display = "none";

	        ResetDropDownLists("dropDownListAdultsR3", null);
	        ResetDropDownLists("dropDownListChildrenR3", null);
	        break;
	    case 3:
	        if (document.getElementById("room1Title") != null)
	            document.getElementById("room1Title").style.display = "";
	        document.getElementById("tableRoom1").style.display = "";
	        document.getElementById("tableRoom2").style.display = "";
	        document.getElementById("tableRoom3").style.display = "";

	        document.getElementById("tableRoom1Children").style.display = "none";
	        document.getElementById("tableRoom2Children").style.display = "none";
	        document.getElementById("tableRoom3Children").style.display = "none";
	        break;
		case 4://"More":
			document.getElementById("tableRoom1").style.display="none";
			document.getElementById("tableRoom2").style.display="none";
			document.getElementById("tableRoom3").style.display="none";
			
		    
			document.getElementById("tableRoom1Children").style.display="none";
			document.getElementById("tableRoom2Children").style.display="none";
			document.getElementById("tableRoom3Children").style.display="none";

			ResetDropDownLists("dropDownListAdultsR1", 1);
			ResetDropDownLists ( "dropDownListAdultsR2", null);
			ResetDropDownLists("dropDownListAdultsR3", null);
			ResetDropDownLists("dropDownListChildrenR1", null);
			ResetDropDownLists("dropDownListChildrenR2", null);
			ResetDropDownLists("dropDownListChildrenR3", null);
			break;
	}
	ShowAppropriateChildrenDOB( "tableRoom1Children", "dropDownListChildrenR1", 1 );
	ShowAppropriateChildrenDOB( "tableRoom2Children", "dropDownListChildrenR2", 2 );
	ShowAppropriateChildrenDOB( "tableRoom3Children", "dropDownListChildrenR3", 3 );   
}

function ShowAppropriateChildrenDOB ( childrenTableName, callerName, i )
{
    var caller = GetControl( callerName, 0, "select" );
    var childrenCount = caller.options[caller.selectedIndex].text;    
    var childrenTable = GetControl( childrenTableName, 0, "table" );
	
	childrenTable.style.display="";
	switch ( childrenCount )
	{
		case "0":
			childrenTable.style.display="none";
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell4'),false);
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell6'),false);
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell8'),false);
			break;
		case "1":
			if ( document.getElementById('tr'+i+'chCell1') != null )
			    document.getElementById('tr' + i + 'chCell1').style.width = "220";

			if (document.getElementById('tr' + i + 'chRow2') != null)
			{	
                document.getElementById('tr' + i + 'chRow2').style.display = "none";
                document.getElementById('tr' + i + 'chRow3').style.display = "none";
            }
            else
            {  
			    document.getElementById('tr'+i+'chCell5').style.display="none";
			    document.getElementById('tr'+i+'chCell6').style.display="none";
			    document.getElementById('tr'+i+'chCell7').style.display="none";
			    document.getElementById('tr'+i+'chCell8').style.display="none";
            }
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell4'),true);
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell6'),false);
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell8'),false);
			break;
		case "2":
			if ( document.getElementById('tr'+i+'chCell1') != null )
			    document.getElementById('tr' + i + 'chCell1').style.width = "130";

            if (document.getElementById('tr' + i + 'chRow2') != null)
			{	
                document.getElementById('tr' + i + 'chRow2').style.display = "";
                document.getElementById('tr' + i + 'chRow3').style.display = "none";
            }
            else
            {	
			    document.getElementById('tr'+i+'chCell5').style.display="inline";
			    document.getElementById('tr'+i+'chCell6').style.display="inline";
			    document.getElementById('tr'+i+'chCell7').style.display="none";
			    document.getElementById('tr'+i+'chCell8').style.display="none";
            }
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell4'),true);
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell6'),true);
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell8'),false);
			break;
		case "3":
			if ( document.getElementById('tr'+i+'chCell1') != null )
			    document.getElementById('tr' + i + 'chCell1').style.width = "40";
				
            if (document.getElementById('tr' + i + 'chRow2') != null)
			{	
                document.getElementById('tr' + i + 'chRow2').style.display = "";
                document.getElementById('tr' + i + 'chRow3').style.display = "";
            }
            else
            {	
			    document.getElementById('tr'+i+'chCell5').style.display="inline";
			    document.getElementById('tr'+i+'chCell6').style.display="inline";
			    document.getElementById('tr'+i+'chCell7').style.display="inline";
			    document.getElementById('tr'+i+'chCell8').style.display="inline";
            }
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell4'),true);
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell6'),true);
			ChangeValidatorsState(document.getElementById('tr'+i+'chCell8'),true);		
			break;
	}						
}

//function InitializeMainLogicControls()
//{
//    updateAccTypesDropDown( 'dropDownListAccommodationType' );
//    updateAccCategoryDropDown( 'dropDownListAccommodationCategory' );
//    PrepareAccommodationNames('dropDownListDestinations','dropDownListAccommodationNames');
//}

var currentBookingProcessKind = "FA";
function AdjustBookingProcessKind( bookingProcessKind )
{
	currentBookingProcessKind = bookingProcessKind;
}

function ResetDropDownLists(dropDownName, index)
{
	var dropDown = GetControl( dropDownName, 0, "select" );
	if(index!=null)
	    dropDown.selectedIndex = index;
	else
	    dropDown.selectedIndex = 0;
}

function ShowRoomsBlock(RoomsBlockControl , DestinationLocationsCountrol) {
    var dropDownListDestinations = GetControl(DestinationLocationsCountrol);
    var roomsBlock = GetControl(RoomsBlockControl);
    if (dropDownListDestinations.value == 0) {
        roomsBlock.style.visibility = "hidden";
        roomsBlock.style.display = "none";
    }
    else {
        roomsBlock.style.visibility = "";
        roomsBlock.style.display = "";
    }
}

var dropDownListDestinationLocations;
var preSelectedDestinationCode;
var RoomsControl;
function PrepareDestinationLocations(DestinationLocationsCountrol, DestinationCountriesControl, SelectedDestinationCodeControl, RoomsBlockControl, languageCodeControl) 
{
    //----------------
    //Extract Controls
    dropDownListDestinationLocations = GetControl(DestinationLocationsCountrol);
    dropDownListDestinationLocations.disabled = "disabled";
    RoomsControl = RoomsBlockControl;
    preSelectedDestinationCode = GetControl(SelectedDestinationCodeControl).value;
    var dropDownListDestinationCountries = GetControl(DestinationCountriesControl);
    var currentLanguageCode = GetControl(languageCodeControl).value;
        //Reset Destination Locations
    dropDownListDestinationLocations.options.length = 0;
//    dropDownListDestinationLocations.options[0] = new Option("", "0");

    if (dropDownListDestinationCountries.value != "0") 
    {
        dropDownListDestinationLocations.options[0] = new Option("Loading...", "0");
        GRS.Distribution.GoRedSea.Client.WebApp.WebServices.SmartMask.GetDestinationLocationListItems(dropDownListDestinationCountries.value, currentLanguageCode, _onGetDestinationLocationListItemsFeedbackReceived, _onGetDestinationLocationListItemsFeedbackFailed, this);
    }
}

function _onGetDestinationLocationListItemsFeedbackReceived(results, context) 
{
    dropDownListDestinationLocations.options.length = 0;
//    dropDownListDestinationLocations.options[0] = new Option("", "0");
    for (var i = 0; i < results.length; i++) 
    {
        dropDownListDestinationLocations.options[i] = new Option(results[i].split(":")[0], results[i].split(":")[1]);
        dropDownListDestinationLocations.options[i].setAttribute("class", results[i].split(":")[2]);
        dropDownListDestinationLocations.options[i].setAttribute("className", results[i].split(":")[2]);
    }

    if (dropDownListDestinationLocations.options.length > 0) 
    {
        if (preSelectedDestinationCode != "" && preSelectedDestinationCode != "0") 
        {
            dropDownListDestinationLocations.value = preSelectedDestinationCode;
            
            if (dropDownListDestinationLocations.value == "" || dropDownListDestinationLocations.value == "0") 
            {
                dropDownListDestinationLocations.value = "G" + preSelectedDestinationCode;
            }
        }

        if (dropDownListDestinationLocations.value == "" || dropDownListDestinationLocations.value == "0") 
        {
            dropDownListDestinationLocations.selectedIndex = 0;
        }            
        ShowRoomsBlock(RoomsControl, dropDownListDestinationLocations.id);
    }
    dropDownListDestinationLocations.disabled = "";
}

function _onGetDestinationLocationListItemsFeedbackFailed(results) {
}
 
