/**
 * Create a new instance of VCMProfileBar
 * @classDescription VCM Profile Bar
 * @param {VCMPage} page Reference to the VCMPage object
 * @return Returns a new instance of VCMProfileBar
 * @constructor
 */
function VCMProfileBar(page) {
	this._page = page;
}

VCMProfileBar.prototype = {
	/**
	 * Reference to the VCMPage
	 * @type {VCMPage}
	 */
	_page: null,
	
	/**
	 * jQuery reference to the modify buttons
	 * @type {jQuery}
	 */
	_jModifyBtns: null,
	
	/**
	 * jQuery reference to the view my activity button
	 * @type {jQuery}
	 */
	_jBtnViewMyActivity: null,
	
	/**
	 * Initialize the profile bar
	 */
	init: function() {
		// Make jQuery reference
		this._jModifyBtns = $('.profileBoxContent > a.btn');
		this._jBtnViewMyActivity = $('#btnViewMyActivity');
		// Add events
		this._jModifyBtns.click($.proxy(this, 'onModifyClick'));
		this._jBtnViewMyActivity.click($.proxy(this, 'onViewMyActivityClick'));
	},
	
	/**
	 * Destroy the profile bar
	 */
	destroy: function() {
		// Remove events
		this._jModifyBtns.unbind('click');
		this._jBtnViewMyActivity.unbind('click');
		// Destroy reference
		this._jModifyBtns = null;
		this._jBtnViewMyActivity = null;
	},
	
	/**
	 * On Modify Click
	 * @param {Event} evt The Event object
	 */
	onModifyClick: function(evt) {
		var m = new VCMInscriptionModal(this._page),
			jBtn = $(evt.target);
		// Open inscription modal on right tab
		if (jBtn.parent('#myInfolettre').length == 1) {
			m.init(2);
		} else if (jBtn.parent('#myPreferences').length == 1) {
			m.init(1);
		} else {
			m.init();
		}
		// Cancel default event
		return false;
	},
	
	/**
	 * On View My Activity Click
	 * @param {Event} evt The Event object
	 */
	onViewMyActivityClick: function(evt) {
		// Show the home page
		this._page.getContent().showHomePage();
		// Cancel default event
		return false;
	}
};


