/*
======================================================================
JavaScript HtmlBuilder class
Author: Alessandro Lacava http://www.alessandrolacava.com
Created: Jul 25th, 2006.
Description: This class is responsible to build the HTML code to use within the ticker.
The code is built by parsing the JSON string. Basically,
this is the only code you need to change if you mean
to display the news in some other way. This class is meant to be used in 
conjunction with the ContentRetriever class that is defined inside 
the contentRetriever.js file.
======================================================================
*/

//HtmlBuilder class
function HtmlBuilder(jsonString)
{
	// JSON text
	this.jsonString = jsonString;
}

//build the HTML code and return it as a javascript array
HtmlBuilder.prototype.getHtml = function()
{
	var ret = [];
	//decode the JSON message
	var obj = this.decodeJson();
	//get the array
	var items = obj.items;
	//build the HTML code using the array
	for(var i = 0; i < items.length; i++)
	{
		var item = "";
		//build the title
		item += this.buildTitle(items[i]);
		item += "<br />";
		//build the description
		item += this.buildDescription(items[i]);
		item += "<br />";
		ret.push(item);
	}
	return ret;			
};

//JSON decoder
HtmlBuilder.prototype.decodeJson = function()
{
	//parse the JSON string
	return eval("(" + this.jsonString + ")");
};

//title builder
HtmlBuilder.prototype.buildTitle = function(item)
{
	var ret = "<a class='title' href='" + item.link + "' target='main'>" + item.title + "</a>";
	return ret;
};

//description builder
HtmlBuilder.prototype.buildDescription = function(item)
{
//dodal target, Boris 5.5.2007
	var ret = "<a class='description' href='" + item.link + "' target='main'>" + item.description + "</a>";
	return ret;	
};
 
function closeWidget(id){	
	var widgets=document.getElementById('marqueeHeader');
	 var node=document.getElementById(id);
//	if (node.attributes['type'].value=="rss")	//remove feed from RSSManager list
//		rssManager.removeFeed(id.substring(id.indexOf('_')+1,id.length));
	widgets.removeChild(node);
}

