/* Javascript */

function switch_image(id,src) {
	document.getElementById(id).src = src;
}

function fill(id,content) {
	document.getElementById(id).innerHTML = content;
}

function show(id) {
	var o = document.getElementById(id).style.display = 'block';
}

function hide(id) {
	var o = document.getElementById(id).style.display = 'none';
}

// 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) {
	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
