var mzPopup=new Class({

	options: {
		usepopback:true,
		popback:'pop_sfondo',
		height:400,
		width:500
	}, 

	initialize: function(element,options){

		this.setOptions(options);
	
		this.popup=$(element);
		this.popupback= (this.options.usepopback) ? $(this.options.popback) : null;
		
	},
	
	show: function(options,url){
	
		var alloptions=$merge(this.options,options);
		
		if(alloptions.usepopback) this.popupback.setStyles({'display':'block','width':window.getScrollWidth()+'px','height':window.getScrollHeight()+'px'})
		this.popup.setStyles({'display':'block',width:alloptions.width+'px',height:alloptions.height+'px',left:(alloptions.left) ? alloptions.left : '50%',top:'50%','margin-left':(alloptions.left) ? '0px' : '-'+(Math.floor(alloptions.width/2))+'px','margin-top':'-'+(Math.floor(alloptions.height/2))+'px'})
		
		if(url) this.load(url,alloptions.complete_func);
	},

	hide: function(reset){
		
		reset = (reset==false) ? false : true;
		
		this.popup.setStyles({'display':'none',width:'0px',height:'0px',left:'0px',top:'0px','margin-left':'0px','margin-top':'0px'})
		if(this.popupback) this.popupback.setStyles({'display':'none','width':'0px','height':'0px'})
		
		if (reset) this.popup.empty();
		
	},
	
	load: function(url,complete_func){

		new Ajax(unescape(url), {
			method: 'get',
			evalScripts: true,
			update: this.popup,
			onComplete: (complete_func==undefined) ? function(){} : complete_func
		}).request();
	
	},
	
	setHTML: function(txt){
		this.popup.empty().setHTML(txt);
	}
	
});

mzPopup.implement(new Options);

