
function addTitleAttributesToHotelsList() {
	hotelSelect = document.getElementById('hotelsSearchForm:hotelId');
	addTitleAttributesToOptionElements(hotelSelect);
}

function addTitleAttributesToOptionElements(selectElement){
	if(selectElement  != null){
		options = selectElement.options;
		if(options != null){
			for (i = 0; i < options.length; i++) {
				option = options[i];
				if(option != null){
					option.title = option.text;
				}
			}
		}
	}
}

/**
 * Apply the given placeholder to the textfield element specified by the given type.
 *
 * @param   type                Used to get the correct textfield element.
 *                              Supported values: 'country', 'region', 'city' and 'hotel'
 * @param   placeholderText     The text to use as placeholder.
 * @param   styleClassName      Name of the style class to apply when the placeholder is active.
 */
function applyFilterBoxPlaceHolder( type, placeholderText, styleClassName )
{
	inputField = document.getElementById("hotelsSearchForm:" + type + "Filter");

	if (inputField.hasFocus) // NOTE: the 'hasFocus' property is being added/updated dynamicly where the textfields are initialized.
	{
		// Ignore the input field that has focus to prevent weird behaviour.
	}
	else
	{
		var options = {
		  values: [placeholderText] ,
		  className: styleClassName
		}

		jQuery.noConflict();
		jQuery(inputField).placeholder(options);
	}
}

function readPlaceholderText( type )
{
	return document.getElementById("hotelsSearchForm:" + type + "FilterPlaceholderText").value;
}
