function checkForm(sYear, sMonth, sDay) {
	vform = document.searchform;
	if ( vform.country[vform.country.selectedIndex].value == 0) 
	{
		alert("Please select destination country.");
		vform.country.focus();
		return false;
	}
	if ( vform.city[vform.city.selectedIndex].value == 0 ) 
	{
		alert("Please select destination city.");
		vform.city.focus();
		return false;
	}	
	
	// start chk booking date
	
	var year = vform.chinyear[vform.chinyear.selectedIndex].value;
	var month = vform.chinmonth[vform.chinmonth.selectedIndex].value;
	var day = vform.chinday[vform.chinday.selectedIndex].value;
	
	var selectedDate = new Date(year, month, day);
	
	var todate = new Date(sYear, sMonth, sDay);	
		
	if ( todate > selectedDate ) 
	{
		alert("Sorry you can't booking in previous date.");
		//vform.city.focus();
		return false;
	}
	
	// end chk booking date
	
	
	// start child age chk	
	
	var num_rooms = vform.Hi_Clt_lstRoomsRequired.value;
	//alert("Please select child age." + num_rooms);
	
	for ( i=1; i<=num_rooms; i++)
	{
		var room_no  = "Hi_Clt_lstRm" + i + "Children";
		
		var num_child = document.getElementById(room_no).value;
		//alert("Please select child age." + num_child);
			
		if ( num_child > 0 )
		{
			for ( j=1; j<=num_child; j++ )
			{
				var roomChildNo = "Hi_Clt_lstRm" + i + "ChildAge" + j;
				//alert("Please select child age." + roomChildNo);
				var childAge = document.getElementById(roomChildNo).value;
				if (  childAge == "" ) 
				{
					alert("Please select Room"+ i +" Child"+ j +" age.");
					//vform.roomChildNo.focus();
					return false;
				}
			}
		}
		
	}
	
	// end child age chk	
	
	//return false;
	return true;
}

function changeDate() {
	vform = document.searchform;
	var mArray = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');	
	var y = vform.chinyear.value * 1;	
	var m = vform.chinmonth.value * 1;
	var d = vform.chinday.value * 1;
	var n = vform.nights.value * 1;
	
	if(m == 12 && (d + n) > 31)
	{
		y = y +1;
	}
	
	chout = new Date(y, m - 1, d + n);
	m = chout.getMonth();
	d = chout.getDate();
	//y = chout.getYear();	
	dateText = mArray[m] + " " + d + ", " + y;
	
	//alert(dateText);
	txtCheckoutDate_V = document.getElementById("txtCheckoutDate_V");	
	txtCheckoutDate_V.value = dateText;
	
	dateText1 = y + "-" + (m + 1) + "-" + d;
	document.searchform.hidden_checkout.value = dateText1;		
}

function changeRoom(max_number_of_rooms) 
{
	
	vform = document.searchform;
	
	var index = 1;
	
	for ( index = 1; index<=vform.rooms.value; index++)
	{
		var id = 'divRoom' + index; 
		
		div = document.getElementById(id);
		
		div.style.display = "block";		
	}
	
	for ( index = index; index<=max_number_of_rooms; index++)
	{
		var id = 'divRoom' + index; 
		
		div = document.getElementById(id);
		
		div.style.display = "none";		
	}
	
	/*
	if (vform.rooms.value == 1) {
		vform.roomtype2.value = "";
		vform.roomtype3.value = "";
		divRoom2.style.display = "none";
		divRoom3.style.display = "none";
	} else if (vform.rooms.value == 2) {
		vform.roomtype3.value = "";
		divRoom2.style.display = "block";
		divRoom3.style.display = "none";
	} else if (vform.rooms.value == 3) {
		divRoom2.style.display = "block";
		divRoom3.style.display = "block";
	}
	*/
}

function changeDateOptions()
{
	
	
	month = document.getElementById('chinmonth');
	
	day = document.getElementById('chinday');
	vform = document.searchform;
	a = month.options[month.selectedIndex].value;
	
	for(i=0; i<day.length; i++)
    {
      day.remove(i);	      
    }	    
	
	if( a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12 )
	{
		

		for(i=0; i<31; i++)
	    {
	      var newOpt = new Option(i+1, i+1);
	      day.options[i] = newOpt;	      
	    }		
	}
	else if( a == 4 || a == 6 || a == 9 || a == 11 )
	{
		for(i=0; i<30; i++)
	    {
	      var newOpt = new Option(i+1, i+1);
	      day.options[i] = newOpt;	      
	    }		
	}
	else if( a == 2 )
	{
		for(i=0; i<28; i++)
	    {
	      var newOpt = new Option(i+1, i+1);
	      day.options[i] = newOpt;	      
	    }		
	}
}


function changeDateOptions2(server_day)
{
	vform = document.searchform;
	
	month = document.getElementById('chinmonth');
	
	day = document.getElementById('chinday');
	
	a = month.options[month.selectedIndex].value;
	
	for(i=0; i<day.length; i++)
    {
      day.remove(i);	      
    }	    
	 
	if( a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12 )
	{
		for(i=0; i<31; i++)
	    {
	      var newOpt = new Option(i+1, i+1);
	      day.options[i] = newOpt;	      
	     
	      if( server_day == (i+1) )
	      {
	      	day.options[i].selected = 1;
	      }
	      
	    }		
	}
	else if( a == 4 || a == 6 || a == 9 || a == 11 )
	{
		for(i=0; i<30; i++)
	    {
	      var newOpt = new Option(i+1, i+1);
	      day.options[i] = newOpt;	      
	      
	      if( server_day == (i+1) )
	      {
	      	day.options[i].selected = 1;
	      }
	    }		
	}
	else if( a == 2 )
	{
		for(i=0; i<28; i++)
	    {
	      var newOpt = new Option(i+1, i+1);
	      day.options[i] = newOpt;	      
	      
	      if( server_day == (i+1) )
	      {
	      	day.options[i].selected = 1;
	      }
	    }		
	}
}


function changeDate1()
{
	changeDateOptions();
	changeDate();
}

function changeDate2(server_day)
{
	changeDateOptions2(server_day);
	changeDate();
}
