
function include_dom(script_filename) 
{
   var html_doc = document.getElementsByTagName('head').item(0);
   var js = document.createElement('script');
   js.setAttribute('language', 'javascript');
   js.setAttribute('type', 'text/javascript');
   js.setAttribute('src', script_filename);
   html_doc.appendChild(js);
   return false;
}

function include(script_filename) 
{
   document.write('<' + 'script');
   document.write(' language="javascript"');
   document.write(' type="text/javascript"');
   document.write(' src="' + script_filename + '">');
   document.write('</' + 'script' + '>');
}


function handle_json() 
{
   if (http_request.readyState == 4) 
   {
      if (http_request.status == 200) 
      {
	 var json_data = http_request.responseText; 
	 var the_object = eval("(" + json_data + ")");
      } 
      else 
      {
	 alert("There was a problem with the URL.");
      }
      http_request = null;
   }  
}

function include2(url)
{
   http_request.open("GET", url, true);
   http_request.onreadystatechange = handle_json;
   http_request.send(null);
}


function get_tag(wdiv, str, title)
{
   var h3 = document.createElement ('h3');
   h3.setAttribute('class', "subheader");
   h3.appendChild(document.createTextNode(title));
   document.getElementById(wdiv).appendChild(h3);
   
   //tempstr = "http://del.icio.us/feeds/json/kjohara/" + str + "?count=100"
   //include_dom(tempstr)
   
   for (var i = (Delicious.posts.length - 1); i >= 0; i--) 
   {
      var post = Delicious.posts[i]
      if (post.t)
      {
         for (var j = 0; j < post.t.length; j++) 
         {   
            tag = post.t[j];
            if (tag == str)
            {
               var p = document.createElement('p');
      	       p.setAttribute('class', "news");
	       
               var a = document.createElement('a');
               a.setAttribute('href', post.u);
               a.appendChild(document.createTextNode(post.d));
  	       // documen.getElementById(wdiv).appendChild(a);
 	       p.appendChild(a);
 	       document.getElementById(wdiv).appendChild(p);
               var br = document.createElement('br');
               //document.getElementById(wdiv).appendChild(br);
            }
         }
      }
   }
   
   var br = document.createElement('br');
   document.getElementById(wdiv).appendChild(br);
}
