//================================================================================//
//	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_FormAction    = obj_Form.action + '/v2/09_otel/otel_ara_sonuc.asp';
	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   - Lütfen arama kriteri seçiniz (Yöre, İl veya İsim ile arama).\t';
	}
	
	if (obj_SearchBy[0].checked == true){
		if (obj_Form.pop_dest.options.length > 2){
			if (n_PopDest == 0){
				str_ErrorMsg += '\n   - Lütfen bir yöre seçiniz.\t';
			}		
		}else{
			str_ErrorMsg += '\n   - İl veya otel ismine göre aramayı deneyiniz.\t';
		}
	}
	
	if (obj_SearchBy[1].checked == true){
		if (obj_Form.city.options.length > 2){
			if (n_City == 0){
				str_ErrorMsg += '\n   - Lütfen bir il seçiniz.\t';
			}
		}else{
			str_ErrorMsg += '\n   - Yöre veya otel ismine göre aramayı deneyiniz.\t';
		}
	}
	
	if (obj_SearchBy[2].checked == true && str_SearchName == ''){
		str_ErrorMsg += '\n   - Lütfen aranacak otelin adını giriniz.\t';
	}
	
	if (check_date(d_ArrDate, '.') != 1){
		str_ErrorMsg += '\n   - Lütfen \'Giriş tarihi\' kontrol ediniz (ör: 01.01.2001).\t';
	}
		
	if (check_date(d_DepDate, '.') != 1){
		str_ErrorMsg += '\n   - Lütfen \'Çıkış tarihi\' kontrol ediniz (ör: 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   - \'Giriş tarihi\' bugünkü tarihinden büyük olmalıdır.\t';
		}
			
		if (date_ms(d_ArrDate, '.') >= date_ms(d_DepDate, '.')){
			str_ErrorMsg += '\n   - \'Çıkış tarihi\', \'Giriş tarihi\'nden büyük olmalıdır.\t';
		}
	}
	
	if (str_ErrorMsg.Trim() != ''){
		alert('Lütfen aşağıda belirtilen alanları tekrar kontrol ediniz:\t\n' + str_ErrorMsg);
	}else{
		obj_Form.action = str_FormAction;
		obj_Form.submit();
	}
}