// on load

$(document).ready(function(){
						   
	popup_flash();
	
})

// auto flash popup

function popup_flash()
{
	$('a.popup_flash').click(function(){
		var title = this.title.split('|');
		var href = assets_url + 'assets/template/flash.php?source=' + this.href + '&width=' + title[1] + '&height=' + title[2] + '&KeepThis=true&TB_iframe=true&';
		var t = title[0];
		var a = href;
		var g = this.rel || false;
		tb_show(t,a,g);
		this.blur();
		return false;			
	})
	//tb_init('a.popup_flash');	
}

// calc bmi index

function get_bmi(bucket_id)
{
	var cm = parseFloat($('#'+bucket_id+' .cm').val());
	var kg = parseFloat($('#'+bucket_id+' .kg').val());
	
	if(cm>0 && kg>0)
	{
		hm2 = cm/100 * cm/100;
		bmi = Math.floor(kg/hm2);
		rem = Math.round((kg/hm2 - bmi) * 10);
		if(bmi < 99)
		{
			var notes = '';
			if(bmi>30)
				notes = 'significant potential for medical implication';
			else if(bmi<30 && bmi>=25)
				notes = 'overweight';
			else if(bmi<25 && bmi>=18.5)
				notes = 'normal';
			else 
				notes = 'underweight';
				
			bmi += '<span>.'+rem+'</span>';
			
			$('#'+bucket_id+' .index').html(bmi);
			$('#'+bucket_id+' .notes').html(notes);	
			
		}
		else
			$('#'+bucket_id+' .index').html('--<span></span>');
	}
}




