// JavaScript Document

//check for a valid time
function ChkTime(ctrl,strAlert){
	alert("---" + ctrl.value);
	alert(replace(".",":"));
	dt=new Date();//ctrl.value
	strNewDate=dt.getDate()+"/"+dt.getMonth()+"/"+dt.getFullYear()+ " " +ctrl.value ;
	dt1=new Date(strNewDate);
	if (isNaN(dt1.getHours())){
		alert( strAlert + " must be a valid time (hh:mm:ss)" );
		ctrl.focus();
		return false;
	}
	return true;
}

//check if the valu in a filed is a valid date
function ChkDate(ctrl,strAlert){
	dt=new Date(ctrl.value);
	//'alert();
	if (isNaN(dt.getDay())){
		alert( strAlert + " must be a valid date (dd/mm/yyyy)" );
		ctrl.focus();
		return false;
	}
	return true;
}

//check the value spplied is a vaid date
function ChkDateVal(val,strAlert){
	dt=new Date(val);
	//'alert();
	if (isNaN(dt.getDay())){
		if (strAlert!=""){
			alert( strAlert + " must be a valid date (dd/mm/yyyy)" );
		}
		return false;
	}
	return true;
}

//check the value spplied is a vaid email
function ChkEmail(ctrl,strAlert){
	//alert(ctrl.value);
	strEml=new String(ctrl.value);
	//'alert();
	if (strEml.indexOf("@")>0){
		if (strEml.indexOf(".")<=0){
			if (strAlert!=""){
				alert( strAlert + " must be a valid Email (foo@bar.com)" );
			}
			ctrl.focus();
			ctrl.select();
			return false;
			}
	}
	else
	{
		if (strAlert!=""){
			alert( strAlert + " must be a valid Email (foo@bar.com)" );
		}
		ctrl.focus();
		ctrl.select();
		return false;
	}
	return true;
}

//will be called by the form
function validateForm(frm){
		if(chkFields(frm)){
				return true;
			}
		else
			return false;
}

//check for empty fiel;d
function checkEmpty(ctrl,strAlert){
	if (ctrl.value==""){
		alert( strAlert + " can not be empty" );
		ctrl.focus();
		return false;
	}
	return true;
}

//function to chkif it is numeric
function chkNum(ctrl,strAlert){
	if (isNaN(ctrl.value)){
		alert( strAlert + " must be a numeric value" );
		ctrl.focus();
		return false;
	}
	return true;
}