// 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() {
			log(jQuery("#headerProductLink"));
			log(jQuery.Menu);
			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");
					if (name == 'esobi_software') {						
						var target = '/web/click/index/topnavi/v25';
						trackClick(target);
						window.location.href = "/en/product/overview.jsp";
						
					} else if (name == 'esobi_mobile_windows') {						
						var target = '/web/click/index/topnavi/wm';
						trackClick(target);
						window.location.href = "/en/product/overview_wm.jsp";
						
					} else if (name == 'esobi_mobile_andriod') {						
						var target = '/web/click/index/topnavi/android';
						trackClick(target);
						window.location.href = "/en/product/overview_android.jsp";
					}
					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();
});
