/**
 * Create a cookie with the products name to get
 *
 * type = the type of TOC to display
 *		chapters or unitsSections
 *
 * id = the id of the book from the DB
 * 	Book's ID:
 * 	1 = Algebra I
 * 	2 = Algebra II
 *	3 = preAlgebra
 * 	? = Geometry
 */
function setTOC(type, id){
	value = type + "," + id;
	createCookie("homeschoolTOC", value);
}

function displayTOC(toc){
	//path = "http://homeschool.dhx2.gotdns.com/";
	//path = "http://" + ((window.location.hostname == "marias") ? "marias/AlgebraHW/homeschool" : window.location.hostname) + "/";
	path = "http://" + ((window.location.hostname == "marias") ? "marias/AlgebraHW/homeschool" : "homeschool.kineticbooks.com") + "/";
//alert("Path: " + path);
	//document.getElementById('loadingImg').visible = true;
	
	//read the cookie
	//cookieValue = readCookie("homeschoolTOC").split(",");
	
	value = toc.split(",");
//alert(toc);
	switch(value[0]){
		case "1":
			type = "chapters";
			break
		case "2":
			type = "unitsSections";
			break
	}
//alert("type = " + type + " value = " + value[1]);
	xmlhttp = getXMLHttpRequestObj();

	xmlhttp.onreadystatechange=function(){
//alert("xmlhttp ready state: " + xmlhttp.readyState + " ---- " + "xmlhttp status: " + xmlhttp.status);
//alert("xmlhttp status: " + xmlhttp.status);
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
			document.getElementById('loadingImg').visible = false;
			e = (document.getElementById('toc')) ? "toc" : "tocKbooks";
			//if(document.getElementById('toc'))
			//	e = "toc";
			//else
			//	e = "tocKbooks";
//alert("e: " + e);
			document.getElementById(e).innerHTML = xmlhttp.responseText;
		}
	}

	xmlhttp.open("POST", path + "bookTOCClass.php", true);
//alert("path to open: " + path + "bookTOCClass.php");
	// need this line of code bc using POST to send data to server
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	//xmlhttp.send("type=" + cookieValue[0] + "&id=" + cookieValue[1]);
	xmlhttp.send("type=" + type + "&id=" + value[1]);
}
