	var ajax = new sack();

	function doit(type,idDomanda) {
		var form = document.getElementById('form1');

		if (!idDomanda) {
			showdomande();
			var selObj = document.getElementById('argomento');
			if (document.getElementById('argomento').options[document.getElementById('argomento').selectedIndex].value==0) {
				hideform();
				document.getElementById('domande').innerHTML='';
				document.getElementById('lato_dx').innerHTML='';
				return;
			}
		}

		ajax.setVar("type", type);
		ajax.requestFile = "/esperto_risponde.php";
		ajax.method = "GET";
		if (type==1) {
			ajax.setVar("idArgomento", form.argomento.value);
			ajax.element = 'domande';
		}else if (type==2) {
			hideform();
			ajax.setVar("idDomanda", idDomanda);
			ajax.element = 'lato_dx';
		}

		ajax.runAJAX();
	}

	function whenLoading(){
		new Fx.Style('askform', 'opacity', {
			'duration' : 1000,
			'onComplete' : function (){
				$('askform').setStyle('display', 'block');
			}
		}).start(0);
	}

	function whenCompleted(){
		showdomande();
	}

	var sendreq = function (result) {
		if (result) {
			var form = document.getElementById('form2');
			ajax.requestFile = "/esperto_risponde.php";
			ajax.method = "POST";
			ajax.setVar("type", 3);
			ajax.element = 'lato_dx';
			ajax.setVar("nome", form.nome.value);
			ajax.setVar("cognome", form.cognome.value);
			ajax.setVar("email", form.email.value);
			ajax.setVar("messaggio", form.messaggio.value);
			ajax.onLoading = whenLoading;
			ajax.onCompletion = whenCompleted;
	
			ajax.runAJAX();
		}
	};

	var showform = function(){
		document.getElementById('lato_dx').innerHTML='';
		hidedomande();
		new Fx.Style($('askform'), 'opacity', {duration: 1000} ).start(1);
	};

	var hideform = function(){
		var div = $('askform').setStyles({
			display:'block',
			opacity: 0
		});
	};

	var showdomande = function(){
		new Fx.Style($('domande'), 'opacity', {duration: 1000} ).start(1);
	};

	var hidedomande = function(){
		var div = $('domande').setStyles({
			display:'block',
			opacity: 0
		});
	};

	window.addEvent('domready', function() {
		hideform();
	});