var popUp=new Class({
	Implements: [Options, Events],
	options:{
		autoClose: true,
		closeLink: true,
		position: 'absolute',
		ids:Number.random(1,10)/Number.random(11,100),
		background:'#FFF'
	},
	initialize: function(micontenido,miyscreen,mixscreen,options){
		this.setOptions(options);
		this.divContenedorPop = new Element('div',{
			styles : {
				'padding':'5px',
				'position':this.options.position,
				'z-index':'20',
				'background-color':this.options.background,
				'border-radius':'5px',
				'-moz-border-radius':'5px',
				'-webkit-border-radius':'5px',
				'border':'#CCC 1px solid',
				'box-shadow':'#333 5px 5px 15px',
				'-moz-box-shadow':'#333 5px 5px 15px',
				'-webkit-box-shadow':'#333 5px 5px 15px',
				'top':miyscreen,
				'left':mixscreen
			}
		});
		if(this.options.closeLink){
			this.divContenedorPop.set('html','<div style="float:right;"><a id="cierraFrame_'+this.options.ids+'" style="color:#800000; cursor:pointer;"><img src="/btn_cerrar.gif" border="0" title="Cerrar Ventana" /></a></div><div id="divFormularioClave_'+this.options.ids+'"></div><div style=" height:11px; width:13px; background: url("lenguetaD.png"); float:right"></div>');
		} else {
			this.divContenedorPop.set('html','<div id="divFormularioClave_'+this.options.ids+'"></div><div style=" height:11px; width:13px; background: url(\'lenguetaD.png\'); position:absolute; right:3px; margin-top:5px;"></div>');
		}
		$(document.body).adopt(this.divContenedorPop);
		$('divFormularioClave_'+this.options.ids).adopt(micontenido);
		if(this.options.autoClose){
			$(document.body).addEvent('click',function(e){if(this.divContenedorPop && !e.target || !$(e.target).getParents().contains(this.divContenedorPop)) this.destruye(); }.bind(this));
		}
		if(this.options.closeLink){
			$('cierraFrame_'+this.options.ids).addEvent('click',function(e){ this.destruye(); }.bind(this));
		}
	},
	destruye: function(){
		this.divContenedorPop.destroy();
		$(document.body).removeEvents();
	},
	hide: function(){
		this.divContenedorPop.hide();
	},
	show: function(){
		this.divContenedorPop.show();
	},
	highlight:function(){
		this.divContenedorPop.highlight();
	}
});
var popUpMask = new Class({
	Implements: [Options, Events],
	options:{
		width:'400px',
		top:'10%',
		closeLink: true,
		ids:Number.random(1,10)/Number.random(11,100),
		background:'#FFF',
		border_size:'5px'
	},
    initialize: function(cont,options){
		this.setOptions(options);
		this.myMask = new Mask('',{id:'miMascara'});
		this.myMask.show();
		this.divContenedorPopup = new Element('div',{
			styles : {
				'width':'100%',
				'position':'fixed',
				'top':this.options.top,
				'z-index':'10'
			}
		});
		this.contenedor = new Element('div',{
			styles:{
				'width':this.options.width,
				'margin':'0 auto',
				'background-color':this.options.background,
				'border':'solid '+this.options.border_size,
				'-moz-border-radius':'5px',
				'-moz-box-shadow':'#999 0 0 10px',
				'border-radius':'5px',
				'box-shadow':'#999 0 0 10px',
				'-webkit-border-radius':'5px',
				'-webkit-box-shadow':'#999 0 0 10px'
			}
		});
		this.closeLink = new Element('img',{
			styles:{'float':'right','cursor':'pointer'},
			src:'/btn_cerrar.gif'
		});
		this.contenido = new Element('div').adopt(cargando);
	
		if(this.options.closeLink){
			this.contenedor.adopt(this.closeLink,this.contenido);
			this.closeLink.addEvent('click',function(e){ this.destruye(); }.bind(this));
		} else {
			this.contenedor.adopt(this.contenido);
		}
	
		this.divContenedorPopup.adopt(this.contenedor);
		$(document.body).adopt(this.divContenedorPopup);
    },
	destruye: function(){
		this.divContenedorPopup.destroy();
		this.myMask.destroy();
	},
	hide: function(){
		this.divContenedorPopup.hide();
		this.myMask.hide();
	},
	show: function(){
		this.divContenedorPopup.show();
		this.myMask.show();
	},
	update:function(el){
		this.contenido.set('text','');
		this.contenido.adopt(el);
		return this;
	}
});
var windowPopUp = new Class({
	Implements: [Options, Events],
	options:{
		width:'600px',
		height:'600px'
	},
    initialize: function(url,nombre,options){
		this.setOptions(options);
		window.open(url,nombre, 'status=0, toolbar=0, location=0, menubar=0,directories=0, resizable=0, scrollbars=0, width='+this.options.width+', height='+this.options.height+'');
    }
});
