function validateStats(frm) {
	if (CheckIsBlank(frm.dfrom, "Please enter the Start Date")) return false;
	if (isDate(frm.dfrom.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.dfrom.focus();
		frm.dfrom.select();
		return false;
	}
	if (CheckIsBlank(frm.dto, "Please enter the End Date")) return false;
	if (isDate(frm.dto.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.dto.focus();
		frm.dto.select();
		return false;
	}
	//Swap date if Start Date > End Date
	var tmpStartDate = new Date(getDateFromFormat(frm.dfrom.value,"dd/MM/yyyy"));
	var tmpEndDate = new Date(getDateFromFormat(frm.dto.value,"dd/MM/yyyy"));
	var tmpDate;
	if (tmpStartDate > tmpEndDate) {
		tmpDate = frm.dfrom.value;
		frm.dfrom.value = frm.dto.value;
		frm.dto.value = tmpDate;
	}
	if (frm.dfrom.value!="") frm.hdfrom.value = formatDate(new Date(getDateFromFormat(frm.dfrom.value,"dd/MM/yyyy")),"yyyyMMdd");
	if (frm.dto.value!="") frm.hdto.value = formatDate(new Date(getDateFromFormat(frm.dto.value,"dd/MM/yyyy")),"yyyyMMdd");
}
function showExtra(id) {
	if (document.getElementById(id).style.display == "block"){
		document.getElementById(id).style.display = "none";
	} else {
		document.getElementById(id).style.display = "block";
	}
}
function validateLinks_Edit(frm) {
	trimAllTextField(frm);
	if (CheckIsBlankcbo(frm.tag, "Please select the Tag Type")) return false;	
	if (CheckIsBlank(frm.linkname, "Please enter the Link Name")) return false;
	if (CheckIsBlank(frm.url, "Please enter the URL")) return false;
	if (isUrl(frm.url.value)==false) {
		alert("Please enter a valid URL");
		frm.url.select();
		frm.url.focus();
		return false;
	}
	return true;
}
function validateLinks_Add(frm) {
	trimAllTextField(frm);
	if (CheckIsBlankcbo(frm.tag, "Please select the Tag Type")) return false;	
	if (CheckIsBlank(frm.linkname, "Please enter the Link Name")) return false;
	if (CheckIsBlank(frm.url, "Please enter the URL")) return false;
	if (isUrl(frm.url.value)==false) {
		alert("Please enter a valid URL");
		frm.url.select();
		frm.url.focus();
		return false;
	}
	return true;
}
function goFPwd(href, acctype) {
	if (acctype[0].checked) { //company
		href += "?acctype=company";
	} else if (acctype[1].checked) { //company
		href += "?acctype=jobseeker";
	}
	location.href = href;
}
function quickJobSearch(frm, v) {
	if (v==1) {
		frm.action = "seeker/jobsearch.php";
	} else {
		frm.action = "jobsearch.php";
	}
	frm.submit();
}
function quickLogin(frm) {
	if (CheckIsBlank(frm.q_userid, "Please enter your UserID")) return false;
	if (CheckIsBlankNoTrim(frm.q_pwd, "Please enter your Password")) return false;
	if (frm.q_acctype[0]!=null) {
		if (CheckIsBlankradio(frm.q_acctype, "Please select Account Type")) return false;
	}
	frm.qtask.value = "qlogin";
	frm.action = "controller.php";
	frm.submit();
}
function chkSet2(isactive, obj) {
	if (getCheckCount(obj)==0) {
		alert("Please select at least one record.");
		return false;
	}
	var frm = document.forms[0];
	if (confirm("Are you sure want to update the selected record(s)?")) {
		frm.action = "../controller.php";
		frm.task.value = (isactive==1?"news_list_update":"news_list_update_inactive");
		frm.submit();
	}
}
function chkSet(isactive, obj) {
	if (getCheckCount(obj)==0) {
		alert("Please select at least one record.");
		return false;
	}
	var frm = document.forms[0];
	if (confirm("Are you sure want to update the selected record(s)?")) {
		frm.action = "../controller.php";
		if (frm.hacctype.value=="co") { //Company		
			frm.task.value = (isactive==1?"acc_list_co_update":"acc_list_co_update_inactive");
		} else { //Seeker
			frm.task.value = (isactive==1?"acc_list_seek_update":"acc_list_seek_update_inactive");
		}
		frm.submit();
	}
}
function validateCoAccList(frm) {
	if ((frm.dfrom.value != "") || (frm.dto.value != "")) {
		if (CheckIsBlank(frm.dfrom, "Please enter the Start Date")) return false;
		if (isDate(frm.dfrom.value,"dd/MM/yyyy")==false) {
			alert("Please enter a valid Date");
			frm.dfrom.focus();
			frm.dfrom.select();
			return false;
		}
		if (CheckIsBlank(frm.dto, "Please enter the End Date")) return false;
		if (isDate(frm.dto.value,"dd/MM/yyyy")==false) {
			alert("Please enter a valid Date");
			frm.dto.focus();
			frm.dto.select();
			return false;
		}
		//Swap date if Start Date > End Date
		var tmpStartDate = new Date(getDateFromFormat(frm.dfrom.value,"dd/MM/yyyy"));
		var tmpEndDate = new Date(getDateFromFormat(frm.dto.value,"dd/MM/yyyy"));
		var tmpDate;
		if (tmpStartDate > tmpEndDate) {
			tmpDate = frm.dfrom.value;
			frm.dfrom.value = frm.dto.value;
			frm.dto.value = tmpDate;
		}
		if (frm.dfrom.value!="") frm.hdfrom.value = formatDate(new Date(getDateFromFormat(frm.dfrom.value,"dd/MM/yyyy")),"yyyyMMdd");
		if (frm.dto.value!="") frm.hdto.value = formatDate(new Date(getDateFromFormat(frm.dto.value,"dd/MM/yyyy")),"yyyyMMdd");
	} else {
		frm.hdfrom.value = "";
		frm.hdto.value = "";
	}	
	return true;
}
function validateForgotPwd(frm) {
	trimAllTextField(frm);
	switch (frm.task.value) {
		case "forgotpwd_co":			
			if (CheckIsBlank(frm.email, "Please enter the Corp Email Address")) return false;
			if (!CheckIsEmail(frm.email, "Please enter a valid Email Address")) return false;
			break;
		case "forgotpwd_seek":
			if (CheckIsBlank(frm.email, "Please enter the Email Address")) return false;
			if (!CheckIsEmail(frm.email, "Please enter a valid Email Address")) return false;
			break;		
	}
	return true;
}
function validateSelectPkg(frm) {
	if (CheckIsBlankradio(frm.pkg_id, "Please select a Package to continue")) return false;
	return true;
}
function validateRegCo(frm, step) {
	trimAllTextField(frm);
	switch (step) {
		case 1:
			if (CheckIsBlank(frm.userid, "Please enter the User ID")) return false;
			if (!CheckNoSpace(frm.userid, null, "User ID")) return false;			
			if (CheckIsBlank(frm.pwd, "Please enter the Password")) return false;
			if (CheckIsBlank(frm.pwd1, "Please retype the Password")) return false;
			if (frm.pwd.value != frm.pwd1.value) {
				alert("Please retype the Password");
				frm.pwd1.focus();
				frm.pwd1.select();
				return false;
			}
			if ((frm.userid_2nd.value != "") || (frm.pwd_2nd.value != "") || (frm.pwd1_2nd.value != "")) {
				if (CheckIsBlank(frm.userid_2nd, "Please enter the User ID")) return false;
				if (!CheckNoSpace(frm.userid_2nd, null, "User ID")) return false;			
				if (CheckIsBlank(frm.pwd_2nd, "Please enter the Password")) return false;
				if (CheckIsBlank(frm.pwd1_2nd, "Please retype the Password")) return false;
				if (frm.pwd_2nd.value != frm.pwd1_2nd.value) {
					alert("Please retype the Password");
					frm.pwd1_2nd.focus();
					frm.pwd1_2nd.select();
					return false;
				}
				if (frm.userid_2nd.value == frm.userid.value) {
					alert("Please enter another User ID as it's already been used as 1st User ID");
					frm.userid_2nd.focus();
					frm.userid_2nd.select();
					return false;
				}
			}
			if (CheckIsBlank(frm.co_name, "Please enter Company Name")) return false;
			if (CheckIsBlank(frm.regno, "Please enter Company's Registration Number")) return false;
			if (CheckIsBlank(frm.email, "Please enter an Email Address")) return false;
			if (!CheckIsEmail(frm.email, "Please enter a valid Email Address")) return false;
			if ((frm.website.value != "") && (isUrl(frm.website.value)==false)) {
				alert("Please enter a valid URL");
				frm.website.select();
				frm.website.focus();
				return false;
			}	
			if (CheckIsBlank(frm.addr, "Please enter an address")) return false;
			if (CheckIsBlank(frm.postcode, "Please enter a Postal Code")) return false;
			if (CheckIsBlank(frm.ctry, "Please select a country ")) return false;		
			if (CheckIsBlank(frm.tel, "Please enter a telephone number")) return false;			
			break;
		case 2:
			if (CheckIsBlankradio(frm.pkg_id, "Please select a Package")) return false;	
			break;
		case 99:
			if (CheckIsBlankChk(frm.chkcorrect, "Please make sure all the info you filled in are correct and tick the checkbox to continue.")) return false;	
			break;			
	}
	return true;
}
function validateRegSeeker(frm, step) {
	trimAllTextField(frm);
	switch (step) {
		case 1:
			frm.nric.value = frm.nric.value.toUpperCase();
			if (CheckIsBlank(frm.userid, "Please enter the User ID")) return false;
			if (!CheckNoSpace(frm.userid, null, "User ID")) return false;			
			if (CheckIsBlank(frm.pwd, "Please enter the Password")) return false;
			if (CheckIsBlank(frm.pwd1, "Please retype the Password")) return false;
			if (frm.pwd.value != frm.pwd1.value) {
				alert("Please retype the Password");
				frm.pwd1.focus();
				frm.pwd1.select();
				return false;
			}
			if (CheckIsBlank(frm.fname, "Please enter the First Name")) return false;
			if (CheckIsBlank(frm.lname, "Please enter the Last Name")) return false;
			if (CheckIsBlankradio(frm.issingaporean, "Please tell us your Nationality")) return false;	
			if (frm.issingaporean[0].checked) {
				if (CheckIsBlank(frm.nric, "Please enter the NRIC No.")) return false;
				if (!nricIsValid(frm.nric.value)) {
					alert("Please enter a valid NRIC No.");
					frm.nric.focus();
					frm.nric.select();
					return false;
				}
			}
			if (CheckIsBlankradio(frm.gender, "Please tell us your Gender")) return false;	
			if (CheckIsBlank(frm.dob, "Please enter the Date of Birth")) return false;
			if (isDate(frm.dob.value,"dd/MM/yyyy")==false) {
				alert("Please enter a valid Date");
				frm.dob.focus();
				frm.dob.select();
				return false;
			}
			if (CheckIsBlank(frm.email, "Please enter the Email Address")) return false;
			if (!CheckIsEmail(frm.email, "Please enter a valid Email Address")) return false;
			if (CheckIsBlank(frm.addr, "Please enter the Address")) return false;
			if (CheckIsBlank(frm.postcode, "Please enter the Post Code")) return false;
			if (CheckIsBlankcbo(frm.ctry, "Please select the Country")) return false;			
			break;
		case 2:
			if (CheckIsBlankradio(frm.pkg_id, "Please select a Package")) return false;	
			break;
		case 99:
			if (CheckIsBlankChk(frm.chkcorrect, "Please make sure all the info you filled in are correct and tick the checkbox to continue.")) return false;	
			break;
	}
	return true;
}
function validateLandingNews(frm) {
	trimAllTextField(frm);
	if (getFCKEditorText("landingnews")=="") {
		alert("Please enter the News Content");
		setFCKEditorFocus("landingnews");
		return false;
	}
	return true;
}
function validateCoNews_Edit(frm) {
	trimAllTextField(frm);
	if (CheckIsBlank(frm.topic, "Please enter the Topic")) return false;
	if (getFCKEditorText("mdesc")=="") {
		alert("Please enter the Content");
		setFCKEditorFocus("mdesc");
		return false;
	}
	//if (CheckIsBlankcbo(frm.ntype, "Please select the Type")) return false;
	if (CheckIsBlankradio(frm.issub, "Please make whether this entry Is Sub News")) return false;
	if (CheckIsBlankradio(frm.isactive, "Please make whether this entry Show to Public")) return false;	
	return true;
}
function validateCoNews_Add(frm) {
	trimAllTextField(frm);
	if (CheckIsBlank(frm.topic, "Please enter the Topic")) return false;
	if (getFCKEditorText("mdesc")=="") {
		alert("Please enter the Content");
		setFCKEditorFocus("mdesc");
		return false;
	}
	//if (CheckIsBlankcbo(frm.ntype, "Please select the Type")) return false;	
	if (CheckIsBlankradio(frm.issub, "Please make whether this entry Is Sub News")) return false;
	if (CheckIsBlankradio(frm.isactive, "Please make whether this entry Show to Public")) return false;	
	return true;
}
function validateSeekerJobSearch(frm) {
	trimAllTextField(frm);
	if (frm.salary_from != null) {
		if ((frm.salary_from.value!="") || (frm.salary_to.value!="")) {
			if (isnumeric(frm.salary_from.value)==false) {
				alert("Please enter a numeric value for Salary Range");
				frm.salary_from.focus();
				frm.salary_from.select();
				return false;
			}
			if (frm.salary_to.value != "") {
				if (isnumeric(frm.salary_to.value)==false) {
					alert("Please enter a numeric value for Salary Range");
					frm.salary_to.focus();
					frm.salary_to.select();
					return false;
				}
			}
			if ((frm.salary_from.value != "") && (frm.salary_to.value == "")) {
				frm.salary_to.value = frm.salary_from.value;
			} else if ((frm.salary_from.value == "") && (frm.salary_to.value != "")) {
				frm.salary_from.value = frm.salary_to.value;
			}
			if ((numeric(frm.salary_from.value))>(numeric(frm.salary_to.value))) {
				tmpValue = frm.salary_from.value;
				frm.salary_from.value = frm.salary_to.value;
				frm.salary_to.value = tmpValue;
			}
		}
		if (frm.yr_exp.value != "") {
			if (isnumeric(frm.yr_exp.value)==false) {
				alert("Please enter a numeric value for Years of experience");
				frm.yr_exp.focus();
				frm.yr_exp.select();
				return false;
			}
		}
		if (frm.yr_aviation.value != "") {
			if (isnumeric(frm.yr_aviation.value)==false) {
				alert("Please enter a numeric value for Years of aviation related experience");
				frm.yr_aviation.focus();
				frm.yr_aviation.select();
				return false;
			}
		}
	}
	return true;
}
function validateCoCanddSearch(frm) {
	if (frm.salary_from != null) {
		if (frm.salary_from.value != "") {
			if (isnumeric(frm.salary_from.value)==false) {
				alert("Please enter a numeric value for Minimum Salary");
				frm.salary_from.focus();
				frm.salary_from.select();
				return false;
			}
		}	
		if (frm.avail[1].checked) {
			if (CheckIsBlank(frm.avail_afterdate, "Please enter the Date")) return false;
			if (isDate(frm.avail_afterdate.value,"dd/MM/yyyy")==false) {
				alert("Please enter a valid Date");
				frm.avail_afterdate.focus();
				frm.avail_afterdate.select();
				return false;
			}
		}
	}
	return true;
}
function validateCoNewsList(frm) {
	if (CheckIsBlank(frm.showstart, "Please enter the Start Date")) return false;
	if (isDate(frm.showstart.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.showstart.focus();
		frm.showstart.select();
		return false;
	}
	if (CheckIsBlank(frm.showstart, "Please enter the End Date")) return false;
	if (isDate(frm.showend.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.showend.focus();
		frm.showend.select();
		return false;
	}
	//Swap date if Start Date > End Date
	var tmpStartDate = new Date(getDateFromFormat(frm.showstart.value,"dd/MM/yyyy"));
	var tmpEndDate = new Date(getDateFromFormat(frm.showend.value,"dd/MM/yyyy"));
	var tmpDate;
	if (tmpStartDate > tmpEndDate) {
		tmpDate = frm.showstart.value;
		frm.showstart.value = frm.showend.value;
		frm.showend.value = tmpDate;
	}
	return true;
}
function validateSeekerResumeReq(frm) {
	if (CheckIsBlank(frm.showstart, "Please enter the Start Date")) return false;
	if (isDate(frm.showstart.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.showstart.focus();
		frm.showstart.select();
		return false;
	}
	if (CheckIsBlank(frm.showstart, "Please enter the End Date")) return false;
	if (isDate(frm.showend.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.showend.focus();
		frm.showend.select();
		return false;
	}
	//Swap date if Start Date > End Date
	var tmpStartDate = new Date(getDateFromFormat(frm.showstart.value,"dd/MM/yyyy"));
	var tmpEndDate = new Date(getDateFromFormat(frm.showend.value,"dd/MM/yyyy"));
	var tmpDate;
	if (tmpStartDate > tmpEndDate) {
		tmpDate = frm.showstart.value;
		frm.showstart.value = frm.showend.value;
		frm.showend.value = tmpDate;
	}
	return true;
}
function validateSeekerHistory(frm) {
	if (CheckIsBlank(frm.showstart, "Please enter the Start Date")) return false;
	if (isDate(frm.showstart.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.showstart.focus();
		frm.showstart.select();
		return false;
	}
	if (CheckIsBlank(frm.showstart, "Please enter the End Date")) return false;
	if (isDate(frm.showend.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.showend.focus();
		frm.showend.select();
		return false;
	}	
	//Swap date if Start Date > End Date
	var tmpStartDate = new Date(getDateFromFormat(frm.showstart.value,"dd/MM/yyyy"));
	var tmpEndDate = new Date(getDateFromFormat(frm.showend.value,"dd/MM/yyyy"));
	var tmpDate;
	if (tmpStartDate > tmpEndDate) {
		tmpDate = frm.showstart.value;
		frm.showstart.value = frm.showend.value;
		frm.showend.value = tmpDate;
	}
	return true;
}
function editEmployment(frm) {
	if (CheckIsBlank(frm.empedit_co_name, "Please enter the Company Name")) return false;
	if (CheckIsBlank(frm.empedit_title, "Please enter the Title / Position")) return false;
	if (CheckIsBlankcbo(frm.empedit_work_from_mth, "Please tell us the Employment Period")) return false;
	if (CheckIsBlank(frm.empedit_work_from_yr, "Please enter the Employment Period")) return false;
	if ( !/^\d{4}$/.test( frm.empedit_work_from_yr.value ) ) {
		alert("Please enter a valid date format");
		frm.empedit_work_from_yr.focus();
		frm.empedit_work_from_yr.select();
		return false;
	}
	if (CheckIsBlankcbo(frm.empedit_work_to_mth, "Please tell us the Employment Period")) return false;
	if (CheckIsBlank(frm.empedit_work_to_yr, "Please enter the Employment Period")) return false;
	if ( !/^\d{4}$/.test( frm.empedit_work_to_yr.value ) ) {
		alert("Please enter a valid date format");
		frm.empedit_work_to_yr.focus();
		frm.empedit_work_to_yr.select();
		return false;
	}
	if (CheckIsBlank(frm.empedit_lastpaid, "Please tell us the Last Withdrawn Salary")) return false;
	if (isnumeric(frm.empedit_lastpaid.value)==false) {
		alert("Please enter a numeric value for Last Withdrawn Salary");
		frm.empedit_lastpaid.focus();
		frm.empedit_lastpaid.select();
		return false;
	}	
	if (getFCKEditorText("empedit_mdesc")=="") {
		alert("Please enter the Responsibilites / Achievements");
		setFCKEditorFocus("empedit_mdesc");
		return false;
	}
	frm.task.value = "editemployment";
	if (confirm("Are you sure want to proceed? Your resume will be updated once you proceed.")) {
		frm.submit();
	}
}
function addEmployment(frm) {
	if (CheckIsBlank(frm.emp_co_name, "Please enter the Company Name")) return false;
	if (CheckIsBlank(frm.emp_title, "Please enter the Title / Position")) return false;
	if (CheckIsBlankcbo(frm.emp_work_from_mth, "Please tell us the Employment Period")) return false;
	if (CheckIsBlank(frm.emp_work_from_yr, "Please enter the Employment Period")) return false;
	if ( !/^\d{4}$/.test( frm.emp_work_from_yr.value ) ) {
		alert("Please enter a valid date format");
		frm.emp_work_from_yr.focus();
		frm.emp_work_from_yr.select();
		return false;
	}
	if (CheckIsBlankcbo(frm.emp_work_to_mth, "Please tell us the Employment Period")) return false;
	if (CheckIsBlank(frm.emp_work_to_yr, "Please enter the Employment Period")) return false;
	if ( !/^\d{4}$/.test( frm.emp_work_to_yr.value ) ) {
		alert("Please enter a valid date format");
		frm.emp_work_to_yr.focus();
		frm.emp_work_to_yr.select();
		return false;
	}
	if (CheckIsBlank(frm.emp_lastpaid, "Please tell us the Last Withdrawn Salary")) return false;
	if (isnumeric(frm.emp_lastpaid.value)==false) {
		alert("Please enter a numeric value for Last Withdrawn Salary");
		frm.emp_lastpaid.focus();
		frm.emp_lastpaid.select();
		return false;
	}
	if (getFCKEditorText("emp_mdesc")=="") {
		alert("Please enter the Responsibilites / Achievements");
		setFCKEditorFocus("emp_mdesc");
		return false;
	}
	frm.task.value = "addemployment";
	if (confirm("Are you sure want to proceed? Your resume will be updated once you proceed.")) {
		frm.submit();
	}
}
function resetEmployment(frm) {
	frm.emp_co_name.value = "";
	frm.emp_title.value = "";
	frm.emp_work_from_mth.selectedIndex = 0;
	frm.emp_work_from_yr.value = "";
	frm.emp_work_to_mth.selectedIndex = 0;
	frm.emp_work_to_yr.value = "";
	frm.emp_lastpaid.value = "";
	setFCKEditorText("emp_mdesc","");
	frm.emp_co_name.focus();
}
function uploadResume(obj) {
	var app_MaxUploadSize = 5 * 1024 * 1024;
	var app_upload_profile_allowflist = "doc,pdf";
	checkUpload(obj, app_upload_profile_allowflist, app_MaxUploadSize, "uploadresume");	
}
function uploadResumePhoto(obj) {
	var app_MaxUploadSize = 512 * 1024;
	var app_upload_profile_allowflist = "swf,gif,jpg,jpeg,png";
	checkUpload(obj, app_upload_profile_allowflist, app_MaxUploadSize, "uploadresumephoto");	
}
function uploadResumePhoto2(obj) {
	var app_MaxUploadSize = 512 * 1024;
	var app_upload_profile_allowflist = "swf,gif,jpg,jpeg,png";
	checkUpload(obj, app_upload_profile_allowflist, app_MaxUploadSize, "uploadresumephoto2");
}
function uploadSeekerVideo(obj) {
	var app_MaxUploadSize = 1024 * 1024;
	var app_upload_profile_allowflist = "wmv,mp3";
	checkUpload(obj, app_upload_profile_allowflist, app_MaxUploadSize, "uploadseekervideo");	
}
function uploadCoLogo(obj) {
	var app_MaxUploadSize = 512 * 1024;
	var app_upload_profile_allowflist = "swf,gif,jpg,jpeg,png";
	checkUpload(obj, app_upload_profile_allowflist, app_MaxUploadSize, "uploadcologo");	
}
function uploadCoLogo2(obj) {
	var app_MaxUploadSize = 512 * 1024;
	var app_upload_profile_allowflist = "swf,gif,jpg,jpeg,png";
	checkUpload(obj, app_upload_profile_allowflist, app_MaxUploadSize, "uploadcologo2");
}
function validateApplyJob(frm) {
	if (CheckIsBlankChk(frm.isagree, "Please agree and then tick the checkbox to continue.")) return false;
	return true;
}
function validateCoCanddMgnt(frm) {
	trimAllTextField(frm);
	if ((frm.added_from.value != "") || (frm.added_to.value != "")) {
		if (CheckIsBlank(frm.added_from, "Please enter the date to continue")) return false;
		if (isDate(frm.added_from.value,"dd/MM/yyyy")==false) {
			alert("Please enter a valid Date");
			frm.added_from.focus();
			frm.added_from.select();
			return false;
		}
		if (CheckIsBlank(frm.added_to, "Please enter the date to continue")) return false;
		if (isDate(frm.added_to.value,"dd/MM/yyyy")==false) {
			alert("Please enter a valid Date");
			frm.added_to.focus();
			frm.added_to.select();
			return false;
		}
		//Swap date if Start Date > End Date
		var tmpStartDate = new Date(getDateFromFormat(frm.added_from.value,"dd/MM/yyyy"));
		var tmpEndDate = new Date(getDateFromFormat(frm.added_to.value,"dd/MM/yyyy"));
		var tmpDate;
		if (tmpStartDate > tmpEndDate) {
			tmpDate = frm.added_from.value;
			frm.added_from.value = frm.added_to.value;
			frm.added_to.value = tmpDate;
		}
		if (frm.added_from.value!="") frm.hadded_from.value = formatDate(new Date(getDateFromFormat(frm.added_from.value,"dd/MM/yyyy")),"yyyyMMdd");
		if (frm.added_to.value!="") frm.hadded_to.value = formatDate(new Date(getDateFromFormat(frm.added_to.value,"dd/MM/yyyy")),"yyyyMMdd");
	}
	return true;
}
function clearJobSearchForm(frm) {
	if (frm.jobtype) {
		frm.jobtype.selectedIndex = 0;
		frm.position.selectedIndex = 0;
		frm.qualification.selectedIndex = 0;
		frm.salary_from.value = "";
		frm.salary_to.value = "";
		frm.yr_exp.value = "";
		frm.emptype.selectedIndex = 0;
		frm.keyword.value = "";
	}
	frm.keyword.value = "";
	frm.keyword.focus();
}
function clearCoSearchForm(frm) {
	if (frm.isfreshgrad) {
		clearSelectRadio(frm.isfreshgrad);
		frm.yr_exp.value = "";
		frm.salary_from.value = "";
		frm.salary_chkexp.checked = false;
		frm.salary_chkcurr.checked = false;
		clearSelectRadio(frm.avail);
		frm.avail_afterdate.value = "";
	}
	frm.edulevel.selectedIndex = 0;
	frm.keyword.value = "";
	frm.keyword.focus();
}
function validateSeekerResumeEdit(frm) {
	trimAllTextField(frm);
	if (CheckIsBlankradio(frm.isfreshgrad, "Please tell us whether are you a Fresh Graduate?")) return false;	
	if (CheckIsBlank(frm.yr_exp, "Please tell us the Years of Experience")) return false;
	if (isnumeric(frm.yr_exp.value)==false) {
		alert("Please enter a numeric value for Years of Experience");
		frm.yr_exp.focus();
		frm.yr_exp.select();
		return false;
	}
	if (CheckIsBlank(frm.yr_aviation, "Please tell us the Years of Aviation Related Experience")) return false;
	if (isnumeric(frm.yr_aviation.value)==false) {
		alert("Please enter a numeric value for Years of Aviation Related Experience");
		frm.yr_aviation.focus();
		frm.yr_aviation.select();
		return false;
	}
	if (CheckIsBlankcbo(frm.edulevel, "Please tell us the Highest Academic Qualification")) return false;
	if (CheckIsBlank(frm.expsalary, "Please enter the Expected Salary")) return false;
	if (isnumeric(frm.expsalary.value)==false) {
		alert("Please enter a numeric value for Expected Salary");
		frm.expsalary.focus();
		frm.expsalary.select();
		return false;
	}
	/*
	if ((numeric(frm.expsalary.value)) < 300) {
		alert("Please enter a numeric value greater than 300");
		frm.expsalary.focus();
		frm.expsalary.select();
		return false;
	}*/
	if (CheckIsBlankradio(frm.availability, "Please tell us the Availability?")) return false;	
	if (frm.availability[1].checked) {
		if (CheckIsBlank(frm.avail_afterdate, "Please enter the Availability Date")) return false;
		if (isDate(frm.avail_afterdate.value,"dd/MM/yyyy")==false) {
			alert("Please enter a valid Date");
			frm.avail_afterdate.focus();
			frm.avail_afterdate.select();
			return false;
		}
	}
	if (frm.avail_afterdate.value!="") frm.havail_afterdate.value = formatDate(new Date(getDateFromFormat(frm.avail_afterdate.value,"dd/MM/yyyy")),"yyyy-MM-dd");
	if (getFCKEditorText("mdesc")=="") {
		alert("Please tell us briefly list a summary of your qualifications, career achievements, areas of strength, personality etc.");
		setFCKEditorFocus("mdesc");
		return false;
	}
	if (CheckIsBlankradio(frm.issearchable, "Please tell us whether you allow pontential employer to search your profile?")) return false;	
	if (frm.isneedresumeappr[0]) {
		if (CheckIsBlankradio(frm.isneedresumeappr, "Please tell us whether you allow pontential employer need your approval before can view your resume?")) return false;
	}
	return true;
}
function validateSeekerCoverLetterEdit(frm) {
	if (frm.isusecover.checked) {
		if (getFCKEditorText("coverletter")=="") {
			alert("Please enter the content of Cover Letter");
			setFCKEditorFocus("coverletter");
			return false;
		}
	}
	return true;
}
function validateCoJobPost_Edit(frm) {
	trimAllTextField(frm);
	if (frm.salary_from.value=="") frm.salary_from.value = "0";
	if (frm.salary_to.value=="") frm.salary_to.value = "0";
	
	if (CheckIsBlank(frm.title, "Please enter the Job Title")) return false;
	if (getFCKEditorText("mdesc")=="") {
		alert("Please enter the Job Description");
		setFCKEditorFocus("mdesc");
		return false;
	}
	if (CheckIsBlankcbo(frm.jobtype, "Please select the Job Type")) return false;
	if (CheckIsBlankcbo(frm.position, "Please select the Job Position")) return false;
	if (CheckIsBlankcbo(frm.qualification, "Please select the Qualification")) return false;
	//if (CheckIsBlank(frm.salary_from, "Please enter the Salary Range")) return false;
	if (frm.salary_from.value!="") {
		if (isnumeric(frm.salary_from.value)==false) {
			alert("Please enter a numeric value for Salary");
			frm.salary_from.focus();
			frm.salary_from.select();
			return false;
		}
	}
	//if (CheckIsBlank(frm.salary_to, "Please enter the Salary Range")) return false;
	if (frm.salary_to.value!="") {
		if (isnumeric(frm.salary_to.value)==false) {
			alert("Please enter a numeric value for Salary");
			frm.salary_to.focus();
			frm.salary_to.select();
			return false;
		}
	}	
	//Swap salary
	if ((frm.salary_from.value!="") || (frm.salary_to.value!="")) {
		var tmpsalary_from = numeric(frm.salary_from.value);
		var tmpsalary_to = numeric(frm.salary_to.value);
		var tmpsalary;
		if (tmpsalary_from > tmpsalary_to) {
			tmpsalary = frm.salary_from.value;
			frm.salary_from.value = frm.salary_to.value;
			frm.salary_to.value = tmpsalary;
		}
	}
	if (CheckIsBlank(frm.yr_exp, "Please enter the Year of Experience")) return false;
	if (isnumeric(frm.yr_exp.value)==false) {
		alert("Please enter a numeric value for Year of Experience");
		frm.yr_exp.focus();
		frm.yr_exp.select();
		return false;
	}
	if (CheckIsBlank(frm.yr_aviation, "Please enter the Year of Aviation Related Experience")) return false;
	if (isnumeric(frm.yr_aviation.value)==false) {
		alert("Please enter a numeric value for Year of Aviation Related Experience");
		frm.yr_aviation.focus();
		frm.yr_aviation.select();
		return false;
	}
	if (CheckIsBlankcbo(frm.emptype, "Please select the Employment Type")) return false;
	if (CheckIsBlankradio(frm.isactive, "Please make whether this entry Show to Public")) return false;	
	return true;
}
function validateCoJobPost_Add(frm) {
	trimAllTextField(frm);
	if (frm.salary_from.value=="") frm.salary_from.value = "0";
	if (frm.salary_to.value=="") frm.salary_to.value = "0";
	
	if (CheckIsBlank(frm.title, "Please enter the Job Title")) return false;
	if (getFCKEditorText("mdesc")=="") {
		alert("Please enter the Job Description");
		setFCKEditorFocus("mdesc");
		return false;
	}
	if (CheckIsBlankcbo(frm.jobtype, "Please select the Job Type")) return false;
	if (CheckIsBlankcbo(frm.position, "Please select the Job Position")) return false;
	if (CheckIsBlankcbo(frm.qualification, "Please select the Qualification")) return false;
	//if (CheckIsBlank(frm.salary_from, "Please enter the Salary Range")) return false;
	if (frm.salary_from.value!="") {
		if (isnumeric(frm.salary_from.value)==false) {
			alert("Please enter a numeric value for Salary");
			frm.salary_from.focus();
			frm.salary_from.select();
			return false;
		}
	}
	//if (CheckIsBlank(frm.salary_to, "Please enter the Salary Range")) return false;
	if (frm.salary_to.value!="") {
		if (isnumeric(frm.salary_to.value)==false) {
			alert("Please enter a numeric value for Salary");
			frm.salary_to.focus();
			frm.salary_to.select();
			return false;
		}
	}	
	//Swap salary
	if ((frm.salary_from.value!="") || (frm.salary_to.value!="")) {
		var tmpsalary_from = numeric(frm.salary_from.value);
		var tmpsalary_to = numeric(frm.salary_to.value);
		var tmpsalary;
		if (tmpsalary_from > tmpsalary_to) {
			tmpsalary = frm.salary_from.value;
			frm.salary_from.value = frm.salary_to.value;
			frm.salary_to.value = tmpsalary;
		}
	}
	if (CheckIsBlank(frm.yr_exp, "Please enter the Year of Experience")) return false;
	if (isnumeric(frm.yr_exp.value)==false) {
		alert("Please enter a numeric value for Year of Experience");
		frm.yr_exp.focus();
		frm.yr_exp.select();
		return false;
	}
	if (CheckIsBlank(frm.yr_aviation, "Please enter the Year of Aviation Related Experience")) return false;
	if (isnumeric(frm.yr_aviation.value)==false) {
		alert("Please enter a numeric value for Year of Aviation Related Experience");
		frm.yr_aviation.focus();
		frm.yr_aviation.select();
		return false;
	}
	if (CheckIsBlankcbo(frm.emptype, "Please select the Employment Type")) return false;
	if (CheckIsBlankradio(frm.isactive, "Please make whether this entry Show to Public")) return false;	
	return true;
}
function validateSeekerChangePwd(frm) {
	if (CheckIsBlank(frm.pwd, "Please enter the Current Password")) return false;
	if (CheckIsBlank(frm.newpwd, "Please enter the New Password")) return false;
	if (CheckIsBlank(frm.newpwd1, "Please re-enter the New Password")) return false;
	if (frm.newpwd.value != frm.newpwd1.value) {  
		alert("Your passwords do not match");
		frm.newpwd1.focus();
		frm.newpwd1.select();
		return false;
	}
	return true;
}
function validateCoChangePwd(frm) {
	if (CheckIsBlank(frm.pwd, "Please enter the Current Password")) return false;
	if (CheckIsBlank(frm.newpwd, "Please enter the New Password")) return false;
	if (CheckIsBlank(frm.newpwd1, "Please re-enter the New Password")) return false;
	if (frm.newpwd.value != frm.newpwd1.value) {  
		alert("Your passwords do not match");
		frm.newpwd1.focus();
		frm.newpwd1.select();
		return false;
	}
	return true;
}
function validateSeekerProfileEdit(frm) {
	trimAllTextField(frm);
	if (CheckIsBlank(frm.fname, "Please enter your First Name")) return false;
	if (CheckIsBlank(frm.lname, "Please enter your Last Name")) return false;
	if (CheckIsBlankradio(frm.gender, "Please select your Gender")) return false;	
	if (CheckIsBlank(frm.dob, "Please enter your Date of Birth")) return false;
	if (isDate(frm.dob.value,"dd/MM/yyyy")==false) {
		alert("Please enter a valid Date");
		frm.dob.focus();
		frm.dob.select();
		return false;
	}
	if (CheckIsBlank(frm.email, "Please enter an Email Address")) return false;
	if (!CheckIsEmail(frm.email, "Please enter a valid Email Address")) return false;
	if (CheckIsBlank(frm.addr, "Please enter an address")) return false;
	if (CheckIsBlank(frm.postcode, "Please enter a Postal Code")) return false;
	if (CheckIsBlank(frm.ctry, "Please select a country ")) return false;		
	return true;
}
function validateCoProfileEdit(frm) {
	trimAllTextField(frm);
	if (CheckIsBlank(frm.co_name, "Please enter Company Name")) return false;
	if (CheckIsBlank(frm.regno, "Please enter Company's Registration Number")) return false;
	if (CheckIsBlank(frm.email, "Please enter an Email Address")) return false;
	if (!CheckIsEmail(frm.email, "Please enter a valid Email Address")) return false;
	if ((frm.website.value != "") && (isUrl(frm.website.value)==false)) {
		alert("Please enter a valid URL");
		frm.website.select();
		frm.website.focus();
		return false;
	}	
	if (CheckIsBlank(frm.addr, "Please enter an address")) return false;
	if (CheckIsBlank(frm.postcode, "Please enter a Postal Code")) return false;
	if (CheckIsBlank(frm.ctry, "Please select a country ")) return false;		
	if (CheckIsBlank(frm.tel, "Please enter a telephone number")) return false;	
	return true;
}

function validateLogin(frm) {
	if (CheckIsBlank(frm.userid, "Please enter your UserID")) return false;
	if (CheckIsBlankNoTrim(frm.pwd, "Please enter your Password")) return false;
	if (CheckIsBlankradio(frm.acctype, "Please select Account Type")) return false;
	return true;
}








//Ver 1.2 - Disable file size check
function checkUpload(file, fileexts, filesize, task) {
	var frm = file.form;
	if (file.value == "") {
		alert("Please select a file to attach.");
		file.focus();
		return false;
	}
	//Check file extension
	var validExts = fileexts.split(",");
	if (!isValidFileExtension(file.value, validExts)) {
		alert("Make sure only supported file is selected");
		file.focus();
		file.select();
		return false;
	}
	//Check file size
	//var fsize = getFileSize(file.value);
	var fsize = 0.1;
	if (fsize == 0) {
		alert("Make sure the content to upload is valid");
		file.focus();
		file.select();
		return false;
	} else if (fsize > filesize) {
		alert("Make sure the content to upload is within size allowed");
		file.focus();
		file.select();
		return false;
	}	
	try {
		try {
			if (task != null) frm.task.value = task;
		} catch (e) {}
		frm.submit();
	} catch (e) {
		alert("Unable to upload your content, make sure the content is valid.");
		file.focus();
		file.select();
		return false;
	}
}
function sortList(frm, sort, sortorder) {
	frm.reset();
	frm.sort.value = sort;
	frm.sortorder.value = sortorder;
	frm.submit();
}

//Ver 2.4 for checkbox named as chk[] Updated 31 Jan 08
function deleteSelected(task, msg, frm, action, atleastmsg, noconfirmation) {
	if (frm == null) frm = document.forms[0];
	if (msg == null) msg = "Are you sure want to delete the selected record(s)?";
	if (atleastmsg == null) atleastmsg = "Please select at least a record to delete";
	if (action == null) action = "controller.php";
	if (noconfirmation == null) noconfirmation = false;
	
	if (document.getElementById('chk[]') == null) {
		//Nothing		
	//} else if (frm.chk.length == null) {
	} else if (frm.elements['chk[]'].length == null) {
		//Only one item
		if (!document.getElementById('chk[]').checked) {
			alert(atleastmsg);
		} else {
			if (noconfirmation) {
				frm.action = action;
				frm.task.value = task;
				frm.submit();
			} else if (confirm(msg)) {
				frm.action = action;
				frm.task.value = task;
				frm.submit();
			}
		}
	} else {
		var cnt = 0;
		for(i=0;i<frm.elements['chk[]'].length;i++){
        	if (frm.elements['chk[]'][i].checked) cnt = cnt + 1;
        }
		if (cnt==0) {
			alert(atleastmsg);
		} else {
			if (noconfirmation) {
				frm.action = action;
				frm.task.value = task;
				frm.submit();
			} else if (confirm(msg)) {
				frm.action = action;
				frm.task.value = task;
				frm.submit();
			}
		}
	}
}
