var sub_aboutus_info = new Array();
var sub_aboutus_total = '';
var no_pages ='';
// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject();

// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject()
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else
    return xmlHttp;
}

function about_us()
{
	
// document.getElementById('product_table').innerHTML = '';
 // only continue if xmlHttp isn't void
 if (xmlHttp)
 {
  // try to connect to the server
  try
  {
    // execute the quickstart.php page from the server

	xmlHttp.open("GET", "./xml/about-us.php?info=ian-blowers", true);
    document.getElementById('contenttext').innerHTML = '<img src="./images/waiting.gif">';

	xmlHttp.onreadystatechange =  handleaboutus;
    xmlHttp.send(null);
  }
  // display the error in case of failure
  catch (e)
  {
    alert("Can't connect to server:\n" + e.toString());
  }
 }
}

 // function called when the state of the HTTP request changes
function handleaboutus()
{
 // alert("request");
  // when readyState is 4, we are ready to read the server response
  if (xmlHttp.readyState == 4)
  {
    // continue only if HTTP status is "OK"
    if (xmlHttp.status == 200)
    {
      try
      {
        // do something with the response from the server
      
	  handleaboutusResponse();
      }
      catch(e)
      {
        // display error message
        alert("Error reading the response: " + e.toString());
      }
    }
    else
    {
      // display status message
      alert("There was a problem retrieving the data:\n" +
            xmlHttp.statusText);
    }
  }
}

// handles the response received from the server
function handleaboutusResponse()
{
 //alert("handle");
  // read the message from the server
  var xmlResponse = xmlHttp.responseXML;
  // catching potential errors with IE and Opera
  if (!xmlResponse || !xmlResponse.documentElement)
    throw("Invalid XML structure:\n" + xmlHttp.responseText);
  // catching potential errors with Firefox
  var rootNodeName = xmlResponse.documentElement.nodeName;
  if (rootNodeName == "parsererror")
    throw("Invalid XML structure:\n" + xmlHttp.responseText);
  // obtain the XML's document element
  xmlRoot = xmlResponse.documentElement;
  // obtain arrays with book titles and ISBNs

  sub_aboutus_total = xmlRoot.getElementsByTagName("sub-aboutus-total")[0].firstChild.data;
  //alert("sub_aboutus_total id - "+sub_aboutus_total);

  var sub_category = '';
  for (var i=0; i<2; i++)
  {
	sub_category = xmlRoot.getElementsByTagName("sub-aboutus-info");
	sub_aboutus_info[i] = sub_category.item(i).firstChild.data;
  }
  
  var myDiv = '';
  var html = '';
  if(sub_aboutus_total > 0)
  {
	    html = "";

		
		document.getElementById('contenttext').innerHTML = html + sub_aboutus_info[0];
		document.getElementById('contenttext').innerHTML = sub_aboutus_info[0];
		document.getElementById('contentnavleft').innerHTML = "<a href=\"Javascript:aboutus_info(1);\"><span class=\"blacktext\">&nbsp;&nbsp;&nbsp;1</span></a>&nbsp;&nbsp;<a href=\"Javascript:aboutus_info(2);\"><span class=\"greytext\">2</span></a>&nbsp;&nbsp;&nbsp;<a href=\"Javascript:aboutus_info(2);\"><img src=\"images/arrow-01-right.gif\" width=\"3\" height=\"5\"  border=\"0\" ></a>";
  }
}

function aboutus_info(page)
{
	if(parseInt(page) == 1)
	{
		//html = "<img src=\"images/ibj-quote.gif\" width=\"235\" height=\"125\" align=\"right\">";
		html = "";
		document.getElementById('contenttext').innerHTML = html + sub_aboutus_info[0];
		document.getElementById('contenttext').innerHTML = sub_aboutus_info[0];
		document.getElementById('contentnavleft').innerHTML = "<a href=\"Javascript:aboutus_info(1);\"><span class=\"blacktext\">&nbsp;&nbsp;&nbsp;1</span></a>&nbsp;&nbsp;<a href=\"Javascript:aboutus_info(2);\"><span class=\"greytext\">2</span></a>&nbsp;&nbsp;&nbsp;<a href=\"Javascript:aboutus_info(2);\"><img src=\"images/arrow-01-right.gif\" width=\"3\" height=\"5\" border=\"0\" ></a>";
	}
	if(parseInt(page) == 2)
	{
		if(sub_aboutus_info[1] != '')
		{
			//html = "<img src=\"images/ibj-quote.gif\" width=\"235\" height=\"125\" align=\"right\">";
			html = "";
			document.getElementById('contenttext').innerHTML = html + sub_aboutus_info[1];
			document.getElementById('contentnavleft').innerHTML = "<a href=\"Javascript:aboutus_info(1);\"><img src=\"images/arrow-01-left.gif\" width=\"3\" height=\"5\"  border=\"0\"></a><a href=\"Javascript:aboutus_info(1);\"><span class=\"greytext\">&nbsp;&nbsp;&nbsp;1</span></a>&nbsp;&nbsp;<a href=\"Javascript:aboutus_info(1);\"><span class=\"blacktext\">2</span></a>&nbsp;&nbsp;&nbsp;<a href=\"Javascript:aboutus_info(2);\">";
		}
	}
}