
function AddWidgetBubble(btn) {
	
	this.btn = btn;
	this.widgetId = btn.id;
	this.userId = YAHOO.util.Dom.get('txtUserId').value;
	
	YAHOO.util.Event.addListener(this.btn, 'click', function() {
		   this.showDialogBubble();
		   WidgetLibraryService.addWidgetToProfile(this.widgetId, this.userId, function(){});
		   this.btn.innerHTML = '<span class="btn_gray_medium on_profile_pos">Added to Profile</span>';
		   YAHOO.util.Event.removeListener(this.btn, 'click');
		   YAHOO.util.Dom.setStyle(this.btn, 'cursor', 'default');
		}, this, true);
	
}

AddWidgetBubble.prototype.showDialogBubble = function() {
	
	var bubble = YAHOO.util.Dom.get('dialog_bubble');//.cloneNode(true);
	//this.colA.appendChild(bubble);
	
	var offsetX = -5;
	var offsetY = -95;
	
	if (BrowserDetect.browser == 'Explorer') {
		offsetY = -101;
	}
	
	var posX = YAHOO.util.Dom.getX(this.btn) + offsetX;
	var posY = YAHOO.util.Dom.getY(this.btn) + offsetY;
	YAHOO.util.Dom.setXY(bubble,[posX,posY]);
	YAHOO.util.Dom.setStyle(bubble, 'visibility', 'visible');
	
}

YAHOO.util.Event.onDOMReady( function() {
	
		var buttons = YAHOO.util.Dom.getElementsByClassName('add_to_profile','a');
		//var colA = YAHOO.util.Dom.get('col_a');
		
		for (var i=0; i < buttons.length; i++) {
			buttons[i] = new AddWidgetBubble(buttons[i]);
		}
		
		var closeBtn = YAHOO.util.Dom.get('close_dialog');
		YAHOO.util.Event.addListener(closeBtn, 'click', function() {
				var bubble = YAHOO.util.Dom.get('dialog_bubble');
				YAHOO.util.Dom.setStyle(bubble, 'visibility', 'hidden');
			}, this, true);
		
	});