﻿/* Funções para gerenciamento dos combos */

function GerenciarFiltroArea() {
    filtro_tema.style.display = "block";
    BuscarTemas();
    //if ($('cmbTemas').value != '') {
        lista_videos.style.display = "block";
        BuscarVideos();
    //}
}

function GerenciarFiltroTema() {
    lista_videos.style.display = "block";
    BuscarVideos();
}
/**************************************************/
function BuscarTemas() {
    if ($('cmbAreas')[0].value == "S")
        $('cmbAreas').remove(0);

    pars = 'ordem=2&valorDaArea=' + $('cmbAreas').value;
    //url = 'http://www.aasp.org.br/aasp/cursos/crs_vv_ajax.asp';
    myAjax = new Ajax.Request(
    url,
    { method: 'get',
        parameters: pars,
        onComplete: TratarTemas
    });
}

function BuscarVideos() {
    var area, tema;

    if ($('cmbAreas').value == '')
        area = 'NULL';
    else
        area = $('cmbAreas').value
    if ($('cmbTemas').value == '')
        tema = 'NULL';
    else
        tema = $('cmbTemas').value;
        
    pars = 'ordem=3&valorDaArea=' + area + '&valorDoTema=' + tema;
    //url = 'http://www.aasp.org.br/aasp/cursos/crs_vv_ajax.asp';
    myAjax = new Ajax.Request(
    url,
    { method: 'get',
        parameters: pars,
        onComplete: TratarVideos
    });
}

function BuscarDadosVideos(id) {
    if (id > 0) {
        if ($('det_' + id).innerHTML.length == 0) {
            $('det_' + id).innerHTML = 'Buscando dados...';
            pars = 'ordem=4&idCurso=' + id;
            //url = 'http://www.aasp.org.br/aasp/cursos/crs_vv_ajax.asp';
            var myAjax = new Ajax.Updater(
	            'det_' + id,
	            url,
            {
                method: 'get',
                parameters: pars
            });
            $('det_' + id).style.display = 'block';
        } else {
            $('det_' + id).innerHTML = '';
        }
    }
}

function BuscarDadosVideosFidelidade(id) {
    if (id > 0) {
        if ($('det_' + id).innerHTML.length == 0) {
            $('det_' + id).innerHTML = 'Buscando dados...';
            pars = 'ordem=5&idCurso=' + id;
            //url = 'http://www.aasp.org.br/aasp/cursos/crs_vv_ajax.asp';
            var myAjax = new Ajax.Updater(
	            'det_' + id,
	            url,
            {
                method: 'get',
                parameters: pars
            });
            $('det_' + id).style.display = 'block';
        } else {
            $('det_' + id).innerHTML = '';
        }
    }
}
/**************************************************/


function TratarTemas(req) {
    var retorno = req.responseText;
    $('filtro_tema').innerHTML = retorno;
}

function TratarVideos(req) {
    var retorno = req.responseText;
    $('lista_videos').innerHTML = retorno;
}

/* Funções para uso do HTML */
function AbrirInscricao(idCurso, nomeCurso) {
    var intLeft, intTop, intWidth, intHeight;
    intWidth = 725;
    intHeight = 480;
    intLeft = eval((screen.width - intWidth) / 2);
    intTop = eval((screen.height - intHeight) / 2);

    var loja = window.open('crs_crt_seleciona.asp?idcurso=' + idCurso + '&nmcurso=' + nomeCurso, 'loja', 'width=' + intWidth + ',height=' + intHeight + ',top=' + intTop + ',left=' + intLeft + ',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no')
    loja.focus();
}