$('document').ready(function() {
	url = new Array();
	text = new Array();
	images = '';
	b=-1;
	$.ajax({
    	type: "GET",
        url: "headers.xml",
        dataType: "xml",
        success: function(xml) {
			$(xml).find('header').each(function() {
				url.push($(this).attr('url'));
				text.push($(this).text());
				images += '<img src="' + $(this).attr('image') + '" alt="' + $(this).text() + '" />';
			}); 
			$('#header').html(images).ready(function() {
					$('#header').cycle({ 
						fx:     'fade', 
						timeout: 5000, 
						before:   onAfter 
					 });
			});
		}
	});			

});

function onAfter() {
	if(b < (text.length - 1)) {
		b++;
	} else {
		b=0;
	}
	$('#header-side span').html(text[b]);
	$('#header-side a').attr('href',url[b]);
}
