function scroll2top(){
  poz-=1;
  div.style.top=poz+"px";
  if(poz<-(div.offsetHeight)){
	   stop_s();
	   start();
  }/*else if(poz==0){
       delay();
  }*/
}

function initScroll(){
    getNews(); 
	div=document.getElementById("news_sc");
	curPoz=0;
	first_time=1;
	xmlHttp2;
	all_items='';
	div.style.position="relative";	
    vf_start();
}
function vf_start(){
  	try{
		if(items) {start();}
	}catch(err){
		setTimeout("vf_start()",1000);
	}
}

function start(){
	div.style.visibility="hidden";
	if(first_time==1){
	  for(var it=0;it<items.length;it++){
		 all_items=all_items+items[it]+"<p align='center'>&mdash;&mdash;&mdash;<p>";
	  }
	  first_time=0;
	}
	div.innerHTML=all_items;
	speed=30;
	sleep=5000;
	//if(curPoz>=items.length) curPoz=0;
	/*if(div.offsetHeight>=200)
	   poz=div.offsetHeight;
	   else poz=200;*/
	   poz=200;
	div.style.top=poz+"px";
	div.style.visibility="visible";
	int=setInterval(scroll2top,speed);
}
function stop_s(){
	 clearInterval(int);
 }
 
function reStart(){
  	int=setInterval(scroll2top,speed);
}

/*function reStartAdd(){
  	int=setInterval(scroll2top,speed);
}

function delay(){
	stop_s();
	tOut=setTimeout("reStartAdd()",sleep);
}*/




function getNews()
{ 
xmlHttp2=GetXmlHttpObject2();
if (xmlHttp2==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="getNews.php";
xmlHttp2.onreadystatechange=stateChanged2;
xmlHttp2.open("GET",url,true);
xmlHttp2.send(null);
}


function stateChanged2() 
{ 
if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
 { 
      items_str=xmlHttp2.responseText;
	  items=items_str.split('<@>');
 } 


}function GetXmlHttpObject2()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


window.onload=initScroll;