//
// jQuery scrollup script  for G+J      
// based on http://www.learningjquery.com/2006/10/scroll-up-newsitem-reader
//

var newsitem_count;
var newsitem_interval;
var old_newsitem = 0;
var current_newsitem = 0;
var linkvalue = 0;

$(document).ready(function(){
  newsitem_count = $('div.newsitem').size();
  $('div.newsitem').eq(current_newsitem).css('top','5px');
  
  newsitem_interval = setInterval(newsitem_rotate,5000); //time in milliseconds
  $('div.scrollup').hover(function() {
    clearInterval(newsitem_interval);
  }, function() {
    newsitem_interval = setInterval(newsitem_rotate,5000); //time in milliseconds
  });
  // SAME HOVER-STOPER FOR NEWSLINK DIV
  $('#newslink').hover(function() {
    clearInterval(newsitem_interval);
  }, function() {
    newsitem_interval = setInterval(newsitem_rotate,5000); //time in milliseconds
  });
  
 // EXTENSION FOR PERMANENT LINK  2009 Kamph.com.mu.ni.ca.tion
 current_newsitem = $('div.newsitem').eq(current_newsitem);
 linkvalue = $("div.hiddenlink",current_newsitem).html();
 $('#newslink').html(linkvalue);
  
});

function newsitem_rotate() {
  current_newsitem = (old_newsitem + 1) % newsitem_count; 
  $('div.newsitem').eq(old_newsitem).animate({top: -205},'slow', function() {
    $(this).css('top','210px');
    });
  $('div.newsitem').eq(current_newsitem).show().animate({top: 5},'slow');  
  old_newsitem = current_newsitem;
  
 // EXTENSION FOR PERMANENT LINK  2009 Kamph.com.mu.ni.ca.tion
 current_newsitem = $('div.newsitem').eq(current_newsitem);
 linkvalue = $("div.hiddenlink",current_newsitem).html();
 $('#newslink').html(linkvalue);
}

function showlinkvalue() {
alert('L'+linkvalue);
}
