/*
 * toodoo JavaScript Library v0.2
 * http://toodoo.ru/
 *
 * Date: 2010-10-04 
 */

var host_url = "http://api.toodoo.ru";

function showWidget(widgetType, blockName, object_id)
{
	if (!object_id)
		return false;

	if (widgetType == "livenet")
		showWidgetLivenet(blockName, object_id, false);

	if (widgetType == "livenet_demo")
		showWidgetLivenet(blockName, object_id, "demo");
	
}

function getURL() 
{
	var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
	getService(Components.interfaces.nsIWindowMediator);
	var recentWindow = wm.getMostRecentWindow("navigator:browser");
	return recentWindow ? recentWindow.content.document.location : null;
}

function showWidgetLivenet(blockName, object_id, mode)
{
	var blockId = document.getElementById(blockName);
	
	blockId.style.width = '180px';
	blockId.style.height = '400px';	
//	blockId.style.border = '1px solid';	
	
	var frm = document.createElement("iframe");
	frm.setAttribute('id', 'toodoo_iframe');
	
	
	if(mode == "demo")
		frm.setAttribute('src', host_url + '/widget/livenet_demo/' + object_id);
	else
		frm.setAttribute('src', host_url + '/widget/livenet/' + object_id + '/' + window.location);

	frm.setAttribute("width", "100%");
	frm.setAttribute("height", "100%");
	frm.setAttribute("frameborder", "0");
	frm.setAttribute("scrolling", "no");
	
	frm.style.overflow = "hidden";
	
	blockId.appendChild(frm);
}
