var req = null
var numProjects
var projects = new Array()


function loadXMLDoc(url)
{ if (window.XMLHttpRequest)
  { req = new XMLHttpRequest()
  } 
  else if (window.ActiveXObject)
  { req = new ActiveXObject("Microsoft.XMLHTTP")
  }
  
  if (req)
  { req.onreadystatechange = processReqChange
    req.open("GET",url,true)
    req.send(null)
  }
}

function processReqChange()
{ var ready = req.readyState
  var data = null
  if (ready == 4)
  { data = req.responseXML
    parseData(data)
    document.getElementById("portfolioList").innerHTML = ""
    populatePage()
  }
  else
  { document.getElementById("portfolioList").innerHTML = "Loading..."
  }
}

function project(data,which)
{ this.client = data.getElementsByTagName("client")[which].firstChild.nodeValue
  this.original = data.getElementsByTagName("original")[which].firstChild.nodeValue
  this.current = data.getElementsByTagName("current")[which].firstChild.nodeValue
  this.display = data.getElementsByTagName("display")[which].firstChild.nodeValue
  this.employer = data.getElementsByTagName("employer")[which].firstChild.nodeValue
  this.image = data.getElementsByTagName("image")[which].firstChild.nodeValue
  this.description = data.getElementsByTagName("description")[which].firstChild.nodeValue
}

function parseData(data)
{ numProjects = data.getElementsByTagName("project").length
  for (i=0;i<numProjects;i++)
  { projects[i] = new project(data,i)
  }
}