﻿resObj={};

jsonp = function(url,func){
	resObj.onload = func;
	var s=document.createElement('script');
	s.charset='utf-8';
	s.src= url;
	document.getElementsByTagName("body")[0].appendChild(s);
}



var socialIMERequestMyServer = Class.create({
	trans:function(sentence,initFunc,option){
		if(typeof(sentence) != "string") return false;
		var purl="http://jime.sourceforge.jp/phpRequest/socialime.php";
		purl +="?sentence=" + encodeURI(sentence);
		if(option =="re") purl +="&option=re";
		var _this = this;

		//送信
		jsonp(purl,function(obj){
			_this.getSentence = function(){
				return sentence;
			};

			_this.getSegmentText=function(segNum){
				if(obj[segNum]){
					return obj[segNum][0];
				}else{
					return false;
				}
			};
			_this.getCandidateList = function(segNum){
				if(obj[segNum]){
					return obj[segNum];
				}else{
					return false;
				}

			};
			initFunc();
		});
	}
});
