var _SURFPOINT = function(argKey){
this.key = argKey;
this.IP = "";
this.prefCode = "";
this.aname = "";
this.jname = "";
this.lat = "";
this.lng = "";
this.CF = "";
this.cityCode = "";
this.cityAname = "";
this.cityJname = "";
this.cityLat = "";
this.cityLng = "";
this.cityCF = "";
this.countryCode = "";
this.countryAname = "";
this.countryJname = "";
this.BCFlag = "";
this.OrgCode = "";
this.OrgOfficeCode = "";
this.OrgIndependentCode = "";
this.OrgName = "";
this.OrgPrefCode = "";
this.OrgCityCode = "";
this.OrgZipCode = "";
this.OrgAddress = "";
this.OrgTel = "";
this.OrgFax = "";
this.OrgIpoType = "";
this.OrgDate = "";
this.OrgCapitalCode = "";
this.OrgEmployeesCode = "";
this.OrgGrossCode = "";
this.OrgPresident = "";
this.OrgIndustrialCategoryL = "";
this.OrgIndustrialCategoryM = "";
this.OrgIndustrialCategoryS = "";
this.OrgIndustrialCategoryT = "";
this.LineCode = "";
this.LineJName = "";
this.LineCF = "";
this.TelCode = "";
this.DomainName = "";
}
_SURFPOINT.prototype.getIP = function(){return decodeURIComponent(this.IP);};
_SURFPOINT.prototype.getPrefCode = function(){return decodeURIComponent(this.prefCode);};
_SURFPOINT.prototype.getPrefAName = function(){return decodeURIComponent(this.aname);};
_SURFPOINT.prototype.getPrefJName = function(){return decodeURIComponent(this.jname);};
_SURFPOINT.prototype.getLat = function(){return decodeURIComponent(this.lat);};
_SURFPOINT.prototype.getLng = function(){return decodeURIComponent(this.lng);};
_SURFPOINT.prototype.getPrefLat = function(){return decodeURIComponent(this.lat);};
_SURFPOINT.prototype.getPrefLng = function(){return decodeURIComponent(this.lng);};
_SURFPOINT.prototype.getPrefCF = function(){return decodeURIComponent(this.CF);};
_SURFPOINT.prototype.getCityCode = function(){return decodeURIComponent(this.cityCode);};
_SURFPOINT.prototype.getCityAName = function(){return decodeURIComponent(this.cityAname);};
_SURFPOINT.prototype.getCityJName = function(){return decodeURIComponent(this.cityJname);};
_SURFPOINT.prototype.getCityLat = function(){return decodeURIComponent(this.cityLat);};
_SURFPOINT.prototype.getCityLng = function(){return decodeURIComponent(this.cityLng);};
_SURFPOINT.prototype.getCityCF = function(){return decodeURIComponent(this.cityCF);};
_SURFPOINT.prototype.getCountryCode = function(){return decodeURIComponent(this.countryCode);};
_SURFPOINT.prototype.getCountryAName = function(){return decodeURIComponent(this.countryAname);};
_SURFPOINT.prototype.getCountryJName = function(){return decodeURIComponent(this.countryJname);};
_SURFPOINT.prototype.getBCFlag = function(){return decodeURIComponent(this.BCFlag);};
_SURFPOINT.prototype.getOrgCode = function(){return decodeURIComponent(this.OrgCode);};
_SURFPOINT.prototype.getOrgOfficeCode = function(){return decodeURIComponent(this.OrgOfficeCode);};
_SURFPOINT.prototype.getOrgIndependentCode = function(){return decodeURIComponent(this.OrgIndependentCode);};
_SURFPOINT.prototype.getOrgName = function(){return decodeURIComponent(this.OrgName);};
_SURFPOINT.prototype.getOrgPrefCode = function(){return decodeURIComponent(this.OrgPrefCode);};
_SURFPOINT.prototype.getOrgCityCode = function(){return decodeURIComponent(this.OrgCityCode);};
_SURFPOINT.prototype.getOrgZipCode = function(){return decodeURIComponent(this.OrgZipCode);};
_SURFPOINT.prototype.getOrgAddress = function(){return decodeURIComponent(this.OrgAddress);};
_SURFPOINT.prototype.getOrgTel = function(){return decodeURIComponent(this.OrgTel);};
_SURFPOINT.prototype.getOrgFax = function(){return decodeURIComponent(this.OrgFax);};
_SURFPOINT.prototype.getOrgIpoType = function(){return decodeURIComponent(this.OrgIpoType);};
_SURFPOINT.prototype.getOrgDate = function(){return decodeURIComponent(this.OrgDate);};
_SURFPOINT.prototype.getOrgCapitalCode = function(){return decodeURIComponent(this.OrgCapitalCode);};
_SURFPOINT.prototype.getOrgEmployeesCode = function(){return decodeURIComponent(this.OrgEmployeesCode);};
_SURFPOINT.prototype.getOrgGrossCode = function(){return decodeURIComponent(this.OrgGrossCode);};
_SURFPOINT.prototype.getOrgPresident = function(){return decodeURIComponent(this.OrgPresident);};
_SURFPOINT.prototype.getOrgIndustrialCategoryL = function(){return decodeURIComponent(this.OrgIndustrialCategoryL);};
_SURFPOINT.prototype.getOrgIndustrialCategoryM = function(){return decodeURIComponent(this.OrgIndustrialCategoryM);};
_SURFPOINT.prototype.getOrgIndustrialCategoryS = function(){return decodeURIComponent(this.OrgIndustrialCategoryS);};
_SURFPOINT.prototype.getOrgIndustrialCategoryT = function(){return decodeURIComponent(this.OrgIndustrialCategoryT);};
_SURFPOINT.prototype.getLineCode = function(){return decodeURIComponent(this.LineCode);};
_SURFPOINT.prototype.getLineJName = function(){return decodeURIComponent(this.LineJName);};
_SURFPOINT.prototype.getLineCF = function(){return decodeURIComponent(this.LineCF);};
_SURFPOINT.prototype.getTelCode = function(){return decodeURIComponent(this.TelCode);};
_SURFPOINT.prototype.getDomainName = function(){return decodeURIComponent(this.DomainName);};
_SURFPOINT.prototype.getPrefLocation = function (pref,value)
{
        var date = new Date();
        var s = document.createElement('script');
        var callback = (value == ""?"&":"&callback=" + value);
        s.src = 'http://api.docodoco.jp/v3/docodoco?_surfpoint=' + pref + '&mode=load' + callback + '&key=' + this.key + '&t='+(new Date()).getTime();
        document.body.appendChild(s);
}
_SURFPOINT.prototype.getIPGeoLocation = function (ip,value)
{
    var date = new Date();
    var s = document.createElement('script');
    var callback = (value == ""?"?":"?callback=" + value);
    s.src = 'http://api.docodoco.jp/v3/docodoco' + callback + '&mode=load&ipadr=' + ip  + '&key=' + this.key + '&t='+(new Date()).getTime();
    document.body.appendChild(s);
}

