
$(document).ready(function(){ 

	$.ajax({
		type: "GET",
		url: "/bcparks/_shared/xml/BCParks100-slideshow.xml",
		dataType: "xml",
		//success: parseXml("1",)
		success: function(result) {
    	parseXml(1,result);
		}
	});
	

	function parseXml(param,xml) {
		var img = document.getElementById("slideshowImg");
		var path = "/bcparks/images/parks100/home-slideshow/";
		var i = 0;
		var ia = 0;
		var ib = 0;
		var sCodeList = new String();
		var iIndex = new Number();
		var aFile = new Array();
		var aTitle = new Array();
		var aActive = new Array();
		
		
		//read photo tags
		$(xml).find("photo").each(function(){
			aFile[i] = $(this).children("file").text();
			aTitle[i] = $(this).children("title").text();
			aActive[i] = $(this).children("active").text();
  		i++;
		});
		
		iIndex = selRandom(aFile.length-1);
		
		//img.src = path + aFile[iIndex];
		img.style.backgroundImage = "url(" + path + aFile[iIndex] + ")";
		//img.alt = aTitle[iIndex];
		$("#slideshowCaption").append(aTitle[iIndex]);
	}
});
