   /*<![CDATA[*/
   function putValuesOfDate() {
       with(document.forms['searchNoticias']) {
           // colocando os dias
           for(var i = 1; i <= 31; i++) {
               var option = document.createElement('option')
               option.appendChild(document.createTextNode(i < 10 ? '0' + i : i))                    
               if(i == sDay) option.selected = 'selected'
               day.appendChild(option)
           }
           // colocando os meses
           for(var i = 1; i <= 12; i++) {
               var option = document.createElement('option')
               option.appendChild(document.createTextNode(i < 10 ? '0' + i: i))
               if(i == sMonth) option.selected = 'selected'
               month.appendChild(option)
           }
           // colocando os anos
           oDate = new Date()
           sYear = oDate.getFullYear()
           for(var i = sYear-1; i <= sYear; i++) {
               var option = document.createElement('option')                   
               option.appendChild(document.createTextNode(i))
               if(i == sReqYear) option.selected = 'selected'
               year.appendChild(option)
           }
           // colocando a data por extenso
           lMonths = new Array('janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro')
           lDays = new Array('Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sábado')
           document.getElementById('extensibleDate').innerHTML = lDays[oDate.getDay()] + ', ' + oDate.getDate() + ' de ' + lMonths[oDate.getMonth()] + ' de ' + oDate.getFullYear() 
        }   
    }

    var oldCategorias = null
    function shiftCategoria(oSender, noalert) {
//      if(!oSender) return
        var textCategoria = document.getElementById('category')
        var value = oSender.options[oSender.selectedIndex].value
        var content = oSender.options[oSender.selectedIndex].innerHTML
        var sub = oSender.getAttribute('sub')
        var id_sessao_hidden = document.getElementById('id_sessao_hidden')
        if(!sub) {   
            if(content.toLowerCase().search('receitas') != -1) {
                oSender.setAttribute('sub', 'sub')
                textCategoria.innerHTML= '<b' + '>Sub<' + '/b>categoria'
                // criando o input hidden
                id_sessao_hidden.value = value
                id_sessao_hidden.name = 'id_sessao'
                // mudando o select
                oSender.removeAttribute('id')
                oSender.setAttribute('id', 'id_tipo_noticia')
                oSender.setAttribute('name', 'id_tipo_noticia')              
                oldCategorias = document.all ? cloneObjects(oSender.getElementsByTagName('option')) : oSender.cloneNode(true)
                // criando os novos options
                var opt = document.createElement('option')
                opt.setAttribute('value', 'back')
                opt.setAttribute('style', 'font-weight: bold')
                opt.style.cssText = 'font-weight: bold'
                opt.setAttribute('selected', '')
                opt.innerHTML = '<< Escolher Categoria'
                var opt2 = document.createElement('option')
                opt2.innerHTML = 'Todas'
                opt2.setAttribute('selected', 'selected')
                opt2.setAttribute('value', '')
                // 'zerando o select'
                removeOptionChilds(oSender)
                oSender.appendChild(opt)
                oSender.appendChild(opt2)
                oSender.options[1].setAttribute('selected', 'selected')
                addOptionChilds(oSender, tiposNoticia, sIdTipoNoticia) 
                oSender.name = 'id_tipo_noticia'
                if(!noalert) alert('Escolha a Subcategoria')                
            } 
        } else {
            if(value == 'back') {
                id_sessao_hidden.name = 'id_sessao_hidden'
                oSender.name = 'id_sessao'
                textCategoria.innerHTML = 'Categoria'
                removeOptionChilds(oSender)
                if(oldCategorias) { 
                    document.all ? addOptionChilds(oSender, oldCategorias, null, true) : oSender.innerHTML = oldCategorias.innerHTML
                    oSender.setAttribute('sub', '')
                }
            }
        }
    }   

    function changeSubitem() {
        var oDestination = document.getElementById('id_sessao')        
        shiftCategoria(oDestination, true)
    }

    function cloneObjects(oSender) {
        var result = new Array()        
        for(var i=0; i<oSender.length; i++) { 
            var opt = document.createElement('option')
            opt.setAttribute('value', oSender[i].value)
            opt.innerHTML = oSender[i].innerHTML
            result.push(opt) 
        }
        return result
    }

    function addOptionChilds(oDestination, options, selected, noObject) {
        var collection = typeof(options) != 'object' ? true : false
        for(var i=0; i<options.length; i++) {
            if(collection || noObject) { 
                var opt = options[i]
            } else {
                var opt = document.createElement('option')
                opt.setAttribute('value', options[i].id_tipo_noticia)
                opt.innerHTML = options[i].nome 
            }
            !collection && selected == options[i].id_tipo_noticia ? opt.setAttribute('selected', 'selected') : null
            oDestination.appendChild(opt)             
        }
    }

    function removeOptionChilds(oDestination) {
        while(oDestination.firstChild)  oDestination.removeChild(oDestination.firstChild)      
    }
    /*]]>*/

