Element.implement({
	loadingOverlayShow: function(options) {
		options = options || {}
		
		var coords = this.getCoordinates();
		var offset = this.getOffsetSize();
		
		var opacity = $chk(options.opacity)
			? options.opacity
			: 0.8;
		
		var overlay = new Element('div', {
			'styles': {
				top: coords.top,
				left: coords.left,
				width: offset.x,
				height: offset.y
			},
			'class': 'ajax_loading'
		}).inject(document.body).setOpacity(opacity);
		this.store('loadingOverlay', overlay);
	},
	loadingOverlayHide: function() {
		this.retrieve('loadingOverlay').dispose();
	}
});
Element.implement({
    visible: function(){
            return this.getStyle('display') == 'none' || this.getStyle('visibility') == 'hidden' ? false : true;
    },
   
    show: function(){
            return this.setStyle('display', '').set('opacity', 1);
    },
   
    hide: function(collapse){
            return collapse ? this.setStyle('display', 'none') : this.set('opacity', 0);
    },
   
    toggle: function(collapse){
            return this.visible() ? this.hide(collapse) : this.show();
    }
});


window.addEvent('domready', function() {

	$('bar').setOpacity(0.3);
	$('bar').addEvent('mouseenter', function() {
		this.setOpacity(0.8);
	});
	$('bar').addEvent('mouseleave', function() {
		this.setOpacity(0.3);
	});
	
	$('footer').setOpacity(0.3);
	$('footer').addEvent('mouseenter', function() {
		var myFx = new Fx.Style(this, 'opacity', {duration: 100}).start(0.3,0.8);
	});
	$('footer').addEvent('mouseleave', function() {
		var myFx = new Fx.Style(this, 'opacity', {duration: 100}).start(0.8,0.3);
	});
	
	$('hull').makeRounded({radius: 10});
	calendar_events_ajax = function(year, month, type, id) {
		$('calendar_wrap').loadingOverlayShow();
		new Request.HTML({
			method: 'get',
			url: '/' + type + '/' + id + '/events/calendar',
			update: 'calendar_wrap',
			evalScripts: true,
			onComplete: function() {
				$('calendar_wrap').loadingOverlayHide();
			}
		}).get({year: year, month: month});
	}
	/*document.mochaScreens = new MochaScreens();
	document.mochaDesktop = new MochaDesktop();
	attachMochaLinkEvents();*/
});
