$(document).ready(function() {

  var title = '';
  var symbol = '_';
  var t;
  var count = 0;
  var hidden_div = $('.hidden')
  var news_div = $('.slideout');
  $('.news_ticker, .news_ticker_title').css('display', 'inline');
  var underscore = $('.underscore');
  $(underscore).css('display', 'inline');
  var date_div = $('.date');
  var fading = $('.slideout, .date');
  
function runIt(data) {
  
  count = count+1;
 if (count == 4) { count = 1; }
 if(count == 1){ date =  data.story1.date;  title = data.story1.story; }
 if(count == 2){ date =  data.story2.date; title = data.story2.story; }
 if(count == 3){ date =  data.story3.date; title = data.story3.story; }
 // if(count == 4){ date =  data.story4.date; title = data.story4.story; }
  hidden_div.hide().text(title);
  new_width = hidden_div.width();
  
  set_time_dec = (new_width / 120) * 1000;
  set_time = Math.round(set_time_dec);


date_div.hide().text(date).slideDown("slow", function(){ 
 news_div.text(title);
  underscore.text(symbol);
 
   news_div.animate({ width: ''+ new_width +'px' }, set_time, function(){
    
	  underscore.hide('fast', function(){
      underscore.text('').fadeIn(4000, function(){
	    date_div.fadeOut(1000);
		news_div.fadeOut(1000, function(){
	       news_div.text('').css('width' ,'0px').fadeIn('fast', runIt(data));
		   
	       }); // end 4th animate (remove text);
		
	      }); // end 3rd animate (fade out text)
		
	  }); // end 2nd animate (hide underscore)
	
  }); // end first animate

}); // end date



} // end function


 $.getJSON('get_news.php','', runIt);
 
 $.extend($.fn.disableTextSelect = function() {
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
	});
	$('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'
$('.news_ticker').disableTextSelect();

						   });