How do I load nivo-slider after the script I wrote to load the html for nivo-slider from an xml file?

How do I load nivo-slider after the script I wrote to load the html for nivo-slider from an xml file?

I wrote a script to pull content from an xml file to write the html code for nivo-slider onto a page. There seems to be an issue with my script or the order in which the scripts load. 

The slider works OK upon initial page load, but if you move between pages mid-slideshow, then it bugs out and on the page you move to and sticks on the last image of the slideshow and then keeps reloading giving an error that says, " GET http://www.kristinemorical.com/design/designsystems/muddog/undefined 404 (Not Found)".

It seems that if you refresh the page it works fine to move between pages or if you hard code the nivo-slider html onto the page it works OK to switch between pages. 

It doesn't work OK with the jQuery I created to pull the content from the xml file and write it to the page. So at least I've pinpointed the issue. 

I'm wondering if it's an issue of the order that the codes load on the page. Basically the code to write the html would have to go onto the page before nivo-slider loads. Not sure what the issue is? Hopefully smebody can help for my sanity sake.

Here's the pages I'm having trouble with:
You can navigate between them with the first two thumbnail icons under Design Systems.

Here's the code I wrote to pull content from an xml file to write the html code for nivo-slider onto a page:
  1. <script>
  2. jQuery(document).ready(function($)
  3.    {
  4.     // get xmlfile.xml and define function.
  5.     $.get('http://www.kristinemorical.com/design/designsystems/unitedway/unitedway.xml', function(d){ 
  6.         
  7.         //Find the child elements of the subchild elements that you wish to display in slider and index the current items of them. 
  8.         //('ind' is the index, and 'item' is the current item).
  9.         //Example: $(d).find('child elements of xml here').each(function(ind,item){
  10.         $(d).find('pic').each(function(ind,item){
  11. // Define the variables used from the subchild elements in the xml file. 
  12. // Example: var yourMadeUpName = $(this).find('subchild element from xml here').text();
  13.             var title = $(this).find('title').text();
  14.       var image = $(this).find('image').text();
  15.       var caption = $(this).find('caption').text();
  16.       var thumbnail = $(this).find('thumbnail').text();
  17.       var klink = $(this).find('link').text();
  18.       var klinkdes = $(this).find('linkdes').text();
  19.             
  20.             //Variable that creates the images with links.
  21.       var html = '<a href="' + klink + '"' + 'rel="prettyPhoto"' + 'title="' + klinkdes + '"' + '>' + '<img src="' + image + '"' + 'title="#htmlcaption' + ind +'"/>' + '</a>';
  22.       //Variable that creates the html captions.
  23.       var caption = '<div id="htmlcaption'+ind+'" class="nivo-html-caption">' + title + '<br><span class="caption">' + caption + '</span></div>';
  24.             
  25.             //Positions the images and links within the div with an id of #slider.
  26.       $('#slider').append($(html));
  27.      
  28.       //Positions the html captions below it.
  29.      $('#slider').after($(caption));
  30.     
  31.      //Remove empty a attributes
  32.      $("a[href='']").replaceWith('<img src="' + image + '"' + 'title="#htmlcaption' + ind +'"/>')
  33.     
  34.      return( true );
  35.         });
  36.     });
  37. });
  38. </script>
I placed it inside the head tags after I call the scripts:
  1. <script type="text/javascript" src="http://www.kristinemorical.com/jquery/jquery-1.9.1.js"></script>
  2. <script type="text/javascript" src="http://www.kristinemorical.com/jquery/accordion.js"></script>
  3. <script type="text/javascript" src="http://www.kristinemorical.com/jquery/jquery-scrollTo.js"></script>
I then placed the nivoslider code at the end of the page just before the footer:

  1. <script type="text/javascript" src="http://www.kristinemorical.com/jquery/jquery.nivo.slider.js"></script>
  2. <!-- initialize nivo-slider -->
  3. <script type="text/javascript">
  4. $(window).load(function() {
  5.     $('#slider').nivoSlider({
  6.         effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
  7.         animSpeed: 500, // Slide transition speed
  8.         pauseTime: 5000, // How long each slide will show
  9.         startSlide: 0, // Set starting Slide (0 index)
  10.         directionNav: true, // Next & Prev navigation
  11.         controlNav: false, // 1,2,3... navigation
  12.         controlNavThumbs: false, // Use thumbnails for Control Nav
  13.         pauseOnHover: false, // Stop animation while hovering
  14.         manualAdvance: false, // Force manual transitions
  15.     });
  16. });
  17. </script>
I already checked to make sure that noConflict is in place for all the jQuery scripts but  jquery-1.9.1.js.