function action(){
	
	var type;
	var event;
	var id;
	var item;
	var itemid;
	var ownerid; 
	
	function set(item, itemid, ownerid){
		
		this.item = item;
		this.itemid = itemid;
		this.ownerid = ownerid;
	}

	this.capture = function(id, event){
		this.id = id;
		this.event = event;
		set($(id).readAttribute('item'), $(id).readAttribute('itemid'), $(id).readAttribute('ownerid'));
		setType(event);
		
		if (event.preventDefault)
      	event.preventDefault();
      else
      	event.returnValue= false;
		
		Send();
		//getItem();
		//alert(getType());
	}

	function getItem(){
		alert('item ' + this.item + ' itemid ' + this.itemid);
	}
	
	function getType(){
		return this.type;
	}
	
	function setType(event){
		
		if (event.which == null)
      	/* IE case */
      	this.type = (event.button < 2) ? "LEFT" : ((event.button == 4) ? "MIDDLE" : "RIGHT");
   	else
      	/* All others */
      	this.type= (event.which < 2) ? "LEFT" : ((event.which == 2) ? "MIDDLE" : "RIGHT");
	}
	
  	function Send(){
		var opt = {
      	// Use POST
      	method: 'post',

      	// Send this lovely data
      	postBody: 'type=' + this.type + '&item=' + this.item + '&itemid=' + this.itemid + '&ownerid=' + this.ownerid,

  			onSuccess: function(transport){
      		var response = transport.responseText;
      		if(response != "" && response.length > 1){
					document.location.href = response;
				}
    		},
    		
			onFailure: function(){ alert('Something went wrong...') }
  			};

      //alert(opt.postBody);
		var ref = new Ajax.Request('/ajax/ActionHandler.php', opt);
	}    


}

var Action = new action();