// namespace : webon.js.form_tools
// version : 1.0.0
// modify : 24/09/2004

function validation(form){
	for(var i=0;i<form.elements.length;i++){
		var input=form.elements[i];
		var check=getAttrValue(input,"check");
		if(typeof(check)=='undefined')continue;
		if(check=="")continue;
		if(validation_check(form,input,check)==false){
			if(input.focus)input.focus();
			return false;
		}
	}
	return true;
	
}

function validation_check(form,input,checkString){
	var checks=checkString.split(";");
	for(var i=0;i<checks.length;i++){
		var c=checks[i];
		var temp=c.split(":");
		var method=temp.length>0?temp[0]:"";
		var params=temp.length>1?","+temp[1]:"";
		if(window[method]){
			var e=method+"(form,input"+params+")";
			var result=eval(e);
			if(result==false)return false;
			
		}else{
			alert("Validation method ["+method+"] not found.");
			return false;
		}
	}
	return true;
}

function show_error_msg(msg,vars,values){
	for(var i=0;i<vars.length;i++){
		var v=vars[i];
		var reg=new RegExp(v,"ig");
		msg=msg.replace(v,values[i]);
	}
	alert(msg);
}








