
// Start function when DOM has completely loaded 
$(document).ready(function(){ 

	// Open the xml file
	$.get(xmlFile,{},function(xml){
      	
		// Build an HTML string
		var myHTMLOutput = '';
		var countPics = 0;
	
		// Run the function for each student tag in the XML file
		$('image',xml).each(function(i) {
			image_ipath = $(this).find("ipath").text();
			image_title = $(this).find("title").text();
			
			// Build HTML data and store in string
			countPics = countPics + 1;
			mydata = BuildRotatorHTML(image_ipath,image_title,countPics);
			myHTMLOutput = myHTMLOutput + mydata;
		});
		
		// Update the DIV with the HTML string
		$("#fade").append(myHTMLOutput);
		
		$.fn.cycle.defaults.speed   = cycleSpeed;
		$.fn.cycle.defaults.timeout = cycleTimeout;
			
		$(function() {
    		// run the code in the markup!
    		$('#imageFader pre code').each(function() {
       		eval($(this).text());
    		});
		});
	});
});
 
function BuildRotatorHTML(image_ipath,image_title,countPics)
{
	// Build HTML string and return
	output = '';
	output += '<img id="rotpic_' + countPics + '" class="pic_rotator" src="';
	output += image_ipath;
	output += '" width="740" height="370" alt="Bild_' + countPics + '"';
	output += 'title="' + image_title + '" border="0" />';
	
	return output;
}


	 
