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 + '&ajax=true&w=' + all_rewrites + '&' + config.pars,
		where:			config.where,
		hideloading:	true || config.hideloading
	});

}
function showembed(userid, where, size, splits) {
	e = embedhtml;
	e = e.replace(/__WIDTH__/g, size || parseInt($F('embedsize')));
	e = e.replace(/__HEIGHT__/g, (size || parseInt($F('embedsize'))) + 20); //hardcoded
	e = e.replace(/__SPLITS__/g, splits || parseInt($F('embedsplits')));
	e = e.replace(/__USERID__/g, userid);
	if (where) {
		$(where).innerHTML = e;
	} else {
		$('embedtest').innerHTML = e;
		$('embedsrc').value = e;
	}
}
function widget_load() {
	request({
		where: 'embedpreviewresult',
		request: 'widget.get',
		pars: Form.serialize('form_widget_generator')
	});
}
