var timer = 5000;
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

$(document).ready(function(){
  headline_count = $("div.headline").size();
  $("div.headline:eq("+current_headline+")").css('top', '0px');
  headline_interval = setInterval(headline_rotate, timer);
  
  $('#scrollup').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate, timer);
    headline_rotate();
  });
	
	/*########*/
	$("#videosNav").change(function(e){
    var _code = $(this).val();
    
    if(_code == "null"){
      $('div.ajax_video_wrapper').html("");
       return;
    }
    
    utube_str ='<object width="425" height="344">';
    utube_str +='<param name="movie" value="http://www.youtube-nocookie.com/v\/' + _code + '&hl=en&fs=1&rel=0&color1=0x5d1719&color2=0xcd311b"><\/param>';
    utube_str +='<param name="allowFullScreen" value="true"><\/param>';
    utube_str +='<param name="allowscriptaccess" value="always"><\/param>';
    utube_str +='<embed src="http://www.youtube-nocookie.com/v\/' + _code + '&hl=en&fs=1&rel=0&color1=0x5d1719&color2=0xcd311b"type="application\/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"  width="425" height="344"><\/embed>';
    utube_str +='<\/object>';
  
    $('div.ajax_video_wrapper').html(utube_str).fadeIn('fast');
  });
	/*########*/
	
});

function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count;
  $("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
    $(this).css('top', '210px');
  });
    
  $("div.headline:eq(" + current_headline + ")").animate({top: 0},"slow");  
  old_headline = current_headline;
}