_SURFPOINT.prototype.changeContents = function( argId,arghtml)
{
    if(document.getElementById)
    {       //e5,e6,n6,n7,m1,o7,s1用
        document.getElementById(argId).innerHTML= arghtml;
    }
    else if(document.all)
    {     //e4用
        document.all(argId).innerHTML= arghtml;
    }
    else if(document.layers)
    {   //n4用
        with(document.layers[argId].document)
        {
            open();
            write(arghtml);
            close();
        }
    }
}
_SURFPOINT.prototype.getContents = function (argId,argPath)
{
    var sp = this;
    var xmlReq = sendRequest(onloadedBridge,'','GET',argPath,true,true)
    
    function onloadedBridge(oj)
    {
        sp.changeContents(argId,oj.responseText);
//        (function(sp) {return function() { sp.(changeAreaContents(argId,oj.responseText);); }; })(this);
    }

    ////
    // 動作可能なブラウザ判定
    ////
    function chkAjaBrowser()
    {
        var a,ua = navigator.userAgent;
        this.bw= { 
          safari    : ((a=ua.split('AppleWebKit/')[1])?a.split('(')[0].split('.')[0]:0)>=124 ,
          konqueror : ((a=ua.split('Konqueror/')[1])?a.split(';')[0]:0)>=3.3 ,
          mozes     : ((a=ua.split('Gecko/')[1])?a.split(' ')[0]:0) >= 20011128 ,
          opera     : (!!window.opera) && ((typeof XMLHttpRequest)=='function') ,
          msie      : (!!window.ActiveXObject)?(!!createHttpRequest()):false 
        }
        return (this.bw.safari||this.bw.konqueror||this.bw.mozes||this.bw.opera||this.bw.msie)
    }

    ////
    // XMLHttpRequestオブジェクト生成
    ////
    function createHttpRequest()
    {
        if(window.XMLHttpRequest){
             //Win Mac Linux m1,f1,o8 Mac s1 Linux k3 & Win e7用
            return new XMLHttpRequest() ;
        } else if(window.ActiveXObject){
             //Win e4,e5,e6用
            try {
                return new ActiveXObject('Msxml2.XMLHTTP') ;
            } catch (e) {
                try {
                    return new ActiveXObject('Microsoft.XMLHTTP') ;
                } catch (e2) {
                    return null ;
                 }
             }
        } else  {
            return null ;
        }
    }

    ////
    // 送受信関数
    ////
    function sendRequest(callback,data,method,url,async,sload,user,password)
    {
        var GET=method.toUpperCase()=='GET';
        var oj = createHttpRequest();
        if( oj == null ) return null;
        
        //強制ロードの設定
        if((sload)?sload:false)url +=((url.indexOf('?')==-1)?'?':'&')+'t='+(new Date()).getTime();

        //ブラウザ判定
        var bwoj = new chkAjaBrowser(),
        o  = bwoj.bw.opera,
        s  = bwoj.bw.safari,
        k = bwoj.bw.konqueror,
        m  = bwoj.bw.mozes ;
                
        //callbackを分解
        //{onload:xxxx,onbeforsetheader:xxx}
        if(typeof callback=='object'){
            var callback_onload = callback.onload;
            var callback_onbeforsetheader = callback.onbeforsetheader;
        } else {
            var callback_onload = callback;
            var callback_onbeforsetheader = null;
        }

        //受信処理
        if(o || s || m){
            oj.onload = function () { callback_onload(oj);oj.abort(); }
        } else {
        
            oj.onreadystatechange =function () 
            {
                if ( oj.readyState == 4 )
                {
                    //alert(oj.status+'--'+oj.getAllResponseHeaders());
                    callback_onload(oj);
                    oj.abort();
                }
            }
        }

        //URLエンコード
        data = uriEncode(data,url);
        if(GET) {
            url += ((url.indexOf('?')==-1)?'?':(data=='')?'':'&')+data;
        }

        //open メソッド
        oj.open(method,url,async,user,password);
        
        
        if(!!callback_onbeforsetheader)callback_onbeforsetheader(oj);

        //デフォルトヘッダapplication/x-www-form-urlencodedセット
        setEncHeader(oj);
        
        //send メソッド
        oj.send(data);

        //URIエンコードヘッダセット
        function setEncHeader(oj){

            //ヘッダapplication/x-www-form-urlencodedセット
            //  このメソッドがWin Opera8.0でエラーになったので分岐(8.01はOK)
            if(!o||typeof oj.setRequestHeader == 'function'){
                oj.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
            }
            return oj
        }

        //URLエンコード
        function uriEncode(data,url){
            var d = [];
            if(typeof data=='object'){
                for(var i in data)p(i,data[i]);
            } else if(typeof data=='string'){
                if(data=='')return '';
                //&と=で一旦分解しencode
                if(data.charAt(0)=='&')data=data.substring(1,data.length)
                var datas = data.split('&');
                for(var i=0;i<datas.length;i++)
                {
                    var dataq = datas[i].split('=');
                    p(dataq[0],dataq[1]);
                }
            } 
            function p(k,v){d.push( encodeURIComponent(k) + "=" + encodeURIComponent(v))};
            return d.join("&");
        }
        return oj
    }
    }

