// Lightbox
var LightboxOptions={};		// Must be a defined symbol

// Functions

// -- General --

// Hides the loading icon, if it exists
function hideLoadingIcon() {
	var loadingIcon = $('mpLoadingIcon');
	if (loadingIcon)
		loadingIcon.hide();
}

function buildGallerySelector(containerId) {
	hideLoadingIcon();
	var gc = $(containerId);
	if (gc && galleries) {
		var c=0;
		galleries.each(function(g){
			var gid = '"g'+g.id+'"';
			var a = Builder.node( 'a',  {id:'g'+g.id, className:'gallery',href:mpOptions.rootUrl+'gallery/?g='+g.id}, [
					Builder.node('img', {onmouseover: "fadeIn("+gid+")", onmouseout: "mpFade("+gid+",{to:.8})",onload:"mpFade("+gid+", {to:.8,duration:.5})", src: mpPhotoUrl(g.photoId,'small'),alt:g.photoTitle} ),
					Builder.node('br'),
					g.title]
			);
			a.setStyle({opacity:0});
			gc.appendChild(a);
		});
	}
}

// -- Photo Functions --

// mpPhotoUrl( name, size )
// Construct the photo url
// Size can be
//		'small'
//		''
//		'square'
function mpPhotoUrl( id, size ) {

	var url = mpOptions.rootUrl + mpOptions.photoPath + id + "_";
	
	switch (size) {
		case 'medium':
			url += 'medium';
			break;
		case 'large':
			url += 'large';
			break;
		case 'thumb':
		case 'thumbnail':
		case 'square':
			url += 'square';
			break;
		default:
			url += 'small';
			break;
	}
	
	url += '.jpg';

	return url;
}

// Prototype extensions
/*
 * InPlaceEditor extension that adds a 'click to edit' text when the field is 
 * empty.
 */
 /*
Ajax.InPlaceEditor.prototype.__initialize = Ajax.InPlaceEditor.prototype.initialize;
Ajax.InPlaceEditor.prototype.__getText = Ajax.InPlaceEditor.prototype.getText;
Ajax.InPlaceEditor.prototype.__onComplete = Ajax.InPlaceEditor.prototype.onComplete;
Ajax.InPlaceEditor.prototype = Object.extend(Ajax.InPlaceEditor.prototype, {

    initialize: function(element, url, options){
        this.__initialize(element,url,options)
        this.setOptions(options);
        this._checkEmpty();
    },

    setOptions: function(options){
        this.options = Object.extend(Object.extend(this.options,{
            emptyText: '<i>Click to edit...</i>',
            emptyClassName: 'inplaceeditor-empty'
        }),options||{});
    },

    _checkEmpty: function(){
        if( this.element.innerHTML.length == 0 ){
        	this.emptySpan = Builder.node('span',{className:this.options.emptyClassName});
        	this.emptySpan.innerHTML = this.options.emptyText;
            this.element.appendChild(this.emptySpan);
        }
    },

    getText: function(){
        this.element.removeChild(this.emptySpan);
        return this.__getText();
    },

    onComplete: function(transport){
        this._checkEmpty();
        this.__onComplete(transport);
    }
});

*/