//
// Parse response from server in XML format.
//
var response;
var finalTipString = '';
var tipArray = null;

function dspRandomTip() {
 
  // Is the readyState = 4?
  if( request.readyState == 4 ) {
    // Is the status = 200?
    if( request.status == 200 ) {
      // Grab the responseText from the XMLHttpRequest.
	  
	  // Here we could just receive the text as a string, if it it coming from 
	  // an unformatted text file using 'responseTest' and the parse it out
	  // with our own routine,
	  // Or we can receive the vales as XML, if the source is in XML format, using 
	  // responseXML.  Then we can use the methods getElementById() and getElementsByTagName()
	  // to parse the data.
	  // Use xmlObject.getElementsByTagName( tagName ) to get a list of the tag values.
	  // Use document.getElementById( elementId ).innerHTML to set the desination of the values.
	  response = request.responseXML;
	  
	  finalTipString  = '<img src="' + response.getElementsByTagName( 'IMAGE' )[0].firstChild.nodeValue + '" alt="" /><p>';
	  finalTipString += response.getElementsByTagName( 'TIP' )[0].firstChild.nodeValue + '</p>';
  	  document.getElementById( 'tipInfo' ).innerHTML = finalTipString;
	  
  	  } else {
	    alert( 'There was a problem retrieving the data: \n' + request.statusText );
	    request = null;
	  }
    }	  

} // end function dspRandomTip()