/**
* Action System Installation
*
* @author	  RaphaeL Pralat <raph@plus2.fr>
* @version    CVS: $Id:$
* @uses       http://prototype.conio.net/
* @uses       http://bennolan.com/behaviour/
* @uses       http://script.aculo.us
*/

var						ActionEvent = {

	rules :				{
	
	/**
	 * Event Action
	 *
	 */
	'.userEventAction' : function(el) {
		el.onclick = function() {
			var action = findParamInClass('action', this);
			var type = findParamInClass('type', this);
			var id = findParamInClass('id', this);
			
			param = "action=" + action + "&type=" + type + "&id=" + id;
			
			if ($('eventForm')) {
				param = param + "&" + $('eventForm').serialize();
			}
			
			new Ajax.Updater('userEventContent', '/ajax/userEvent', {
				parameters	: param,
				method		: 'post',
				onComplete	: ActionEvent.reload
			});
		}
	},
	
	

		
	
	'lastbutnotleast': {}
	}, /** rules **/
	
	'reload' :	function(ajax) {
		 Behaviour.apply(ActionUser.rules);
	}	
}


function findParamInClass(param, el) {
   var regexp = new RegExp(param + '_([A-Za-z0-9/:?&\-\._]+)');
   var mymatch = regexp.exec(el.className);
   if(mymatch) {
       return mymatch[1];
   }
   return false;
}

Behaviour.register(ActionEvent.rules);