<!--

var iSol = 0;
var pSol = true;
var timeSol = 5000;

function getXMLHTTPRequest()
{
  try {
    request = new XMLHttpRequest();
  } catch(err1) {
    try {
	  request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(err2) {
	  try {
	    request = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch(err3) {
	    request = false;
	    alert("There is an error");
	  }
	}
  }
  return request;
}

function setNewItem(oRequest, itemNumber, divId) {
  var titleValue = oRequest.responseXML.getElementsByTagName("title")[itemNumber];
  if (!titleValue) {
  // need to reset to first solution
	itemNumber = 0;
    var titleValue = oRequest.responseXML.getElementsByTagName("title")[itemNumber];
  }
  
  var title = titleValue.childNodes[0].nodeValue;

  var infoTypeValue = oRequest.responseXML.getElementsByTagName("type")[itemNumber];
  var infoType = infoTypeValue.childNodes[0].nodeValue;
  
  if (infoType == "News") {
    title = "News - " + title;
  }

  var descriptionValue = oRequest.responseXML.getElementsByTagName("description")[itemNumber];
  var description = descriptionValue.childNodes[0].nodeValue;

  var linkValue = oRequest.responseXML.getElementsByTagName("link")[itemNumber];
  var link = linkValue.childNodes[0].nodeValue;
  
  document.getElementById(divId).innerHTML =
         "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"#797979\">"

		 +"<tr valign=\"center\">"
		 +"<td align=\"center\"><font color=\"#FFFFFF\"><b>"
		 +title
		 +"</b></font>"
		 +"</td>"
		 +"</tr>"

		 +"<tr valign=\"center\" bgcolor=\"#FFFFFF\">"
		 +"<td height=\"100\" align=\"center\">"
		 +description
		 +"</td>"
		 +"</tr>"

		 +"<tr valign=\"center\" bgcolor=\"#FFFFFF\">"
		 +"<td align=\"right\">"
 		 +"<a href=\""
		 +link
		 +"\">read more ...</a>"
		 +"</td>"
		 +"</tr>"

		 +"</table>";
		 
  return itemNumber;
}

// following function is called from the page it is loaded in - e.g.: Home Page
function setItems() {
  solRequest = getXMLHTTPRequest();
  getSolutions();
  setSolution();
  intervalSolutionID = window.setInterval("setSolution()",timeSol);
}

// Solution Specific Functions
function getSolutions() {
  var sURL  = "src/solutions.xml";
  myRand = parseInt(Math.random()*9999999999999);
  var mySURL = sURL+"?rand="+myRand;

  solRequest.open("GET",mySURL,false);
  solRequest.send(null)

//  if (solRequest.status==200) alert(solRequest.responseText);
//  else alert("Error executing XMLHttpRequest call!");
}

function setSolution() {
  iSol = setNewItem(solRequest, iSol, 'Nav_Bar_Solution') + 1;
}

function startStopSolution(){
  if (pSol) {
    window.clearInterval(intervalSolutionID);
    document.getElementById('sol_pause_play').innerHTML = '<img src="images/play.png">';
	pSol = false;
  } else {
    document.getElementById('sol_pause_play').innerHTML = '<img src="images/pause.png">';
    setSolution();
    intervalSolutionID = window.setInterval("setSolution()",timeSol);
	pSol = true;
  }
}
 
function previousSolution() {
  if (pSol) {
    startStopSolution();
    iSol = iSol - 2;
  }
  if (iSol >= 0) {
    iSol = setNewItem(solRequest, iSol, 'Nav_Bar_Solution') - 1;
  }
}

function nextSolution() {
  if (pSol) {
    startStopSolution();
  }
  iSol = setNewItem(solRequest, iSol, 'Nav_Bar_Solution') + 1;
}

//-->


