

$(function() {
    $('.downmovie').click(function(event) {
        var id = $(this).attr('id')
        var href = $(this).attr('href')
        var hc = window.location.href
        var url = '../addcount/' + id

        if(hc.search('director')){
            url = '../../addcount/' + id
        }

        event.preventDefault();
        $.ajax({
            url: url,
            success : function(data){
                $('#down' + id).text(data);
            }
        })

        var msg = 'Gracias al "honorable" poder legislativo de mi país, ya no es posible compartir nada, contactanos en nuestro canal de Telegram si tienes dudas: @mauflix'
        alert(msg);

    });
});


function director_change(){
    var directors = document.getElementById('directors')
    if(directors.selectedIndex){
        name = directors.options[directors.selectedIndex].value
        window.location.href = '/movies/director/' + name
    }else{
        window.location.href = '/movies'
    }
}


function search_movie(){
    var search = document.getElementById('search')
    window.location.href = '/movies/' + search.value
}


function search_key_press(ev){
    alert(ev.keyCode)
}
