/*
 * Framework Javascript (ToutoulJs)
 *	Fichier : popup.js
 *  Auteur : Le TOULLEC Martial
 * 	Url : http://www.hackariens.fr
 *  Date création : 6 Juillet 2010
 *  Date modification : 17 Juin 2011
 *  version : 1.8
*/
var popup = {
	variable: {
		titre: '',
		message: '',
		options: ""
	},
	Init: function(){
		body = document.getElementsByTagName('body')[0];
		popupdialog = document.getElementById('PopupDialog');
		if(popupdialog==null){
			popupdialog = document.createElement('div');
			popupdialog.setAttribute('id','PopupDialog');
			avant = body.firstChild;
			body.insertBefore(popupdialog,avant);
		}
		$("#PopupDialog:ui-dialog").dialog("destroy");
	},
	OptionsAlert: function(){
		options = {
			height:300,
			width:400,
			buttons: {
				Ok: function() {
					popup.Cacher();
				}
			}
		};
		return options;
	},
	Set: {
		Titre: function(chaine){
			popup.variable.titre = chaine;
		},
		Message: function(chaine){
			popup.variable.message = chaine;
		}
	},
	Afficher: function(data){
		popup.Init();
		popupdialog = document.getElementById('PopupDialog');
		popupdialog.innerHTML = "<p>"+popup.variable.message+"<p>";
		options = {
			title: popup.variable.titre,
			modal: true,
			draggable: true,
			resizable: true,
			closeText: 'hide',
			width: 400,
			beforeClose: function(event,ui){
				popup.FlashActif();
			},
			beforeClose: function(event,ui){
				popup.FlashActif();
			},
			open: function(event,ui){
				popup.FlashCacher();
			}
		};
		if(data!=""){
			if(data.buttons!=""){
				options.buttons = data.buttons
			}
			if(data.width!=""){
				options.width = data.width;
			}
			if(data.height!=""){
				options.width = data.height;
			}
		}
		$("#PopupDialog").dialog(options);
	},
	FlashActif: function(){
		$('embed').css('visibility','visible');
		$('iframe').css('visibility','visible');
	},
	FlashCacher: function(){
		$('embed').css('visibility','hidden');
		$('iframe').css('visibility','hidden');
	},
	Cacher: function(){
		popup.Init();
		popup.variable.titre = '';
		popup.variable.message = '';
		popup.variable.mot = '';
		popup.FlashActif();
		$("#PopupDialog").dialog("close");
	}
};

