// JavaScript Document

////////////////////////////////////
function showLoadScreen(div)
{
	if(isObject(div))
		div = div.id;
	var dim = Element.getDimensions(div);
	var divscreen = "<div id=\""+div+"_screen\" style=\"width: "+dim['width']+"px; height: "+dim['height']+"px;\" class=\"load_screen\"><div class=\"load_indicator\"></div></div>";
	$(div).innerHTML = divscreen+$(div).innerHTML;
}

function ajax(get, post, div)
{
	new Ajax.Updater(
		div, 
		get, 
		{
			parameters: '&typepage=ajax&layer='+div+'&'+post,
			asynchronous:true, 
			evalScripts:true
		}
	);	
}

function ajaxSimple(get, post, div)
{
	showLoadScreen(div);
	ajax(get, post, div);
}

function ajaxMenu(get, post, div)
{
	ajax(get, post, div);
}

function ajaxForm(serialize, get, div)
{
	showLoadScreen(div);
  new Ajax.Updater(
		div,
		get,
		{
			parameters: '&typepage=ajax&layer='+div+'&'+serialize,
			contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
			asynchronous:true, 
			evalScripts:true
	 	}
	);
}

function ajaxOnglet(get, post, div)
{
	showLoadScreen(div);
	ajax(get, post, div);
}

function ajaxAction(get, post, div)
{
	showLoadScreen(div);
	ajax(get, post, div);
}

function ajaxListe(get, post, div)
{
	showLoadScreen(div);
	ajax(get, post, div);
}

function ajaxLogin(serialize)
{
	new Ajax.Request("?", 
		{
			method: 'post', 
			parameters: serialize, 
			onComplete: showResponse = function(req){
				$('result').innerHTML = req.responseText;
				}
		});
}


