$(document).ready(function(){
	$.ajax({
		 type: "GET",
		 url: "/externals/ramowka.xml",
		 dataType: "xml",
		 success: function(xml) {
			var current_title_text
			var current_dj_text
			var current_start_text
			var current_end_text
			var next_title_text
			var next_dj_text
			var next_start_text
			var next_end_text

			$(xml).find('Current').each(function(){
				current_title_text = $(this).find('title').text()
				current_dj_text = $(this).find('dj').text()
				current_start_text = $(this).find('start').text()
				current_end_text = $(this).find('end').text()
			});

			$(xml).find('Next').each(function(){
				next_title_text = $(this).find('title').text()
				next_dj_text = $(this).find('dj').text()
				next_start_text = $(this).find('start').text()
				next_end_text = $(this).find('end').text()
			});

			$("div[class*='item_ramowka']").each(function(){
				if($(this).hasClass('antena')){
					$(this).children().each(function(){
						if($(this).hasClass('data')) {
							$(this).html(current_start_text + ' - ' + current_end_text)
						}
						if($(this).hasClass('blok')){
							$(this).html(current_title_text + ' prowadzi: ' + current_dj_text)
						}
					});
				}
				if($(this).hasClass('wkrotce')){
					$(this).children().each(function(){
						if($(this).hasClass('data')) {
							$(this).html(next_start_text)
						}
						if($(this).hasClass('program')){
							$(this).html(next_title_text)
						}
					});
				}
			 });
		 }
	 });
});
