var req;


window.addEvent('domready', function() {
	
	var path = '';
	
	req = new Request.HTML({method: 'get',url:path+'index.php', 
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
			$('form_bmi').set('text', '');
			//Inject the new DOM elements into the results div.
			$('form_bmi').adopt(html);
			//$('glossary_content').setStyle('visibility', 'visible');
			if ($('berechnen')) {
			$('berechnen').addEvent('click', function(){
				if ($('groesse').get('value') > 0 && $('gewicht').get('value') > 0) req.send('eID=user_glossary_ajax&view=0&groesse=' + $('groesse').get('value') + '&gewicht=' + $('gewicht').get('value'));
				else {
					alert("Bitte geben Sie ein Gewicht und eine Größe an!");
				}
			});
			}
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('form_bmi').set('text', 'The request failed.');
		}
	});
	//alert(index + " = " + item.get('text'));
	$('berechnen').addEvent('click', function(){
			if ($('groesse').get('value') > 0 && $('gewicht').get('value') > 0) req.send('eID=user_glossary_ajax&view=0&groesse=' + $('groesse').get('value') + '&gewicht=' + $('gewicht').get('value'));
			else {
				alert("Bitte geben Sie ein Gewicht (in kg) und eine Größe (in cm) an!");
			}
	});

	

});

function show_form() {
	req.send('eID=user_glossary_ajax&view=1');
}
