var domain = 'http://' + window.location.hostname + '/';
var sendButton = Class.create({
	initialize: function(url,objName) {
	this.url=domain+url;
	this.name=objName;
	},
	add: function(id, button) {
		//alert(added);
		if(id!=null) {
			new Ajax.Request(this.url,{
				method:'get',
				parameters: {'id': id, 'ajax': 'ajax','action':'add'},
				onSuccess: function(transport) {
					$(button).href='#';
					$(button).innerHTML='hinzugefügt';
				}
			});
		}
	},
	del: function(id,button) {
		if(id!=null) {
			new Ajax.Request(this.url,{
				method:'get',
				parameters: {'id': id, 'ajax': 'ajax','action':'delete'},
				onSuccess: function(transport) {
					$(button).innerHTML='gelöscht';
				}
			});
		}
	},
	register: function(id,button) {
		if(id!=null) {
			new Ajax.Request(this.url,{
				method:'get',
				parameters: {'id': id, 'ajax': 'ajax','action':'add'},
				onSuccess: function(transport) {
					$(button).href='#';
					$(button).innerHTML='hinzugefügt';
				}
			});
		}
	},
	createButton: function(id, label) {
		var button = '<a id="'+this.name+'_';
		button += id+'" href="javascript:'+this.name+'.add('+ id;
		button += ', \''+this.name+'_'+ id +'\')" class="btn_blue">'+ label +'</a>';
		return button;
	},
	createButtonForTable: function(id, label) {
		var button = '<a id="'+this.name+'_table_';
		button += id+'" href="javascript:'+this.name+'.add('+ id;
		button += ', \''+this.name+'_table_'+ id +'\')" class="tableButton">'+ label +'</a>';
		return button;
	}
});
var objRememberList = new sendButton('index.php?module=rememberlist','objRememberList');
var objUserCourtsList = new sendButton('index.php?module=usercourts','objUserCourtsList');

//var test= objRememberList.createButton(1,"merken");
//alert(test);
