var Popin = {

	masque : null,
	conteneur : null,
	iframe : null,
	duree : 0,

	init : function(pIdMasque, pIdConteneur, pDureeAffichage) {
		this.masque = $('#'+pIdMasque);
		this.conteneur = $('#'+pIdConteneur);
		if (pDureeAffichage != undefined && pDureeAffichage>0) {
			this.duree = pDureeAffichage * 1000;
		}
		this.iframe = $('<iframe id="masqueIframe" src="javascript:false;"></iframe>');
		this.masque.before(this.iframe);
		this.resize();
		this.show();
	},

	resize : function() {
		if (Popin.conteneur[0] != undefined) {
			var lHeight = $(document).height();
			var lWidth = $(document).width();
			Popin.iframe.height(lHeight);
			Popin.iframe.width(lWidth);
			Popin.masque.height(lHeight);
			Popin.masque.width(lWidth);
			Popin.conteneur.height($(window).height());
			Popin.conteneur.width($(window).width());
		}
	},

	show : function() {
		if (Popin.conteneur[0] != undefined) {
			$(window).bind('resize',Popin.resize);
			$('#media_box > object').css('display','none');
			Popin.masque.show();
			Popin.conteneur.show();
			if (Popin.duree > 0) {
				window.setTimeout(Popin.hide,Popin.duree);
			}
		}
	},

	hide : function() {
		if (Popin.conteneur[0] != undefined) {
			$(window).unbind('resize',Popin.resize);
			Popin.masque.hide();
			Popin.conteneur.hide();
			Popin.iframe.hide();
			$('#media_box > object').css('display','');
		}		
	}

}
