$(document).ready(function(){
    shuffleWidgets();
    $("#slider").easySlider({
        speed: 			400,
        auto:			true,
        pause:			6000,
        continuous:		true,
        navBtnImg: "/home/index/img/sliderButtons.png",
        navBtnHeight: 34,
        navBtnWidth: 34,
        navBtnIndent: 10,
        height: 208,
        width: 400
    });
    $('#dialog').dialog({
        autoOpen: false,
        dialogClass: "ui-dialog-widget",
        draggable: false,
        modal: true
    });
    loadRandomTestimonial();
});
function ajaxLoad(url, type, callback) {
    $.ajax({type: "GET", url: url, dataType: type, success: function(xml) {
            callback(xml);
        }
    });
}
function loadRandomTestimonial() {
    ajaxLoad("/home/index/testimonials.xml", "xml", function(xml) {
        var testimonials = $(xml).find("testimonial");
        var t = testimonials[Math.floor(Math.random() * testimonials.length)];
        var q = $(t).text(), n = $(t).attr("name"), s = $(t).attr("school");
        $("#quote").text(q);
        $("#quoter").text(n + ", " + s);
    });
}
function shuffleWidgets() {
    var widgets = new Array();
    $("#slider li").each(function(i, e) {
        widgets.push("<li>" + $(e).html()) + "</li>";
    });
    var nwo = "";
    while(widgets.length > 0) {
        var rndW = Math.floor(Math.random() * widgets.length);
        nwo += widgets[rndW];
        widgets.splice(rndW, 1);
    }
    $("#slider ul").html(nwo);
}
