newsticker =
{
	tickerindex:0,

	startTicker: function()
	{
		$.ajax({
			url: "./news/rss_xml/news-rss20.xml",
			type: "GET",
			dataType: "xml",
			cache: false,
			error: function(request,textStatus,errorThrown){
			  console.log(textStatus);
			  console.log(request);
			  console.log(errorThrown);
			},
			success: function(xml){
		  		  
				var list = $(xml).find("item");
		  
				newsticker.tickerindex = 0;
				
				if (list.length==1)
				{
					var listElement = $(list).get(0);
            		
					var text = $(listElement).find("description");
					var textAsString = "<b>"+$(listElement).find("title").text()+"</b><br/>"+$(text).text();
					textAsString = textAsString.replace(/\r\n/g, ", ");
					textAsString = textAsString.replace(/\\'/g, "'");
					textAsString = textAsString.replace(/\r/g, ", ");
					textAsString = textAsString.replace(/\n/g, ", ");
					textAsString = textAsString.replace(/%0A/g,", ");  
					textAsString = textAsString.replace(/%0D%0A/g,", ");  
					textAsString = textAsString.replace(/%0D/g,", ");  
					//textAsString = textAsString.replace(/- /g,"");  
						
					$(".headlines").html(textAsString);
				}
				else
				{
					var timer = setInterval(function(){
        				if(newsticker.tickerindex >= list.length)
            			{
            				newsticker.tickerindex = 0;
	            		}
	            
	            		var listElement = $(list).get(newsticker.tickerindex);
            
						$(".headlines").slideUp("slow", function() {
						
							var text = $(listElement).find("description");
							var textAsString = "<b>"+$(listElement).find("title").text()+"</b><br/>"+$(text).text();
							textAsString = textAsString.replace(/\r\n/g, ", ");
							textAsString = textAsString.replace(/\\'/g, "'");
							textAsString = textAsString.replace(/\r/g, ", ");
							textAsString = textAsString.replace(/\n/g, ", ");
							textAsString = textAsString.replace(/%0A/g,", ");  
							textAsString = textAsString.replace(/%0D%0A/g,", ");  
							textAsString = textAsString.replace(/%0D/g,", ");  
							//textAsString = textAsString.replace(/- /g,"");  
								
							$(".headlines").html(textAsString);
							$(".headlines").slideDown("slow");
							newsticker.tickerindex = newsticker.tickerindex+1;
						});

        			}, 5000);
				}
  			}
		});
	},
};
