// JavaScript Document
var jobReq
function loadJobsXML()
{
jobReq=null;

// Mozilla, Safari, ...
if (window.XMLHttpRequest) 
	{ 
  	jobReq = new XMLHttpRequest();
	if (jobReq!=null)
  		{
		jobReq.onreadystatechange=show_Jobs
  		jobReq.open("GET","jobs/mosaicjobs_en.xml",true)
  		jobReq.send(null)		
  		}
  	else
  		{
  		alert("Your browser does not support XMLHTTP.")
  		}
    }
// code for IE
else if (window.ActiveXObject)
  {
  jobReq=new ActiveXObject("Microsoft.XMLHTTP")
  if (jobReq!=null)
  	{
	
	jobReq.open("GET","jobs/mosaicjobs_en.xml",true)
	jobReq.send(null)	
	jobReq.onreadystatechange=show_Jobs()
  	}
  else
  	{
  	alert("Your browser does not support XMLHTTP.")
  	}
  }

}

function show_Jobs()
{

// if jobReq shows "loaded"
if (jobReq.readyState==4)
  {

  // if "OK"
  if (jobReq.status==200)
  {
  var risp = jobReq.responseXML.documentElement;
  
  // Show the PhD availabilities
  var phd="<h2>PhD positions/Training subjects</h2>";

  xphd=risp.getElementsByTagName("mosaic_phd");
  for (i=0;i<xphd.length;i++)
    {
	var xt=risp.getElementsByTagName("mosaic_phd_title")[i].firstChild.nodeValue;
	var xs=risp.getElementsByTagName("mosaic_phd_supervisor")[i].firstChild.nodeValue;
	var xc=risp.getElementsByTagName("mosaic_phd_contact")[i].firstChild.nodeValue;	
	var xd = risp.getElementsByTagName("mosaic_phd_descr")[i].firstChild.nodeValue;
    var xe = risp.getElementsByTagName("mosaic_phd_exp")[i].firstChild.nodeValue;
	var xfn = risp.getElementsByTagName("mosaic_phd_pdf_filename")[i].firstChild.nodeValue;
	try
        {
		phd=phd + "<h4>" + xt + "</h4>" + "<p>" + xd +"</p><br />" + "Contact: <a href='mailto:%20" + xc+"'>" + xs + 
			"</a><br/>Deadline: " + xe + "<br />"
		if (xfn!="Nd") phd=phd +"<a href='../mosaic/jobs/pdf_files/" + xfn + "'><img src='images/pdf_Logo.gif' alt='Pdf' /></a><hr>";
		if (xfn=="Nd") phd = phd + "<hr />";
        }
      catch (er)
        {
        phd=phd + "error loading<br />"
        }
	}
  document.getElementById('PhD').innerHTML=phd;

  // Show the PostDoc availabilities
  var pd="<h2>Post Docs positions</h2>";
  xpd=risp.getElementsByTagName("mosaic_postdoc");
  for (i=0;i<xpd.length;i++)
    {
	xt=risp.getElementsByTagName("mosaic_pd_title")[i].firstChild.nodeValue;
	xs=risp.getElementsByTagName("mosaic_pd_supervisor")[i].firstChild.nodeValue;
	xc=risp.getElementsByTagName("mosaic_pd_contact")[i].firstChild.nodeValue;
	xd=risp.getElementsByTagName("mosaic_pd_descr")[i].firstChild.nodeValue;
  	xe=risp.getElementsByTagName("mosaic_pd_exp")[i].firstChild.nodeValue;
	var xfn=risp.getElementsByTagName("mosaic_pd_pdf_filename")[i].firstChild.nodeValue;
      try
        {
        pd=pd + "<h4>" + xt + "</h4>" + "<p>" + xd +"</p><br />" + "Contact: <a href='mailto:%20" + xc+"'>" + xs + 
			"</a><br/>Deadline: " + xe + "<br />"
		if (xfn!="Nd") pd=pd +"<a href='../mosaic/jobs/pdf_files/" + xfn + "'><img src='images/pdf_Logo.gif' alt='Pdf' /></a><hr>";
		if (xfn=="Nd") pd = pd + "<hr />";			
        }
      catch (er)
        {
        pd=pd + "error loading<br />"
        }
	}
  document.getElementById('PostDocs').innerHTML=pd;
  
  // Show the stage availabilities

  var st="<h2>Short training periods</h2>";
  xst=risp.getElementsByTagName("mosaic_stage");
  for (i=0;i<xst.length;i++)
    {
	xt=risp.getElementsByTagName("mosaic_st_title")[i].firstChild.nodeValue;
	xs=risp.getElementsByTagName("mosaic_st_supervisor")[i].firstChild.nodeValue;
	xc=risp.getElementsByTagName("mosaic_st_contact")[i].firstChild.nodeValue;
	xd=risp.getElementsByTagName("mosaic_st_descr")[i].firstChild.nodeValue;
    xe=risp.getElementsByTagName("mosaic_st_exp")[i].firstChild.nodeValue;
	var xfn=risp.getElementsByTagName("mosaic_st_pdf_filename")[i].firstChild.nodeValue;
      try
        {
        st=st + "<h4>" + xt + "</h4>" + "<p>" + xd +"</p><br />" + "Contact: <a href='mailto:%20" + xc+"'>" + xs + 
			"</a><br/>Deadline: " + xe + "<br />"
		if (xfn!="Nd") st=st +"<a href='../mosaic/jobs/pdf_files/" + xfn + "'><img src='images/pdf_Logo.gif' alt='Pdf' /></a><hr>";
		if (xfn=="Nd") st = st + "<hr />";			
        }
      catch (er)
        {
        st=st + "error loading<br />"
        }
	}
  document.getElementById('ShortPeriod').innerHTML=st;


  }
  else
  {
  alert("Problem retrieving XML data:" + jobReq.status) // + jobReq.statusText)
  }
  }
}
// JavaScript Document
