var jXML = {
    getRandomObj: function(xml,nodes) {
        var response = {};
        for (var node in nodes) {
            var a = [];
            var b = [];
            $(nodes[node][0],xml).each(function(i) {
                b[i] = this;
            });
            var c = b.length;
            if (nodes[node][1] != null && nodes[node][1] < c) 
            {
                c = nodes[node][1];
            }
            for (i = 0; i < c; i++) {
                var e = Math.floor(Math.random() * b.length);
                a[i] = b[e];
                b.splice(e,1);
            }
            response[node] = a;
        }
        return response;
    }
};
  
var newsitemsRight;
var curritemRight=0;
var iPauseRight=0;
    
function initTickerRight(){
	//news ticker stuff
   
    var tickerSelector = "div.leftBarA ul#ticker li";
    newsitemsRight = $(tickerSelector).hide().hover(
        function()
        {
            $(this).addClass("hovered");
            iPauseRight=1;
        },
        function()
        {
            $(this).removeClass("hovered");
            iPauseRight=0;
        }
    ).filter(":eq(0)").show().add(tickerSelector).size();
    setInterval(ticknewsRight,8000); //time in milliseconds
    
    //news ticker    
}

var newsitemsRightB;
var curritemRightB=0;
var iPauseRightB=0;
function initTickerRightB(){

    var tickerSelector = "div.leftBarC ul#ticker li";
    newsitemsRightB = $(tickerSelector).hide().hover(
        function()
        {
            $(this).addClass("hovered");
            iPauseRightB=1;
        },
        function()
        {
            $(this).removeClass("hovered");
            iPauseRightB=0;
        }
    ).filter(":eq(0)").show().add(tickerSelector).size();
    setInterval(ticknewsRightB,40000); //time in milliseconds
  
}
function ticknewsRightB()
{
  if(iPauseRightB==0)
  {
    $("div.leftBarC #ticker li:eq("+curritemRightB+")").fadeOut("slow",function(){$(this).hide();});
    curritemRightB = ++curritemRightB%newsitemsRightB;
    $("div.leftBarC #ticker li:eq("+curritemRightB+")").fadeIn("slow");
   }
}
function ticknewsRight()
{
  if(iPauseRight==0)
  {
    $("div.leftBarA #ticker li:eq("+curritemRight+")").fadeOut("slow",function(){$(this).hide();});
    curritemRight = ++curritemRight%newsitemsRight;
    $("div.leftBarA #ticker li:eq("+curritemRight+")").fadeIn("slow");
   }
}

