/**
 *  This is the SiteController. It is mainly used to register other controllers and execute
 *  the other controller's behaviors.
 *  http://www.thinkingphp.org/2006/11/23/how-to-organize-your-cakephp-app’s-javascript-ii/
 */
SiteController = {
	controllers: [],
	menuSize: {},

	initialize: function() {
		this.registerController(this);
		this.applyBehaviors();
	},
	
	applyBehaviors: function() {
		$(this.controllers).each(function() {
			for (var fct in this.Behaviors) {
				if (typeof(this.Behaviors[fct]) == 'function' && !(Function[fct])) {
					this.Behaviors[fct]();
				}
			}
		});
	},
	
	Behaviors: {
		externalLinks: function() {
			$('a[rel=external],a[href^=http]:not(.logo)').click(function() {
				window.open(this.href);
				return false;
			});
		},
		fixPng: function() {
			if ($.browser.msie && $.browser.version <= 6.0) {
				// Fix ALPHA-PNG
				$.ifixpng('/js/jquery/plugins/ifixpng/pixel.gif');
				$('#logo a').ifixpng().css({cursor:'pointer'});
			}
		},
		lightbox: function() {
			$.Lightbox.construct({
				opacity: 0.7,
				show_linkback:	false,
				show_info: true,
				show_extended_info: true,
				text: {
					close: 'Schließen',
					image:	'Bild',
					of: 'von'
				},
				files: {
					images: {
						prev: '/img/lightbox/prev.gif',
						next: '/img/lightbox/next.gif',
						blank: '/img/lightbox/blank.gif',
						loading: '/img/lightbox/loading.gif'
					}
				}
			});
		}
		
	},

	registerController: function(controller) {
		this.controllers.push(controller);
	}
};
$(document).ready(function() { SiteController.initialize(); } );
