$(document).ready(function () {

    var testimonials = new Object();
    var stagList = $('#stagTestimonials');
    var henList = $('#henTestimonials');

    // get the testimonials
    $.ajax({
        type: "GET",
        url: "/data/testimonialsFeed.svc/GetTestimonials",
        dataType: "json",
        success: function (result) {
            testimonials = result;
            stagList.empty();
            henList.empty();

            for (var i = 0; i < testimonials.length; i++) {
                if (testimonials[i].Categories.indexOf("stag")>=0)
                    $("<li>" + testimonials[i].Comments + " </li>").appendTo('#stagTestimonials');

                if (testimonials[i].Categories.indexOf("hen")>=0)
                    $("<li>" + testimonials[i].Comments + " </li>").appendTo('#henTestimonials');

            }

            // JavaScript Document
            jQuery(function () {
                jQuery('#stagTestimonials').ulslide({
                    width: 360,
                    height: 'auto',
                    bnext: '#stagArrNext',
                    bprev: '#stagArrPrev',
                    affect: 'slide',
                    axis: 'x',
                    autoslide: 6000
                });
            });
            jQuery(function () {
                jQuery('#henTestimonials').ulslide({
                    width: 360,
                    height: 'auto',
                    bnext: '#henArrNext',
                    bprev: '#henArrPrev',
                    affect: 'slide',
                    axis: 'x',
                    direction: 'b',
                    autoslide: 6000
                });
            });

        }
    });

});
