// JavaScript Document

function getInnerText (node) {
if (typeof node.textContent != 'undefined') {
return node.textContent;
}
else if (typeof node.innerText != 'undefined') {
return node.innerText;
}
else if (typeof node.text != 'undefined') {
return node.text;
}
else {
switch (node.nodeType) {
case 3:
case 4:
return node.nodeValue;
break;
case 1:
case 11:
var innerText = '';
for (var i = 0; i < node.childNodes.length; i++) {
innerText += getInnerText(node.childNodes[i]);
}
return innerText;
break;
default:
return '';
}
}
}



function cleanWhitespace(node) {
var notWhitespace = /\S/
 // alert("in cleanWhitespcae");
  for (var x = 0; x < node.childNodes.length; x++) {
    var childNode = node.childNodes[x]
    if ((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))) {
// that is, if it's a whitespace text node
      node.removeChild(node.childNodes[x])
      x--
    }
    if (childNode.nodeType == 1) {
// elements can have text child nodes of their own
      cleanWhitespace(childNode)
    }
  }
}

//document.addEventListener("load", function() {
//  cleanWhitespace(document)
//}, true)


 var xmlDoc;
 
function load_xml()
{
  if (document.implementation && document.implementation.createDocument)
		{
        // MOZILLA
		xmlDoc = document.implementation.createDocument("", "",null);
		xmlDoc.load("news.xml");		
		xmlDoc.onload= readXML;
		}
	else
		{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.load("news.xml");		
		fill_xmldata(xmlDoc);
		}
}


function fill_xmldata(xmlDoc)
{

     var mytd = document.getElementById("newstable");
     var tbl     = document.createElement("table");
     var tblBody = document.createElement("tbody");     
	 var xmlDoc;
    
       
     x = xmlDoc.getElementsByTagName("date");
	 y = xmlDoc.getElementsByTagName("news");
	 z = xmlDoc.getElementsByTagName("nlink");

	 var srcHolder =  document.getElementById("newstable");
	 var srcTable = document.createElement("table");
	 srcTable.width = "335";
	 srcHolder.appendChild(srcTable);
	 
	 var tmpRow = null;
	 var tmpCell = null; 
	  
    
		for (i=0;i<8;i++)
		{
		    var mydate = x[i];
			var mynews = y[i];
			var mylink = z[i];
			
		    tmpRow = srcTable.insertRow();
			tmpCell = tmpRow.insertCell();
            tmpCell.width = "28";
            tmpCell.vAlign = "top";
			tmpCell.innerHTML = "<img src=" + "images/drop_folder.gif" + " width=" + "23" + " height=" + "23" + " />" ;
			tmpCell = null;

 			 tmpCell = tmpRow.insertCell();
			 tmpCell.vAlign = "top";
			 tmpCell.setAttribute("class", "footer");   
			 
			 tmpCell.innerHTML = "<span class=" + "footer" + ">" + mydate.childNodes[0].nodeValue +"</span>";
			 tmpCell.innerHTML = tmpCell.innerText + "<br /><a href=" + mylink.childNodes[0].nodeValue + " class=" + "bodytxt" + ">" + mynews.childNodes[0].nodeValue + "</a>" ;
			 tmpCell = null;		

			tmpRow = null;
		}
	 

}


function readXML()
 {
	
    
	 x = xmlDoc.getElementsByTagName("date");
	 y = xmlDoc.getElementsByTagName("news");
	 z = xmlDoc.getElementsByTagName("nlink");
	 
	
	 var srcHolder =  document.getElementById("newstable");
	 var srcTable = document.createElement("table");
	 srcTable.width = "335";
	 srcHolder.appendChild(srcTable);
	 
	 var tmpRow = null;
	 var tmpCell = null; 
	 
	for (i=0;i<8;i++)
	{
			var mydate = x[i];
			var mynews = y[i];
			var mylink = z[i];
			
		    tmpRow = srcTable.insertRow(-1);
			tmpCell = tmpRow.insertCell(-1);
            tmpCell.width = "28";
            tmpCell.vAlign = "top";
			tmpCell.innerHTML = "<img src=" + "images/drop_folder.gif" + " width=" + "23" + " height=" + "23" + " />" ;
			tmpCell = null;
			
			
			 tmpCell = tmpRow.insertCell(-1);
			 tmpCell.vAlign = "top";
			 tmpCell.setAttribute("class", "footer");   
			 
			 tmpCell.innerHTML = "<span class=" + "footer" + ">" + x[i].textContent +"</span>";
			 tmpCell.innerHTML = tmpCell.innerHTML + "<br /><a href=" + mylink.textContent + " class=" + "bodytxt" + ">" + mynews.textContent + "</a>" ;
			 tmpCell = null;				
			tmpRow = null;
			
	 
	} 

 } 	