Overlay = {
init: function(){
		this.start();
	},

start: function(){
		//SI DIVS EXISTENT PAS ON LES CRÉE//	
		$('<div id="HoverNav" style="display:none;"></div>').prependTo('body');  
		$('<div id="Overlay" style="display:none;"></div>').prependTo('body');  	

		$('#Overlay').css({'opacity':'0.5', 'z-index':'20', 'background-color':'#000000', 'position':'absolute','top':'0px','left':'0px'});
		$('#HoverNav').css({'z-index':'21', 'position':'absolute','top':'0px','left':'0px'});
		
		$('#Overlay').click(function(){
			Overlay.hide();
			return false;
		});
	},

set_width_ie6: function(){
	_w=$('#HoverNav #popup div:first').css("width");
	if(typeof(_w)!='undefined'){_w=_w.split('px')[0];}
	
	_padding_left=$('#HoverNav #popup div:first').css("padding-left");
	if(typeof(_padding_left)!='undefined'){_padding_left=_padding_left.split('px')[0];}else{_padding_left=0;}
	_padding_right=$('#HoverNav #popup div:first').css("padding-right");
	if(typeof(_padding_right)!='undefined'){_padding_right=_padding_right.split('px')[0];}else{_padding_right=0;}
	
	if(typeof(_w)=='undefined' || _w=='auto'){
		$('#HoverNav #popup').css('overflow','auto');
		_w=500;
	}
	_w=parseFloat(_w) + parseFloat(_padding_left) + parseFloat(_padding_right);
	//alert(_w);

	if(_w>1){
		clearInterval(inter);
		$('#HoverNav').width(_w);
		
		windowTop("HoverNav");
		$('#close').css({'position':'absolute', 'top':'12px', 'left': (_w-$('#close').width() - 10)+'px'});
		$('#HoverNav').css('visibility','visible');
		
		//alert($('#HoverNav #popup').scrollHeight);
	}
},
	
display: function(_content){
		$('#content object').css('visibility', 'hidden');
		/*if(_width==undefined){_width=550;}*/

		// annuler suivi lien sur IE6 => fonctions.js //
		suppr_event_ie6();

		this.arrayPageSize = getPageSize();
		_content='<div id="popup"><a id="close" style="cursor:pointer;">FERMER</a>'+ _content ;
		_content+='</div>';
		
		//SI DIV PAS ENCORE AFFICHÉ => FADE IN//
		if($('#HoverNav').css('display') == 'none'){
			$('#HoverNav').html('');
			$('#Overlay').width(this.arrayPageSize[0]);
			$('#Overlay').height(this.arrayPageSize[1]);
			//$('#HoverNav').css({'width': _width + 'px'});
			//$('#Overlay').css('filter', 'alpha(opacity=60)');
			
			
			$('#HoverNav').html(_content);
			
			$('#HoverNav').show();
			$('#HoverNav').css('visibility','hidden');

			if(_overlay_from_url==0){$('#popup').css('padding','10px');}
			else{$('#popup').css('padding','0');}
			
			$('#Overlay').fadeIn("fast", function(){
				if (nav[0]=='IE' && (nav[1]<8)){
					/**CAS PARTICULIER IE POUR WIDTH AJUSTÉE**/
					inter=setInterval("Overlay.set_width_ie6()", 100);
				}else{
					windowTop("HoverNav");
					$('#HoverNav').css('visibility','visible');
				}
				
				if($('#HoverNav').height() > 450){
					$('#HoverNav .content').css('height', '450px');
					$('#HoverNav .content').css('overflow', 'auto');
				}
			});
			
			$('#close').click(function(){
				Overlay.hide();
				return false;
			});			

			if (nav[0]=='IE' && nav[1]==6){
				/*$('#page select').css();*/
				$('body > *').bgiframe();
			}
		}else{
			$('#HoverNav').html(_content);
			
			if (nav[0]=='IE' && nav[1]==6){
				/**CAS PARTICULIER IE 6 POUR WIDTH AJUSTÉE**/
				$('#popup').width(1);
				inter=setInterval("Overlay.set_width_ie6()", 100);
			}
			
			$('#close').click(function(){	
				Overlay.hide();
				return false;
			});	
		}
	},

	display_from_url:function(_url, _datas){
		/** !!! join datats (&) !!! **/
		_overlay_from_url=1;
	
		$.ajax({
type: "GET",
url: _url,
async: false,
data: '',
success: function(msg){
				Overlay.display(msg);
				_overlay_from_url=0;
			}
		});
	},

hide:function(){
		$('#HoverNav').fadeOut('fast');
		$('#Overlay').fadeOut('fast', function(){
			$('#content object').css('visibility', 'visible');
		});
		
		
	}
};

$(function(){
	_overlay_from_url=0;
	Overlay.init();
});
