/*******************************************************************************/
/* Required:      prototype                                                    */
/* Usage example: leftInContainer(['tag_id_1','tag_id_2'],$('container1'),10)  */
/* Effect:        align elements with id 'tag_id_1' and 'tag_id_2' to the left */
/*                into element with id 'container1' with left offset 10px.     */
/*******************************************************************************/

function leftInContainer(aElements,oContainer,iOffset) {
	var iAccumulatedWidth = 0;
	for(var i=0;i<aElements.length;i++)	{
		$(aElements[i]).setStyle({left:(iOffset+iAccumulatedWidth)+'px'});
		iAccumulatedWidth += $(aElements[i]).getWidth();
	}
}

function rightInContainer(aElements,oContainer,iOffset) {
	var iAccumulatedWidth = 0;
	for(var i=0;i<aElements.length;i++)	{
		iAccumulatedWidth += $(aElements[i]).getWidth();
		$(aElements[i]).setStyle({left:$(oContainer).getWidth()-iAccumulatedWidth-iOffset+'px'});
	}
}

function horitzontalCenterInContainer(aElements,oContainer) {
	var iAccumulatedWidth = 0;
	var iInitialLeft = 0;
	for(var i=0;i<aElements.length;i++)	{
		iAccumulatedWidth += $(aElements[i]).getWidth();
	}
	iInitialLeft = ($(oContainer).getWidth()/2)-(iAccumulatedWidth/2);
	iAccumulatedWidth = 0;
	for(var i=0;i<aElements.length;i++)	{
		$(aElements[i]).setStyle({left:(iInitialLeft+iAccumulatedWidth)+'px'});
		iAccumulatedWidth += $(aElements[i]).getWidth();
	}
}

function topInContainer(aElements,oContainer,iOffset) {
	var iAccumulatedHeight = 0;
	for(var i=0;i<aElements.length;i++)	{
		$(aElements[i]).setStyle({top:(iAccumulatedHeight+iOffset)+'px'});
		iAccumulatedHeight += $(aElements[i]).getHeight();
	}
}

function bottomInContainer(aElements,oContainer,iOffset) {
	var iAccumulatedHeight = 0;
	for(var i=0;i<aElements.length;i++)	{
		iAccumulatedHeight += $(aElements[i]).getHeight();
		$(aElements[i]).setStyle({top:$(oContainer).getHeight()-iAccumulatedHeight-iOffset+'px'});
	}
}

function verticalCenterInContainer(aElements,oContainer) {
	var iAccumulatedHeight = 0;
	var iInitialLeft = 0;
	for(var i=0;i<aElements.length;i++)	{
		iAccumulatedHeight += $(aElements[i]).getHeight();
	}
	iInitialLeft = ($(oContainer).getHeight()/2)-(iAccumulatedHeight/2);
	iAccumulatedHeight = 0;
	for(var i=0;i<aElements.length;i++)	{
		$(aElements[i]).setStyle({top:(iInitialLeft+iAccumulatedHeight)+'px'});
		iAccumulatedHeight += $(aElements[i]).getHeight();
	}
}

