//AJAX
var httpReponse = '';

function	ajax(nameScript,data,nameFunction)
{
	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)
			{		
				httpReponse = xhr_object.responseText;
				if(nameFunction != '') eval(nameFunction +';')
			}
		}
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);
	}
	else
		nameFunction('noAjax');
}

function actionDOM(){
	//alert(unescape(httpReponse));
	//eval(httpReponse);
	document.getElementById('contenu').innerHTML = unescape(httpReponse);
}

function in_array(val,tab)
{
	if(tab!='')
	{
		for (t=0 ; t<tab.length ; t++)
		{
			if(tab[t]==val)
				return true;
		}
	}
	return false;
}

function ajaxPagination(nump,nbp,hide)
{
	var classe;
	var tabElement 	= new Array('first','prev','next','end');
	
	var tabHide		= hide.split(',');
	for (i=0 ; i<tabElement.length ; i++)
	{
		couleur = (in_array(tabElement[i],tabHide)) ? 'aaa' : '000';
		document.getElementById(tabElement[i]).style.backgroundColor = '#'+couleur;
	}

	document.getElementById('numP').innerHTML = nump;
	document.getElementById('nbP').innerHTML = nbp;
}

function getCont(type,critere)
{
		ajax('../php/getCont.php','type='+type+'&'+critere,'actionDOM()');
}

function popup (url, win, width, height)
{
	options = 'width=' + width + ',height=' + height;
	return window.open(url, win, options);
}
