function callMethod(method, form, param)
	{
		// cere date
		if (method == 'submit')
		{
			var f = $(form);
			
			for ( var i = f.length - 1; i > 0; i-- )
			{
				var f_el = f.elements[i];
				
				if ( f_el.id != param.id ) {
					$('h_'+f_el.id).value = '';
					f_el.parentNode.style.display = 'none';
					f_el.length = 1;
				} else {
					break;
				}
			}

			if (param.options[param.selectedIndex].value == -2) {
				$('comanda').setStyle('display', 'block');
				$('h_'+param.id).value = param.options[param.selectedIndex].text;
			} else if (param.selectedIndex > 0) {
				f.send({onComplete: function (resp) {populateBox(resp, this)}.bind(param)});

				$('comanda').setStyle('display', 'none');
			}

			return false;
		}
		// trimite comanda
		else if (method == 'comanda')
		{
			$(form).send({onComplete: function (resp) {displayMessage(resp)}});

			return false;
		}
	}

function populateBox ( resp, box )
	{
		var f = $('product_list');
		var m = resp.substr(0, 6).toLowerCase();
		
		if (m == 'eroare') {
			alert(resp);
		} else {
			resp = resp.split('||');
			
			if (box.id == 'type') {
				$('h_type').value = box.options[box.selectedIndex].text;
				var next = f.elements[1];

				for (var i = 2; i <= resp.length; i += 2) {
					next.options[i/2] = new Option(resp[i-1],resp[i-2]);
				}

				next.options[i/2] = new Option( ' - Alt producator - ', -2 );
			} else if (box.id == 'producator') {
				$('h_producator').value = box.options[box.selectedIndex].text;
				var next = f.elements[2];

				for (var i = 1; i <= resp.length; i++) {
					next.options[i] = new Option(resp[i-1],resp[i-1]);
				}

				next.options[i] = new Option( ' - Alta imprimanta - ', -2 );
			} else if (box.id == 'printer') {
				$('h_printer').value = box.options[box.selectedIndex].text;
				var next = f.elements[3];

				for (var i = 2; i <= resp.length; i += 2) {
					next.options[i/2] = new Option(resp[i-1],resp[i-2]);
				}

				next.options[i/2] = new Option( ' - Alt cartus - ', -2 );
			} else if (box.id == 'cartus') {
				$('cod_produs').value = box.options[box.selectedIndex].value;
				$('h_cartus').value = box.options[box.selectedIndex].text;
				$('comanda_inner').setHTML(resp);
				$('comanda').setStyle('display', 'block');
			}
			
			if (next) {
				next.getParent().setStyle('display', 'block');
			}
		}
	}


/* afiseaza un mesaj customizat */
/* - in viitor - */
function displayMessage( mes )
	{
		var m = mes.substr(0, 6).toLowerCase();
		
		if ( m == 'eroare' )
		{
			alert(mes);
		}
		else if ( m == 'succes' ) 
		{
			alert(mes);
		}
	}
