var m = 1;

//function to remove options
function RemoveOptions(objCal) {

    m = 1;
   if (objCal.options.length > 0 )
   {
		for(i=0;objCal.options.length;i++)
		{
		    objCal.options[0] = null;
		    objCal.remove(i);

		}
   }
}
function FillCountryCombo()
{
	var ArrayCountry = strcountry.split("~")
	var k =1;
	RemoveOptions(document.searchForm.cmbCountry)
	document.searchForm.cmbCountry.options[0] = new Option("-- Select a Country --","select");
	for(i=0;i<ArrayCountry.length;i++)
	{
			document.searchForm.cmbCountry.options[k] = new Option(ArrayCountry[i],ArrayCountry[i]);
			k+=1;
	}
	document.searchForm.cmbCountry[0].selected =true;
}

function PopulateCountryCity()
{
	var selectedCountry = document.searchForm.cmbCountry.options[document.searchForm.cmbCountry.selectedIndex].value;
	var ArrayCity = strcity.split("||")
	var ArrayCountryCity = strcitycountry.split("~~")
	var k =1;
	RemoveOptions(document.searchForm.cmbCity)
	RemoveOptions(document.searchForm.cmbHotel)
	document.searchForm.cmbHotel.options[0] = new Option("-- Select a Hotel---","select");
	document.searchForm.cmbHotel[0].selected=true;
	document.searchForm.cmbCuisine[0].selected=true;
	document.searchForm.cmbCity.options[0] = new Option("--Select a City--","select");
	for(j=0;j<ArrayCity.length;j++)
	{
		var cc = selectedCountry + "~" +ArrayCity[j];
		for(i=0;i<ArrayCountryCity.length;i++)
		{
			if (ArrayCountryCity[i]==cc)
			{
				document.searchForm.cmbCity.options[k] = new Option(ArrayCity[i],ArrayCity[i]);
				k+=1;
			}
		}
}
if (document.searchForm.cmbCountry.options[document.searchForm.cmbCountry.selectedIndex].value == 'INDIA') {
    for (var i = 1; i < document.searchForm.cmbCity.length; i++) {
        document.searchForm.cmbCity[i].selected = true;
        PopulateCityHotel();
    }
    document.searchForm.cmbCity[0].selected = true;
}
else {
    	if(document.searchForm.cmbCity.length==2)
    	{
    	document.searchForm.cmbCity[1].selected =true;
    	PopulateCityHotel();
    	}
    	else
    	{
    	document.searchForm.cmbCity[0].selected =true;
    	document.searchForm.cmbHotel[0].selected =true;
    	}
}
	
}



function PopulateCityHotel()
{
	var selectedCountry = document.searchForm.cmbCountry.options[document.searchForm.cmbCountry.selectedIndex].value;
	var selectedCity2 = document.searchForm.cmbCity.options[document.searchForm.cmbCity.selectedIndex].value;
	var ArrayHotel = strhotel.split("||")
	var ArrayCityHotel = strcityhotel.split("~~")
	var ArrayHotelID = strcityhotel2.split("~~")
	//alert (ArrayCityHotel);
	//var ArrayHotelID = ArrayCityHotel.split("//");
	//alert (ArrayHotelID);
	
	//RemoveOptions(document.searchForm.cmbHotel)
	document.searchForm.cmbHotel.options[0] = new Option("-- Select a Hotel---","select");
	for(j=0;j<ArrayHotel.length;j++)
	{
		var cc = selectedCity2 + "~" +ArrayHotel[j];
		//alert (cc);
		for(i=0;i<ArrayCityHotel.length;i++)
		{
			if (ArrayCityHotel[i]==cc) {
			    //alert(ArrayCityHotel[i]);
				var tryFurther=ArrayCityHotel[i];
				var tryFurther1=ArrayHotelID[i];
				var tryFurtherMore=tryFurther.split("~")
				var tryFurtherMore1=tryFurther1.split("//")
				//alert (tryFurtherMore1[1]);
				document.searchForm.cmbHotel.options[m] = new Option(tryFurtherMore[1],tryFurtherMore1[1]+"-"+tryFurtherMore[2]);
				m+=1;
			}
		}
	}
	if(document.searchForm.cmbHotel.length==2)
	document.searchForm.cmbHotel[1].selected =true;
	else
	document.searchForm.cmbHotel[0].selected =true;
	//document.searchForm.cmbHotel[0].selected =true;
}	

function hotelcount(city)
{
var flg=0;
var hotelname;
  var ArrayCityHotel = strcityhotel2.split("~~");
  for(m=0;m<ArrayCityHotel.length;m++)
     {
       var countarray=new Array();
       var ctyhotel=ArrayCityHotel[m];
       countarray=ctyhotel.split("//");
       //alert(countarray[0]);
       if(countarray[2]==city)
        {
        flg++;
        hotelname=countarray[3]+"|"+countarray[0]+"|"+countarray[1];
        }
        
     }
     if(flg==1)
        {
        return hotelname;
        }
        else
        {
        return "abc";
        }
  
}

