﻿var __thumbW = 320;
var __thumbH = 320;
var __scaleMode = 2;

var __isSetup = false;
var __isLoaded = false;

var __divName = "";


jq31CB(document).ready(function() {
    if (__isLoaded) return;
    __isLoaded = true;
    if (__isSetup) StartNBChamberGallery();

});



function SetupNBChamberGallery(divName) {
    __divName = divName;
    __isSetup = true;
    if (__isLoaded) StartNBChamberGallery();
}


function StartNBChamberGallery() {

    var coll = jq31CB('#' + __divName + ' div');
    for (var n = 0; n < coll.length; n++) {
        var path = jq31CB(jq31CB(coll[n]).get(0)).attr('rel');
        var properties = jq31CB(jq31CB(coll[n]).get(0)).attr('title');
        SetupThumb(path, n, properties);
    }

}


function SetupThumb(path, id, properties) {

    var props = properties.split('/');
    var title = props[0] + " • " + props[1];

    var thumb = "/w/" + __thumbW + "/h/" + __thumbH + "/sm/" + __scaleMode + "/p" + path + ".jpgx";

    jq31CB('#' + __divName).append('<a href="' + path + '" title="' + title +
        '" class="NBChamber_ImgLink" id="_pic_' + id + '" rel="NBChamberSlideShow">' +
        '<img src="' + thumb + '" alt="' + title + '" class="NBChamber_Img" /></a>');

    jq31CB('#' + __divName + ' #_pic_' + id).colorbox({ title: '<span class="NBChamber_ImgCaption">' + title +
        '</span>', photo: true
    });

}
