﻿$(function() {
    $.ajax({
        type: "GET",
        url: "/testimonials.xml",
        dataType: "xml",
        success: function(xml) {
            var i = 0;
                $(xml).find('testimonial').eq(i).each(function() {
                    var content = $(this).find('content').text();
                    var name = $(this).find('name').text();
                    var pos = $(this).find('position').text();
                    var bus = $(this).find('business').text();
                    $('#name')
				.empty()
				.append(name);
                    $('#position')
            	.empty()
				.append(pos);
                    $('#business')
				.empty()
				.append(bus);
                    $('blockquote')
                .empty()
				.append(content);

                });
                $('#testimonialsFade').animate({ "backgroundColor": "#ffffff" }, 6000).fadeOut(1000);
                i++;
                $(document).everyTime(7000, function() {
                    $(xml).find('testimonial').eq(i).each(function() {
                        var content = $(this).find('content').text();
                        var name = $(this).find('name').text();
                        var pos = $(this).find('position').text();
                        var bus = $(this).find('business').text();
                        $('#name')
				    .empty()
				    .append(name);
                        $('#position')
            	    .empty()
				    .append(pos);
                        $('#business')
				    .empty()
				    .append(bus);
                        $('blockquote')
                    .empty()
				    .append(content);

                    }); //close each(
                    $('#testimonialsFade').fadeIn(1000).animate({ "backgroundColor": "#ffffff" }, 5000).fadeOut(1000);
                    if (i < $(xml).find('testimonial').length - 1) {
                        i++;
                    } else {
                        i = 0;
                    }
                });
        } //close success
    }); //close $.ajax(
});         //close $(
					
