/**
 * This mini AJAX library provides conveniency functions to change the content of a 
 * div. with the text of a given page.
 */
 var p2b_connection = null;
 var p2b_target_id = null;
 
 function p2b_getp2b_connection(){
	var cnx = null;
	try{
		cnx = new XMLHttpRequest();
	}catch(ms_err){
		try{
			cnx = new ActiveXObject('Msxml2.XMLHTTP');  
		}catch(ms_err_again){
			cnx = new ActiveXObject('Microsoft.XMLHTTP');
		}
	}
	return cnx;
 }
 
 
 function p2b_triggerChange(id_of_the_div, url_of_the_content){
	var now = new Date();
	p2b_target_id = id_of_the_div;
	p2b_connection = p2b_getp2b_connection();
	p2b_connection.onreadystatechange = p2b_doTheChangeForReal;
	p2b_connection.open("GET", url_of_the_content+"?time="+now.getTime(), true);
	p2b_connection.send(null);
 }
 
 function p2b_doTheChangeForReal(){
	if(p2b_connection.readyState == 4){
		if(p2b_connection.status == 200){
			p2b_setTheContent(p2b_connection.responseText);
		}else{
			p2b_setTheContent("<H1>Sorry we encountered an error while loading the content of this page.</H1> If the problem persists over time, do not hesitate to contact us and let us know what happened.");
		}
	}
 }
 
 function p2b_setTheContent(html_content){
	var div = document.getElementById(p2b_target_id);
	div.innerHTML = html_content;
 }
