// retrieve text of an XML document element, including
// elements using namespaces
function getElementTextNS(prefix, local, parentElem, index) {
    var result = "";
    if (prefix && $j.browser.msie) {
        // IE/Windows way of handling namespaces
		
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        // the namespace versions of this method 
        // (getElementsByTagNameNS()) operate
        // differently in Safari and Mozilla, but both
        // return value with just local name, provided 
        // there aren't conflicts with non-namespace element
        // names
        result = parentElem.getElementsByTagName(local)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes 
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
            return result.firstChild.nodeValue;
        }
    } else {
        return "n/a";
    }
} 
 $j.ajax({
   url: "http://www.kenneth-koh.com/blog/?feed=rss2",
   dataType: ($j.browser.msie) ? "text" : "xml",
   success: function(data){
     var xml;
     if (typeof data == "string") {
       xml = new ActiveXObject("Microsoft.XMLDOM");
       xml.async = false;
       xml.loadXML(data);
     } else {
       xml = data;
     }

     var items = xml.getElementsByTagName("item");
     newsItems = items; // for later use.
     var pubDate;
     var link;
     var title;
     var innerHtml = "";
     for(index=0; index < items.length && index < 3; index++)
     {
          pubDate = items[index].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue;
          link = items[index].getElementsByTagName("link")[0].childNodes[0].nodeValue;
          title = items[index].getElementsByTagName("title")[0].childNodes[0].nodeValue;

          // nieuws met datum!
          //innerHtml += '<div class="item"><div class="datetime"><p>'+pubDate.substr(4,pubDate.length-18);
          //innerHtml += '</p></div><div class="title"><a onclick="javascript:Go('+ index +')" href="';      // onclick is the IE fix for menu items ;((
          
          // nieuws zonder datum
          innerHtml += '<div class="item">';
          innerHtml += '<div class="title" style="width: 250px;"><a onclick="javascript:Go('+ index +')" href="';      // onclick is the IE fix for menu items ;((
          if( $j("#home").length > 0){
            innerHtml += "http://www.kenneth-koh.com/index.php?id=45";
          }
          //innerHtml += '</p></div><div class="title"><a href="'+link;
          innerHtml += "#"+index+'">'+title;
          innerHtml += '</a></div></div>';
     }

     $j("#latest-news").html( innerHtml );

     Update( location.hash.substring(1) );

//     <div id="latest-news">
//     	<div class="item">
//	     <div class="datetime"><p> 15 Jul 2008 </p></div><div class="title"><a href="#0">Studio Kenneth&amp;Koh in tijdschrift “Kunstzone”</a></div></div><div class="item"><div class="datetime"><p> 10 Jul 2004 </p></div><div class="title"><a href="#1">Hello world!</a></div></div></div>


  /*
	 //
	 // Show last article...
	 //
	 var articleHtml = "<h2>"+ items[0].getElementsByTagName("title")[0].childNodes[0].nodeValue +"</h2>";
	 articleHtml += getElementTextNS('content', 'encoded', items[0], 0);

	 $j("#latest-news-item").html( articleHtml );
	// sifr
	if(typeof sIFR == "function"){
sIFR.replaceElement( "#nieuws h2", named({sFlashSrc:"./assets/templates/studiokk/sifr/Swis721LtCnBT.swf", sColor:"#333333", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"textalign=left&offsetTop=0"}) );
	 }
	 */
  }
});