
function function_set_search_box_visible(search_form_id)
{
	if(search_form_id == "hotel")
	{
		show(search_form_id);
		hide('landmark');
		document.getElementById('action_list').value = "search_"+search_form_id;
		
		//change tabs
		document.getElementById("station_search_div_button").src = dir_value+"/images/buttons/bt_station_search_off.gif";
		document.getElementById("hotel_search_div_button").src = dir_value+"/images/buttons/bt_hotel_search_on.gif";	
		
	}
	else
	{
		show(search_form_id);
		hide('hotel');
		document.getElementById('action_list').value = "search_"+search_form_id;
		
		//change tabs
		document.getElementById("station_search_div_button").src = dir_value+"/images/buttons/bt_station_search_on.gif";
		document.getElementById("hotel_search_div_button").src = dir_value+"/images/buttons/bt_hotel_search_off.gif";
	}
	
	
}


function set_check_out_date()
{
	content_type = '';

	nights = document.getElementById(content_type + 'nights');
	var nr_nights = nights.options[nights.selectedIndex].value;
	
	try{
		//alert(nr_nights);
		
		check_in_date_string = document.getElementById(content_type + 'check_in_date');
		check_in_date_string = check_in_date_string.value;

		
		year_in = check_in_date_string.substr(6,4);
		month_in = check_in_date_string.substr(3,2);
		day_in = check_in_date_string.substr(0,2);
		
		//alert(year_in + "|" + month_in + "|" + day_in);
		
		check_in_date_obj = new Date();
		check_in_date_obj.setFullYear(year_in);
		check_in_date_obj.setMonth(month_in-1);
		check_in_date_obj.setDate(day_in);
	}
	catch(err)
	{
		alert("Date format dd-mm-yyyy");
		return false;
	}
	
	check_out_date_obj = new Date();
	
	
	
	check_out_date_obj.setTime(check_in_date_obj.getTime() + ( 86400000 * nr_nights)); 
	//alert(check_out_date_obj);
	var year_out = check_out_date_obj.getFullYear();
	var month_out = check_out_date_obj.getMonth() + 1;
	var day_out = check_out_date_obj.getDate();           		
	
	month_out += "";
	day_out += "";
	if (month_out.length == 1)
	{
		month_out = "0" + month_out;
	}
	if (day_out.length == 1)
	{
		day_out = "0" + day_out;
	}
	new_date = day_out+"-"+month_out+"-"+year_out;
	
	document.getElementById(content_type + 'check_out_date').innerHTML = new_date;
}


/**************************************************************************
Search form
**************************************************************************/


function refresh_room_types(room_number)
{
	//alert("aici");
	adults = document.getElementById(room_number + "adults").value;
	children = document.getElementById(room_number + "children").value;
	
	var guest_combos = new Array();
	guest_combos["1;0"] = "0,1,2,3";
	guest_combos["1;1"] = "0,2,3";
	guest_combos["1;2"] = "0,4,6,7";
	guest_combos["1;3"] = "0,5,8";
	guest_combos["2;0"] = "0,2,3";
	guest_combos["2;1"] = "0,4,6,7";
	guest_combos["2;2"] = "0,5,8";
	guest_combos["2;3"] = "0,8";
	guest_combos["3;0"] = "0,4";
	guest_combos["3;1"] = "0,5,8";
	guest_combos["3;2"] = "0";
	guest_combos["3;3"] = "0";
	guest_combos["4;0"] = "0,5";
	guest_combos["4;1"] = "0";
	guest_combos["4;2"] = "0";
	guest_combos["4;3"] = "0";
	
	var room_types = new Array();
	room_types[0] = "any";
	room_types[1] = "Single";
	room_types[2] = "Double";
	room_types[3] = "Twin";
	room_types[4] = "Triple";
	room_types[5] = "Quad";
	room_types[6] = "Twin+child";
	room_types[7] = "Double+child";
	room_types[8] = "Family";
	
	var room_types_list = guest_combos[adults + ';' + children];
	room_types_indices = room_types_list.split(",");
	
	var room_options;
	var selected;
	for (i=0; i < room_types_indices.length; i++) {
		selected = "";
		room_options = room_options + "<option value=" + room_types_indices[i] + " " + selected + ">" + room_types[room_types_indices[i]] + "</option>";
	}
	
	document.getElementById(room_number + "room_types").innerHTML = "<select id='" + room_number + "room_type_id' name='" + room_number + "room_type_id' style='width:90px' class='form_element'>" + room_options + "</select>";
}

	




function refresh_room_display(total_rooms, max_rooms)
{
	for (j=1; j <= max_rooms; j++) {
		room_number = "r"+ j;
		div_name = "div_" + room_number;
		if (j <= total_rooms) {
			
			//alert(div_name);
			show(div_name);
			//alert("aici1");
			//refresh_room_types(room_number);
			//alert("aici2");
			display_child_ages(room_number);
			//alert("aici3");
		}
		else {
			//alert(div_name);
			hide(div_name);
		}
	}

}






function display_child_ages(room_number)
{
	children = document.getElementById(room_number + "children").value;
	div_name = "div_" + room_number + "child_ages";
	//alert(div_name);
  	if (children == 0)
  	{
  		hide(div_name);
		document.getElementById('children_age_title').innerHTML = "";
  	}
	else
	{
		document.getElementById(div_name).style.display = 'inline';
		document.getElementById('children_age_title').innerHTML = "Children age";
	}
  	return true;
}



/**************************************************************************
validate search form
***************************************************************************/
function validate_search_form()
{
	
}

/**************************************************************************
Visibility
**************************************************************************/

function show(obj)
{
	document.getElementById(obj).style.display = 'block';
}

function hide(obj)
{
	document.getElementById(obj).style.display = 'none';
}
