$(document).ready(function(){
  /* RTN Spotlight
  ** 
  ** looks for divs with the class 'newslider-horizontal' with the data-xml-url attribute
  */
  $(".newslider-horizontal").each(function() {
    var slider = $(this);
    $.ajax({
      url: slider.attr("data-xml-url"),
      dataType: "xml",
      cache: false,
      context: this,
      success: function(xml) {
        $(this).find('.sliderkit-nav-clip').append('<ul></ul>');
        var thumbList = $(this).find('.sliderkit-nav-clip ul');
        var panels = $(this).find('.sliderkit-panels');
        var xmlCount = $(xml).find('object').length;
        $(xml).find('object').each(function() {
          thumbList.append('<li style="width: '+ Math.floor(100/xmlCount) +'%"><a href="#"><img src="' + $(this).find('thumb').text() + '"/></a></li>');
          panels.append('<div class="sliderkit-panel"><div class="sliderkit-news"><img src="' + $(this).find('image').text() + '"/><h3>' + $(this).find('title').text() + '</h3><p>' + $(this).find('caption').text() + '<a href="' + $(this).find('url').text() + '"> Read more &raquo;</a></p></div></div>');
        });
        $(this).sliderkit({
          auto:true,
          autospeed: 4000,
          shownavitems:xmlCount,
          panelfx:"sliding",
          panelfxspeed:1000,
          panelfxeasing:"easeOutExpo",
          mousewheel:true,
          keyboard:true,
          fastchange:false
        });
      }
    })
  });
});	


