util = {
	/**
	*	Make ajaxRequest to server by form id
	*
	*	@param {String} id - The id of the form
	*	@param {Object} params - name value pairs to be sent to with request, 
	*		for example: {param1: '1', p2: 'eqwed'}; must be flat.
	*	@param {function} successFnk: - callback returning the json succ object
	*				eg.: function(obj) { //process response json obj from server }	
	*/
	ajaxRequest: function(form_id, params, successFnk) {
		Ext.Ajax.request({
	        url: Ext.query('#'+form_id)[0].action,
	        success: function(res, action){
	        	var r = res.responseText;
	        	try{
	        		r = Ext.decode(r);
	        	}catch(e){}
           		successFnk(r);
	        },
	        
	        failure: function(res, action){
	            Ext.Msg.show({
	                title: 'Error', //TODO: error message if ajax failed
	                msg: res.statusText,
	                buttons: Ext.Msg.OK,
	                icon: Ext.MessageBox.ERROR
	            });
	        },
	        timeout: 300000,
	        params: params,
	        method: 'post'
	    });
	},
	/**
	*	submits the form by form id
	*
	*	@param {String} id - The id of the form
	*	@param {Object} params - name value pairs to be sent to with request, 
	*		for example: {param1: '1', p2: 'eqwed'}; must be flat.
	*		if you need to send whole json object use Ext.encode:
	*		eg. submitForm('form_id', {json: Ext.encode(myobject)});
	*/
	submitForm: function(form_id, params) {
		var form = Ext.query('#'+form_id)[0];
		for(var k in params) {
			if(typeof params[k]!='function') {
				this.createHidden(form, k, params[k]);
			}
		}
		//debugger;
		form.submit();
		return form;
	},
	
	/**
	*	Create hidden element
	*
	*	@param {HTMLElement} p - element
	*	@param {String} n - name 
	*	@param {String} v - value
	*/
	createHidden: function(p, n, v) {
		var hid = document.createElement("INPUT");
		hid.type = "hidden";
		hid.name = n;
		hid.value = v;
		p.appendChild(hid);
	}
}
