function closeWin(){
	var newWin = null;
	if (newWin != null)
	{
		if(!newWin.closed)
		newWin.close();
	}
}

function popUp(strURL,  strHeight, strWidth) 
{
	closeWin();
	var strOptions="";
	strOptions="status,height="+strHeight+",width="+strWidth;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
} 


function eleid(id) {return document.getElementById(id);}

function canAjax() {
    if(window.XMLHttpRequest || window.ActiveXObject) return true;
    return false;
}

/*function enchargement(status) 
{
    if (status) {
        eleid('loading').style.visibility='visible';
    } else {
        eleid('loading').style.visibility='hidden';
    }
}*/

function ajaxget(elehtml, fichier)
{
	//enchargement(true); //patience
	if (canAjax())
	{
		xhr_object=null;
	    if (window.XMLHttpRequest) {// Firefox
	        xhr_object = new XMLHttpRequest();
	    } else if(window.ActiveXObject) {// Internet Explorer
	        xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	    } else { 
	        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	    }
			
			xhr_object.open("GET", fichier, true); //synchrone
			xhr_object.send(null);
			xhr_object.onreadystatechange = function() {
				if(xhr_object.readyState == 4)  //4: terminé 3 en cours de traitement 2 chargée 1 en chargement 0 non initialisée
				{
					elehtml.innerHTML=(xhr_object.responseText); //envoi du contenu
					//enchargement(false); 
				}
				else return(false);	
			}
			
	}
}

function ajaxRetourne(fichier)
{

	//enchargement(true); //patience
	if (canAjax())
	{
	
		xhr_object=null;
	    if (window.XMLHttpRequest) {// Firefox
	        xhr_object = new XMLHttpRequest();
	    } else if(window.ActiveXObject) {// Internet Explorer
	        xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	    } else { 
	        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	    }
			
			xhr_object.open("GET", fichier, true); //synchrone
			xhr_object.send(null);
			
			xhr_object.onreadystatechange = function() {
				if(xhr_object.readyState == 4)  //4: terminé 3 en cours de traitement 2 chargée 1 en chargement 0 non initialisée
				{
					return xhr_object.responseText; //envoi du contenu
					//enchargement(false); 
				}
				else return(false);	
			}
			
	}
}


function verificationOnline(){
		ajaxRetourne('./ajax/ajax.online.php');	
}
function verificationMessage(){
	//	contenu = ajaxRetourne('./ajax/ajax.message.php');
		ajaxget(eleid('nvmessage'), './ajax/ajax.message.php');	
/* 		if (contenu !="")
		{
			document.title= "Un nouveau message";
			eleid('nvmessage').innerHTML=contenu;
		} */
}
function changerstatus_sound(){
		ajaxget(eleid('soundmsg'), './ajax/ajax.sound-msg.php');	
}
function definir_sound(fichier)
{
		ajaxget(eleid('choisi'), './ajax/ajax.definirsound.php?s='+fichier);	
}
function ajouter_radio()
{
	ajaxget(eleid('laradio'), './ajax/ajax.radio.php');	
}

function ajouter_recherche()
{
	ajaxget(eleid('pubapres'), './ajax/ajax.ads.php');
}
