/**
 * This script defines HTML utility functions.
 * Dependencies: Platform.js
 */



function GetHTMLObjectById(id) {
    if (_docByID) return document.getElementById(id);
    else if (_docAll) return document.all[id];
    else alert("Browser not supported at this time.");
}

function GetHTMLObjectPosition(obj) {
	var pt = {x:0, y:0, w:0, h:0};

	if (obj != null) {
		pt.w = obj.offsetWidth;
		pt.h = obj.offsetHeight;

		while (obj != null) {
			pt.x += obj.offsetLeft;
			pt.y += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}

	return pt;
}

function SetHTMLObjectPosition(obj, x, y, w, h) {
	obj.style.left = "" + x + "px";
	obj.style.top = "" + y + "px";

	if (w > 0) obj.style.width = "" + w + "px";
	if (h > 0) obj.style.height = "" + h + "px";
}

function SetHTMLObjectVisibility(obj, vis) {
	if (!vis) obj.style.visibility = 'hidden';
	else obj.style.visibility = 'visible';
}

function SetHTMLObjectExistence(obj, exists) {
	if (exists) obj.style.display = '';
	else obj.style.display = 'none';
}

function SetHTMLObjectExistenceDIV(obj, exists) {
	if (exists && _docAll) obj.style.display = '';
	else if (exists) obj.style.display = 'table-cell';
	else obj.style.display = 'none';
}

function HTMLObjectExists(obj) {
	return (obj.style.display == 'none') ? false : true;
}

function ToggleHTMLObjectExistence(obj) {
	if (!HTMLObjectExists(obj)) obj.style.display = '';
	else obj.style.display = 'none';
}
