function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=1024,height=768,left = 0,top = 0');");
}

function switch_display_hide(div,image,img_plus,img_moins){
    if (document.getElementById(div).style.display == "block")
    {   document.getElementById(image).src = img_plus;
        document.getElementById(div).style.display = "none";
    }
    else{
        document.getElementById(image).src = img_moins;
        document.getElementById(div).style.display = "block";
    }
}

function switch_hide_display(div,image,img_plus,img_moins){
    if (document.getElementById(div).style.display == "none")
    {   document.getElementById(image).src = img_moins;
        document.getElementById(div).style.display = "block";
    }
    else{
        document.getElementById(image).src = img_plus;
        document.getElementById(div).style.display = "none";
    }
}

// on nomme la fenêtre pour afficher la page de retour internaute dans cette page
self.name="_self";

function Ouvrir_Spplus()
{
  // Largeur et hauteur préconisées de la fenêtre SPPLUS
var PopupSpplus_largeur	= 670;
var PopupSpplus_hauteur	= 535;

  // Position haut et gauche de la fenêtre SPPLUS pour affichage centré dans l'écran
var PopupSpplus_top	=((screen.height-PopupSpplus_hauteur)/2);
var PopupSpplus_left	=((screen.width-PopupSpplus_largeur)/2);

// Ouverture du popup SPLUS avec barre état uniquement et focus sur la fenêtre
var win = window.open('', "_self","status=yes,top="+PopupSpplus_top+",left="+PopupSpplus_left+",width="+PopupSpplus_largeur+",height="+PopupSpplus_hauteur);
win.focus();
}

// AJAX
function writebox(texte,id_box,htmlorvalue) {
	if (htmlorvalue == 'value') {
		document.getElementById(id_box).value = texte;
	}
	else {
		document.getElementById(id_box).innerHTML = texte;
	}
}

function ajax(fichier,destination,htmlorvalue) {
	var imgloading = '';
	if (htmlorvalue != 'value') {
		imgloading = '<img src="<?=BASE.DIR_IMAGES; ?>ajax-loading.gif" alt="Loading" /> ';
	}
	
	writebox(imgloading+'Chargement en cours...',destination,htmlorvalue);
	if (text = file(fichier))
    {   writebox(text,destination,htmlorvalue);
    }
    else
    {   writebox('Erreur. Fichier : '+fichier+' - Bloc de destination : '+destination,destination);
    }
}

function file(fichier) {
    if (window.XMLHttpRequest)
    {     xhr_object = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {     xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {     return(false);
    }
    xhr_object.open("GET",fichier,false);
    xhr_object.send(null);
    if (xhr_object.readyState == 4)
    {	return(xhr_object.responseText);
    }
    else
    {	return(false);
    }
}
// EOF AJAX
