function ScrollToElement(theElement){

	var selectedPosX = 0;
	var selectedPosY = 0;
              
	while(theElement != null){
		selectedPosX += theElement.offsetLeft;
		selectedPosY += theElement.offsetTop;
		theElement = theElement.offsetParent;
	}
                        		      
	window.scrollTo(selectedPosX,selectedPosY);

}

function getData(){

	setInterval("dataCheck('newsTable')", 25000);
	
}

function dataCheck(list){	
	

	var xmlhttp = false;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}


	randParameter=parseInt(Math.random()*99999999);  
	var serverPage = "list_return_data.php?" + "list=" + list + "&rand=" + randParameter;
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		
			ajaxReturn = xmlhttp.responseText;
			ajaxReturn = unescape(ajaxReturn);
			ajaxReturn = ajaxReturn.replace(/1plus1/gi,"+");
			
			if (ajaxReturn == ""){
			
				
			} else {
				var ajaxReturn = ajaxReturn.split("_z_z_");
				
				var list_date = ajaxReturn[0];
				var list_text = ajaxReturn[1];
				
				
				
				// -------- SPACER
				
				var list_table = document.getElementById(list + "_table").insertRow(0);
				
				var list_date_cell = list_table.insertCell(0);
				var list_text_cell = list_table.insertCell(1);
				
				list_date_cell.innerHTML = "";
				list_date_cell.className = list + "_spacer";
				
				list_text_cell.innerHTML = "";
				list_text_cell.className = list + "_spacer";
				
				
				
				// -------- CONTENT

				
				var list_table = document.getElementById(list + "_table").insertRow(0);
				
				var list_date_cell = list_table.insertCell(0);
				var list_text_cell = list_table.insertCell(1);
				
				list_date_cell.innerHTML = list_date;
				list_date_cell.className = list + "_dateContainer";
				
				list_text_cell.innerHTML = list_text;
				list_text_cell.className = list + "_textContainer";
				
				ScrollToElement(document.getElementById("scroll_to_this"));
				
				// -------- BLINK
					blink_cell(list + "_table");
					
					
			
			}
			
			

		}
	}
	xmlhttp.send(null);
	

}



function blink_cell(table){

	var table = table;

	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffd800'",100);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffdb14'",120);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffdd21'",140);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffe033'",160);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffe346'",180);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffe556'",200);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffe765'",220);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffea77'",240);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#ffed8b'",7260);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fff09d'",7280);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fff3b1'",7300);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fff6c4'",7320);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fff7cd'",7340);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fff8d3'",7360);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fffadc'",7380);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fffbe3'",7400);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fffbe8'",7420);
	setTimeout("document.getElementById('" + table + "').rows[0].style.backgroundColor='#fffcec'",7440);
	setTimeout("document.getElementById('" + table + "').rows[0].style.background='transparent'",7460);	
}
