function initCategories(marca)
{
    var index = 0;
    selectCategory = document.frmProducts.selCategory;
    
    selectCategory.length = 0;
    selectCategory[0] = new Option ("- Category -", 0);
    
    var cat = categories.split(',');
    for (i=0;i<cat.length;i++)
    {
		var m = cat[i].split('#');
		selectCategory.options[selectCategory.length] = new Option (m[1],m[0]);
		if (marca == m[0]) index = selectCategory.length-1;
    }

    selectCategory.selectedIndex = index;
}

function fillSelect (category,sub_id)
{
	
	var indexSub = 0;
    var selectCategory = document.frmProducts.selCategory;
    var selectSubcategory = document.frmProducts.selSubcategories;
	
    selectSubcategory.length = 0;
    selectSubcategory.options[selectSubcategory.length] = new Option ("- Subcategory -",0);
    
	if (category==0)
	{
		selectSubcategory.disabled = true;
		return;
	}
	try
	{
		var mod = subcategories[category].split(',');
		if(subcategories[category] && mod && mod.length)
		for (i=0;i<mod.length;i++)
		{
			var model = mod[i].split('#');
			selectSubcategory.options[selectSubcategory.length] = new Option (model[1],model[0]);
			if (model[0]==sub_id)  indexSub = selectSubcategory.length-1;
		}
		selectSubcategory.selectedIndex = indexSub;
	}
	catch(e){}
    selectSubcategory.disabled = false;
}
