forum = function() {}

forum.Confirm = function(msg, yes, no, a) {
	new forum.ConfirmWindow(msg, yes, no, a);
	return false;
}

forum.ConfirmWindow = new Class({
	initialize: function(msg, yes, no, a) {

		var _obj = this;
		this.a = a;
		
		this.confirmWindow = new Element("div", { 
			'class': "forum-confirm",
			'text': msg 
		});
		
		var divControls = new Element("div", { 'class': "controls" });
		this.confirmWindow.grab(divControls);
				
		divControls.grab(new Element("a", {
			'href': "#",
			'text': yes,
			'events': {
		        'click': function(){
					_obj.approve();
					return false;
		        }
			}
		}));
		
		divControls.grab(new Element("a", {
			'href': "#",
			'text': no,
			'events': {
		        'click': function(){
					_obj.abort();
					return false;
		        }
			}
		}));
		
		this.bg = new Element("div", { 
			'class': "forum-confirm-bg"
		});
		
		this.bg.setStyle('opacity', 0);		
		
		document.body.appendChild(this.bg);
		this.bg.tween('opacity', 0, 0.5);
		
		document.body.appendChild(this.confirmWindow);		
	}, 
	
	approve: function() {
		window.location.href = this.a.href; 
	}, 
	
	abort: function() {
		document.body.removeChild(this.bg);
		document.body.removeChild(this.confirmWindow);
	} 
});

// 
