this.width = 530;
this.height = 400;

function kalorias(peso) {
	var actividad = $('actividades').value.split(','); // 7 calorias
	var duracion = $('duracion').value * 1; // minutos

	// kgs a lbs
	peso = peso * 2.205
	calories = (Math.round(peso * duracion * actividad[1]));
	$('calorias').value = calories;
}
function cargar(seccion) {

	if ($('message'))
	{
		$('message').dispose();
	}
	/*$('contenido').innerHTML = "<img src='/theme/images/loading.gif' /> Cargando ...";*/
	
	window.location.hash = seccion;
		
	$('locationhash').setProperty('name', seccion);
 	$('contenido').load('/'+seccion);
}
function loading(div)
{
	$(div).setStyle('display','none');
	var div2 = new Element('div').inject(div, 'after');	
	div2.innerHTML = "<img src='/theme/images/loading.gif' /> Espere por favor ...";
}
function sel(id, tipo)
{
		$('ticker').setProperty('src','/gadgets/tickers_imagen?update='+id+'&tipo='+tipo);	
		$('fb-modal').fade('out');	
}
function enviar_calorias()
	{		
    var value = $('q').value;
    value = value = value.replace(' ','-'); // replace       	       
    window.location.href = '/calorias/alimentos/'+escape(value);
 return false;
}
function msg(txt)
{
	if ($('msg'))
	{
		$('msg').dispose();
	}
	tipo = 'notice floating2';
	txt = JSON.decode(txt);
	if (txt.valido)
	{
		tipo = 'success floating';
	}

	var div = new Element('div')
	.setProperty('id','msg')
	.addClass(tipo)
	.inject('contenido','before')
	.fade ( 'in' )	
				
	var h1 = new Element('h5')
	.inject(div);
	h1.innerHTML = txt.titulo;
	
	var p = new Element('p')
	.inject(div);
	p.innerHTML = txt.mensaje;
	
	
	(function(){ div.fade('out');}).delay(3000);
	(function(){ div.dispose();}).delay(4000);
	
	refresh();
	
}
function refresh()
{
	if ($('seccion_peso'))
	{
		stats_peso(this.limit, this.order,this.peso_deseado, this.order);
	}
	if ($('seccion_ejercicios'))
	{
		stats_ejercicios(this.limit, this.order);
	}
	if ($('seccion_calorias'))
	{
		stats_calorias(this.limit, this.order);
	}
}
function enviar_form(f)
{	
	$(f).set('send',{onComplete:function(response){
         msg(response);
     }
	}).send();        
}
function stats_ejercicios (limit, order)
{	
	// <![CDATA[		
	var so = new SWFObject("/theme/flash/amline/amline.swf", "amline", this.width,this.height, "8", "#FFFFFF");
	so.addVariable("path", "/theme/flash/");
	so.addVariable("settings_file", encodeURIComponent("tmp/xml/actividades.php"));                // you can set two or more different settings files here (separated by commas)
	so.addVariable("data_file", encodeURIComponent("/stats/actividades?limit="+ limit +"&order="+order));
	so.addParam("wmode", "opaque");
	
	so.write("flashcontent");
	// ]]>
	this.limit = limit;
	this.order = order;
}
function stats_calorias (limit, order)
{

	// <![CDATA[		
	var so = new SWFObject("/theme/flash/amline/amline.swf", "amline",  this.width,this.height, "8", "#FFFFFF");
	so.addVariable("path", "/theme/flash/");
	so.addVariable("settings_file", encodeURIComponent("tmp/xml/calorias.php"));                // you can set two or more different settings files here (separated by commas)
	so.addVariable("data_file", encodeURIComponent("/stats/calorias?limit="+ limit +"&order="+order));
	so.addParam("wmode", "opaque");
	
	so.write("flashcontent");
	// ]]>
	this.limit = limit;
	this.order = order;
}
function stats_peso (limit, order, peso_deseado, medida)
{	
	// <![CDATA[		
	var so = new SWFObject("/theme/flash/amline/amline.swf", "amline",  this.width,this.height, "8", "#FFFFFF");
	so.addVariable("path", "/theme/flash/");
	so.addVariable("settings_file", encodeURIComponent("tmp/xml/peso.php?peso_deseado="+peso_deseado+"&medida="+medida));                // you can set two or more different settings files here (separated by commas)
	so.addVariable("data_file", encodeURIComponent("/stats/peso?limit="+ limit +"&order="+order));
	so.addParam("wmode", "opaque");
	
	so.write("flashcontent");
	// ]]>
	this.peso_deseado = peso_deseado;
	this.limit = limit;
	this.order = order;
	this.medida = medida;
	
}
function stats_medidas (limit, order)
{	
	// <![CDATA[		
	var so = new SWFObject("/theme/flash/amline/amline.swf", "amline",  this.width,this.height, "8", "#FFFFFF");
	so.addVariable("path", "/theme/flash/");
	so.addVariable("settings_file", encodeURIComponent("tmp/xml/medidas.php"));                // you can set two or more different settings files here (separated by commas)
	so.addVariable("data_file", encodeURIComponent("/stats/medidas?limit="+ limit +"&order="+order));
	so.addParam("wmode", "opaque");
	
	so.write("flashcontent");
	// ]]>
	this.peso_deseado = peso_deseado;
	this.limit = limit;
	this.order = order;
	this.medida = medida;
	
}