if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();} // code for IE7+, Firefox, Chrome, Opera, Safari
else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}// code for IE6, IE5
xmlhttp.open("GET","locations.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 
x=xmlDoc.getElementsByTagName("LOC");
i=1;
toggle="";

function nav(id, i) {
	resetlinks(id);
	if (id=="FTW" || id=="IND" || id=="INS" || id=="KKM" || id=="top1" || id=="top2" || id=="main") {
		getxml(i);
		if (id.substring(0, 3)=="top") {
			active=id.substring(0, 3);
			$("#map").hide();
		}
		else {
			active=id;
			expandprogram();
			$("#span3").show();
			$("#map").show();
		}
		if (id=="IND") {
			$("#span1").show();
			$("#news").show();
		}
		else {
			$("#span1").hide();
			$("#news").hide();
		}
		$("#info").show();
		$("#info2").hide();
		$("#flash2").load('c' + active + '.html');
		document.getElementById("flash2").innerHTML=flash2;
		setbottom();
	}
	else if (id=="map") {
		$("#info").show();
		$("#info2").hide();
		flash2='<iframe width="416" height="313" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=' + mapimbed + '"></iframe>';
		document.getElementById("flash2").innerHTML=flash2;
	}	
	else if (id=="news") {
		$("#flash2").load("newsletters.html");
		$("#info").show();
		$("#info2").hide();
		getxml(1); //presently only IND is submitting newsletters
		setbottom(i);
	}
	else if (id=="curriculum" || id=="ourmission" || id=="ourname" || id=="owner" || id=="2015-05" || id=="2015-04" || id=="2015-03" || id=="2015-02" || id=="2015-01" || id=="2014-12" || id=="2014-11") {
		if (active=="top" || active=="main") {
			name="";
		}
		expandprogram();
		document.getElementById("info2").innerHTML = '<iframe src="../../apps/pdfjs/web/viewer.html?file=../../../files/' + id + '.pdf" width="100%" height="442"></iframe>';
		$("#info").hide();
		$("#info2").show();
	}
}
function expandprogram() {
	$("#left").hide();
	$("#ads").hide();
	document.getElementById("main").style.width = "720px";
	document.getElementById("bottom").style.width = "720px";
	if (name!="") {
		document.getElementById("program").innerHTML = name + "&nbsp- Program Details";
	}
	else {
		document.getElementById("program").innerHTML = "Program Details";
	}
}
function setbottom(setbtm) {
	if (setbtm==100) {direml="info@findingmenow.com"; diremltxt="Info@FindingMeNow.com";}
	bottom='<div class="link"><a href="https://www.google.com/maps/place/' + maplink + '" target="_blank"><div align="center" class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><font class="ws11"><span itemprop="streetAddress">' + address + '</span><br><span itemprop="addressLocality">' + city + '</span>, <span itemprop="addressRegion">' + st + '</span> <span itemprop="postalCode">' + zip + '</span></font></div></a></div><div class="linkline" padding="25px"><div class="link"><a class="ws11" href="tel:' + ph + '">Ph: ' + ph + '</a></div><div class="link">Fax: ' + fax + '</div></div><div class="link"><a href="mailto:' + direml + '" target="_blank"><div align="center"><font class="ws11">' + diremltxt + '</font></div></a></div>';
	document.getElementById("bottom").innerHTML=bottom;
}
function resetlinks(id) {
	var links = document.getElementsByClassName("link");
	for (j=0; j<links.length; j++) {links[j].style.backgroundColor = "";}
	document.getElementById(id).style.backgroundColor = "#3e3e50";
}
function getxml(i) {
	name=(x[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue);
	mapimbed=(x[i].getElementsByTagName("MAPIMBED")[0].childNodes[0].nodeValue);
	maplink=(x[i].getElementsByTagName("MAPLINK")[0].childNodes[0].nodeValue);
	address=(x[i].getElementsByTagName("ADDRESS")[0].childNodes[0].nodeValue);
	city=(x[i].getElementsByTagName("CITY")[0].childNodes[0].nodeValue);
	st=(x[i].getElementsByTagName("ST")[0].childNodes[0].nodeValue);
	zip=(x[i].getElementsByTagName("ZIP")[0].childNodes[0].nodeValue);
	ph=(x[i].getElementsByTagName("PH")[0].childNodes[0].nodeValue);
	fax=(x[i].getElementsByTagName("FAX")[0].childNodes[0].nodeValue);
	direml=(x[i].getElementsByTagName("DIREML")[0].childNodes[0].nodeValue);
	diremltxt=(x[i].getElementsByTagName("DIREMLTXT")[0].childNodes[0].nodeValue);
}
function loadcss(css) {
	if (toggle=="new") {
		css="indexStyle.css";
		logo="images/logo.jpg";
		toggle="";
		document.getElementById("cf4a").setAttribute("style", "border-color:#c0c0c0;");
	} else{toggle="new";logo="images/logo.png";document.getElementById("cf4a").setAttribute("style", "border-color:#3e3e50;");}
	document.getElementById("pagestyle").setAttribute("href", css);
	document.getElementById("logo").setAttribute("src", logo);
	
}