var req;

var data = "";


function loadXMLDoc(cat,loc) {
	req = false;
//	alert(cat)

	var url = 'ajaxtest.php'
//    var url = "http://sys116:3000/cgi-bin/ads.cgi";

//alert(url);

    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }

	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}

function processReqChange() {
	    // only if req shows "loaded"
    if (req.readyState == 4) {
		// only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...
			var s=req.responseText;
//			alert(s);

//if (s){
//spons.innerHTML = "Sponsored Listings";
//}
			display.innerHTML = s;
			
//			response  = req.responseXML.documentElement;
//response  = req.responseXML;
//response.setContentType("text/xml;charset=UTF-8"); 
//alert(response);

			 var robotArray = req.responseXML.getElementsByTagName('Number');
			 len = robotArray.length;

/*			for (i=0;i<len;i++ )
			{
                businessname=response.getElementsByTagName('businessName')[i].firstChild.data;
				phonenumberdisplay=response.getElementsByTagName('phoneNumberDisplay')[i].firstChild.data;
				description1=response.getElementsByTagName('description1')[i].firstChild.data;
				description2=response.getElementsByTagName('description2')[i].firstChild.data;
				detailedlistingurl=response.getElementsByTagName('detailedListingURL')[i].firstChild.data;
				businessname_final = "<a href="+detailedlistingurl+" target=_blank><font color=#990000><b>"+businessname+"</b></font></a>";
				phonenumberdisplay_final = "<font color=#009900 size=3><strong>"+phonenumberdisplay+"</strong></font>";

                
                img = "<img src=images/phoneicon.gif>&nbsp;";
				document.write("<br>");
				document.write(businessname_final);
				document.write("<br>");
				document.write(description1);
				document.write("<br>");
				document.write(description2);
				document.write("<br>");
				document.write(img);
				document.write(phonenumberdisplay_final);
				document.write("<br><br>");
				data += businessname_final;
				data += "<BR>";
                data += description1;
				data += "<BR>";
				data += description2;
				data += "<BR>";
				data += img;
				data += phonenumberdisplay_final;
				data += "<BR><BR><BR><BR>";
				display.innerHTML = data;

				
			}*/
        } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
        }
    }
}



