﻿<!--
/*
	By:				Johnny Tran
	Date Created:	10/11/2007

	Usage:
		var domObj = AV.Util.Dom.getControl('targetControlId');
		var domStyleObj = AV.Util.Dom.getStyleObject('targetControlId');

		document.write(domObj.value);
		document.write(domStyleObj.color);
		document.write(AV.Util.Dom.getStyle('targetControlId', 'color'));

		domObj.value = 'Hello World';
		domStyleObj.color = '#000000';
		AV.Util.Dom.setStyle('targetControlId', 'color', '#000000');
*/
if (AV == null || typeof(AV) != "object") { var AV = new Object(); }
if (AV.Util == null || typeof(AV.Util) != "object") { AV.Util = new Object(); }

AV.Util.Dom = {

	privateVar		: new function()
	{
	},

	Hide		: function(targetControl)
	{
		targetControl.style.display = 'none';
	},

	ControlX : function(targetControl)
	{
		var curLeft = document.documentElement.scrollLeft;

		if (targetControl.offsetParent)
		{
			curLeft = targetControl.offsetLeft

			while (targetControl = targetControl.offsetParent)
				curLeft += targetControl.offsetLeft
		}

		return curLeft;
	},

	ControlY : function(targetControl)
	{
		var curTop = document.documentElement.scrollTop;

		if (targetControl.offsetParent)
		{
			curTop = targetControl.offsetTop

			while (targetControl = targetControl.offsetParent)
				curTop += targetControl.offsetTop
		}

		return curTop;
	},

	Show		: function(targetControl)
	{
		targetControl.style.display	= 'block';
	},

	// Cross-Browser DomObj
	getControl		: function(targetControlId)
	{
		if (document.getElementById)
			return document.getElementById(targetControlId);
		else if (document.all)
			return document.all[targetControlId];
		else if (document.layers)
			return document.layers[targetControlId];

		return;
	},

	// Cross-Browser DomStyleObj
	getStyleObject	: function(targetControlId)
	{
		return this.getControl(targetControlId).style;
	},

	getStyle	: function(targetControlId, property) { return this.getStyleObject(targetControlId)[property]; },
	setStyle	: function(targetControlId, property, value) { this.getStyleObject(targetControlId)[property] = value; }
}
// -->

