function getAttribute(node, attrName)
{
	return node.getAttribute(attrName);
}

function doSetVis(node, group, value)
{
    var groupValue;
    
    groupValue1 = getAttribute(node, "label");
    groupValue2 = getAttribute(node, "id");

	if (groupValue1 == group || groupValue2 == group)
	{
		if (value == "off")
 		{
			node.style.display="none";
	 	}
		else
		{
        	node.style.display="";
		}  
	}
}

function setVis(blockName, value)
{
	var ele, i;
    var spanArray = cbeGetElementsByTagName("SPAN");
    for (i = 0; i < spanArray.length; i++) 
    {  
    	ele = spanArray[i];
        doSetVis(ele, blockName, value);
    }
    var spanArray = cbeGetElementsByTagName("DIV");
    for (i = 0; i < spanArray.length; i++) 
    {  
    	ele = spanArray[i];
        doSetVis(ele, blockName, value);
    }
    spanArray = cbeGetElementsByTagName("P");
    for (i = 0; i < spanArray.length; i++) 
    {  
    	ele = spanArray[i];
        doSetVis(ele, blockName, value);
    }
}

function hidepanels()
{
	setVis("moreblock", "off");
	return true;	
}
	
function showmore(link, block)
{
	link.style.display = "none";
	setVis(block, "on");
	return false;
}

var aPopup;

function hideLayer(l)
{
	if (l != null)
		l.cbe.hide();
	else
	if (aPopup != null)
	{
		aPopup.cbe.hide();
		aPopup = null;
	}
}

function getAbsX(node)
{
	var rv = 0;
	if (node.offsetParent != null)
	{
		rv = node.offsetLeft;
		rv += getAbsX(node.offsetParent);
	}
	else
	{
  		return node.offsetLeft;
	}
	if (rv >= 0)
		return rv;
    else
    	return 0;
}

function getAbsY(node)
{
	var rv = 0;
	if (node.offsetParent != null)
	{
	    rv = node.offsetTop;
		rv += getAbsY(node.offsetParent);
	}
	if (rv >= 0)
		return rv;
    else
    	return 0;
}

function linkClick(l)
{
    var blockName;

  	blockName = getAttribute(l, "BlockName");
   
	var CurElem = cbeGetElementById(blockName);
	if (CurElem)
	{
    	var DivValue = CurElem.innerHTML;
		var TargetBlock = cbeGetElementById("div_popup");
		var adiv = cbeGetElementById("left");
		var cdiv = cbeGetElementById("content");		
		if (TargetBlock)
		{
	 		TargetBlock.innerHTML = DivValue;
	 		TargetBlock.cbe.show();
			aPopup = TargetBlock;
	 		var xx = getAbsX(l);
			//if (is.ie) 
		//		xx += adiv.offsetWidth;
	 		var yy = getAbsY(l)  - TargetBlock.clientHeight - 4;
			if (cdiv != null)
			{
				if (xx + TargetBlock.offsetWidth > cdiv.offsetWidth)
				  xx = cdiv.offsetWidth - TargetBlock.offsetWidth - 6;
				if (xx < 0)
				  xx = 0;
			}
			TargetBlock.cbe.moveTo(xx, yy);
        }
		else
	    	alert("div_popup not found");		
	}
	else
    	alert("Element " + blockName + " not found");
	return true;
}

