function busca_videos(termo) {
     $(document).ajaxStart(function () {
//      $(".textos").html('<p>Aguarde...Estamos realizando a busca</p>');
//  
//      $("#aguardeS").css("display", "block");
//      $("#blanketS").css("display", "block"); 
    });
    $(document).ajaxComplete(function () {
        $("#aguardeS").css("display", "none");
        $("#blanketS").css("display", "none");
    });
    
    if ($(".lista-videos").children().length == 0) {
    $.ajax({
        url: "https://www.googleapis.com/youtube/v3/search",
        type: "GET",
        crossDomain: true,
        data: {part: "snippet", q: termo, maxResults: 12, key: "AIzaSyCZ-KzK4j2utqcWFd9o-GD7zwj5jeryXiI", regionCode: "BR", order: "relevance"},
        success: function (responde) {
            for (x in responde.items) {
                    $(".lista-videos").append('\n\
                    <div class="col s12 m2 sp1">\n\
                       <div class="card card-video-cont">\n\
                        <div class="card-image card-video">  \n\
                         <a style="color:black;" href="https://www.youtube.com/watch?v=' + responde.items[x].id.videoId + '"  target="_blank"><img src="https://i.ytimg.com/vi/' + responde.items[x].id.videoId + '/hqdefault.jpg"><h6 class="legenda-video roboto"><i class="fa fa-youtube-play" style="color:red;"></i> ' + responde.items[x].snippet.title + '</h6></a>\n\
                        </div>\n\
                    </div>');
            }
        }
    });
   }
}

function busca_livros(termo) {
     $(document).ajaxStart(function () {
//      $(".textos").html('<p>Aguarde...Estamos realizando a busca</p>');
//  
//      $("#aguardeS").css("display", "block");
//      $("#blanketS").css("display", "block"); 
    });
    $(document).ajaxComplete(function () {
        $("#aguardeS").css("display", "none");
        $("#blanketS").css("display", "none");
    });
     if ($(".lista-livros").children().length == 0) {
    $.ajax({
        url: "https://www.googleapis.com/books/v1/volumes",
        type: "GET",
        crossDomain: true,
        data: {part: "snippet", q: termo, maxResults: 12, key: "AIzaSyDpK9duRMYIIdch0W6fZj8ZvPvyExLcqqU", regionCode: "BR", order: "relevance"},
        success: function (responde) {
            $(".lista-livros").html('');
            for (x in responde.items) {
                $(".lista-livros").append('<div class="col s12 m2 sp2"><div class="card card-video-cont"> <div class="card-image card-video"><a href="' + responde.items[x].volumeInfo.infoLink + '" target="_blank"><img style="max-height:150px;" src="https://books.google.com.br/books/content?id=' + responde.items[x].id + '&printsec=frontcover&img=1&zoom=5&edge=curl&imgtk=AFLRE71LJ7r73UXGpXFxH7abY1Rs41gW4jebMirfCt1Z5-uAsnquYoJN9vMGlvlm1oX4_z4Hgqp0B7LOXMguByPeHZlpn08gz4Oxc079oidzF__MCAmBVWmG0fDHOEvHzsE1AAGT5vrB"><h6 class="legenda-video roboto" style="color:black">' + responde.items[x].volumeInfo.title + '</h6></a></div></div>');
            }
        }
    });
     }
}

function busca_wikipedia(termo) {
     $(document).ajaxStart(function () {
//      $(".textos").html('<p>Aguarde...Estamos realizando a busca</p>');
//  
//      $("#aguardeS").css("display", "block");
//      $("#blanketS").css("display", "block"); 
    });
    $(document).ajaxComplete(function () {
        $("#aguardeS").css("display", "none");
        $("#blanketS").css("display", "none");
    });
    $.ajax({
        url: "https://pt.wikipedia.org/w/api.php",
        type: "GET",
        dataType: 'jsonp',
        crossDomain: true,
        data: {action: "opensearch", search: termo, format: "json"},
        success: function (responde) {
            var geral = responde[3];
            if (geral.length > 0) {
               $("#wikipedia").html('').append("<h4 style='font-size: 19pt;'>Resultados para: " + responde[0] + "</h4><ul class=\"list-group lista-wikipedia\"></ul>");
                for (x in geral) {
                    $(".lista-wikipedia").append('<li class=\"list-group-item\" style="padding: 8px;"><a href="' + geral[x] + '" target=\"_blank\" style="color: #2BA447;"><span style="font-size: 14pt; text-transform: capitalize;"><i class="fa fa-book"></i> ' + responde[1][x] + '</span></a></li>');
                }
            } else {
                $("#wikipedia").html('').append("<h5 style='font-size: 19pt;'>Nenhum resultado para: " + responde[0] + "</h5>");
            }
        }
    });
}


