// trim functionality
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}

function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function isIntMobile(frm, obj, val) {
	if (trim(val).length > 0) {
		var pattern = "^[+][1-9]{1}[0-9]*$"
		return (val.match(pattern) != null) ? true : false
	} else {
		return true
	}	
}

function isMobile(frm, obj, val) {
	if (trim(val).length > 0) {
		var pattern = "^06[1-8]{1}[0-9]{7}$"
		return (val.match(pattern) != null) ? true : false
		
	} else {
		return true
	}	
}

function isZip(frm, obj, val) {
	if (trim(val).length > 0) {
		var pattern = "^[1-9][0-9]{3}\s?[a-zA-Z]{2}$"
		return (val.match(pattern) != null) ? true : false
	} else {
		return true
	}
}

function isPhone(frm, obj, val) {
	if (trim(val).length > 0) {
		var pattern = "^[0-9]{10}$"
		return (val.match(pattern) != null) ? true : false
	} else {
		return true
	}
}

function isAlphaNumeric(frm, obj, val) {
	if (trim(val).length > 0) {
		var pattern = "^[a-zA-Z0-9]+$"
		return (val.match(pattern) != null) ? true : false
	} else {
		return true
	}	
}

function IsPswrdMinLength(frm, obj, val) {
	if(val.length > 4){
		return true
	} else {
		return false
	}
}

function onValidatePositiveResponseRequiredRadioGroup(frm, obj, val) {
	if (frm.IsParticipant) {
		var IsParticipant = frm.IsParticipant[0].value == 1 ? frm.IsParticipant[0].checked : frm.IsParticipant[1].checked
		if (IsParticipant) return _CF_hasValue(obj, "RADIO", false )
		return true
	} else {
		return true
	}
}

function onValidateNegativeResponseRequiredRadioGroup(frm, obj, val) {
	if (frm.IsParticipant) {
		var IsParticipant = frm.IsParticipant[0].value == 1 ? frm.IsParticipant[0].checked : frm.IsParticipant[1].checked
		if (!IsParticipant) return _CF_hasValue(obj, "RADIO", false )
		return true
	} else {
		return true
	}
}

function onValidatePositiveResponseRequiredCheckbox(frm, obj, val) {
	if (frm.IsParticipant) {
		var IsParticipant = frm.IsParticipant[0].value == 1 ? frm.IsParticipant[0].checked : frm.IsParticipant[1].checked
		if (IsParticipant) return obj.checked
		return true
	} else {
		return true
	}
}

function onValidateNegativeResponseRequiredCheckbox(frm, obj, val) {
	if (frm.IsParticipant) {
		var IsParticipant = frm.IsParticipant[0].value == 1 ? frm.IsParticipant[0].checked : frm.IsParticipant[1].checked
		if (!IsParticipant) return obj.checked
		return true
	} else {
		return true
	}
}