function $()
{
	argument = arguments[0];
	if (document.layers) { // Netscape
		return document.layers[argument];
	} else if ($) { // Netscape 6 && IE
		return document.getElementById(argument);
	}
}


function cleanCombo(sField) 
{
	if (!sField) return false;
	$(sField).options.length = 0;
}


function createOption(objCombo, optValue, optText)
{
	newOption = document.createElement('option');
	newText = document.createTextNode(optValue);
	newOption.setAttribute('value', optText);
	newOption.appendChild(newText);
	objCombo.appendChild(newOption);
}


function addToComboJSON(jsonArray, comboId, keyName, valueName) 
{
	objCombo = $(comboId);
	if (objCombo && jsonArray.length) 
	{
		cleanCombo(comboId, 1);
		objCombo.options[0] = new Option('Selecione uma Categoria', '0');

		for(var i = 0 ; i < jsonArray.length; i++) 
		{
			createOption(objCombo, ajaxDecode(jsonArray[i][valueName]), jsonArray[i][keyName]);
		}
	}
}