var DrCustomAlert = new Class({
	initialize: function(alert) {
		
			
			this.fond = new Element('div', {
				'class' : 'fondDrArrayImageViewer'
			});
			
			
			alert.setStyle('display','block');
			
			var size = alert.getSize().size;
			
			alert.setStyle('display','none');
			
			this.previous = alert.getPrevious();
			
			this.conteneur = alert;
			
						
			this.conteneur.setStyles({"display":'block',
										'position': 'fixed',
										'top':0,
										'left':0,
										'z-index':10002
									//	'width':(size.x - 40)+'px'
										
			});
			
			
			
			this.timeeffect = 300;
			

			
			
			this.fond.setOpacity(0);
			this.conteneur.setOpacity(0);
			
			this.fond.injectTop($(document.body));
			this.conteneur.injectTop($(document.body));
			
			
			
			
			
			this.conteneur.setStyle('top',(getWindowHeight()-parseInt(this.conteneur.getStyle('height')))/2);
			this.conteneur.setStyle('left',(getWindowWidth()-parseInt(this.conteneur.getStyle('width')))/2);
			

		
			
			
			var annim = this.fond.effect('opacity', {duration: this.timeeffect, transition: Fx.Transitions.linear});
			annim.start(0, 0.7);
			
			this.annim2 = this.conteneur.effects({duration: this.timeeffect, transition: Fx.Transitions.Cubic.easeOut}).start({'opacity':[0,1]});
	
			
			window.addEvent('resize',function(){
				
				this.annim2.start({
					'top':((getWindowHeight()-parseInt(this.conteneur.getStyle('height')))/2),
					'left':((getWindowWidth()-parseInt(this.conteneur.getStyle('width')))/2)					
				});
			}.bind(this));
			
			
			annim.addEvent('onComplete',function(){
				
				this.fond.addEvent('click',function(){this.close();}.bind(this));			
				
			}.bind(this));
		
				
		
		
		
	},
	close: function(){
		
		var tout= $$(this.fond,this.conteneur);
		
		
		var fx =new Fx.Elements(tout,{duration:200});
		fx.start({'0':{'opacity': [0]},'1':{'opacity': [1,0]}});
		
		fx.addEvent('onComplete',function(){this.removeAll();}.bind(this));
		
	},
	removeAll:function(){
		this.fond.remove();
		
		if(this.previous){
			this.conteneur.injectAfter(this.previous);
		}
	}
});



function getWindowHeight()
{
	 myHeight = 0;
	  if( document.documentElement && ( document.documentElement.clientHeight  ) ) {
		  //IE 6+ in 'standards compliant mode'
		    
		    myHeight = document.documentElement.clientHeight;
	  } else if( typeof( window.innerHeight ) == 'number' ) {
		  //Non-IE	  
		    myHeight = window.innerHeight;
		  
		 
	  } else if( document.body && ( document.body.clientHeight ) ) {
	    //IE 4 compatible	   
	    myHeight = document.body.clientHeight;
	  }
	  	  
	  return myHeight;
	  
	 
}

function getWindowWidth()
{
	
	 var myWidth = 0;
	 
	  if( document.documentElement && ( document.documentElement.clientWidth  ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		   
	  } else if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    
	  }  else if( document.body && ( document.body.clientWidth  ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	   
	  }
	
	  return myWidth ;
	 
}



