// Creating Module
var WebHeader = (function() {
	// static private methods
	function log(msg) {
		if (window.console != null) {
			console.log(msg);
		}
	}

	function constructor(caller, data) {
		// instance private methods
		function initialize() {
			jQuery("#headerProductLink").menu({
				content : $("#product_menu").html(),
				width : 130,
				doCheckHeight : false,
				itemSwapContentClass : "hover_content",
				hoverTriggerPopup : true,
				positionOffset : {
					x : 2,
					y : 2
				},
				onItemChosen : function(item, text) {
					log("===================[onItemChosen]===================");
					var name = $(item).attr("name");
					var prefix_target = '/web/click/index/topnavi';
					switch (name) {
						case 'esobi_V25' :
							var target = prefix_target + '/v25';
							trackClick(target);
							window.location.href = "/en/product/overview.jsp";
							break;
						case 'esobi_newsxpresso' :
							var target = prefix_target + '/newsxpresso';
							trackClick(target);
							window.location.href = "/en/product/overview_newsxpresso.jsp";
							break;
						case 'esobi_wm' :
							var target = prefix_target + '/wm';
							trackClick(target);
							window.location.href = "/en/product/overview_wm.jsp";
							break;
						case 'esobi_andriod' :
							var target = prefix_target + '/android';
							trackClick(target);
							window.location.href = "/en/product/overview_android.jsp";
							break;
						case 'newsxpresso_windows' :
							var target = prefix_target + '/newsxpresso_windows';
							trackClick(target);
							window.location.href = "/en/product/overview_newsxpresso.jsp";
							break;
						case 'newsxpresso_android' :
							var target = prefix_target + '/newsxpresso_android';
							trackClick(target);
							window.location.href = "/en/product/overview_newsxpresso_ag.jsp";
							break;
					}
					log(name);
				},
				onShow : function() {
					// log('show');
				},
				onClose : function() {
					// log('close');
				}
			});
		}

		return { // instance public methods
			initialize : initialize
		};
	} // constructor end

	var uniqueInstance; // private attribute that holds the single instance.
	return { // static public methods
		getInstance : function(caller, data) {
			if (!uniqueInstance) {
				uniqueInstance = constructor(caller, data);
				uniqueInstance.initialize();
			}
			return uniqueInstance;
		}
	}
})();

jQuery(document).ready(function() {
			WebHeader.getInstance();
		});

