function isUsed(tableName, columnName, value) {
	var isUsed = true;
	var opt = {
		method: 'post',
		postBody: 'table_name='+tableName+'&col_name='+columnName+'&value='+value,
		asynchronous: false,
		onSuccess: function(t) {
			if (t.responseText != "true") {
				isUsed = false;
			}
		},
		on404: function(t) {
			alert('Error 404: location "' + t.statusText + '" was not found. ');
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		} 
	}
	new Ajax.Request( root + 'ajax/is_used.php', opt);
	return isUsed;
}

function emailUsed(email) {
	var isUsed = false;
	var opt = {
		method: 'post',
		postBody: 'email='+email,
		asynchronous: false,
		onSuccess: function(t) {
			if (t.responseText == "true") {
				isUsed = true;
			}
		},
		on404: function(t) {
			alert('Error 404: location "' + t.statusText + '" was not found. ');
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		} 
	}
	new Ajax.Request( root + 'ajax/email_used.php', opt);
	return isUsed;
}

function submitForm(url, formid) {
	var html = '';
	var opt = {
		method: 'post',
		postBody: $(formid).serialize(true),
		asynchronous: false,
		onSuccess: function(t) {
			if (t.responseText != "") {
				html = t.responseText;
			}
		},
		on404: function(t) {
			alert('Error 404: location "' + t.statusText + '" was not found. ');
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		} 
	}
	new Ajax.Request( url, opt);
	$(obj).innerHTML = html;
	return isUsed;
}

function json_select_update(e, value_col, text_col, json_str) {
	e.options.length = 0;
	var jsons = json_str.split("\r\n");
	var i = 0, json;
	var value, text;
	for(i = 0; i < jsons.length; i++) {
		if(jsons[i].length>0) {
			json = jsons[i].evalJSON();
			eval('value = json.'+value_col+';');
			eval('text = json.'+text_col+';');
			e.options.add(new Option(text, value));
		}
	}
}