function subofficeOptions() {

	xmlhttp=null;
	
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		alert("Your browser does not support XMLHTTP!");
		return;
	}
	
	switch(document.getElementById('officeList').selectedIndex) {
		case 0: id='none'; 		break;
		case 1: id='sec';  		break;
		case 2: id='service'; 	break;
		case 3: id='bureau'; 	break;
		case 4: id='ro'; 		break;
		case 5: id='agency'; 	break;
		case 6: id='polo'; 		break;
	}
	
	if(id=='none') {
		document.getElementById('suboffice').innerHTML = "<select id='subofficeList' name='subofficeList' onChange='showContacts();'><option>Select an office first</option></select>";
		document.getElementById('dynamic_container').innerHTML = "";
	}
	else {
		url="serverscript.php?office=" + id;
		xmlhttp.open("GET",url,false);
		xmlhttp.send(null);
		document.getElementById("suboffice").innerHTML = "<select id='subofficeList' name='subofficeList' onChange='showContacts();'>" + xmlhttp.responseText + "</select>";
	}
}

function showContacts() {
	xmlhttp=null;
	
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	
	switch(document.getElementById('officeList').selectedIndex) {
		case 0: id='none'; 		break;
		case 1: id='sec';  		break;
		case 2: id='service'; 	break;
		case 3: id='bureau'; 	break;
		case 4: id='ro'; 		break;
		case 5: id='agency'; 	break;
		case 6: id='polo'; 		break;
	}
	
	officeId=document.getElementById('officeList').selectedIndex;
	subofficeId=document.getElementById('subofficeList').value;
	selectedSuboffice=document.getElementById('subofficeList').selectedIndex;

	newInnerHTML="";
	
	if(officeId==0) {
		document.getElementById('dynamic_container').innerHTML = "";
	}
	if(selectedSuboffice==0) {
		document.getElementById('dynamic_container').innerHTML = "";
	}
	else {
		url="serverscript2.php?office=" + officeId + "&suboffice=" + subofficeId + "&prefix=" + id;
	
		xmlhttp.open("GET",url,false);
		xmlhttp.send(null);
		newInnerHTML = newInnerHTML + xmlhttp.responseText;
	
		xmlhttp2=null;
		
		if (window.XMLHttpRequest) {
			xmlhttp2=new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
			xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
		}
		else {
			alert('Your browser does not support XMLHTTP!');
			return;
		}
	
		url="serverscript3.php?office=" + officeId + "&suboffice=" + subofficeId;
		
		xmlhttp2.open("GET",url,false);
		xmlhttp2.send(null);
		newInnerHTML = newInnerHTML + xmlhttp2.responseText;

		document.getElementById('dynamic_container').innerHTML = newInnerHTML;
	}
}
