var core_url = "/index.php";

$jQ(document).ready(function() {
	$jQ('div.aButton').click(function() {
		$jQ('div.aContent').slideUp('normal');	
		if ($jQ(this).next().is(':hidden')) {
			$jQ(this).next().slideDown('normal');
		}
	});
	$jQ("div.aContent").hide();
	php.beforeSend = function () {
		return true;
	}
	php.complete = function () {
		return true;
	}
	php.error = function () {
		return true;
	}
	LoadData('load_question', 'polls', 0);
});

function LoadData(op, module_name, value) {
	$jQ.ajax({
		url: core_url,
		type: "POST",
		data: "op=" + op + "&module_name=" + module_name + "&value=" + value,
		dataType : "json",
		beforeSend: function() {
			return php.beforeSend();
		},
		success: function(data, textStatus) {
			return php.success(data, textStatus);
		},
		error: function (xmlEr, typeEr, except) {
			return php.error(xmlEr, typeEr, except);                  
		},
		complete: function (XMLHttpRequest, textStatus) {
			return php.complete(XMLHttpRequest, textStatus);
		}
	});
	return false;
}

function LoadForm(form) {
	$jQ.ajax({
		url: core_url,
		type: "POST",
		data: $jQ('#'+form).formToArray(true),
		enctype: "multipart/form-data",
		dataType : "json",
		beforeSend: function() {
			return php.beforeSend();
		},
		success: function(data, textStatus) {
			return php.success(data, textStatus);
		},
		error: function (xmlEr, typeEr, except) {
			return php.error(xmlEr, typeEr, except);                  
		},
		complete: function (XMLHttpRequest, textStatus) {
			return php.complete(XMLHttpRequest, textStatus);
		}
	});
	return false;
}

function clearForm(form) {
	$jQ('form#'+form+' :input').each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
	});
};