var SURFPOINT = new _SURFPOINT('m5Zm9rVHf0ObhGMbuThFd7orhEuUyCfUfNgEvdn8gko8CGsDJM5B1LVCRrAf9asZ');
SURFPOINT.IP = "38.107.191.85";
SURFPOINT.prefCode = "00";
SURFPOINT.aname = "unknown";
SURFPOINT.jname = "%E5%88%A4%E5%AE%9A%E4%B8%8D%E6%98%8E";
SURFPOINT.lat = "";
SURFPOINT.lng = "";
SURFPOINT.CF = "00";
SURFPOINT.cityCode = "00000";
SURFPOINT.cityAname = "unknown";
SURFPOINT.cityJname = "%E5%88%A4%E5%AE%9A%E4%B8%8D%E6%98%8E";
SURFPOINT.cityLat = "";
SURFPOINT.cityLng = "";
SURFPOINT.cityCF = "00";
SURFPOINT.countryCode = "US";
SURFPOINT.countryAname = "United States";
SURFPOINT.countryJname = "%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd";
SURFPOINT.BCFlag = "";
SURFPOINT.OrgCode = "";
SURFPOINT.OrgOfficeCode = "";
SURFPOINT.OrgIndependentCode = "";
SURFPOINT.OrgName = "";
SURFPOINT.OrgPrefCode = "";
SURFPOINT.OrgCityCode = "";
SURFPOINT.OrgZipCode = "";
SURFPOINT.OrgAddress = "";
SURFPOINT.OrgTel = "";
SURFPOINT.OrgFax = "";
SURFPOINT.OrgIpoType = "";
SURFPOINT.OrgDate = "";
SURFPOINT.OrgCapitalCode = "";
SURFPOINT.OrgEmployeesCode = "";
SURFPOINT.OrgGrossCode = "";
SURFPOINT.OrgPresident = "";
SURFPOINT.OrgIndustrialCategoryL = "";
SURFPOINT.OrgIndustrialCategoryM = "";
SURFPOINT.OrgIndustrialCategoryS = "";
SURFPOINT.OrgIndustrialCategoryT = "";
SURFPOINT.LineCode = "z";
SURFPOINT.LineJName = "%E5%88%A4%E5%AE%9A%E4%B8%8D%E6%98%8E";
SURFPOINT.LineCF = "00";
SURFPOINT.TelCode = "00";
SURFPOINT.DomainName = "unknown";
