﻿function parseXml(xml)
{
	//Read all Testimonials
	$Testimonials = $(xml).find("Testimonial");
	//Randomly select a single Testimonial
	$randomTestimonial = $Testimonials.eq(Math.floor(Math.random() * $Testimonials.length));
	//Select specific nodes of Testimonials
	$rtSubject = $randomTestimonial.find('Subject').text();
	$rtText = $randomTestimonial.find('Text').text();
	$rtAuthor = $randomTestimonial.find('Author').text();

	//Output Testimonials to Div with ID output
    $("#sideTestimonials").html("<h5>" + $rtSubject + "</h5>");
    $("#sideTestimonials").append($rtText + "<p>");
    $("#sideTestimonials").append($rtAuthor + "<br />");
	
	//All Testimonials
	$rtMainString = "";
	$Testimonials.each(function() {
        	//Select specific nodes of Testimonials
		$rtMainString += "<h5>";
		$rtMainString += $('Subject', this).text();
		$rtMainString += "</h5>";
		$rtMainString += $('Text', this).text();
		$rtMainString += "<p>";
		$rtMainString += $('Author', this).text();
		$rtMainString += "<br /><hr>";
	
    });
	$("#hiddenTestimonials").html($rtMainString);

}

