
    var myArray = []; //declare and initialize array
	function randOrd(){
		return (Math.round(Math.random())-0.5);
	} 
    $(document).ready(function() {
        $.ajax({
            type: "GET",
            url: "../homeGallery/gallery.xml", //xml file 
			dataType: "xml",
            success: function(xml) {
                var count = 0; //counter
                $(xml).find('site').each(function() {

                    var imageURL = $(this).find('imageURL').text(); //location of the image

					//append to array
                    myArray[parseInt(count)] = new Array(imageURL); 
					
                    count++;
					
					myArray.sort( randOrd );
                });

                var mygallery2 = new simpleGallery({
                    wrapperid: "features", //ID of main gallery container,
                    dimensions: [610, 245], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
					
                    imagearray: myArray, //assing the array var to here
                    
					autoplay: [true, 5000, 99 ], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
                    persist: true,
                    fadeduration: 1000, //transition duration (milliseconds)
                    oninit: function() { //event that fires when gallery has initialized/ ready to run
                    },
                    onslide: function(curslide, i) { //event that fires after each slide is shown
                        //curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
                        //i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
                    }
                })
            }
        });

    });

