function getXmlObject(){
	var xmlHttp = null;
	try{
		xmlHttp=new XMLHttpRequest();
  	} catch (e){
  		try{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      		}catch (e){
 			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
 		}	
	}
	return xmlHttp;
}

function populateMenu(){
	if (document.getElementById('auto_menu')){
		var ajax = getXmlObject();
		ajax.open ('GET',location.protocol + "//" + location.host + '/populate_menu.php',false);  /*Use false to block until menu is loaded - p7init script will break if menu is not fully loaded*/
		ajax.send (null);
		document.getElementById('auto_menu').innerHTML = ajax.responseText;
	}
}

function populateEvents(which_page){
	
	if (document.getElementById('populate_events')){
		var ajax = getXmlObject();
		ajax.onreadystatechange = function(){
			if (ajax.readyState == 4){
	
				document.getElementById('populate_events').innerHTML = ajax.responseText;
			}
		}
	
		ajax.open ('GET',location.protocol + "//" + location.host + '/event_populate.php?which_page=' + which_page,true);  /*should be ok without urlencode if called properly*/
		ajax.send (null);
	}
}
