//================================================================================//
//	check turkey hotels search form
//================================================================================//

function check_search_form(obj_Form){
	var obj_SearchBy      = obj_Form.location;
	var n_PopDest         = obj_Form.pop_dest.options[obj_Form.pop_dest.options.selectedIndex].value.Trim();
	var n_City            = obj_Form.city.options[obj_Form.city.options.selectedIndex].value.Trim();
	var str_SearchName    = obj_Form.facility_name.value.Trim();
	var d_ArrDate         = obj_Form.arr_day.value.Trim();
	var d_DepDate         = obj_Form.dep_day.value.Trim();
	var n_SearchByChecked = 0;
	var str_ErrorMsg      = '';
	
	//================================================================================//
	//	check required form fields
	//================================================================================//
	
	for (i = 0; i < obj_SearchBy.length; i++){
		if (obj_SearchBy[i].checked == true){
			n_SearchByChecked++;
		}
	}
	
	if (n_SearchByChecked != 1){
		str_ErrorMsg += '\n   - Please verify the destination by selecting a popular destination or city, or by entering the name of your destination into the textbox.\t';
	}
	
	if (obj_SearchBy[0].checked == true){
		if (obj_Form.pop_dest.options.length > 2){
			if (n_PopDest == 0){
				str_ErrorMsg += '\n   - Please select a popular destination.\t';
			}		
		}else{
			str_ErrorMsg += '\n   - Try searching according to city or hotel name.\t';
		}
	}
	
	if (obj_SearchBy[1].checked == true){
		if (obj_Form.city.options.length > 2){
			if (n_City == 0){
				str_ErrorMsg += '\n   - Please select a city.\t';
			}
		}else{
			str_ErrorMsg += '\n   - Try searching according to popular destination or hotel name.\t';
		}
	}
	
	if (obj_SearchBy[2].checked == true && str_SearchName == ''){
		str_ErrorMsg += '\n   - Please enter the name of the hotel.\t';
	}
	
	if (check_date(d_ArrDate, '.') != 1){
		str_ErrorMsg += '\n   - Please verify your check in date (eg: 01.01.2001).\t';
	}
		
	if (check_date(d_DepDate, '.') != 1){
		str_ErrorMsg += '\n   - Please verify your check out date (eg: 01.01.2001).\t';
	}
	
	if (check_date(d_ArrDate, '.') == 1 && check_date(d_DepDate, '.') == 1){
		if (date_ms(d_ArrDate, '.') <= date_ms(get_today_date('.'), '.')){
			str_ErrorMsg += '\n   - Your check-in date must be after today.\t';
		}
			
		if (date_ms(d_ArrDate, '.') >= date_ms(d_DepDate, '.')){
			str_ErrorMsg += '\n   - There is an error with the check out date. Check out date must be after check in date.\t';
		}
	}
	
	if (str_ErrorMsg.Trim() != ''){
		alert('Please correct or provide the required information:\t\n' + str_ErrorMsg);
	}else{
		obj_Form.submit();
	}
}