var tdvfif_ContainerId = "tdvfifContainer";
var tdvfif_UniqueId = 0;

function tdvfif_init()
{
	document.write("<div id='" + tdvfif_ContainerId + "' style='relative'></div>");
}

function tdvfif_getContainer()
{
	return document.getElementById(tdvfif_ContainerId);
}

function tdvfif_getDivId(id)
{
	return "tdvfif_div" + id;
}

function tdvfif_getDiv(id)
{
	return document.getElementById(tdvfif_getDivId(id));
}

function tdvfif_getIFrameId(id)
{
	return "tdvfif_iframe" + id;
}

function tdvfif_getIFrame(id)
{
	return document.getElementById(tdvfif_getIFrameId(id));
}

//Devuelve el identificador del iframe
function tdvfif_add()
{	
	var id = tdvfif_UniqueId;
	tdvfif_UniqueId++;	
	
	var div = document.createElement('div');
	div.setAttribute('id', tdvfif_getDivId(id));
	div.style.position = "absolute";
	div.style.backgroundColor = "transparent";
	div.style.border = "0px";
	div.style.visibility = "hidden";
	
	var container = tdvfif_getContainer();
	container.appendChild(div);	
	
	return id	
}

function tdvfif_remove(id)
{	
	var container = tdvfif_getContainer();
	var div = tdvfif_getDiv(id);
	container.removeChild(div);	
}

function tdvfif_setPosition(id, x, y, w, h) 
{
	var div = tdvfif_getDiv(id);	
	div.style.left = x + 'px';
	div.style.top = y + 'px';
	var iframe = tdvfif_getIFrame(id);	
	iframe.width = w;
	iframe.height = h;
}

function tdvfif_hide(id)
{
	var div = tdvfif_getDiv(id);	
	div.style.visibility = "hidden";
}
	
function tdvfif_show(id, x, y, w, h)
{
	var div = tdvfif_getDiv(id);	
	div.style.visibility = "visible";
	tdvfif_setPosition(id, x, y, w, h) 
}

function tdvfif_load(id, url)
{
	var div = tdvfif_getDiv(id);
	div.innerHTML = "<iframe id='" + tdvfif_getIFrameId(id) +"' src='" + url + "' frameborder='0'></iframe>";	
}

function tdvfif_getURL(id)
{
	var iframe = tdvfif_getIFrame(id);
	return iframe.contentWindow.location.href;
}

tdvfif_init();