// render properties on page from XML file

var xmlUrl = "xml/secrets.xml";

//This function spits the secrets for a specified category for use on the homepage
function renderSecretsForHomepageByCategoryName(categoryName)
{
	var xmlDoc=null;
	if (window.ActiveXObject)
	{
	// code for IE
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	}
	else if (document.implementation && document.implementation.createDocument)
	{
		// code for Mozilla, Firefox, Opera, etc.
		xmlDoc=document.implementation.createDocument("","",null);
	}
	else
	{
		alert('Your browser cannot handle this script');
	}
	if (xmlDoc!=null) 
	{		
		xmlDoc.async=false;
		xmlDoc.load(xmlUrl);
		var x=xmlDoc.getElementsByTagName("SECRET");
				
		var	displayCount = x.length;
		var pageName = "";
		
		for (var i=0;i<displayCount;i++)
		{ 
			
			if (x[i].getElementsByTagName("CATEGORY")[0].childNodes[0].nodeValue == categoryName)
			{
				
				switch (categoryName)
				{
					case "A Relationship for Success":
						pageName = "aRelationshipForSuccess.html";
						break;
						
					case "A Community of Learning":
						pageName = "aCommunityOfLearning.html";
						break;
						
					case "Techniques that Work":	
						pageName = "teachingTechniquesThatWork.html";
						break;
						
					case "Testing to Improve Teaching":
						pageName = "testingToImporoveTeaching.html";
						break;
				}	
				
				document.write("<li>");
				document.write("	<div class='secretNum'>Secret " + x[i].getElementsByTagName("ID")[0].childNodes[0].nodeValue + ":</div>");
				document.write("	<div class='secretTitle'>");
				document.write("		<a href='" + pageName + "?s=" + x[i].getElementsByTagName("ID")[0].childNodes[0].nodeValue + "'>");
				document.write(				x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
				document.write("		</a>");
				document.write("	</div>");
				document.write("	<div style='clear:both'></div>");
				document.write("</li>");
			}
		}
	}
}

//This function spits the secrets for a specified category
function renderSecretsByCategoryName(categoryName)
{
	var xmlDoc=null;
	if (window.ActiveXObject)
	{
	// code for IE
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	}
	else if (document.implementation && document.implementation.createDocument)
	{
		// code for Mozilla, Firefox, Opera, etc.
		xmlDoc=document.implementation.createDocument("","",null);
	}
	else
	{
		alert('Your browser cannot handle this script');
	}
	if (xmlDoc!=null) 
	{		
		xmlDoc.async=false;
		xmlDoc.load(xmlUrl);
		var x=xmlDoc.getElementsByTagName("SECRET");
				
		var	displayCount = x.length;	
		var secretId = 0;
		
		document.write("<ul id='ulSecrets' class='clearfix'>");
		for (var i=0;i<displayCount;i++)
		{ 		
			if (x[i].getElementsByTagName("CATEGORY")[0].childNodes[0].nodeValue == categoryName)
			{	
				secretId = x[i].getElementsByTagName("ID")[0].childNodes[0].nodeValue;
				document.write("<li><a href='javascript:void(0);' id='linkSecret" + secretId + "' onclick='showSecret(" + secretId + ");'>Secret " + secretId + "</a></li>");
			}				
		}
		
		var pageName = "";
		switch (categoryName)
		{
			case "A Relationship for Success":
				pageName = "aRelationshipForSuccess_research.html";
				break;
				
			case "A Community of Learning":
				pageName = "aCommunityOfLearning_research.html";
				break;
				
			case "Techniques that Work":	
				pageName = "teachingTechniquesThatWork_research.html";
				break;
			
			case "Testing to Improve Teaching":
				pageName = "testingToImporoveTeaching.html";
				break;
		}	
		document.write("	<li><a href='javascript:void(0);' id='linkSecret" + "Research" + "' onclick='showSecret(\"Research\");'>Research</a></li>");
		document.write("</ul>");		
		document.write("<div id='welcome'>");                    	
                    
		switch (categoryName)
		{
			case "A Relationship for Success":
				document.write("<p>Success in the classroom starts with the relationship between the teacher and the student. Some characterize it as a deep bond born out of mutual respect. Others describe it as a powerful conviction in the potential of every child to learn. Still others refer to it as the ability to personally connect with students or, more simply, the rapport teachers have with the children in their classes.  For outstanding teachers, building the relationship with the children may require engaging their families as well.</p>"); 
				document.write("<p>The winning teachers, by an overwhelming majority, believe the relationship with their students is the foundation for learning. Moreover, they believe forging a genuine bond with students enables teachers to have a powerful impact on students. Alliances with families strengthen the student-teacher relationships, which then amplifies impact on student learning. Five secrets capture the advice of the teachers.</p>");
				break;
				
			case "A Community of Learning":
				document.write("<p>Successful teachers create a community of learning and an environment for achievement. These teachers establish a classroom that is safe for students, both physically and academically. In these secure surroundings, students are able to take the risks necessary for success. Importantly, silence is not a characteristic of these classrooms. In fact, these classrooms are buzzing and bustling with activity.</p>");  
				document.write("<p>The award winning teachers believe the atmosphere within the classroom must start with the teacher. Three secrets capture the general advice from the teachers.</p>");
				break;
				
			case "Techniques that Work":			
				document.write("<p>Successful educators are the personification of an ideal learner. They are self-motivated. The teachers provide structured learning without being rigid. They are constantly seeking new and better ways to achieve success. They are relentless problem solvers. They take a realistic and practical approach toward a long-term goal of learning - and the love of it - for every student.</p>");
				document.write("<p>Although they taught very different students, the winning teachers shared many common approaches and techniques. Here are their secrets to success.</p>"); 
				break;
			
			case "Testing to Improve Teaching":
				document.write("<p>Effective teachers embrace assessment as a critical instructional tool. These teachers collect and seamlessly integrate data into their day-to-day teaching.  The data helps them decide what to teach and how to adapt instruction for individuals and groups of students.  It also gives teachers the empirical evidence to evaluate themselves and determine what is working - and what is not - so they can improve.  A perpetual cycle of teach-assess-teach-assess allows both teachers and students to build on their strengths and overcome their weaknesses.</p> ");
				break;
		}	
		
		document.write("</div>");
		document.write("<div id='divSecrets'>");
		
		for (var i=0;i<displayCount;i++)
		{ 			
			if (x[i].getElementsByTagName("CATEGORY")[0].childNodes[0].nodeValue == categoryName)
			{
				secretId = x[i].getElementsByTagName("ID")[0].childNodes[0].nodeValue;
				document.write("<div id='secret" + secretId + "' style='display:none'>");
				document.write("   <h3>Secret #" + secretId + ": " + x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "</h3>");
				document.write(    x[i].getElementsByTagName("DESCRIPTION")[0].childNodes[0].nodeValue);
				document.write("</div>");				
			}				
		}
		
		document.write("</div>");
		
	}
}

function showSecret(secretNumber)
{
	resetAllSecrets();
	if (secretNumber)
	{
		var mySpan = document.getElementById("secretNumber");
		var myLink = document.getElementById("linkSecret" + secretNumber);
		var myDiv = document.getElementById("secret" + secretNumber);
		myLink.className = "current";
		myDiv.style.display = "block";		
		mySpan.innerHTML = "Secret " + secretNumber;
	}
	else 
	{
		document.getElementById("welcome").style.display = "block";
	}
}

function resetAllSecrets()
{
	document.getElementById("welcome").style.display = "none";
	
	var x = document.getElementById("ulSecrets").getElementsByTagName("a");
	var y = document.getElementById("divSecrets").getElementsByTagName("div");
	
	for(var i=0;i<x.length;i++)
	{    	
		x[i].className = "";
	}
	
	for(var i=0;i<y.length;i++)
	{
		y[i].style.display = "none";
	}	
}
