/*=================================================================================================
To get the DOM node's position relative to document
=================================================================================================*/
function pos_(node)
{
	var thepos = new Object();
	thepos.x=0;
	thepos.y=0;
	var obj=node;
	while(obj) 
	{
		thepos.x+=parseInt(obj.offsetLeft);
		thepos.y+=parseInt(obj.offsetTop);
		obj=obj.offsetParent;
	}
	return thepos;
};
//The End

/*=================================================================================================
To get the DOM node's margin border padding
=================================================================================================*/
function margin_(node)
{
	node = (typeof node == "string") ? document.getElementById(node) : node ;
	var margin=new Object();
	if(window.getComputedStyle)
	{
		margin.left=parseInt(window.getComputedStyle(node,null).marginLeft) || 0;
		margin.right=parseInt(window.getComputedStyle(node,null).marginRight) || 0;
		margin.top=parseInt(window.getComputedStyle(node,null).marginTop) || 0;
		margin.bottom=parseInt(window.getComputedStyle(node,null).marginBottom) || 0;
	}
	else if(node.currentStyle)
	{
		margin.left=(node.currentStyle.marginLeft.indexOf("%") != -1) ? (parseInt(node.currentStyle.marginLeft)/100*parseInt(node.parentNode.offsetWidth)) : (parseInt(node.currentStyle.marginLeft) || 0);
		margin.right=(node.currentStyle.marginRight.indexOf("%") != -1) ? (parseInt(node.currentStyle.marginRight)/100*parseInt(node.parentNode.offsetWidth)) : (parseInt(node.currentStyle.marginRight) || 0);
		margin.top=(node.currentStyle.marginTop.indexOf("%") != -1) ? (parseInt(node.currentStyle.marginTop)/100*parseInt(node.parentNode.offsetHeight)) : (parseInt(node.currentStyle.marginTop) || 0);
		margin.bottom=(node.currentStyle.marginBottom.indexOf("%") != -1) ? (parseInt(node.currentStyle.marginBottom)/100*parseInt(node.parentNode.offsetHeight)) : (parseInt(node.currentStyle.marginBottom) || 0);
	}
	else
	{
		alert('the function pos_ will not work correctly!');	
	}
	margin.X=margin.left+margin.right;
	margin.Y=margin.top+margin.bottom;
	return margin;
}

function border_(node)
{
	node = (typeof node == "string") ? document.getElementById(node) : node ;
	var border=new Object();
	if(window.getComputedStyle)
	{
		border.left=parseInt(window.getComputedStyle(node,null).borderLeftWidth) || 0;
		border.right=parseInt(window.getComputedStyle(node,null).borderRightWidth) || 0;
		border.top=parseInt(window.getComputedStyle(node,null).borderTopWidth) || 0;
		border.bottom=parseInt(window.getComputedStyle(node,null).borderTopWidth) || 0;
	}
	else if(node.currentStyle)
	{
		border.left=(node.currentStyle.borderLeftWidth.indexOf("%") != -1) ? (parseInt(node.currentStyle.borderLeftWidth)/100*parseInt(node.parentNode.offsetWidth)) : (parseInt(node.currentStyle.borderLeftWidth) || 0);
		border.right=(node.currentStyle.borderRightWidth.indexOf("%") != -1) ? (parseInt(node.currentStyle.borderRightWidth)/100*parseInt(node.parentNode.offsetWidth)) : (parseInt(node.currentStyle.borderRightWidth) || 0);
		border.top=(node.currentStyle.borderTopWidth.indexOf("%") != -1) ? (parseInt(node.currentStyle.borderTopWidth)/100*parseInt(node.parentNode.offsetHeight)) : (parseInt(node.currentStyle.borderTopWidth) || 0);
		border.bottom=(node.currentStyle.borderBottomWidth.indexOf("%") != -1) ? (parseInt(node.currentStyle.borderTopWidth)/100*parseInt(node.parentNode.offsetHeight)) : (parseInt(node.currentStyle.borderBottomWidth) || 0);
	}
	else
	{
		alert('the function pos_ will not work correctly!');	
	}
	border.X=border.left+border.right;
	border.Y=border.top+border.bottom;
	return border;
}

function padding_(node)
{
	node = (typeof node == "string") ? document.getElementById(node) : node ;
	var padding=new Object();
	if(window.getComputedStyle)
	{
		padding.left=parseInt(window.getComputedStyle(node,null).paddingLeft) || 0;
		padding.right=parseInt(window.getComputedStyle(node,null).paddingRight) || 0;
		padding.top=parseInt(window.getComputedStyle(node,null).gpaddingTop) || 0;
		padding.bottom=parseInt(window.getComputedStyle(node,null).paddingBottom) || 0;
	}
	else if(node.currentStyle)
	{
		padding.left=(node.currentStyle.paddingLeft.indexOf("%") != -1) ? (parseInt(node.currentStyle.paddingLeft)/100*parseInt(node.parentNode.offsetWidth)) : (parseInt(node.currentStyle.paddingLeft) || 0);
		padding.right=(node.currentStyle.paddingRight.indexOf("%") != -1) ? (parseInt(node.currentStyle.paddingRight)/100*parseInt(node.parentNode.offsetWidth)) : (parseInt(node.currentStyle.paddingRight) || 0);
		padding.top=(node.currentStyle.paddingTop.indexOf("%") != -1) ? (parseInt(node.currentStyle.paddingTop)/100*parseInt(node.parentNode.offsetHeight)) : (parseInt(node.currentStyle.paddingTop) || 0);
		padding.bottom=(node.currentStyle.paddingBottom.indexOf("%") != -1) ? (parseInt(node.currentStyle.paddingBottom)/100*parseInt(node.parentNode.offsetHeight)) : (parseInt(node.currentStyle.paddingBottom) || 0);
	}
	else
	{
		alert('the function pos_ will not work correctly!');	
	}
	padding.X=padding.left+padding.right;
	padding.Y=padding.top+padding.bottom;
	return padding;
}
//The End

function setOpacity_(node,opacity)
{
	node = (typeof node == "string") ? document.getElementById(node) : node ;
	if(browser.opera) node.style.opacity = (opacity/100); 
	if(browser.mozilla) node.style.MozOpacity = (opacity/100); 
	if(browser.safari) node.style.KhtmlOpacity = (opacity/100); 
	if(browser.msie) node.style.filter = "alpha(opacity="+opacity+")";	
}