/* Static variables */

//var avoidElements = new Array('head','foot'); // <- example
var avoidElements = new Array();

/* End static variables */



/* Standard framework function to give mCCWrapper the remaining window height if avoidElements is defined */

function autosize_mCCWrapper()
{
	try 
	{ 
		var offsetHeight = 0;
		var windowHeight = window.getSize().y;
		Array.each(avoidElements,function(el,i)
		{
			offsetHeight += $(el).getSize().y;
		});
		var totalElementHeight = offsetHeight + $('mCC').getSize().y;
		if(totalElementHeight < windowHeight)
		{
			var newHeight = windowHeight - offsetHeight;
			$('mCCWrapper').setStyle('height', newHeight+'px');
		}
	} 
	catch (e){ }
}

/* Standard framework function to maximize mCCWrapper to full window height and centering mCC horizontaly within it. */

function center_center(CC,C)
{
	try 
	{
		var objType = 'element';
		if(typeOf($('head'))==objType) $('head').setStyle('display','none');
		if(typeOf($('foot'))==objType) $('foot').setStyle('display','none');
		if(typeOf(CC)==objType && typeOf(C)==objType)
		{
			var windowHeight = window.getSize().y;
			var space = (windowHeight-C.getSize().y)/2;
			var newHeight = windowHeight - space;
			CC.setStyle('padding-top',space+'px');
			CC.setStyle('height',newHeight+'px');
		}
	} 
	catch (e){ }
}


/* [Beta] Standard framework function to remove backgrounds from previous child, used in li menus */

function removeBackgroundOnPreviousChild(el)
{
	try 
	{
		var previous = el.getFirst().get('rel') - 1;
		if(previous>0)
		{
			var ul = $('nav').getChildren();
			ul[previous-1].getFirst().setStyle('background','none');
		}
	}
	catch (e){ }
}


/* Standard framework function to make columns with same classname the same height as the highest one */

function makeSameHeight(elements)
{
	try 
	{
		var heighest = 0;
		Array.each(elements,function(el,i)
		{
			heighest = (el.getSize().y>heighest ? el.getSize().y : heighest);
		});
		Array.each(elements,function(el,i)
		{
			el.setStyle('height',heighest+'px');
		});
	}
	catch (e) {}
}

/* [Beta] Function to give style .last on last li-element in all uls  */

function markLastLis()
{
	try 
	{
		var uls = $$('ul,ol');
		Array.each(uls,function(el,i)
		{
			lis = el.getChildren('li');
			lis[lis.length-1].addClass('last');	
		});
	}
	catch(e){}
}


/* [Beta] Function to center element within its parent */

function centerElement(el)
{
	try
	{
		var parent = el.getParent('div');
		var width = el.getSize().x;
		var widthParent = parent.getSize().x;
		var padding = Math.floor((widthParent - width) / 2);
		var newWidthParent = widthParent - (padding*2);
		el.setStyles(
		{
			'width':width+'px'
		});	
		parent.setStyles(
		{
			'padding-left':padding+'px',
			'padding-right':padding+'px',
			'width': newWidthParent+'px'
		});
	}
	catch(e){}
}

/* Mootools 1.2 legacy function - to support deprecated $chk() */

var $chk = function(obj){
	return !!(obj || obj === 0);
};

