﻿// JScript ファイル
var xmlHttp; 

function ajxGeomSrchXml(url,extents, aplUseNo,page,chkBunrui,callBackFunc)
{  
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    
    url += "?q="+extents;
    url += "&r="+aplUseNo;
    url += "&p="+page;
    url += "&b="+chkBunrui;
//alert ("url:::" + url);
    
    xmlHttp.onreadystatechange=function(){
        if (xmlHttp.readyState==4){
            //console.time("parse time");
            if(httpRequest.status == 200){
                var xmlDoc=xmlHttp.responseXML.documentElement; 
                var countNode=xmlDoc.getElementsByTagName('gtitle').length;

                if (countNode !=0) 
                {
                    for (i=0; i<countNode; i++){
                        
                        var geom = new geomInfo();
                        geom.aplUseNo=xmlDoc.getElementsByTagName('aplUseNo')[i].childNodes[0].nodeValue;
                        geom.geomNo=xmlDoc.getElementsByTagName('geomNo')[i].childNodes[0].nodeValue;
                        geom.title=xmlDoc.getElementsByTagName('gtitle')[i].childNodes[0].nodeValue;
                        geom.bunruiId=xmlDoc.getElementsByTagName('bunrui')[i].childNodes[0].nodeValue;
                        geom.pointType=xmlDoc.getElementsByTagName('pointType')[i].childNodes[0].nodeValue;
//                        if(xmlDoc.getElementsByTagName('thumImg')[i].childNodes[0]){
//                            geom.thumImg=xmlDoc.getElementsByTagName('thumImg')[i].childNodes[0].nodeValue;
//                        }
                        //geom.address=xmlDoc.getElementsByTagName('address')[i].childNodes[0].nodeValue;
                        
                        if (xmlDoc.getElementsByTagName('point')[i].childNodes.length!=0){
	                        var ajxPoint=xmlDoc.getElementsByTagName('point')[i].childNodes[0].nodeValue;
	                        var ajxPointSplit=ajxPoint.split(" ");               
	                        if (ajxPoint.length>0){
	                            geom.x = ajxPointSplit[0];
	                            geom.y = ajxPointSplit[1];
	                            targetMe(geom);
	                        }
                        }
                    }
                }else{
                    //alert("There is no data in this region");
                }
                
            }else{
                //alert('There was a problem with the request');
            }
            //console.timeEnd("parse time");
            callBackFunc(1);
        }
    };
    
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

