﻿/// <reference name="MicrosoftAjax.js"/>


Type.registerNamespace("NotesFor");

NotesFor.Gallery = function(element) {
    NotesFor.Gallery.initializeBase(this, [element]);
    this._handlerUrl = '';
    this._folderUrl = '';
    this._cssClass = 'nfGallery';
    this._files = new Array();
    this._totalFiles = 0;
    this._size = 100;
}

NotesFor.Gallery.prototype = {
    initialize: function() {
        NotesFor.Gallery.callBaseMethod(this, 'initialize');

        var controlID = this.get_id();
        // Add custom initialization here
        var div = $("<div></div>");
        div.addClass(this.get_cssClass());
        var ulImage = $("<ul></ul>");
        var liImage = null;
        var img = null;
        var a = null;
        for (var i = 0; i < this._totalFiles; i++) {
            liImage = $("<li></li>");
            a = $("<a></a>");
            a.attr('href', this.get_folderUrl() + this._files[i]);
            img = $("<img></img>");
            img.attr('src', this.get_handlerUrl() + '?path=' + this.get_folderUrl() + '&size=' + this.get_size() + '&pos=' + i);
            a.append(img);
            liImage.append(a);
            ulImage.append(liImage);
        }
        div.append(ulImage);
        var controlSpan = $(this.get_element());
        controlSpan.append(div);

        //Activate the lightbox plugin
        $(function() {
            $('#' + controlID + ' a').lightBox();
        });
    },
    dispose: function() {
        //Add custom dispose actions here
        NotesFor.Gallery.callBaseMethod(this, 'dispose');
    },

    get_handlerUrl: function() {
        return this._handlerUrl;
    },
    set_handlerUrl: function(value) {
        this._handlerUrl = value;
    },

    get_folderUrl: function() {
        return this._folderUrl;
    },
    set_folderUrl: function(value) {
        this._folderUrl = value;
    },

    get_cssClass: function() {
        return this._cssClass;
    },
    set_cssClass: function(value) {
        this._cssClass = value;
    },

    get_files: function() {
        return this._files;
    },
    set_files: function(value) {
        this._files = value;
    },

    get_totalFiles: function() {
        return this._totalFiles;
    },
    set_totalFiles: function(value) {
        this._totalFiles = value;
    },

    get_size: function() {
        return this._size;
    },
    set_size: function(value) {
        this._size = value;
    }
}
NotesFor.Gallery.registerClass('NotesFor.Gallery', Sys.UI.Control);

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
Type.registerNamespace('NotesFor');NotesFor.Resource={};
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();