//Declare the varibale name outside the function so it is global.
var sp;
function slide(){
	var className = 'SlidingPanelsContent';		 //change the className that is on all your content panels..
	var panelCount = sp.getContentPanelsCount();//get panel length
	var current = sp.getCurrentPanel();		 //get current panel
	var group = sp.getContentGroup();			 //get our group
	var panelNumber = 0;
	if(group.hasChildNodes()){
		var j = 0;
		for(var i = 0, l = group.childNodes.length; i < l; i ++){
			if(group.childNodes[i].className && group.childNodes[i].className.search(new RegExp("\\b" + className + "\\b")) != -1){ // if it has SlidingPanelsContent class we found the correct node.
				if(group.childNodes[i] == current) // if it matches our current panel, we have a number
					panelNumber = j;

				j++; //increase our panelcounter
			}
		}

	}
	sp.showPanel(((panelNumber + 1 /* its currently 0 based, and the panelCount isnt so we need to increase */) != panelCount ? (panelNumber + 1) : 0));
};

function start(){
	var slideShow = setInterval(slide,6000);
}

function InitPage()
{
	sp = new Spry.Widget.SlidingPanels("ticker");
	Spry.$$("#link1, #link4, #link6").addEventListener("click", function(){sp.showPanel('item2');return false; }, false);
	Spry.$$("#link2, #link5").addEventListener("click", function(){sp.showPanel('item1');return false; }, false);
	Spry.$$("#link3, #link7").addEventListener("click", function(){sp.showPanel('item3');return false; }, false);
}
Spry.Utils.addLoadListener(InitPage);

