window.onload = initPage;

function initPage() 
{
	var fields = document.getElementById("main").getElementsByTagName("input");
	
	for (var i=0; i<(fields.length - 2); i++)
	{
	   var currentField = fields[i];
	   
	   currentField.onfocus = checkField;	
	}
}

function checkField()
{

/*
if (document.getElementById("fielddescription") == null);
	{
		var node = document.getElementById("main");
		var createNode = document.createElement("div");
			createNode.id="fielddescription";
		    node.appendChild(createNode);
			
			//alert(createNode.id);
			
	}  */
	
	//alert(this.name);
	
	var node = document.getElementById("fielddescription");
	//alert(node);
	if (this.name == "name")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("Your name must be between two and twenty five characters long and can contain letters, apostrophies, hyphens, and underscores. "));
	
	//alert("Node name");
	//document.getElementById("fielddescription").firstChild.nodeValue= "Name decription";	
	
	}
	
	if (this.name == "address")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("Your address can be up to 80 characters long and can include letters, spaces, apostrophies, hyphens, and periods."));
		
	}
	
	if (this.name == "contact")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("If you like, allow us to contact you. It will help us with our work."));	
	
	}
	
	if (this.name == "phone")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("Enter your phone number like: 218-555-5555"));
	
	}
	
	
	if (this.name == "email")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("Your email must be in the form of:  PaleMale@NewYork.com "));
			
	}
	
	if (this.name == "species")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("The species can contain hyphens, apostrophies, spaces, and can be up to 50 characters long."));
			
	}
	
	if (this.name == "location")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("Your location can be from 10 to 250 characters."));
			
	}
	
	if (this.name == "description")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("Your description can be from 10 to 250 characters."));
			
	}
	
	if (this.name == "dates")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("Your dates can be from 10 to 250 characters."));
			
	}
	
	if (this.name == "comments")
	{		
		while (node.firstChild)
			node.removeChild(node.firstChild);
		node.appendChild(document.createTextNode("Your comments can be up to 250 characters."));
			
	}
	
	

}