/*
Global Layer Functions
- _findLayer
- _getLayerWidth
- _setLayerWidth
- _getLayerXPos
- _setLayerXPos
- _getLayerHeight
- _setLayerHeight
- _getLayerYPos
- _setLayerYPos
- _getLayerAttribute
- _setLayerAttribute 
- _setLayerVisible
- _setLayerbgcolor
- _setLayerContent
*/
var timer;

function _findLayer(id,doc)
{
	if(id && id != null)
	{
		if(!doc || doc == null)
		{
			doc = document;
		}
		if(doc.all)
		{
			node = doc.all[id];
		}
		else if(doc.getElementById)
		{
			node = doc.getElementById(id);
		}
		else if(doc.layers)
		{
			node = doc.layers[id];
			for(var i=0; !node && i < doc.layers.length; i++)
			{
				node = _findLayer(id,doc.layers[i].document);
			}   
		}
		return node;
	}
	return null;
}

function _getLayerWidth(obj)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(obj != null)
	{
		if(document.layers)
		{
			return obj.clip.width;
		}
		else
		{
			return obj.offsetWidth;
		}
	}
	return null;
}

function _setLayerWidth(obj,px)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(obj != null)
	{
		if(document.layers)
		{
			obj.clip.width = px;
			return obj.clip.width;
		}
		else
		{
			obj.style.width = px;
			return obj.style.width;
		}
	}
	return null;
}

function _getLayerXPos(obj)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(obj != null)
	{
		if(document.layers)
		{
			return obj.left;
		}
		else
		{
			return obj.offsetLeft;
		}
	}
	return null;
}

function _setLayerXPos(obj,px)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(obj != null)
	{
		if(document.layers)
		{
			obj.left = px;
			return obj.left;
		}
		else
		{
			obj.style.left = px;
			return obj.style.left;
		}
	}
	return null;
}

function _getLayerHeight(obj)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(obj != null)
	{
		if(document.layers)
		{
			return obj.clip.height;
		}
		else
		{
			return obj.offsetHeight;
		}
	}
	return null;
}

function _setLayerHeight(obj,px)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(obj != null)
	{
		if(document.layers)
		{
			obj.clip.height = px;
			return obj.clip.height;
		}
		else
		{
			obj.offsetHeight = px;
			return obj.style.height;
		}
	}
	return null;
}

function _getLayerYPos(obj)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(obj != null)
	{
		if(document.layers)
		{
			return obj.top;
		}
		else
		{
			return obj.offsetTop;
		}
	}
	return null;
}

function _setLayerYPos(obj,px)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(obj != null)
	{
		if(document.layers)
		{
			obj.top = px;
			return obj.top;
		}
		else
		{
			obj.style.top = px;
			return obj.style.top;
		}
	}
	return null;
}

function _getLayerAttribute(obj,attribute)
{
	var ret = null;
	if(!obj || !attribute || obj == null || attribute == null)
	{
		return;
	}
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	if(document.layers)
	{
		eval("ret = obj." + attribute + ";");
	}
	else
	{
		eval("ret = obj.style." + attribute + ";");
	} 
	return ret;
}

function _setLayerAttribute(obj,attribute,value)
{
	/*
	Possible Attributes: zIndex;
	*/
	if(!obj || !attribute || !value || obj == null || attribute == null || value == null)
	{
		return;
	}
	if(typeof(obj) == "string")
	{
		obj = findLayer(obj); 
	}
	if(document.layers)
	{
		if(isNaN(value) == true)
		{
			eval("obj." + attribute + " = '" + value + "'");
		}
		else
		{
			eval("obj." + attribute + " = " + value);
		}
	}
	else
	{
		if(isNaN(value) == true)
		{
			eval("obj.style." + attribute + " = '" + value + "'" );
		}
		else
		{
			eval("obj.style." + attribute + " = " + value);
		}
	} 
	return null;
}

function _setLayerVisible(obj,value)
{
	if(value && (value == "show" || value == "visible" || value == 1 || value == true))
	{
		if(document.layers)
		{	
			value = 'show';
		}
		else
		{
			value = 'visible';
		}
	}
	else
 	{
		if(document.layers)
		{
			value = 'hide';
		}
		else
		{
			value = 'hidden';
		}
	}
	_setLayerAttribute(obj,'visibility',value);
	return;
}

function _setLayerbgcolor(obj,color)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	else
	{
		obj = obj;
	}
	if(document.all || document.getElementById)
	{
		obj.style.background18 = color;
	}
	if(document.layers)
	{
		obj.bgcolor = color;
	}
	return;
}

function _setLayerContent(obj,value)
{
	if(typeof(obj) == "string")
	{
		obj = _findLayer(obj);
	}
	else
	{
		obj = obj;
	}
	if(!obj == null || value == null)
	{
		window.status = "No object or value found to write!";
		return;
	}
	if(document.all || document.getElementById)
	{
		obj.innerHTML = value;
	}
	else
	{
		obj.document.open();
		obj.document.write(value);
		obj.document.close();
	}
	return;
}