// JavaScript Document
var myArray = [];
$(document).ready(function() {
	$.ajax({
		type: "GET",
		url: "/ctaBanners/xml/images.xml", //xml file 
		dataType: "xml",
		success: function(xml) {
			var count = 0; //counter
			$(xml).find('site').each(function() {

				var url = $(this).find('url').text(); //url 
				var target = $(this).find('target').text(); //_blank, _new
				var imageURL = $(this).find('imageURL').text(); //location of the image
				var alt = $(this).find('alt').text(); //alternate text of the image

				//append to array
				myArray[parseInt(count)] = new Array(imageURL, url, target, alt); 
				
				count++;
			});

			var mygallery2 = new simpleGallery({
				wrapperid: "simplegallery2", //ID of main gallery container,
				dimensions: [493, 180], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
				
				imagearray: myArray, //assing the array var to here
				
				autoplay: [true, 10000, 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)
				}
			})
		}
	});

});
		