//	create a new stylemanager object
var SM = new StyleManager();

function MainMenu(styleManager){
	this.prev_l1 = 0;
	this.defaultMenu = null;

	this.sm = styleManager;

	this.imgs = new Object();

	this.imgs.level1 = new Object();

	this.imgs.level1.off = new Object();

	this.imgs.level1.on = new Object();

	this.imgs.level1.off['mainNavLevel1_company'] = new Image();
	this.imgs.level1.off['mainNavLevel1_gls_platform'] = new Image();
	this.imgs.level1.off['mainNavLevel1_products'] = new Image();
	this.imgs.level1.off['mainNavLevel1_roi_tools'] = new Image();
	this.imgs.level1.off['mainNavLevel1_support'] = new Image();
	this.imgs.level1.off['mainNavLevel1_partners'] = new Image();
	this.imgs.level1.off['mainNavLevel1_newsroom'] = new Image();

	this.imgs.level1.off['mainNavLevel1_company'].src = "/images/nav/company_of.gif";
	this.imgs.level1.off['mainNavLevel1_gls_platform'].src = "/images/nav/glsadv_of.gif";
	this.imgs.level1.off['mainNavLevel1_products'].src = "/images/nav/products_of.gif";
	this.imgs.level1.off['mainNavLevel1_roi_tools'].src = "/images/nav/roitools_of.gif";
	this.imgs.level1.off['mainNavLevel1_support'].src = "/images/nav/support_of.gif";
	this.imgs.level1.off['mainNavLevel1_partners'].src = "/images/nav/partners_of.gif";
	this.imgs.level1.off['mainNavLevel1_newsroom'].src = "/images/nav/newsroom_of.gif";

	this.imgs.level1.on['mainNavLevel1_company'] = new Image();
	this.imgs.level1.on['mainNavLevel1_gls_platform'] = new Image();
	this.imgs.level1.on['mainNavLevel1_products'] = new Image();
	this.imgs.level1.on['mainNavLevel1_roi_tools'] = new Image();
	this.imgs.level1.on['mainNavLevel1_support'] = new Image();
	this.imgs.level1.on['mainNavLevel1_partners'] = new Image();
	this.imgs.level1.on['mainNavLevel1_newsroom'] = new Image();

	this.imgs.level1.on['mainNavLevel1_company'].src = "/images/nav/company_on.gif";
	this.imgs.level1.on['mainNavLevel1_gls_platform'].src = "/images/nav/glsadv_on.gif";
	this.imgs.level1.on['mainNavLevel1_products'].src = "/images/nav/products_on.gif";
	this.imgs.level1.on['mainNavLevel1_roi_tools'].src = "/images/nav/roitools_on.gif";
	this.imgs.level1.on['mainNavLevel1_support'].src = "/images/nav/support_on.gif";
	this.imgs.level1.on['mainNavLevel1_partners'].src = "/images/nav/partners_on.gif";
	this.imgs.level1.on['mainNavLevel1_newsroom'].src = "/images/nav/newsroom_on.gif";




}

MainMenu.prototype.show = function(nickname){
	this.hide();

	//	handle the button portion
	var name = 'mainNavLevel1_' + nickname;

	if(document.images){
		//if(this.prev_l1) document.images[this.prev_l1].src = this.imgs.level1.off[this.prev_l1].src;
		document.images[name].src = this.imgs.level1.on[name].src;
	}

	this.prev_l1 = name;
}

MainMenu.prototype.hide = function(){
	if(document.images && this.prev_l1 && (this.prev_l1 != ('mainNavLevel1_'+this.defaultMenu))){
		document.images[this.prev_l1].src = this.imgs.level1.off[this.prev_l1].src;
	}
}


MainMenu.prototype.showDefault = function(){
	if(this.defaultMenu != null){
		this.show(this.defaultMenu);
	}else{
		this.hide();
	}
}

MainMenu.prototype.removeTimeout = function(){
	this.__hideTimer = clearTimeout(this.__hideTimer);
}

MainMenu.prototype.resetTimeout = function(){
	this.__hideTimer = setTimeout('MM.hide()', 300);
}

MainMenu.prototype.l2mOver = function(){
//	this.removeTimeout();
}

MainMenu.prototype.l2mOut = function(){
//	this.resetTimeout();
}

MainMenu.prototype.l1mOut = function(){
	this.showDefault();
}

MainMenu.prototype.setMenu = function(nickname){
	if(nickname == '') return;
	//	handle the drop down portion
	var name = 'mainNavLevel2_' + nickname;	
	this.sm.setVisOfObj(name, true);
	this.defaultMenu = nickname;
	this.show(this.defaultMenu);
}


var MM = new MainMenu(SM);

