function add_to_field(where, what) {
	$(where).value += what;
}
function ajax_load(config) { //(url, pars, where, onsuccess, hideloading) {
	if ((config.where != '') && (typeof(config.where) != 'undefined')) {
		if ($(config.where) != null) {
			if (config.hideloading == true) {
				//do nothing
			} else {
				var toinsert = '<span style="background:#CCFFCC;border:1px solid #77CC77;padding:3px;position:absolute;z-index:2">Loading...</span>'; //hardcoded loading
				$(config.where).innerHTML = toinsert + $(config.where).innerHTML;
			}
		} else {
			alert('id="' + config.where + '" not found. cannot load "' + config.url + '"');
		}
	} else {
		config.where = '';
	}
	
	var myAjax = new Ajax.Request(
		config.url,
		{
			method: 'post',
			parameters: 'random=' + Math.random() + '&' + config.pars,
			onSuccess: function(t) {
				if (config.where != '') {
					$(config.where).innerHTML = t.responseText;
				}
				eval(config.onsuccess);
				t.responseText.evalScripts();
			},
			onFailure: function(t) {
				error_filler(t, config.where, config.url);
			}
		}
	);
}

function request(config) {
	if (typeof(config.where) != 'string') {
		config.where = 'div_' + config.request;
	}
	
	ajax_load({
		url:			root_address + 'ajax.request.php',
		pars:			'request=' + config.request + '&w=' + all_rewrites + '&' + config.pars,
		where:			config.where,
		hideloading:	true || config.hideloading
	});

}
function word_vote(word_id, word_votetype) {
	request({
		request:	'browse.vote',
		pars:		'word_id=' + word_id + '&word_votetype=' + word_votetype,
		where:		'votes_for_word_' + word_id
	});
}
