var reqXML;
var CSM = "default";
var targetContainer;
var results;
// this makes the request object that is used to fetch the data
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
// This function loads the URL passed and then writes the information
// to the container specified. The Mode can be one of 3 things..
// WriteToTextbox - writes the results of the URL to the textbox's value property
// SetResponseToVar - assigns the results of the request to a global variable
// default - writes the results of the request as the inner HTML of the container
function loadDocument(url,theContainer,modeForCS)
{
targetContainer = theContainer;
CSM = modeForCS;
http.open('get', url);
http.onreadystatechange = doStateChange;
http.send(null);
}
// fetches the URL and on state change will call the doStateChangeToResults function
// note: you can not pass arguments on this call (bummer)
function getResults(url)
{
http.open('get', url);
http.onreadystatechange = doStateChangeToResults;
http.send(null);
}
// this is called when the state of the request changes
// there are 4 states and we care about the last one.
function doStateChange()
{
// 4 is complete
if (http.readyState == 4) {
if (http.status == 200)
{
switch(CSM)
{
case 'WriteToTextbox':
//alert("write to textbox");
writeToTextbox(targetContainer,http.responseText);
break;
case 'SetResponseToVar':
//alert("write to textbox");
SetResponseToVar(targetContainer,http.responseText);
break;
case 'default':
//alert("default");
writeToContainer(targetContainer,http.responseText);
break;
}
} else {
var theError = "Could not load";
}
}
}
// this is a dumbed down function that just looks at the container and
// if it is empty, it will load the URL you pass it. If it is not
// empty, it will delete the contents of the container.
function changeState(url,theContainer)
{
if(document.getElementById(theContainer).innerHTML != "")
{
writeToContainer(theContainer,"");
}
else
{
loadDocument(url,theContainer,"default");
}
}
// this will write the content of textToDisplay to the innerHTML
// of the ID passed
function writeToContainer(id,textToDisplay)
{
document.getElementById(id).innerHTML = textToDisplay;
}
// this will write the content of textToDisplay to the
// value property of the ID passed
function writeToTextbox(id,textToDisplay)
{
document.getElementById(id).value = textToDisplay;
}
// this will write the contents of textToSet to be the
// value of the variable passed
// THIS IS NOT USED CURRENTLY, EMPTY STUB LEFT
function SetResponseToVar(id,textToSet)
{
}
function ShowHide(id) {
document.getElementById(id).style.visibility = 'hidden';
}
// Sets the classname on a given tag by ID
function ChangeClassName(id, newClass)
{
if (document.getElementById(id))
document.getElementById(id).className=newClass;
}
// this will show the enhanced items, turn off the DISPLAY link
function showEnhancedItem(id, newClass) {
ChangeClassName(id,"enhancedItemsVisible");
ChangeClassName(id + "HideControl","enhancedItemsControlsDisplay");
ChangeClassName(id + "Control","enhancedItemsControlsHidden");
}
// this hides the enhanced items and turns the display link back on
function hideEnhancedItem(id, newClass) {
ChangeClassName(id,"enhancedItemsHidden");
ChangeClassName(id + "HideControl","enhancedItemsControlsDisplayHidden");
ChangeClassName(id + "Control","enhancedItemsControlsDisplay");
}
