var msgbox = {
	buttons: new Array(),
	setWidth: '50%',

	addButton: function(title, onclick, href)
	{
		var array = new Array();
		array.push(title);
		array.push(onclick);
		array.push(href);
		this.buttons.push(array);
	},
	
	setUserWidth: function(userWidth)
	{
		this.setWidth = userWidth ;
	},

	show: function(json)
	{
		json = eval(json);
		if (json.title == null)
		{
			json.title = '';
		}
		var html = '';
		html += '<div class="msgbox">';
			html += '<div class="head">'+json.title+'</div>';
			html += '<div class="content';
			if (json.alert == true)
			{
				html += ' alert';
			}
			html += '">';
			html += json.text;
			html += '</div>';
			html += this.getButtonsHtml();
		html += '</div>';
		$.fn.colorbox({initialWidth: 0, initialHeight: 0, width: this.setWidth, html:html});
		this.buttons = new Array();
	},

	getButtonsHtml: function()
	{
		var result = '<div class="buttons"><div class="error" style="margin: 0; padding:0">';
		for (var i in this.buttons){
			var elem = this.buttons[i];
			if (typeof elem == 'object')
			{
				var title = elem[0];
				var onclick = elem[1];
				var href = elem[2];

				if (href == null)
				{
					href = 'javascript: void(0);';
				}
				result += "<a href='"+href+"' onclick='"+onclick+"' class='buttonV1'><b>"+title+"</b></a>";
			}
			else
			{
				break;
			}
		}
		result += '</div><div class="clear"></div></div>';
		return result;
	},

	close: function()
	{
		$.fn.colorbox.close();
	}
};