var _SURFPOINT = function(argKey){
this.key = argKey;
this.prefCode="";
this.aname = "";
this.jname = "";
this.lat = "";
this.lng = "";
this.cityCode="";
this.cityAname = "";
this.cityJname = "";
this.cityLat = "";
this.cityLng = "";
this.CountryCode="";
this.countryAname = "";
this.countryJname = "";
}
_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.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.getCountryCode = function(){return decodeURIComponent(this.countryCode);};
_SURFPOINT.prototype.getCountryAName = function(){return decodeURIComponent(this.countryAname);};
_SURFPOINT.prototype.getCountryJName = function(){return decodeURIComponent(this.countryJname);};
_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/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/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('NadK2ToBJoNoi5crgr4n1NqZm3MGPFyVMzWzhJ0nqjGOpexnSntRe25oI1lKqaeN');
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.cityCode = "00000";
SURFPOINT.cityAname = "unknown";
SURFPOINT.cityJname = "%E5%88%A4%E5%AE%9A%E4%B8%8D%E6%98%8E";
SURFPOINT.cityLat = "";
SURFPOINT.cityLng = "";
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";

