// JavaScript Document
var quotearray = new Array();
var attribarray = new Array();
var quote_autoplay = true;
var filter_value = new String();

//$(document).ready(readfilterXML("golf"));
/*
$(document).ready(function()
{
  $.ajax({
    type: "GET",
    url: "testimonials.xml",
    dataType: "xml",
    success: parseXml,
  });
});
*/
function readfilterXML(passed_value)
{
	filter_value = passed_value;
  $.ajax({
    type: "GET",
    url: "testimonials.xml",
    dataType: "xml",
    success: parseXml
  });
}

function parseXml(xml)
{
	var holdclass = filter_value;
	// need to seek class within id "quote" like "#quote.class" to find out what it is
  //find every testimonial and load the array
  $(xml).find("testimonial").each(function()
  {
	var tempclass = $(this).attr("class");
//	$("#error").html(tempclass);
	if ((tempclass == holdclass) || (holdclass == "all"))	 {
		tempquote = $(this).find("quote").text();
if(tempquote) {
quotearray.push("&quot;" + tempquote + "&quot;");
tempname = $(this).find("name").text();
if(tempname == "\n"){tempname = "";}
temptitle = $(this).find("title").text();
if(temptitle == "\n"){temptitle = "";}
temporg = $(this).find("organization").text();
if(temporg == "\n"){temporg = "";}
if(tempname && (temptitle || temporg)){tempname += ",";}
if(temptitle && temporg){temptitle += ",";}
attribarray.push(tempname + temptitle + temporg);
tempname = "";
temptitle = "";
temporg = "";}

//  $("span.quote").html("&quot;" + $(this).find("quote").text() + "&quot;<br />");
//print each testimonial name, title, and org if exists
/*
  $("span.attrib").html("- " + $(this).find("name").text() + "");
  $("span.attrib").append(", " + $(this).find("title").text() + "");
  $("span.attrib").append(", " + $(this).find("organization").text() + "<br />"); */
}
});
  rotatequote();
}

function rotatequote()
{
	thequote = quotearray.shift(); //Pull the top one
	quotearray.push(thequote); //And add it back to the end
	theattrib = attribarray.shift(); //Pull the top one
	attribarray.push(theattrib); //And add it back to the end
	
	document.getElementById('quote').innerHTML = thequote;
	document.getElementById('attrib').innerHTML = theattrib;
	// This rotates the quote every 10 seconds.
	// Replace 10000 with (the number of seconds you want) * 1000
	t=setTimeout("rotatequote()",6000);
}

//$(document).ready(readfilterXML("golf"));

//window.load = initQuote();
