/**
 * @author Alexandre ARASTE
 * Mars 2007
 * V 1.0
 * Nécessite prototype.js v 1.5.0 (http://prototypejs.org/)
 * Nécessite  curvyCorners  (http://www.curvycorners.net)
 * Crée un filtre (this.filter) opaque de la taille de la page et affiche this.message centré sur la page.
 */
 
var OBJdisplayMessage=Class.create()
OBJdisplayMessage.prototype = {
	initialize:function(filterId, messageId){
		/*Définit le div qui sert de filtre */
		if (!$(filterId)){
			var d = document.createElement('DIV')
			d.id=filterId
			this.filter = $(d)
			document.body.appendChild(d)
		}else {this.filter=$(filterId)}
		
	    this.filter.setStyle({height:'100%', width:'100%', zIndex:'1000', MozOpacity:'0.5', filter:'alpha(opacity=50)', backgroundColor:'#4f4c4c', position:'absolute', top:'0px', left:'0px'})
		this.filter.hide()
		
		if (messageId) this.setMessage(messageId, false)
		
	    this.setPosition=function(){
	        var h = ((this.filter.clientHeight - this.message.clientHeight) / 2) + 'px'
	        var l = ((this.filter.clientWidth - this.message.clientWidth) /2) + 'px'
	        this.message.setStyle({top:h, left:l})
	    }
	    
	    this.onResize=function(){
	        var style
	        if (window.outerHeight){style={height:window.outerHeight+'px', width:window.outerWidth+'px'}}
	        if (window.clientHeight){style={height:window.clientHeight+'px', width:window.clientWidth+'px'}}
	        this.setPosition()
	    }.bind(this)
	},
	
	showMessage:function(){
        this.filter.show()
        this.message.show()
        this.setPosition()
        Event.observe(window, 'resize', this.onResize, true)
	},
	
	hideMessage:function(){
	    this.message.hide()
	    this.filter.hide()
	    Event.stopObserving(window, 'resize', this.onResize, true)
	},
	
	setMessage:function(objMessage, bDisplay){
	    this.message = (typeof objMessage=='string')?$(objMessage):$(objMessage)
		$(this.message).setStyle({position:'absolute', zIndex:'1001'})
		this.message.hide()
		 settings = {
             tl:{ radius: 20 },
             tr:{ radius: 20 },
             bl:{ radius: 20 },
             br:{ radius: 20 },
             antiAlias: true,
             autoPad: true,
             validTags: ["div"]
         }
      
      var myBoxObject = new curvyCorners(settings, this.message);
      myBoxObject.applyCornersToAll();
      
      if (bDisplay) this.showMessage()
	},
	
	toggle:function(){
	        if (!this.message.visible()){this.showMessage();return}
	        this.hideMessage()
	}
}