var loadstatustext = '<span style="color:#FFFFFF;"> Cargando...</span>';

$(document).ready(function () {
  cM('#menu', '#btnm_1', '#contenido', 'GET', './includes/index.tpl.html', '');
});

function cPg(met, url, id_p, pars){
	var obj = $(id_p);

	$.ajax({
		type: met,
		url: url,
		data: pars,
		success: function(html){
			obj.html(html);
		}
	});
} // end of the 'cPg(id_p, met, url, pars)' function

function cM(menu, id_i, id_p, met, url, pars){
	var obj = $(id_p);
	obj.html(''+loadstatustext+'');
	
	if(id_i != '') mM(menu, id_i);
	obj.load(url);
} // end of the 'cM(menu, id_i, id_p, met, url, pars)' function

function mM(menu, id_i){
	var id_i = id_i;
	var aItems = $(menu + " .imenu");
	var nrobtn = aItems.length;
	var pref = "#btnm_";
	var prefo = "#o_";
	var prefd = "#d_";
	var j = id_i.charAt(id_i.length-1);
	
	for(var i=1; i<=nrobtn; i++){
		if(('btnm_' + i  + '') != id_i){
			var btn = $(pref + i);
			btn.removeClass('menus');
			btn.addClass('linksm');
			var vo = prefo+i;
			var vd = prefd+i;
			$(vo).hide();
			$(vd).hide();
		}
	}

	btnA = $(id_i);
	btnA.removeClass('linksm');
	btnA.addClass('menus');
	var prefod = '#o_'+j+'';
	var prefdd = '#d_'+j+'';
	$(prefod).show();
	$(prefdd).show();
} // end of the 'mM(menu, id_i)' function

function oW(urpi_root_path, width, height){
	window.open(urpi_root_path,'','width='+width+',height='+height+',left=150,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,fullscreen=no');
} // end of the 'oW(urpi_root_path, width, height)' function

function clearMsg(obj) {
	var obj = $(obj);
	obj.html('');
} // end of the 'clearMsg(obj)' function