// JavaScript Document

function countStories(idName)
{
	
	this.numberOfStories = 0;
	this.StoryNumber = new Array();
	
	this.StoryNumber.length = 0;
	
	for (var x=0; x<10; x++)
	{
		try // try to do the functionality within the Try statement succesfuly
		{
			//alert (x);
			//alert (window.document.getElementById(idName + x).nodeName);
			if (window.document.getElementById(idName + x).nodeName == 'DIV')
			{
				//alert (x);
				this.StoryNumber[this.numberOfStories] = x;
				this.numberOfStories ++;
			}
			
		} 
		catch(err) // Chach the error if ther was one and store the error message in (err)
		{ 
			// Run this only if the Try functionality fails to run correctly
			//alert ("Story number " + x + " does not exist.");
		}
	}
	
	
	/*
	for (var y=0; y<this.numberOfStories; y++)
	{
		alert("Story " + this.StoryNumber[y] + " exists.");
	}
	*/
	
	//alert(this.StoryNumber);
}


/*
DOM notes

document.getElementsByTagName('head').item(0).appendChild(script);
document.getElementById('idRefresh')


	x.innerHTML - the inner text value of x (a HTML element)
    x.nodeName - the name of x
    x.nodeValue - the value of x
    x.parentNode - the parent node of x
    x.childNodes - the child nodes of x
    x.attributes - the attributes nodes of x


    x.getElementByID(id) - get the element with a specified id
    x.getElementsByTagName(name) - get all elements with a specified tag name
    x.appendChild(node) - insert a child node to x
    x.removeChild(node) - remove a child node from x



alert(window.document.getElementById('idNewsWrapper').childNodes[0].length);


*/