//AJAX
var fd_httpReponse = '';

function	fd_ajax_exec(nameScript,data,nameFunction)
{//alert(nameScript);
	var xhr_object	= null;

	if(window.XMLHttpRequest)		// Firefox 
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) 	// Internet Explorer 
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	if (xhr_object != null)
	{
		xhr_object.open("POST", nameScript, true);
					
		xhr_object.onreadystatechange = function()
		{ 
			if(xhr_object.readyState == 4)
			{		
				if(xhr_object.status  == 200)
				{
					httpReponse = xhr_object.responseText;
					if(nameFunction != '') eval(nameFunction +';')
			 	}
				else
				{
					httpReponse="Error code " + xhr_object.status;
				}
			}
		}
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);
	}
	else
		nameFunction('noAjax');
}

function fd_actionDOM(){//alert(unescape(httpReponse));
	eval(unescape(httpReponse));
}

function fd_fillObj(obj,val)
{
	if(document.getElementById(obj))
		document.getElementById(obj).innerHTML = unescape(val);
}

function fd_fillAtt(obj,type,val)
{
	if(document.getElementById(obj))
		document.getElementById(obj).setAttribute(unescape(type),unescape(val));
}


function fd_hash(page){
	var hash = parent.location.hash;
	
	if(page!=parent.location.hash){
		if(hash!=""){
			if(typeof(page)=='undefined'){
				fd_ajax("datagrid",hash.substring(1));}
			else{
				parent.location.hash = page;		
				fd_ajax("datagrid",hash.substring(1));}

	}}
	
	
}
//	pour zt
function fd_ajax(type,critere)
{
	//alert(fd_PATH);
	//fd_PATH	=	'http://'+window.location.host+'/';
	fd_ajax_exec(fd_PATH+'librairie/class.fondation/lib/fdGstAjax.php?fd_path='+fd_PATH,'type='+type+'&'+critere,'fd_actionDOM()');
}

//apparition temporisée
var fd_T = '';
function fd_showObj(nomObj, duration)
{
	if(document.getElementById(nomObj))
	{
		document.getElementById(nomObj).style.display='block';
		if(duration!='inf')
		{
			clearTimeout(fd_T);
			var href = document.getElementById(nomObj).getElementsByTagName('A');
			for (var i = 0; i < href.length; i++)
			{
				href[i].onmouseover= function (){ showObj(nomObj,duration); }
			}
			fd_T = setTimeout('fd_hideObj("'+nomObj+'");',duration);
		}
	}
}
function fd_hideObj(nomObj)
{
	if(document.getElementById(nomObj))
		context = document.getElementById(nomObj);
	else if (parent.document.getElementById(nomObj))
		context = parent.document.getElementById(nomObj);
	else if(top.document.getElementById(nomObj))
		context = top.document.getElementById(nomObj);

	context.style.display = 'none';
}

