$(function(){	
	/*
	* @description		Grid maker
	* @param			DOM element
	* @returns			Draw background-image
	*/
	grid = function( element ) {
		$('div').css('background','none');
		$(element).addClass('grid');
	}
});

/*
* @description		PX to EM calculator
* @param			desired pixel value
* @returns			Alert window with EM value to use and inherited font-size, rounded to 3 decimal places
*/
$.fn.extend({
	px: function( pixel ) {
		var em = parseFloat(this.css('font-size'));
		var lh = parseFloat(this.css('line-height'));
		var final_em = ( 1 / em ) * pixel;
		var round_em = Math.round( Math.round( final_em * Math.pow( 10, 3 + 1 ) ) / Math.pow( 10, 1 ) ) / Math.pow(10,3);
		alert( 'For ' + pixel + 'px use ' + round_em + 'em.\nInherited font-size is ' + em + 'em.\nInherited line-height is ' + lh + '.');
	}
});


/*
* @description		Contents menu
* @param			DOM element
* @returns			list
*/
$.fn.contentMenu = function(o){
	o = $.extend({
		"head"		: "",
		"beforeLink": "",
		"divID"		: "navegacao_local",
		"aClass"	: "inPage",
		"insertMethod"	: "before",
		"insertTarget"	: this.eq(0) }, o || {});
	$.cm = ($.cm) ? $.cm : [];
	var $list = $("<p></p>"),
		lastInd = this.length-1,
		lis = '',
		s = $.cm.length,
		menu = $.cm[s] = $('<div id="'+o.divID+'"></div>').append(o.head,$list);
		menu[0].serial = s;
	o.insertTarget[o.insertMethod](menu);
	return this.each(function(i){
		this.id = this.id || "menu"+s+"-el"+i;
		lis += ' <a href="#'+this.id+'" class="'+o.aClass+'">'+$(this).text()+'</a>';
		if (i==lastInd){ $list.append(lis); }
	});
};