// JavaScript Document
$(document).ready(function(){
	
	var art_num = 0;
	var cyc_art = 1;
	var scroll_top = 0;
	
	$.ajax({
        type: "GET",
		url: "pressroom/xml/maxim_press.xml",
		dataType: "xml",
		success: function(xml) {
				var i = 0;
				var divhtml = "";
				
							
				
				// Populates the Branch Array
				$(xml).find('article').each(function(){
													 
					i = i + 1;							

											 
					if($(this).attr('ticker') == "Yes"){
						
						divhtml = divhtml + '<span class="article" id="press' + i + '"><a href="/pressroom/index.html?artid=press' + i + '">' + $(this).attr('title') + '</a></span><br /><br />';
						art_num = art_num + 1;
						
					}				
					
					
				});
				
				if(art_num == 0){
					
					$('#News_Ticker').hide();
					
					divhtml = '<span class="article">There are currently no press articles released.</span><br />';
					
				}
				
				$('#ticker_scroll_articles').html(divhtml);
				
					
		 }
	});
			
	rotate_ticker = function() {
		timer = setInterval(function() {
			var scroll_top_str = "";
			
			
			 if (cyc_art == art_num){
				$('#ticker_scroll_articles').stop().animate({top: '0px'}, 300);
				cyc_art = 1;
				scroll_top = 0;
				
			 } else {
				scroll_top = scroll_top - 30;
				scroll_top_str = scroll_top + 'px';
				
				$('#ticker_scroll_articles').stop().animate({top: scroll_top_str}, 800);
				cyc_art = cyc_art + 1;
			 }
	       
										 
    	}, 3000);
	};
	
	rotate_ticker();
	
});
