/*
Script Openbox Fade 2.0.0
©2010 djm Web sprl

Need jQuery 1.3.2
*/
jQuery.noConflict();

var fadeBoxFct;
if (!fadeBoxFct) fadeBoxFct = function() {
	this.fadebox = false;
	this.speed='slow';
	this.op_back='0.75';
}

jQuery.extend(fadeBoxFct.prototype, {
	show_fadebox : function(fichier) {
		var obj=this;
		jQuery.ajax({
			type: "GET",
			url: fichier,
			dataType: "html",
			success: function(content) {
				obj.construct_fadebox(content);
				jQuery(obj.fadebox).css('background-image','none');
				}
			});
		},
	construct_fadebox : function(content) {
		var obj=this;
		if (!this.fadebox) {
			this.fadebox = document.createElement('div');
			jQuery(this.fadebox).css({
				'position':'absolute',
				'background-color':'#FFFFFF',
				'background-image':'url(./images/waiting.gif)',
				'background-repeat':'no-repeat',
				'background-position':'center center',
				'border':'solid 1px #000000',
				'top':'100px',
				'left':'50%',
				'z-index':'15001',
				'padding':'5px'
				});
			jQuery(this.fadebox).addClass('fadebox').appendTo('body');
			
			this.fadebox_close = document.createElement('a');
			jQuery(this.fadebox_close).css({
				'display':'block',
				'font-family':'"Trebuchet MS", Tahoma, Arial, sans-serif',
				'text-decoration':'none',
				'color':'#000000',
				'font-size':'16px',
				'font-weight':'bold',
				'text-align':'right',
				'margin-bottom':'5px',
				'cursor':'pointer'
				});
			jQuery(this.fadebox_close).text('X');
			jQuery(this.fadebox_close).addClass('fadebox_close').appendTo(this.fadebox);
			jQuery(this.fadebox_close).click(function(){
				obj.hide_fadebox();
				});
			
			this.fadebox_content = document.createElement('div');
			jQuery(this.fadebox_content).css({
				'color':'#000000'
				});			
			jQuery(this.fadebox_content).addClass('fadebox_content').appendTo(this.fadebox);
			
			this.fadebox_back = document.createElement('div');
			jQuery(this.fadebox_back).css({
				'position':'absolute',
				'top':'0px',
				'left':'0px',
				'background-color':'#000000',
				'z-index':'15000',
				'opacity':this.op_back
				});
			jQuery(this.fadebox_back).html('&nbsp;');
			jQuery(this.fadebox_back).addClass('fadebox_back').appendTo('body');
			jQuery(this.fadebox_back).click(function(){
				obj.hide_fadebox();
				});
			}
			
			jQuery(this.fadebox).css({
				'opacity':'0',
				'display':'block'
				});
			jQuery(this.fadebox_back).css({
				'opacity':'0',
				'display':'block'
				});	
			jQuery(this.fadebox_content).html(content);
			this.get_size_fadebox();
			this.get_size_fadebox_back();
			jQuery(this.fadebox).fadeTo(this.speed,1);
			jQuery(this.fadebox_back).fadeTo(this.speed,this.op_back);
			jQuery(window).scroll(function () {
				obj.get_size_fadebox_back();
				});
			jQuery(window).resize(function () {
				obj.get_size_fadebox_back();
				});
		},
	hide_fadebox : function () {	
		jQuery(this.fadebox_content).html('');
		jQuery(this.fadebox).css('display','none');
		jQuery(this.fadebox_back).css('display','none');
		},
	get_size_fadebox : function() {
		var posLeft;
		var posTop;
		posLeft = ((jQuery(this.fadebox).width())/2);
		posTop = (((jQuery(this.fadebox).height())+15)/2);
		jQuery(this.fadebox).css({
			'margin-left':'-'+posLeft+'px',
			'top':'50%',
			'margin-top':jQuery(window).scrollTop()-posTop+'px'
			});
		},
	get_size_fadebox_back : function() {
		jQuery(this.fadebox_back).css({
			'top':jQuery(window).scrollTop()+'px',
			'left':jQuery(window).scrollLeft()+'px',
			'height':jQuery(window).height()+'px',
			'width':jQuery(window).width()+'px'
			});
		}
	});