function updatecalc(what, val)
{
	if (what == 'type') {
		var j = "update=1&val=" + val;
	}
	
	var myAjax = new Ajax("ajax/calc.php", {
	postBody:j
	,onComplete:function(res){
		$('calc').setHTML(res);

	},method: 'post'}).request();
}
function checkact(state, val)
{
	$('act0').style.display = 'none';
	$('act1').setHTML('<center><img src="./imgs/load.gif"><br />Veuillez patienter un moment...</center>');
	if (state == true) {
		var j = "update=2&val=" + val + "&state=1";
	} else {
		var j = "update=2&val=" + val + "&state=0";
	}
	var myAjax = new Ajax("ajax/calc.php", {
	postBody:j
	,onComplete:function(res){
		$('calc').setHTML(res);
		$('act0').style.display = 'block';
		$('act1').setHTML('');
	},method: 'post'}).request();
	
	return true;
}
function checkdept(state, val)
{
	$('dept0').style.display = 'none';
	$('dept1').setHTML('<center><img src="./imgs/load.gif"><br />Veuillez patienter un moment...</center>');
	if (state == true) {
		var j = "update=3&val=" + val + "&state=1";
	} else {
		var j = "update=3&val=" + val + "&state=0";
	}
	var myAjax = new Ajax("ajax/calc.php", {
	postBody:j
	,onComplete:function(res){
		$('calc').setHTML(res);
		$('dept0').style.display = 'block';
		$('dept1').setHTML('');
	},method: 'post'}).request();	
}
function updatesearch(val)
{
	var j = "seek=" + val;
	
	var myAjax = new Ajax("act.php", {
	postBody:j
	,onComplete:function(res){
		$('actbox').setHTML(res);

	},method: 'post'}).request();	
	return false;
}
function gen_go()
{
	var j = "gen=1";
	
	var myAjax = new Ajax("ajax/calc.php", {
	postBody:j
	,onComplete:function(res){
		$('calc').setHTML(res);
		$('dept0').style.display = 'block';
		$('dept1').setHTML('');
	},method: 'post'}).request();	
	return false;
}
function genlist()
{
	$('dept0').style.display = 'none';
	$('dept1').setHTML('<center><img src="./imgs/load.gif"><br />Veuillez patienter un moment...</center>');
	
	var j = "check=1";
	var myAjax = new Ajax("ajax/calc.php", {
	postBody:j
	,onComplete:function(res){
		if (res == '1') {
			
			gen_go();
		} else {
			alert('Etape incomplète');
			$('dept0').style.display = 'block';
			$('dept1').setHTML('');
		}

	},method: 'post'}).request();	
	return false;	
}

Window.onDomReady(function(){
	if (document.getElementById('type1')) {
		$('type1').addEvent('change',function(){
			updatecalc('type', 1);
		});
		$('type2').addEvent('change',function(){
			updatecalc('type', 2);
		});
	}
});

