/**
 * VCM Header
 * @classDescription Class for the header
 * @param {VCMPage} page Reference to the VCMPage parent
 * @return {VCMHeader} Returns a new VCMHeader object
 * @constructor
 */
function VCMHeader(page) {
	this._page = page;
}

VCMHeader.prototype = {
	/**
	 * Reference to a VCMPage object
	 * @type {VCMPage}
	 */
	_page: null,
	/**
	 * jQuery reference to the languages links
	 * @type {jQuery}
	 */
	_jLangLinks: null,
	/**
	 * jQuery reference to the home link
	 * @type {jQuery}
	 */
	_jHome: null,
	/**
	 * jQuery reference to the menu links
	 * @type {jQuery}
	 */
	_jMenuLinks: null,
	
	/**
	 * Initialize the header
	 */
	init: function() {
		console.log('VCMHeader.init();');
		// Get jQuery references
		this._jLangLinks = $('.langLink');
		this._jHome = $('#home, #bannerLnk');
		this._jMenuLinks = $('#menuBar a');
		// Add events
		this._jLangLinks.click($.proxy(this, 'onLangClick'));
		this._jHome.click($.proxy(this, 'onHomeClick'));
		this._jMenuLinks.click($.proxy(this, 'onMenuClick'));
	},
	
	/**
	 * Destroy the header
	 */
	destroy: function() {
		console.log('VCMHeader.destroy();');
		// Remove events
		this._jLangLinks.unbind('click');
		this._jHome.unbind('click');
		this._jMenuLinks.unbind('click');
		// Destroy jQuery reference
		this._jLangLinks = null;
		this._jHome = null;
		this._jMenuLinks = null;
	},
	
	/**
	 * On language link click
	 * @param {Event} evt The Event object
	 * @private
	 */
	onLangClick: function(evt) {
		console.log('VCMHeader.onLangClick();');
		var params = VCMHistory.getParams();
		params.lang = $(evt.currentTarget).attr('id').substr(0, 2).toUpperCase();
		this._page.load(params);
		return false;
	},
	
	/**
	 * On home link click
	 * @param {Event} evt The Event object
	 * @private
	 */
	onHomeClick: function(evt) {
		console.log('VCMHeader.onHomeClick();');
		this._page.getContent().reset();
		this._page.load();
		return false;
	},

	/**
	 * On menu link click
	 * @param {Event} evt The Event object
	 * @private
	 */
	onMenuClick: function(evt) {
		console.log('VCMHeader.onMenuClick();');
		this._jMenuLinks.removeClass('selected');
		$(evt.currentTarget).addClass('selected');
		this._page.getContent().showActivities();
		this._page.getSideBar().displayCMS();
		return false;
	},
	
	deselectDay: function() {
		this._jMenuLinks.removeClass('selected');
	}
	
};


