function JSONFeedCallback(obj,callerID){
buildContainer(callerID);
var postCount,itemRSS,itemTitle,itemDate,itemLink,container,caller;
caller=document.getElementById(callerID+"feed");
container = caller;
itemRSS = obj.rss.channel;
try{
  postCount = itemRSS.item.length;
}catch(err){
  postCount = "";
}
	itemRSS.RSSfeed = BLOGRSS;
	itemRSS.title = BLOGTITLE;
	itemRSS.description = BLOGDESCRIPTION;
if (!obj.error) {
  var div = "<div style=\"background:url(/citylink/images/"+TITLEBAR_COLOR+"Gray_bkg.gif);height:25px;\"><b class=\"blog_titleFont\"><a href=\""+itemRSS.link+"\" style=\"color:"+TITLEBARFONT_COLOR+";text-decoration:none;\">"+itemRSS.title+"</a></b><a href=\""+itemRSS.RSSfeed+"\"><img style=\"float:right;margin:3px\" src=\"/2004_IMG/rss_icon2.gif\" alt=\"Subscribe to RSS feed\" border=\"0\" /></a></div>"
  div +="<ol class=\"blog_entry_ol\" >";
	div +="<li class=\"blog_entry_desc\"><em>"+itemRSS.description+"</em></li>";
  try{

    var containerWidth=document.getElementById('feedContainerDept').style.width;
    containerWidth = containerWidth.replace('px','');
    var truncCharCnt = containerWidth/9.5;

  for (var i = 0; i < postCount && i < BLOGENTRIES_DISPLAYCOUNT; i++) {
      var entry = itemRSS.item[i];
			var altRow="";
      if(i%2){
  			altRow = "blog_evenRow";
			}else{
				altRow = "blog_oddRow";
			}
/*
if(i<=4){
  			altRow = altRow+" entries5";	
			}else if(i>4){
        altRow = altRow+" entries10";
      }
*/
entry.title = entry.title.replace(/[\u20AC][\u02DC]|[\u20AC][\u2122]/g,"");
entry.title = entry.title.replace(/[\u20AC]|[\u00E2]|[\u20AC][^a-zA-Z 0-9]/g,"");

//entry.title = entry.title.replace(/(&#8220;)|(&#8221;)|[\u8220]|[\u8221]|[“”\u8220\u8221]/g, "&quot;");
//entry.title = entry.title.replace(/(&#8216;)|(&#8217;)|[\u00E2]|[\u8216]|[\u8217]|[‘’\u8216\u8217]/g, "'");
//    entry.title =  entry.title.replace(/[^a-zA-Z 0-9]+/g,'');
      div = div + "<li id=\"blogentry"+i+"\" onmouseover=\"this.className='blog_hoverState'\" onmouseout=\"this.className=\'"+altRow+"\'\" class=\""+altRow +"\"><em class=\"blog_dateStyle\">"+dateFormat(entry.pubDate)+"</em> - <a style=\"text-decoration:none;\" href=\""+entry.link+"\">"+truncStr(entry.title,truncCharCnt)+"</a></li>"
		}
  }catch(err){
  }
    container.innerHTML = div+"</ol>";
	 	
  }else{
//	  var container = document.getElementById("feed");
    container.innerHTML="<p align=\"center\">The current information cannot be displayed at this time.</p>";
	}
}

function buildContainer(callerID){
  var mainContainer = document.getElementById(callerID);
  var div = "<div id=\""+callerID+"feed\" class=\"feedDisplay\">Loading...</div>";
  div += "<div style=\"background:url(/citylink/images/citylink_titleback.jpg);border:1px solid #cecfce\"><img style=\"float:left;\" src=\"/citylink/images/sealthLogo2.gif\" alt=\"City of Seattle logo\" border=\"0\"/><div style=\"background:url(/citylink/images/citylink_titleback.jpg);height:27px;\"><a href=\"http://citylink.seattle.gov/\"><img style=\"margin-left:0px\" src=\"/citylink/images/cityLinkLogo2.gif\" alt=\"CityLink Seattle\" border=\"0\" /></a></div>"
  div += "<div style=\"background:url(/citylink/images/cityLinkGreen.gif);height:17px;\"><strong style=\"float:left;padding-left:4px;font-family:verdana;font-size:11px;color:#363636\">Your City, Right Now</strong><a href=\"http://citylink.seattle.gov/\" style=\"color:#363636;text-decoration:none;float:right;font-family:verdana;font-size:11px;padding-right:3px;padding-top:2px\"><strong>CityLink.Seattle.gov</strong></a></div>"
  div += "</div>"
  mainContainer.innerHTML = div;
}

function truncStr(str,len){
if(str.length > len){
  str = str.substr(0,len);
  str = str.substr(0,str.lastIndexOf(" "))+"...";
}
  return str;  
}

function dateFormat(dateObj){
var strDate = dateObj.slice(5,dateObj.length-15);
strDate = strDate.split(" ");
switch (strDate[1].toUpperCase()){
case "JAN" :
  strDate[1] = "01";
  break;
case "FEB":
  strDate[1] = "02";
  break;
case "MAR":
  strDate[1] = "03";
  break;
case "APR":
  strDate[1] = "04";
  break;
case "MAY":
  strDate[1] = "05";
  break;
case "JUN":
  strDate[1] = "06";
  break;
case "JUL":
  strDate[1] = "07";
  break;
case "AUG":
  strDate[1] = "08";
  break;
case "SEP":
  strDate[1] = "09";
  break;
case "OCT":
  strDate[1] = "10";
  break;
case "NOV":
  strDate[1] = "11";
  break;
case "DEC":
  strDate[1] = "12";
  break;
default:
}

var newDate = strDate[1]+"/"+strDate[0]+"/"+strDate[2].substring(2,4);
  return newDate;
}
