function GkAlert () {}

GkAlert.prototype.destroy = function (e) {
	Event.stop(e);
	$('GkAlert').remove();
}

GkAlert.prototype.build = function (o) {
	var alertHtml = '<div id="GkAlert">';
	alertHtml += '<div id="GkAlertBg"></div>';
	alertHtml += '<div id="GkAlertBox">';
	alertHtml += '<div id="GkAlertText">';
	alertHtml += o.message;
	alertHtml += '</div>';
	alertHtml += '<div id="GkAlertButtons">';
	if (o.type && o.type == 'progress') {
		alertHtml += "Cette fenêtre se fermera automatiquement à la fin de l'opération";
	} else {
		
		if (!o.type || o.type == 'alert') {
			alertHtml += '<a href="#" id="GkAlertOkBtn" /><span>OK</span></a>';
			
		} else if (o.type == 'confirm') {
			this.onConfirm = o.onConfirm;
			alertHtml += '<input type="button" value="OUI" onclick="GkAlert.onConfirm()" /> ';
			alertHtml += '<input type="button" value="NON" onclick="GkAlert.destroy()" />';
		}
		
	}
	alertHtml += '</div>';
	alertHtml += '</div>';
	alertHtml += '</div>';
	new Insertion.Bottom(document.body, alertHtml);
	
	if ($('GkAlertOkBtn')) {
		Event.observe($('GkAlertOkBtn'), 'click', GkAlert.destroy);
		$('GkAlertOkBtn').focus();
	}
}

GkAlert.prototype.init = function (o) {
	this.build(o);
}

GkAlert = new GkAlert();
