/**
 * DAM Image Gallery
 * 
 * Please check the javascript code after changes with JSlin
 * (http://jslint.com/). 
 * 
 * @author Chris Müller <mueller@cyperfection.de> 
 * @version $Id: gallery.js 319 2009-11-24 12:55:48Z christian $
 * @package typo3
 * @subpackage cyz_imagegallery   
 */ 

/*jslint
	bitwise: true,
	browser: true,
	eqeqeq: true,
	immed: true,
	newcap: true,
	nomen: true,
	onevar: true,
	plusplus: true,
	regexp: true,
	undef: true
*/
/*global
	$
*/


/***** Constants **************************************************************/

var CyzGalleryLibraryConfig = {
	// Selector id of the "images per page" box
	boxId: 'cyz-gallery-box',

	// Selector id of the "images per page" options
	optId: 'cyz-gallery-opt'
};



/***** Processing *************************************************************/

function CyzGalleryLibrary() {
	/**
	 * Callback function on click "images per page"
	 * @param {Event}
	 * @private
	 */
	function imagesPerPageClick(e) {
		// Verarbeitung stoppen
		e.stop();

		if ($(CyzGalleryLibraryConfig.optId).visible()) {
			$(CyzGalleryLibraryConfig.optId).hide();
		} else {
			$(CyzGalleryLibraryConfig.optId).show();
		}
	}



	/**
	 * Initializing
	 * This function will be called when the html code is loaded
	 * @public
	 */
	this.init = function () {
		if ($(CyzGalleryLibraryConfig.boxId) && $(CyzGalleryLibraryConfig.optId)) {
			$(CyzGalleryLibraryConfig.boxId).observe('click', imagesPerPageClick);
		}
	};
}


/***** Start ******************************************************************/
document.observe('dom:loaded', function() {
	var cyzGalleryLibrary = new CyzGalleryLibrary();
	cyzGalleryLibrary.init();
});

