function validateFlyDriveDateFormat(fieldName,error,componentId, defaultVal){
if(isKeyboard()) {
if(!isValidDate(jQuery("#"+fieldName).val())) {
showFlyDriveErrorMsg(fieldName,error,componentId, defaultVal);
return true;
}
}
return false;
}
function checkMandatoryFlyDrive(fieldName,error,componentId, defaultVal) {
if ((jQuery("#"+fieldName).val() == "") || (jQuery("#"+fieldName).val().indexOf(defaultVal) >= 0)) {
showFlyDriveErrorMsg(fieldName,error,componentId, defaultVal);
return true;
}
return false;
}
function showFlyDriveErrorMsg(fieldName,error,componentId, defaultVal) {
if(typeof toolTipError != 'undefined' && toolTipError) {
showGeneralInputError(fieldName,error);
} else {
jQuery("#labelErrorMsgCar_"+componentId).text(error);
jQuery("#"+fieldName).focus();
}
jQuery("#"+fieldName).focus();
}
function doFlyDriveSubmit(componentId) {
// if we are in accessibility mode we show more informative error msg
if(isKeyboard()) {
if (validateFlyDriveDateFormat("flyCheckInDate_"+componentId,'מתי? יום, חודש, שנה DD/MM/YYיום בשתי ספרות קו נטוי חודש בשתי ספרות קו נטוי שנה בשתי ספרות ',componentId, 'ת. יציאה')) return;
if (checkMandatoryFlyDrive("flyCheckInDate_"+componentId,'מתי? יום, חודש, שנה DD/MM/YYיום בשתי ספרות קו נטוי חודש בשתי ספרות קו נטוי שנה בשתי ספרות ',componentId, 'ת. יציאה')) return;
if (validateFlyDriveDateFormat("flyCheckOutDate_"+componentId,'מתי? יום, חודש, שנה DD/MM/YYיום בשתי ספרות קו נטוי חודש בשתי ספרות קו נטוי שנה בשתי ספרות ',componentId, 'ת. חזרה')) return;
if (checkMandatoryFlyDrive("flyCheckOutDate_"+componentId,'מתי? יום, חודש, שנה DD/MM/YYיום בשתי ספרות קו נטוי חודש בשתי ספרות קו נטוי שנה בשתי ספרות ',componentId, 'ת. חזרה')) return;
// this check is only for accessibility!!!! cause here we remove 'calendarSearchTrigger' and there we are checking if the destination is not empty
if(checkMandatoryFlyDrive("flyDest_"+componentId,'נא להזין יעד' , componentId, 'בחר יעד')) {return;}
} else {
if (checkMandatoryFlyDrive("flyCheckInDate_"+componentId,'נא להזין תאריך יציאה',componentId, 'ת. יציאה')) return;
if (checkMandatoryFlyDrive("flyCheckOutDate_"+componentId,'נא להזין תאריך חזרה',componentId, 'ת. חזרה')) return;
}
if (!checkFromToDate("flyCheckInDate_"+componentId, "flyCheckOutDate_"+componentId,'תאריך חזרה צריך להיות אחרי תאריך יציאה', "labelErrorMsgCar_"+componentId)) return;
jQuery("#searchBtn").attr("disabled","true");
var message = "חבילה ל-" + jQuery("#flyDest_"+componentId).val() + " " + atDateMsg + " "+ jQuery("#flyCheckInDate_"+componentId).val();
jQuery("#loadingDiv").text(message);
if(jQuery("#popupTextChange").length > 0)
setPopupText(jQuery("#flyCheckInDate_"+componentId).val(), jQuery("#flyCheckOutDate_"+componentId).val(), '',jQuery("#flyDest_"+componentId).val(),'FlyDrive')
$(".loadPopup").bPopup();
navigateToUrl("/SearchFlyDrive.do" , "SearchFlyDrive_" + componentId , "compareList=&");
// focus on loading pop-up for accessibility issues
jQuery("#popupLoader").focus();
}
$(document).ready(function() {
// when in keyboard mode - eliminate calender pop up
if (isKeyboard()) { // we are in accessibility mode
// remove pop up of select destinaiton
jQuery("#flyDest_" + compId).removeClass("flyDriveDest"+compId)
jQuery("#flyDest_" + compId).unbind("")
// make it possible to write destination
jQuery("#flyDest_" + compId).removeAttr("readonly")
// remove pop up of select dates
jQuery("#flyCheckInDate_" + compId).removeClass("calenderSearchTrigger")
jQuery("#flyCheckInDate_" + compId).unbind("")
jQuery("#flyCheckOutDate_" + compId).removeClass("calenderSearchTrigger")
jQuery("#flyCheckOutDate_" + compId).unbind("")
} else {
// we are in regular mode - no accessibility issues
}
});