function deleter(table, id, execute) {
	this.table = table;
	this.id = id;
	this.callback = defaultDeleteCallback;
	this.execute = executeDelete;
	if (execute == true) {
		if (confirm("Skutočne zmazať?")) {
			this.execute();
		}
	}
}

function executeDelete() {
	$.ajax( {
		type : 'POST',
		url : homelink + '/ajaxer/deleter',
		data : 'table=' + this.table + '&id=' + this.id,
		success : this.callback
	});
}

function defaultDeleteCallback(msg) {
	if (msg == '') {
		window.location.reload();
	}
	else {
		alert(msg);
	}

}

$.fn.setHover = function(colorOn,colorOut) {
	if(colorOut == null) colorOut = 'white';
	
	return $(this).hover(function() {
		$(this).css('background-color', colorOn);
	}, function() {
		$(this).css('background-color', colorOut);
	});
}

function dataRequest(urll){
	var success = function(msg) {
	};
	var url = homelinkHead+'/'+urll;
	var params = {};
	this.addParam = function(name, value){
		params[''+name] = value;
	}

	this.send = function(){
		$.ajax({
	        type: "POST",
	        url: url,
	        data: params,
	        dataType: 'json',
	        success: function(msg) {
				if(msg.ok == 'ok') success(msg);
				else alert(msg.ok);
			}
	      });
	}

	this.onSuccess = function(func){
		success = func;
		}
}

