var add;
function addEntry(strURL, strAdd){
	add = strAdd;
	
	// create the xmlHttp object
	xmlHttp = GetXmlHttpObject();
	
	// check to see if an object was returned
	if(xmlHttp == null){
		alert("This browser does not support AJAX");
		return false;
	}
	
	// set the ready state handler
	xmlHttp.onreadystatechange = addEntryStateChange;
	
	// use the url
	xmlHttp.open("GET", strURL, true);
	xmlHttp.send(null);
}

function addEntryStateChange(){
	if(xmlHttp.readyState == 4){
		// check to make sure there wasn't an error
		if(xmlHttp.responseText.indexOf("Error")<0){
			var objAdd = document.getElementById(add);
			// remove the object
			objAdd.innerHTML += xmlHttp.responseText;
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

var objRowTemp;
function archiveNews(objRow, intID){
	objRowTemp = objRow;
	
	// create the xmlHttp object
	xmlHttp = GetXmlHttpObject();
	
	// check to see if an object was returned
	if(xmlHttp == null){
		alert("This browser does not support AJAX");
		return false;
	}
	
	// set the ready state handler
	xmlHttp.onreadystatechange = archiveNewsStateChange;
	
	// create the url
	var strURL = "site.php?action=archiveNewsAjax&newsID=" + intID;
	
	// use the url
	xmlHttp.open("GET", strURL, true);
	xmlHttp.send(null);
	
	return false;
}

function archiveNewsStateChange(){
	if(xmlHttp.readyState == 4){
		document.getElementById('newsTable').deleteRow(objRowTemp.parentNode.parentNode.rowIndex);
	}
}

var remove;
function removeEntry(strURL, strRemove){
	
	// check to make sure the user wants to delete this
	if(confirm('Are you sure you want to remove this entry?') == false){
		return;
	}

	remove = strRemove;
	
	// create the xmlHttp object
	xmlHttp = GetXmlHttpObject();
	
	// check to see if an object was returned
	if(xmlHttp == null){
		alert("This browser does not support AJAX");
		return false;
	}
	
	// set the ready state handler
	xmlHttp.onreadystatechange = removeEntryStateChange;
	
	// use the url
	xmlHttp.open("GET", strURL, true);
	xmlHttp.send(null);
}

function removeEntryStateChange(){
	if(xmlHttp.readyState == 4){
		// check to make sure there wasn't an error
		if(xmlHttp.responseText.indexOf("Error")<0){
			// get the object to remove
			var objRemove = document.getElementById(remove);
			
			// remove the object
			objRemove.parentNode.removeChild(objRemove);
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

function siteUpdateMode(strMode){
	// update the div based on the mode
	xmlHttp = GetXmlHttpObject();
	
	// check to see if the object has been returned
	if(xmlHttp == null){
		document.getElementById("siteModePanel").innerHTML = "This browser doesn't support AJAX";
		return;
	}
	
	// set the ready state change 
	xmlHttp.onreadystatechange = siteUpdateModeStateChange;
	
	// create the url
	var strURL = "site.php?action=" + strMode;
	
	// send the query
	xmlHttp.open("GET", strURL, true);
	xmlHttp.send(null);
	
}

function siteUpdateModeStateChange(){
	if(xmlHttp.readyState == 4){
		document.getElementById("siteModePanel").innerHTML = xmlHttp.responseText;
	}
}

function unarchiveNews(objRow, intID){
	objRowTemp = objRow;
	
	// create the xmlHttp object
	xmlHttp = GetXmlHttpObject();
	
	// check to see if an object was returned
	if(xmlHttp == null){
		alert("This browser does not support AJAX");
		return false;
	}
	
	// set the ready state handler
	xmlHttp.onreadystatechange = unarchiveNewsStateChange;
	
	// create the url
	var strURL = "site.php?action=unarchiveNewsAjax&newsID=" + intID;
	
	// use the url
	xmlHttp.open("GET", strURL, true);
	xmlHttp.send(null);
	
	return false;
}

function unarchiveNewsStateChange(){
	if(xmlHttp.readyState == 4){
		document.getElementById('newsTable').deleteRow(objRowTemp.parentNode.parentNode.rowIndex);
	}
}
