var acciones = {
    borrar_permisos : function(id,confirm_msg){
        if(confirm(confirm_msg)){
            $.post('/Admin/Permisos/delete', {
                'id': id
            }, function(data){
                if (api_processJson(data)){
                    $('#content').showloading();
                    $('#content').load('/Admin/Permisos', {
                        'orionload':1
                    },function(){
                        orion.xhr.preload();
                    });
                }
            }, 'json');
        }
    },

    editar_permisos : function(id){
        orion_box.xhr('/Admin/Permisos/add', 300, 200, {'id':id});
    }
}

var NuevaGaleria = function(pres_id){
    var ViewRef = prompt('Ingrese aquí una breve descripción para las fotos');

    if(ViewRef){
        //alert(ViewRef);
        ViewRef = encodeURI(ViewRef);
        orion_box.iframe('/Admin/Content/upload?pres_id=' + pres_id + '&ViewRef=' + ViewRef, 700, 500);
    }

}

var App = {};
App.Admin = {};

App.Admin.Content = {

    metadataadd : function(refId, name, value,labelId){
        $.post('/Admin/Content/metadataadd', {
            'refId': refId,
            'name': name,
            'value' : value,
            'labelId' : labelId
        }, function(data){
            if(orion.forms.jsonResponse(data, 0) == true){
                orion.xhr.refresh();
            }

        }, 'json');
    },

    metadataremove : function(id,confirm_msg){
        if(confirm(confirm_msg)){
            $.post('/Admin/Content/metadataremove', {
                'id': id
            }, function(data){
                if(orion.forms.jsonResponse(data, 0) == true){
                    orion.xhr.refresh();
                }
            }, 'json');
        }
    },

    metalabeladd : function(label,refId,type){
        $.post('/Admin/Content/metalabeladd', {
            'label': label,
            'refId': refId,
            'type' : type
        }, function(data){
            if(orion.forms.jsonResponse(data, 0) == true){
                orion.xhr.refresh();
            }

        }, 'json');
    },

    metalabelremove : function(labelId,confirm_msg){
        if(confirm(confirm_msg)){
            $.post('/Admin/Content/metalabelremove', {
                'id': labelId
            }, function(data){
                if(orion.forms.jsonResponse(data, 0) == true){
                    orion.xhr.refresh();
                }
            }, 'json');
        }
    },

    presvisible : function(presId,visible){

        if(visible){
            visible = 1;
        }else{
            visible = 0;
        }

        $.post('/Admin/Content/presvisible', {
            'presId': presId,
            'visible': visible
        }, function(data){
            if(orion.forms.jsonResponse(data, 0) == true){
                //orion.xhr.refresh();
            }

        }, 'json');
    }

}

App.Admin.newsletter = {

    add : function(title, desc,content){
        $.post('/Admin/newsletter/add', {
            'title': title,
            'desc' : desc,
            'content' : content
        }, function(data){
            if(orion.forms.jsonResponse(data, 0) == true){
                orion.xhr.refresh();
            }

        }, 'json');
    },

    change : function(newsId,title, desc){
        $.post('/Admin/newsletter/change', {
            'newsId' : newsId,
            'title': title,
            'desc' : desc
        }, function(data){
            if(orion.forms.jsonResponse(data, 0) == true){
                //orion.xhr.refresh();
            }

        }, 'json');
    },

    remove : function(id,confirm_msg){
        if(confirm(confirm_msg)){
            $.post('/Admin/newsletter/remove', {
                'id': id
            }, function(data){
                if(orion.forms.jsonResponse(data, 0) == true){
                    orion.xhr.refresh();
                }
            }, 'json');
        }
    },
    
    removeEmail : function(id,confirm_msg){
        if(confirm(confirm_msg)){
            $.post('/Admin/newsletter/removeEmail', {
                'id': id
            }, function(data){
                if(orion.forms.jsonResponse(data, 0) == true){
                    orion.xhr.refresh();
                }
            }, 'json');
        }
    },

    manage: function(id){
        var url = '/Admin/newsletter/manage?id=' + id;
        orion.xhr.load(url, 'content');
    },

    mails: function(newsId){
        var UserCamp = new OrionModalBox('UserCamp', {title:'Agregar Emails al Newsletter',width:500,height:600});
        var url = '/Admin/newsletter/mails?id=' + newsId;
        UserCamp.load(url);
    },

    cabecera: function(newsId){
        var UserCamp2 = new OrionModalBox('UserCamp2', {title:'Imagen de la cabecera',width:738,height:353});
        var url = '/Admin/newsletter/cabecera?id=' + newsId;
        UserCamp2.load(url);
    },

    cabeceraselector: function(newsId,imgId){
        $.post('/Admin/newsletter/cabeceraselector', {
            'newsId': newsId,
            'imgId' : imgId
        }, function(data){
            if(orion.forms.jsonResponse(data, 0) == true){
                var box = new OrionModalBox();
                box.close('UserCamp2');
            }

        }, 'json');
    },

    reset: function(newsId,confirm_msg){
        if(confirm(confirm_msg)){
            $.post('/Admin/newsletter/reset', {
                'id': newsId
            }, function(data){
                if(orion.forms.jsonResponse(data, 0) == true){
                    orion.xhr.refresh();
                }
            }, 'json');
        }
    },

    sent: function(newsId,confirm_msg){
        if(confirm(confirm_msg)){
            $.post('/Admin/newsletter/sent', {
                'id': newsId
            }, function(data){
                if(orion.forms.jsonResponse(data, 0) == true){
                    orion.xhr.refresh();
                }
            }, 'json');
        }
    },

    noticias: function(newsId){
        
    }

}

$(document).ready(function() {

});