

// Eseguo un submit con un request ajax
// e aggiorno il div passato al secondo parametro
// con il response
function ajax_submit(formId, divId)
{
	var ajax = new Ajax($(formId).action, {
		update: $(divId),
		data: $(formId)
	}).request();
}

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

	/* Glossario! */
	var Tips2 = new Tips($$('.tipx'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
	
	/*
	* La microgallery
	*/
	var hli = $$(".highlight");
	
	hli.each(function(element) {

		element.addEvent('click', function(e) {
			
			e = new Event(e).stop();
			expanded = new Element('div', {'class': 'expanded', 'events': {
				'click': function(e){
					e = new Event(e).stop();
					new Fx.Style(this, 'opacity', {duration: 300}).start(0);
				}}
			});
			
			var hide = new Fx.Style(expanded, 'opacity', {duration: 300});
			
			expanded.inject(document.body);
			expanded.setOpacity(0);

			loadedImages = '';

			var neww = 0;
			var newh = 0;
			
			new Asset.images(element, {
			
				onProgress: function() {
				
					expanded.setStyles({
						'left': e.page.x - (this.width / 2),
						'top': e.page.y - (this.height / 2),
						'width': this.width,
						'height': this.height
					});

					loadedImages = this;										
				},
			
				onComplete: function() {
					
					loadedImages.inject( expanded );
					
					hide.start(0, 1);
					
				}
				
			});

		});				

	});

});