function favoritos(title,url)
{
	var url = "http://"+url;
    if (window.sidebar) window.sidebar.addPanel(title, url,"");

    else if( window.opera && window.print )
    {
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
    }

    else if( document.all ) window.external.AddFavorite( url, title);
}

function popup(uri,w,h)
{
	window.open(""+uri+"","Popup","location=1,status=1,scrollbars=1,width="+w+",height="+h+"");
}

<!-- alterValue(this, 'nome'); -->

function alterValue(component, val) {
    if (component.value == '') {
        component.value = val;
    } else if (component.value == val) {
        component.value = '';
    }
}

/**
 * Preenche uma combo box a partir de um array
*/
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
    var i, j;
    var prompt;
    
    if ((itemArray == '0') || (itemArray == -1) || (itemArray == null)) {
        selectCtrl.disabled = true;
    } else {
        selectCtrl.disabled = false;
    }
    
    // empty existing items
    for (i = selectCtrl.options.length; i >= 0; i--) {
        selectCtrl.options[i] = null; 
    }
    prompt = (itemArray != null) ? goodPrompt : badPrompt;
    if (prompt == null) {
        j = 0;
    } else {
        selectCtrl.options[0] = new Option(prompt);
        j = 1;
    }
    if (itemArray != null) {
        // add new items
        for (i = 0; i < itemArray.length; i++) {
            selectCtrl.options[j] = new Option(itemArray[i][0]);
            if (itemArray[i][1] != null) {
                selectCtrl.options[j].value = itemArray[i][1]; 
            }
            j++;
        }
        // select first item (prompt) for sub list
        selectCtrl.options[0].selected = true;
    }
}

/*
  *	PESQUISA AVANCADA
  */
function updateCB(url,div) {
	// Loading 
	//$('marca_loading').innerHTML = "<img src='/media/images/ajax-loader.gif' />";
	//$('produto_loading').innerHTML = "<img src='/media/images/ajax-loader.gif' />";
    var gets = "categoriaid=" + $('categoria_cb').value + "&marcaid=" + $('marca_cb').value;
    var myAjax = new Ajax.Updater(div,
                                  url,
                                  {
									method: 'get',
									onSuccess: function(transport) {
										// Executa incio
									},
									onComplete: function(transport) {
										// Executa depois de todo o load
									},
									parameters: gets
                                  });
}

function filtro() {
	
	if($('nivel3_cb').value){
		categoria = "/c/"+$('nivel3_cb').value;
	} else {
		if($('categoria_cb').value){
			categoria = "/c/"+$('categoria_cb').value;
		}else{
			categoria = "";
		}
	}

	if($('marca_cb').value)
		marca = "/m/"+$('marca_cb').value;
	else
		marca = "";

	if($('produto_cb')){
		if($('produto_cb').value)
			produto = "/p/"+$('produto_cb').value;
		else
			produto = "";
	} else {
		produto = "";
	}
	
	if(($('produto_cb') && $('produto_cb').value) || $('categoria_cb').value || $('nivel3_cb').value || $('marca_cb').value){
		window.location = "/catalogo/resultadoPa/cat/"+$('cat').value+categoria+marca+produto;
	} else {
		alert('Deve escolher um critério de pesquisa.');
	}
}