var Feedfunc = function(){};

Feedfunc.prototype = {
  
  //HttpRequestオブジェクト作成
  ajaxObj: function(){
    var xmlhttp;
    
    try{
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch(e){
      try{
	    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  catch(e){
	    xmlhttp = undefined;
	  }
    }
    if(!xmlhttp){
      xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
  },
  
  //feedを取る関数
  ajaxGet: function(obj,target,url){
    var request = this.ajaxObj();
    
    request.onreadystatechange = function(){
      if(request.readyState == 4){
	    if(request.status == 200){
	      var feedtxt = request.responseText;
		  var feedobj = request.responseXML;
		  var cText = feedobj.getElementsByTagName("title")[1].firstChild.nodeValue;
		  var cLink = feedobj.getElementsByTagName("link")[0].firstChild.nodeValue;

		  var num = cText.indexOf(":");
		  cText = cText.slice(num+2,cText.length+1);
		  
		  var aNode =  document.createElement("a");
		  aNode.setAttribute("href",cLink);
		  aNode.setAttribute("target","_blank");
		  var cNode = document.createTextNode(cText);
		  
		  aNode.appendChild(cNode);
		  document.getElementById(obj).appendChild(aNode);
		  document.ajax.result.value = feedtxt;
		  
	    } else {
	      alert("エラー：status=" + request.status);
	    }
	  }
	
    };
  
    request.open("GET",target+"?url="+url,true);
    request.send("");

  }  
};

var feedfunc = new Feedfunc();
feedfunc.ajaxGet("bubble-in","feed.php","http://twitter.com/statuses/user_timeline/29422931.rss");
