// JavaScript Document
var peopleReq
var pId=0;

function getVar()
	{
     var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)
     return infos
 }
function set_pId(new_pId)
{
	pId = new_pId;	
}

function loadInfoXML()
{
peopleReq=null

// Mozilla, Safari, ...
if (window.XMLHttpRequest) 
	{ 
  	peopleReq = new XMLHttpRequest();
	if (peopleReq!=null)
  		{
  		peopleReq.onreadystatechange=show_info
  		peopleReq.open("GET","../people/mosaicpeople.xml",true)
  		peopleReq.send(null)
  		}
  	else
  		{
  		alert("Your browser does not support XMLHTTP.")
  		}
    }
// code for IE
else if (window.ActiveXObject)
  {
  peopleReq=new ActiveXObject("Microsoft.XMLHTTP")
  if (peopleReq!=null)
  	{
  	peopleReq.open("GET","../people/mosaicpeople.xml",true)
  	peopleReq.send(null)	
	peopleReq.onreadystatechange=show_info()


  	}
  else
  	{
  	alert("Your browser does not support XMLHTTP.")
  	}
  }

}


function show_info()
{
//alert("New Ready State is:"+peopleReq.readyState);
// if peopleReq shows "loaded"
if (peopleReq.readyState==4)
  {
  // if "OK"
  if (peopleReq.status==200)
    {
  	//alert("XML data OK"); 
    var response = peopleReq.responseXML.documentElement;
	
	// Show personal image
    var xpic="<img src='images/";

    xp=response.getElementsByTagName("mosaic_photo")[pId].firstChild.nodeValue;

    try
    	{
        xpic= xpic + xp + "' alt='main image' />"
        }
    catch (er)
        {
        xpic="error loading picture"
        }
	document.getElementById("Picture").innerHTML=xpic;
  
    // Show personal contact info
    var contact="<h3>";

    xn=response.getElementsByTagName("mosaic_name")[pId].firstChild.nodeValue;
    xs=response.getElementsByTagName("mosaic_surname")[pId].firstChild.nodeValue;
	xe=response.getElementsByTagName("mosaic_email")[pId].firstChild.nodeValue;
	xw=response.getElementsByTagName("mosaic_persoweb")[pId].firstChild.nodeValue; 
	xp=response.getElementsByTagName("mosaic_phone")[pId].firstChild.nodeValue;
	xf=response.getElementsByTagName("mosaic_fax")[pId].firstChild.nodeValue;
	xa=response.getElementsByTagName("mosaic_office")[pId].firstChild.nodeValue;

    try
    	{
        contact=contact + xn + " " + xs + "</h3><a href='mailto:%20" + xe + "?subject=Replace _AT_ with @'>" + xe + "</a><br /><a href='" + xw +"'>" + xw + "</a><br />Phone: " + xp + "<br />Fax: "+ xf + "<br />Office: " + xa
        }
    catch (er)
        {
        contact="error loading contact"
        }
	document.getElementById("PeopleContact").innerHTML=contact;
	
	// Show personal bio info
    var bio="<p>";

    xb=response.getElementsByTagName("mosaic_bio")[pId].firstChild.nodeValue;

    try
    	{
        bio=bio + xb +"</p>"
        }
    catch (er)
        {
        bio="error loading bio"
        }
	document.getElementById("PeopleBio").innerHTML=bio;
	}
  }
else
  {
  //alert("Problem retrieving XML data: " + peopleReq.readyState  + peopleReq.status); 
  }
}

