var Validate = new Object();

//**********************************************************************************//
Validate.validateCareerSubmitForm = function(formName){
    var frmObj = document.forms[formName];

    var currDate = $('#curr_date').val(); //yyyy-mm-dd
    var currDateArr = currDate.split('-');
    currDate = new Date(currDateArr[0], currDateArr[1] - 1, currDateArr[2]);
    
    var startDate = new Date($('#career select[name=start_dd_year]').val(),
                            $('#career select[name=start_dd_month]').val() - 1,
                            $('#career select[name=start_dd_day]').val());
    if (startDate < currDate) {
        alert('Invalid Classified Start Date. It must be later than current date')
        return false;
    }

    var deadline_year = $('#career select[name=deadline_dd_year]').val();
    var deadline_month = $('#career select[name=deadline_dd_month]').val();
    var deadline_day = $('#career select[name=deadline_dd_day]').val();

    //validate only if there are any deadline entered
    if (deadline_year != '' || deadline_month != '' || deadline_day != '')
    var deadline = new Date(deadline_year, deadline_month - 1, deadline_day);
    if (deadline < currDate) {
        alert('Invalid Application Deadline date. It must be later than current date')
        return false;
    }

    if (!frmObj.agree_terms.checked) {
        alert('You have to agree to the terms & conditions first before submitting the career ad!');
        return false;
    }
    
    return true;

} 


////**********************************************************************************
//Validate.validateEditProfile = function(){
//  formName  = document.forms['editProfile'];
//
//
//// sur name
//         if (isTextEmpty(formName.last_name.value))
//         {
//           alert('Please enter the surname!');
//           formName.last_name.select();
//           return false;
//         }
//
//// first_name
//         if (isTextEmpty(formName.first_name.value))
//         {
//           alert('Please enter your first name!');
//           formName.first_name.select();
//           return false;
//         }
//
//// date_of_birth
//         if (isTextEmpty(formName.dob_day.value) || isTextEmpty(formName.dob_month.value) || isTextEmpty(formName.dob_month.value))
//         {
//           alert('Please enter your date of birth!');
//           formName.dob_day.focus();
//           return false;
//         }
//
//// work_phone
//         if (isTextEmpty(formName.work_phone.value))
//         {
//           alert('Please enter your office telephone no!');
//           formName.work_phone.select();
//           return false;
//         }
//
//// phone
//         if (isTextEmpty(formName.phone.value))
//         {
//           alert('Please enter your residential telephone no!');
//           formName.phone.select();
//           return false;
//         }
//
//// hk_id_no
//         if (isTextEmpty(formName.hk_id_no.value))
//         {
//           alert('Please enter your HK ID no.!');
//           formName.hk_id_no.select();
//           return false;
//         }
//
//// email
//         if (!isValidEmail(formName.email.value))
//         {
//           alert('Please enter a valid email address!');
//           formName.email.select();
//           return false;
//         }
//
//
//}
//
////**********************************************************************************
//Validate.validateEditPassword = function(){
//  formName = document.forms['editPassword'];
//
//  if (isTextEmpty(formName.old_password.value)|| isTextEmpty(formName.new_password1.value) || isTextEmpty(formName.new_password2.value) )
//         {
//           alert('Please enter proper values!');
//           formName.old_password.select();
//          return false;
//          }
//
//  if ( formName.new_password1.value != formName.new_password2.value )
//         {
//           alert('Your new password and confirm password are not the same!');
//           formName.new_password1.select();
//          return false;
//  }
//
//
//        
// if (confirm('Are you sure you want to modify this entry?'))
//  {
//    formName.submit();
//  } else {
//    return false;
//  }
//
//}
//
////**********************************************************************************
//Validate.validateEnquiry = function(){
//  formName  = document.forms['enquiry'];
//
//// name
//         if (isTextEmpty(formName.name.value))
//         {
//           alert('Please enter your name!');
//           formName.name.select();
//           return false;
//         }
//
//// email
//         if (!isValidEmail(formName.email.value))
//         {
//           alert('Please enter a valid email address!');
//           formName.email.select();
//           return false;
//         }
//
//// country
//         if (!isDropDownSelected('country', 'enquiry' ))
//         {
//           alert('Please select your country!');
//           formName.country.focus();
//           return false;
//         }
//
//// comments
//         if (isTextEmpty(formName.comments.value))
//         {
//           alert('Please enter your comments!');
//           formName.comments.select();
//           return false;
//         }
//} 
//
