var loading="<img src='<? echo get_front_office(); ?>common/images/loading.gif' /> chargement en cours..."

function envoieRequete(url,id)
{
	document.getElementById(id).innerHTML=loading;
	var xhr_object = null;
	if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest(); // pour Firefox et autres
	else if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); // pour Internet Explorer
	else { // XMLHttpRequest non supporté par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		return; 
	} 
    // On ouvre la requete vers la page désirée
    xhr_object.open("GET", url, true);
    xhr_object.onreadystatechange = function(){
    	if ( xhr_object.readyState == 4 ){
			// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
        	document.getElementById(id).innerHTML = xhr_object.responseText;
     	}
    }
    // dans le cas du get
    xhr_object.send(null);
 }
 
function detail(str) {
	var el = document.getElementById(str);
	var tab = str.split(/-/);
	var id = tab[0];
	var type = tab[1];
	if(el.parentNode.className!='annonce_det'){
		el.parentNode.className='annonce_det';
		envoieRequete("<? echo get_front_office(); ?>detail.php?id="+id+"&type="+type,str);
	}
	else{
		el.parentNode.className='annonce';
		envoieRequete("<? echo get_front_office(); ?>resume.php?id="+id+"&type="+type,str);
	}
}


function sel_onglet(table,id,_new,dest){
	rlist = _new.parentNode.getElementsByTagName('div');
	_old=null;
	num=rlist.length;
	if (num!=0){
		i=0;
		while(i<rlist.length){
			if(rlist[i].className=='current') _old = rlist[i];
			i++;
		}
	}
	if(_old==null){
		_new.className='current';
		document.getElementById(dest).style.display='block';
		document.getElementById(dest).style.visibility='visible';
		envoieRequete('<? echo get_front_office(); ?>info_detaillees.php?id='+id+'&table='+table,dest);
	}
	else if(_old==_new){
		_old.className='';
		document.getElementById(dest).innerHTML='';
		document.getElementById(dest).style.visibility='hidden';
	}
	else{
		_old.id='';
		_old.className='';
		_new.id='current'+id;
		_new.className='current';
		document.getElementById(dest).style.visibility='visible';
		envoieRequete('<? echo get_front_office(); ?>info_detaillees.php?id='+id+'&table='+table,dest);
	}
}

function over(el){
	if(el.className!="annonce_det")
		el.className="annonce_over";
}

function out(el){
	if(el.className!="annonce_det")
		el.className="annonce";
}

function popup(url,width,height){
	NewWin=window.open(url,'home','width='+width+',height='+height+',scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,resizable=yes');
}

function popup_img(img){
	w=open("",'image','width=200,height=200,toolbar=no,scrollbars=no,resizable=no');	
	w.document.write("<HTML><HEAD><TITLE>Photo</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  if(document.images[0].width>800) document.images[0].width=\"900\"; else taille =\"petit\"; window.resizeTo(document.images[0].width+15,document.images[0].height+60); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize();' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><center><IMG src='"+img+"' border=0 alt='FSI' name='photo'></center>");
	//w.document.write("<p align='center'><a href='javascript:window.close()'>Fermer</a></p>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}