var base_url = 'http://juegos.ie.st/';

function add_favs(cod_user, cod_game){

        if(cod_user == undefined){
                alert("Error: se esperaba un código de usuario");
                return;
        }

        if(cod_game == undefined){
                alert("Error: se esperaba un código de juego");
                return;
        }

        $.ajax({
                type: "GET",
		url: base_url + 'ajax/favs.php',
                data: "action=add&cod_user="+cod_user+"&cod_game="+cod_game,
                success: function(msg){
                        document.getElementById("favourites").innerHTML = msg;
                },
                error: function(xho){
                        document.getElementById("favourites").innerHTML = "Error:"+xho.responseText;
                }
        });
}

function del_favs(cod_user, cod_game){

        if(cod_user == undefined){
                alert("Error: se esperaba un código de usuario");
                return;
        }

        if(cod_game == undefined){
                alert("Error: se esperaba un código de juego");
                return;
        }

        $.ajax({
                type: "GET",
                url: base_url + 'ajax/favs.php',
                data: "action=del&cod_user="+cod_user+"&cod_game="+cod_game,
                success: function(msg){
                        document.getElementById("favourites").innerHTML = msg;
                },
                error: function(xho){
                        document.getElementById("favourites").innerHTML = "Error:"+xho.responseText;
                }
        });
}

function warning(cod_user, cod_game){

        if(cod_user == undefined){
                alert("Error: se esperaba un código de usuario");
                return;
        }

        if(cod_game == undefined){
                alert("Error: se esperaba un código de juego");
                return;
        }

        $.ajax({
                type: "GET",
                url: base_url + 'ajax/favs.php',
                data: "action=war&cod_user="+cod_user+"&cod_game="+cod_game,
                success: function(msg){
                        document.getElementById("warning").innerHTML = msg;
                },
                error: function(xho){
                        document.getElementById("warning").innerHTML = "Error:"+xho.responseText;
                }
        });
}
