//Initial Functions

window.addEvent('domready', function(){
    writeAnnouncement();
});

//Subnavigation

function showSubNav(subnavname) {
	document.getElementById("subnav_welcome").className = "";
	document.getElementById("subnav_welcome").className = "invisible";
	document.getElementById("subnav_info").className = "";
	document.getElementById("subnav_info").className = "invisible";
	document.getElementById("subnav_gui").className = "";
	document.getElementById("subnav_gui").className = "invisible";
	document.getElementById("subnav_pro").className = "";
	document.getElementById("subnav_pro").className = "invisible";
	document.getElementById("subnav_ath").className = "";
	document.getElementById("subnav_ath").className = "invisible";
	document.getElementById("subnav_sl").className = "";
	document.getElementById("subnav_sl").className = "invisible";
	document.getElementById(subnavname).className = "";
	document.getElementById(subnavname).className = "visible";
}

//Announcement

function writeAnnouncement() {
	
var xhttp = null;
var xmlAnn = null;

if (window.XMLHttpRequest) {
  xhttp = new XMLHttpRequest();
}
else {
  xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xhttp.open("GET","http://phsfalcons.org/xml/announcement.xml",false);
xhttp.send("");
xmlAnn = xhttp.responseXML;

if (xmlAnn!=null) {
    var ann=xmlAnn.getElementsByTagName("item");
	var annString="";
	if (ann.length < 5) {
		for (j=0;j<ann.length;j++) {
			annString += "<div class=\"item\">";
			annString += "<div class=\"item_title\">";
			annString += ann[j].getElementsByTagName("title")[0].childNodes[0].nodeValue;
			annString += "</div>";
			annString += "<div class=\"item_content\">";
			annString += ann[j].getElementsByTagName("content")[0].childNodes[0].nodeValue;
			annString += "</div>";
			annString += "</div>";
		}
	} else {
		for (j=0;j<5;j++) {
			annString += "<div class=\"item\">";
			annString += "<div class=\"item_title\">";
			annString += ann[j].getElementsByTagName("title")[0].childNodes[0].nodeValue;
			annString += "</div>";
			annString += "<div class=\"item_content\">";
			annString += ann[j].getElementsByTagName("content")[0].childNodes[0].nodeValue;
			annString += "</div>";
			annString += "</div>";
		}
	}
    
	document.getElementById("announ_main").innerHTML = annString;
}

}

