$(document).ready(function(){
	var photoNum;
	var currentPhoto = 0;
	
	//interval time
	var time = 600;
	var theInt = null;
	
	var speed = 1000;
	
	var images = {};
	var xmlObj;
	$.ajax({
		url: 'topLoad.xml',
		dataType: 'xml',
		success: function(xml){
			xmlObj = xml;
			xmlParse(xmlObj);
		}
	});
	function xmlParse(xml){
	
		var current = 0;
		
		$(xml).find('image').each(function(i){
			images[i] = {
				'path': $(this).attr('path'),
				'href': $(this).attr('href'),
				'pos': '#img' + $(this).attr('pos')
			}
			$(images[i].pos + ' img').attr('src', images[i].path);
			$(images[i].pos + ' a').attr('href', images[i].href);
			$(images[i].pos).css('opacity', '0.3');
			photoNum = i;
		});
		theInt = setInterval(loadPhoto, time);
	}
	function loadPhoto(){
		clearInterval(theInt);
		$(images[currentPhoto].pos).fadeTo(speed, 1.0);
		currentPhoto++;
		if (currentPhoto <= photoNum) {
			theInt = setInterval(loadPhoto, time);
		}
	}
});

