// -------------NEWS_TABLE.JS TABLE-------------------

newsHold=new Array();
var holder;
var NVP;

function buildNewsHoldArray(){
	
	holder=document.getElementById("NEWS") //get subelements in main div
	NVP = holder.getElementsByTagName("list_item");
	
	
	for(n=0;n<NVP.length;n++) {

		newsHold[newsHold.length]=NVP[n].parentNode.innerHTML //extract html and push to newsHold
		
				}
	
		document.getElementById("NEWS").innerHTML="" // clear main div innerHTML
		
		startNews()
}	
	
var NV,s
var newsCurrent=0	
var roll_over = 0
var NV_height, NV_width	
function startNews(){

	
	NV=document.getElementById("NEWS")
	NV_height = NV.offsetHeight;
	NV_width = NV.offsetWidth;
	
	NV.onmouseover = function() {
		roll_over = 1
	}	
	NV.onmouseout = function() {
		roll_over = 0
	}		
		
	if(NV.innerHTML.length<5){
		tmp = buildNewsBlock("&nbsp;&nbsp;&nbsp; ")
		tmp.style.height= NV_height + "px"
		NV.appendChild(buildNewsBlock(tmp))
	}
	if(newsCurrent < newsHold.length){
		tmp =buildNewsBlock(newsHold[newsCurrent])
		tmp.style.height= NV_height + "px"
		NV.appendChild(tmp)
		newsCurrent++
		
		
	}else{
		newsCurrent=1
		tmp =buildNewsBlock(newsHold[0])
		tmp.style.height= NV_height + "px"
		NV.appendChild(tmp)
		
	}
	
	scrollNext()
	
}

scrollNext =function(){
	
	clearTimeout(s)
		ObLast=NV.childNodes[NV.childNodes.length-1]
		
		if(NV.scrollTop < NV_height){
			if (roll_over == 0){
			NV.scrollTop += 2
			}
			s=setTimeout('scrollNext()', 20)
			
		}else{
			
			ob2Remove = NV.childNodes[0]
			NV.removeChild(ob2Remove)
			NV.scrollTop= 0
			s=setTimeout('startNews()',3000)
		
	}
}

buildNewsBlock = function(p){
	tmp=document.createElement("DIV")
	tmp.className="newsBlock"
	tmp.style.height = NV_height+"px";
	tmp.style.width = NV_width+"px";
	tmp.innerHTML=p


	return tmp
}
onLoadArr[onLoadArr.length] = buildNewsHoldArray
//buildNewsHoldArray();

