function w(s){
    document.write(s);
}
function l(url,text,flag){
	if (flag) return "<a href=\"" + url + "\"" +  " target=\"_blank\" " + ">" + text + "</a>";    	
	else return "<a href=\"" + url + "\">" + text + "</a>";    	
}
function d(cls,text){
	w('<div class="' + cls + '">');
	w(text);
	w('</div>');
}
function a(){
	return new Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
}
function isArray()
{
  if (typeof arguments[0] == 'object')
  {  
    var criterion = arguments[0].constructor.toString().match(/array/i);
   return (criterion != null);  
  }
  return false;
}


function feedpeek(obj) {
w('<p class="disclaimer">Many thanks to <a href="http://wesheme.blogspot.com/2007/11/how-i-peek-feed.html">Ko Andy Myint</a> for the FeedPeek source code.</p>');
  for (var i = 0; i <  obj.count ; i++) {
	if (i == obj.count) break;
	var ent = obj.value.items[i];
	
    var links = ent.link;
	var comments = "";
	if (isArray(links)){
		url = links[4].href;
		comments = l(links[1].href,links[1].title,true);
	}else{
		url = links;
		var pos  =url.indexOf("/",10);
		if (pos > 0 && url.indexOf("feeds") > 0 ){
			if (url.indexOf("blogspot") > 0 ) 
				url = url.substring(0,pos);
		}	
	}

    var pDate = ent.pubDate;
	var author;
	if (ent.author != null){
		author = ' - ' + ent.author.name;    
	} else {
                author = ' - ' + obj.value.items[i]['dc:creator'];    
        }
    var re = /<\S[^>]*>/g; 
	var regimg = /<img[^>]*(?=src)*>/;
	temp = ent.description;
	if (temp.length == 0 ){
		temp = ( ent.content == null ?  ent.summary : ent.content).content;
		temp  = (temp.length == 0 && ent.summary != null ?  ent.summary.content : temp);
	}   	var match = temp.match(regimg);
	var imgText = '';
	var exLength = 0;
	if (match != null && match.length > 0 ){
		imgText = temp.match(regimg)[0]; 
		exLength = imgText.length;	
		imgText = '<div class="blog-image">' + imgText + '</div>';		
	}	 
    var pCnt = temp.replace("<br/>", " ").replace("<br />", " ").replace(re, "").substring(0,180);
    var title = l(url, ent.title,true);
    var rmLink = l(url,"...",true);
    var mnth = pDate.substring(5,7);
    var ma = a();	
    
    if (i%2==0){
		w('<div class="myanmar-blog">');   
	}else{
		w('<div class="myanmar-blog alternate">');   
	}
    
		d("title",title); 
		d("author", ma[parseInt(mnth,10)] + ' ' + pDate.substring(8,10) + author);
		//d("summary",imgText + pCnt +  rmLink );    
    w('</div>');  
    author = null;
	}

}
