//<?
//////////////////////////////////////////////////////////////////////////
//AJAX
//////////////////////////////////////////////////////////////////////////
var doAJAXcall = false; //initally set AJAX call to false

// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject(); 

var dayOfWeek = ["Su","Mo","Tu","We","Th","Fr","Sa","Su"];
var month = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug", "Sep", "Oct", "Nov", "Dec"];

// creates an XMLHttpRequest instance
function createXmlHttpRequestObject() 
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // this should work for all browsers except IE6 and older
  try
  {
    // try to create XMLHttpRequest object
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    // assume IE6 or older
    var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0',
                                    'MSXML2.XMLHTTP.5.0',
                                    'MSXML2.XMLHTTP.4.0',
                                    'MSXML2.XMLHTTP.3.0',
                                    'MSXML2.XMLHTTP',
                                    'Microsoft.XMLHTTP');
    // try every prog id until one works
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) 
    {
      try 
 
      { 
        // try to create XMLHttpRequest object
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch (e) {}
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}



function showCategoryDesc(catID) {
	//wait a second
	doAJAXcall = true;
    setTimeout('showCategoryDescAjax(' + catID + ')', 1000);
}

//make asynchronous HTTP request using the XMLHttpRequest object 
function showCategoryDescAjax(catID) {
  // proceed only if the xmlHttp object isn't busy and our call hasn't been cancelled
  if (doAJAXcall && (xmlHttp.readyState == 4 || xmlHttp.readyState == 0))
  {
	    // execute 
	    url = "ajax_get_green_fee.php?id=" + catID + "&chk=8276";
	    //alert(url);
	    xmlHttp.open("GET", url, true);  
	    // define the method to handle server responses
	    xmlHttp.onreadystatechange = handleServerResponse;
	    // make the server request
	    xmlHttp.send(null);
  }
}

// executed automatically when a message is received from the server
function handleServerResponse() 
{
  // move forward only if the transaction has completed
  if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
      xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlDocumentElement = xmlResponse.documentElement;
      
		$catList = xmlDocumentElement.getElementsByTagName("category");      
		if ($catList.length > 0) {
			category = getFirstItemDataValue($catList);
			
			//note for the desc, html will be displayed as html
			catDesc = xmlDocumentElement.getElementsByTagName("categoryDesc")[0].firstChild.data;
		}
      //display popup
      olib3(catDesc, category, -90, 15);
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

//?>

