$(document).ready( function() {
    
    $(".delete").click( function() {
        Boxy.confirm("Are you sure that you want to permanently delete this tune from upatune?", function() {
            var tune_id = this.name;
            $.ajax({
                type: "POST",
                url: "controller/tune/delete",
                data: "tune_id="+tune_id,
                dataType: "json",
                timeout: 20000,
                cache:false,
                success: function(j){
                    if(j.type == "ok") {
                        var id = "#tune_" + j.id;
                        $(id).css("background-color", "#FF0000");
                        $(id).hide();
                    }
                    insertMsg(j.type, j.msg);
                },
                error: function(XMLHttpRequest, textStatus, errorThrown){
                    insertMsg("error", "Error: "+errorThrown);
                }
            });
        }, {title: 'Come on! Why?'});
        return false;
    });

});    


function addToPlaylist(id){
	$.ajax({
   		type: "POST",
   		url: "controller/tune/addtoplaylist",
   		data: "id="+id,
   		dataType: "json",
   		timeout: 20000,
   		cache:false,
   		success: function(j){
			Boxy.alert(j.msg, null, {title: 'Notifications'});
   			//insertMsg(j.type, j.msg);
   		},
   		error: function(XMLHttpRequest, textStatus, errorThrown){
			Boxy.alert(j.error, null, {title: 'Error'});
   			//insertMsg("error", "Error: "+textStatus);
   		}
   	});
}