$(document).ready(function() {
	// wrap span-Element into a.button
	$('a.button:not(:has(input))').wrapInner('<span />');
	
	// lib.MEDIA
	$('#media').ready(function() {
		$.ajax({
			type: 'GET',
			url: window.location.href,
			data: 'type=71629',
			dataType: 'xml',
			success: function(xml) {
				$(xml).find('media>img').each(
					function() {
						$('<img />')
							.attr('src',    $(this).attr('src'   ))
							.attr('width',  $(this).attr('width' ))
							.attr('height', $(this).attr('height'))
							.attr('alt',    $(this).attr('alt'   ))
							.attr('title',  $(this).attr('title' ))
							.load(function(){
								// static: new images will be appended to the bottom of the list
								$('#media').append($(this));
								// random: new images will be added randomly to the list 
								// $('#media>img:nth-child(' + Math.ceil(Math.random() * $('#media>img').length) + ')').after($(this));
								$('#media').cycle(
									{
										fx:     'fade',
										timeout: 4000,
										speed:   2500,
										random:  0      // does not work with with $.cycle.lite.min.js
														// but we don't care, because the preloading would mix up and brake the slideshow anyways
									}
								);
							});
					}
				);
			}
		});
	});
});
