﻿function busca() {
    this.MudaPesquisa = function(exibir) {
        $('spBuscaLivre').style.display = exibir == 1 ? '' : 'none';
    };

    this.submit = function() {
        var url;

        if ($('TipoMedia0').checked == true) url = 'galeriadefotos.vxlpub?';
        if ($('TipoMedia1').checked == true) url = 'buscavideos.vxlpub?';
        if ($('TipoMedia2').checked == true) url = 'buscaatores.vxlpub?';

        if ($('sltRaca').selectedIndex == 0 && $('sltCategoria').selectedIndex == 0 && $('sltCorCabelo').selectedIndex == 0 && $get('txtBuscaLivre') == '') {
            alert('Selecione pelo menos um item para a pesquisa.');
            return;
        }


        if ($('sltRaca').selectedIndex != 0) {
            url = url + "CodRaca=" + $('sltRaca').options[$('sltRaca').selectedIndex].value + "&";
        }

        if ($('sltCategoria').selectedIndex != 0) {
            url = url + "CodCategoria=" + $('sltCategoria').options[$('sltCategoria').selectedIndex].value + "&";
        }

        if ($('sltCorCabelo').selectedIndex != 0) {
            url = url + "CodCorCabelo=" + $('sltCorCabelo').options[$('sltCorCabelo').selectedIndex].value + "&";
        }

        if ($get('txtBuscaLivre') != '') {
            url = url + "Busca=" + $get('txtBuscaLivre') + "&";
        }

        url = url.substr(0, url.length - 1);
        window.location = url;
    }

}

var oBusca = new busca();