
// fill the rest of the drop downs				
var iCallID = 0;
var stateDescription="";
	function ajax(stateID, showID, description)
	{
				result = createXMLRequest();
				stateDescription =description;
				iCallID = callService(result, loadListings, "returnListings", "StateID=" + stateID + "&ShowID=" + showID  );
	}
	
	function loadListings()
	{
		// only if result shows "loaded"
		if (result.readyState == 4 ) {
			// only if "OK"
			if (result.status == 200) {		
				
				var listings = result.responseXML.getElementsByTagName('string').item(0);
                //var x = GetTextValue(listings);
                document.getElementById('testtable').innerHTML = (listings.text || listings.textContent || listings.firstChild.nodeValue);
                loadListingData(stateDescription);
		
			} else {
				alert("There was a problem retrieving the XML data:\n" +
					result.statusText);
			}
		}
	}

    function GetTextValue(result)
    {
        if (result.childNodes.length > 1)
        {
            return result.childNodes[1].nodeValue;
        }
        else if(result.firstChild)
        {
            return result.firstChild.nodeValue;
        }
        return "";
    }

	function createXMLRequest() {
		var lReq;
		if (window.XMLHttpRequest) {
			lReq = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			lReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return lReq;
	}
	
	// This method is used to call the webservice 
	function callService(req, eventHandler, serviceMethod, params)
	{
		var url = 'WebServices/Listings.asmx/';
		
		// branch for native XMLHttpRequest object
		if (window.XMLHttpRequest) {
			req.onreadystatechange = eventHandler;			
			req.open("POST", url +  serviceMethod, true);			
			req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			req.send(params);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			if (req) {
				req.onreadystatechange = eventHandler;
				req.open("POST", url +  serviceMethod, true);
				req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				req.send(params);
			}
		}
	}
	
	
