//window.onfleXcrollRun=function(){
//fleXnewsTicker('vendegkonyv-scroll',1,50,0.3,false,false,false);
//}

// syntax: autoscroll-div-id, px/frame, ms/scroll, accel, startwait how long to wait at the beginning, endwait, waitonce

//waitOnce: only wait at the start of the scroll for once when first scroll starts
//             accepted values: true||false
//Removable comments-end-

function fleXnewsTicker(targetDivId,stepsPerFrame,frameLength,acceleratioN,startWait,endWait,waitOnce) {


	if(typeof(fleXenv)=="undefined") return false;
	var fDiv=document.getElementById(targetDivId),sPos,actSteps=0,tData=[];
	if (fDiv==null) return false;
	if (!fDiv.fleXcroll) fleXenv.fleXcrollMain(fDiv);

	fleXenv.addTrggr(fDiv,'mouseover', function(){tData.tickerHover=true;});
	fleXenv.addTrggr(fDiv,'mouseout', function(){tData.tickerHover=false;startScroll();});

	initScroll();

	function initScroll(reStart){
	if(reStart&&!tData.tickerHover) sPos=fDiv.fleXcroll.setScrollPos(false,0);
	if(startWait&&((reStart&&!waitOnce)||!reStart))  {
		if(tData.restartTimeout) window.clearTimeout(tData.restartTimeout);
		tData.restartTimeout=window.setTimeout(function(){startScroll(reStart)},startWait)
		}
	else startScroll();
	};
	
	function startScroll(){
	if(tData.tickInterval) return;
	tData.tickInterval=window.setInterval(function(){
		if(tData.tickerHover&&actSteps>0) actSteps=Math.max(0,actSteps-acceleratioN);
		if(actSteps<stepsPerFrame&&!tData.tickerHover) actSteps=Math.min(stepsPerFrame,actSteps+acceleratioN);
		sPos=fDiv.fleXcroll.scrollContent(false,actSteps+'px');
			if(sPos[1][0]==sPos[1][1]) {if(endWait) tPause(endWait); else tPause(frameLength);}
			else if(tData.startTimeout) window.clearTimeout(tData.startTimeout);
		if(actSteps===0) {window.clearTimeout(tData.tickInterval);tData.tickInterval=false;};
	}
	,frameLength);
	};
	
	var tPause=function(waitMsec){
			if(tData.tickInterval) window.clearTimeout(tData.tickInterval);tData.tickInterval=false;
			if(tData.startTimeout) window.clearTimeout(tData.startTimeout);
			tData.startTimeout=window.setTimeout(function(){initScroll(true)},waitMsec);
		};
};

