/* e-service common function */
$e=
{
	data:{
		_submit:function(n){
			$g.form=$(n.form);
			ColdFusion.Ajax.submitForm(n.form,n.url,n.callback,n.onerror);
		}
	},
	error:{
		_exist:function(n){
			var cf=ColdFusion.JSON.decode(n);
			if(cf.error.length){
			return true;
			}
			return false;
		},
		_process:function(n){
			var cf=ColdFusion.JSON.decode(n);
			$e.error._clear();
			if(cf.error.length){
				var focused=0;
				var type,allow;
				for(var i=0;i<cf.error.length;i++){
					for(id in cf.error[i]){
					$e.error._show({id:id,text:cf.error[i][id]});
					}
					if(!focused){
						type=$g.form[id].type;
						allow={};
						allow[type]=0;
						allow["text"]=1;
						if(allow[type]){
							focused=1;
							$g.form[id].focus();
						}
					}
				}
				return false;
			}
			return true;
		},
		_clear:function(n){
			for(id in $g.error){
			$($g.error[id]).style.display="none";
			}
		},
		_show:function(n){
			var id="e_"+n.id;
			$(id).style.display="block";
			$(id).innerHTML=n.text;
			$g.error[n.id]=id;
		},
		_alert:function(n){
			window.alert("["+n+"] Your session has expired.");
		}
	}
};

/* e-service temporary storage */
$g=
new function(n){
	this.error={};
	this.form=$("myForm");
}

