function ValidateHotelSearchForm( form )
{
	/*
	var Destination	=	form.tbSearchString;
	if(Destination.value.length==0)
	{
		alert("Моля въведете дестинация!");
		//Destination.focus();
		return false;
	}
	*/
	
	var CheckIn		=	form.tbDateFrom;
	if (isDate(CheckIn.value)==false)
	{
		alert("Моля въведете начална дата!");
		CheckIn.focus();
		return false;
	}

	var CheckOut	=	form.tbDateTo;
	if (isDate(CheckOut.value)==false)
	{
		alert("Моля въведете крайна дата!");
		CheckOut.focus();
		return false;
	}

	if (compareDates(CheckIn.value, CheckOut.value) >= 0)
	{
		alert("Моля въведете валидни дати!");
		CheckIn.focus();
		return false;
	}
	
	/*
	var RoomCnt	=	form.sCount1;
	
	if ( RoomCnt.selectedIndex < 1)
	{
		alert("Моля изберете брой стаи");
		RoomCnt.focus();
		return false;
	}
	*/

	var AdultsCnt	=	form.sAdults1;
	if (0 > RoomCnt.selectedIndex)
	{
		alert("Моля изберете брой възрастни");
		AdultsCnt.focus();
		return false;
	}
	
	

    return true;
}

function isDate(str_date)
{
	return (str_date.match(/(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-(19|20)[0-9][0-9]/) == null) ? false : true;
}

function compareDates(str_date_a, str_date_b)
{
	array_date_a = str_date_a.split('-');
	array_date_b = str_date_b.split('-');

	year_a = array_date_a.pop();
	year_b = array_date_b.pop();

	month_a = array_date_a.pop();
	month_b = array_date_b.pop();

	day_a = array_date_a.pop();
	day_b = array_date_b.pop();

	if (year_a == year_b)
	{
		if (month_a == month_b)
		{
			if (day_a == day_b)
				return 0;
			else
			{
				if (day_a < day_b)
					return -1;
				else
					return 1;
			}
		}
		else
		{
			if (month_a < month_b)
				return -1;
			else
				return 1;
		}
	}
	else
	{
		if (year_a < year_b)
			return -1;
		else
			return 1;
	}
}

function validate_form( form )
{

	var Username	=	form.user;
	if(Username.value.length==0)
    {
        alert ( "Please fill in the 'Username' box." );
        Username.focus();
        return false;
    }

    var Password	=	form.pass;
	if(Password.value.length==0)
    {
        alert ( "Please fill in the 'Password' box." );
        Password.focus();
        return false;
    }

    return true;
}

function validate_log_to_res_form( form )
{

	var Username	=	form.OurRefNum;
	if(Username.value.length==0)
    {
        alert ( "Please fill in the 'Reservation number' box." );
        Username.focus();
        return false;
    }

    var Password	=	form.UserPassword;
	if(Password.value.length==0)
    {
        alert ( "Please fill in the 'Password' box." );
        Password.focus();
        return false;
    }

    return true;
}

function show_rooms(form) {
	
	var s_room_type_count1	=	form.sCount1;
	var s_room_type_count2	=	form.sCount2;
	var s_room_type_count3	=	form.sCount3;
	
	var div2 = document.getElementById("rooms_2");
	var div3 = document.getElementById("rooms_3");
	
	/*
	if (s_room_type_count1.selectedIndex < 1 ) {
		
		s_room_type_count2.selectedIndex = 0;
		div2.style.display = 'none';
	}
	else {
		div2.style.display = 'block';
	}
	*/
	div2.style.display = 'block';
	
	if (s_room_type_count2.selectedIndex < 1 ) {
		
		s_room_type_count3.selectedIndex = 0;
		div3.style.display = 'none';
	}
	else {
		div3.style.display = 'block';
	}
}

function show_ages(form, type){
	
	try {

		var form;
		var type;
	  	var children 	= 	document.forms[form].elements['sChildren'+type];
	  	
	  	//alert(children)
	  	
		var age1	=	document.getElementById("sChAges"+type+1);
		var age2	=	document.getElementById("sChAges"+type+2);
		var l_age	=	document.getElementById("label_age"+type);
		
		if (children.value == 0){
			age1.style.display = 'none';
			age2.style.display = 'none';
			l_age.style.display = 'none';
		}
	
		if (children.value == 1){
			age1.style.display = 'block';
			age2.style.display = 'none';
			l_age.style.display = 'block';
			age1.focus()
		}
	
		if (children.value == 2){
			age1.style.display = 'block';
			age1.focus()
			age2.style.display = 'block';
			l_age.style.display = 'block';
		}
		
	
	  	
	  } catch (e) {
	  	//alert("Oops! Something bad just happened. Calling 911...");
	  	return false;
	  }	
	  
	  return true;
}