// WebBrowser specific code
function verifyCreated(id) {
	var div = document.getElementById('div' + id);
	if (div == null) {
		div = document.createElement('div');
		div.setAttribute('id', 'div' + id);
		div.style.position = 'absolute';
		div.style.visibility = 'hidden';
		div.style.overflow = 'hidden';
		var body = document.getElementsByTagName("body")[0];
		body.appendChild(div);
	}
	var iframe = document.getElementById('iframe' + id);
	if (iframe == null) {
		iframe = document.createElement('iframe');
		iframe.setAttribute('id', 'iframe' + id)
		iframe.style.position = 'relative';
		iframe.style.backgroundColor = 'white';
		iframe.style.borderStyle = 'none';
		iframe.setAttribute('frameborder', '0');
		div.appendChild(iframe);
	}
	return iframe;
}

function updateBrowser(id, x, y, width, height, clipX, clipY, clipWidth, clipHeight) {
	if ((width <= 0) || (height <= 0)) {
		hideBrowser(id);
		return;
	}
	var iframe = verifyCreated(id);
	iframe.style.left = -clipX;
	iframe.style.top = -clipY;
	iframe.style.width = width;
	iframe.style.height = height;
	iframe.style.display = '';
	
	var flash = document.getElementById('imirus');
	
	var div = document.getElementById('div' + id);
	div.style.left = x + clipX;
	div.style.top = y + clipY + flash.offsetTop;;
	div.style.width = clipWidth;
	div.style.height = clipHeight;
	div.style.visibility = 'visible';
	div.style.display = '';
}

function loadURL(id, url) {
	var iframe = verifyCreated(id);
	iframe.src = url;
}

function hideBrowser(id) {
	//var iframe = document.getElementById('iframe' + id);
	//iframe.style.visibility = 'hidden';
	//iframe.style.display = 'none';
	
	var div = document.getElementById('div' + id);
	div.style.visibility = 'hidden';
	div.style.display = 'none';
}
