﻿var ControlContainer = null;
function openControlWindow(id, path, title, options) { var url = ControlContainer + '?c=' + path; return MsgWindow.open(id, 'iframe', url, title, options); }
// global function for alerting users
function alt(t, m, icon, cb) { return MsgWindow.alert(m, t, icon, cb); }
// auto size the current window
function ModuleWindow_Resize() { WebWindow_Resize(); }

Namespace.Manager.Register('Websites.Blog');
Namespace.Manager.Register('Tags');

Websites.Blog.Entries = {
    DivId: 'divBlogEntries'
    , View_Callback: function(e) {

    }
    , View_Init: function(e) {
        e.LoaderDivId = Websites.Blog.Entries.DivId;
        return true;
    }
    , Load: function(m, y) {
        this.View_Archive({ Month: m, Year: y });
        return false;
    }
    // , View_Archive : function() // Generated By Ajax.NET
};


Websites.Login = {
    Url: null,
    Start: function(obj) {
        var w = MsgWindow.open('editor', 'iframe', this.Url, GetResourceText('Login'), { modal: true, width: 315, height: 190, showhandle: true });
        return false;
    }
};


Websites.Contact = {
    Send_Callback: function(obj) {
        if (obj.ContactEmailResponse)
            updateDiv('ContactEmailStatus', obj.ContactEmailResponse);
    }
    , Send_Init: function(e) {
        e.LoaderDivId = 'ContactEmailStatus';
        e.LoaderImage = MsgWindowIcons.Loading;
        return true;
    }
};

Websites.Comments = {
    WinSettings: { width: 400, height: 470, resize: true, dragenabled: true }
    , AddComment: function(blogId, callback) {
        var win = openControlWindow('addcomment', 'blog/addcomment&blogid=' + blogId, GetResourceText('AddComment', 'EduportalFxWebsites'), this.WinSettings);
        win.onclose = function() {
            if (callback) {
                callback({ BlogId: blogId });
                return true;
            }

        }
        return false;
    },
    ReplyToComment: function(blogId, replyId, callback) {
        var win = openControlWindow('addcomment', 'blog/addcomment&blogid=' + blogId + '&replyId=' + replyId, GetResourceText('AddComment', 'EduportalFxWebsites'), this.WinSettings);
        win.onclose = function() {
            if (callback) {
                callback({ BlogId: blogId });
                return true;
            }
        }
        return false;
    },
    Init: function(e) {
        e.LoaderDivId = 'ContactEmailStatus';
        e.LoaderImage = MsgWindowIcons.Loading;
        return true;
    },
    Callback: function(e) {
        if (e.Message) {
            updateDiv('ContactEmailStatus', '');
            return alt(GetResourceText('AlertMessageTitle', 'EduportalFxWebsites'), e.Message);
        }
        CloseWebWindow();
    },
    Delete: function(commentId, serverCall, blogId) {
        return serverCall({ commentId: commentId, BlogId: blogId });
    },
    Edit: function(Id, callback, blogId) {
        var win = openControlWindow('editcomment', 'blog/editcomment&Id=' + Id, GetResourceText('Edit', 'EduportalFxWebsites'), this.WinSettings);
        win.onclose = function() {
            if (callback) {
                callback({ BlogId: blogId });
                return true;
            }
        }
        return false;
    }
};

Websites.Tags = {
    Delete: function(tagid, callback) {
        return callback({ tagId: tagid });
    }
};
