﻿
menu_type = new Array();

menu_type[1] = JC_Company_Menu;

menu_type[2] = JC_product_Menu;

function menu_getPos(el,sProp)
{
	var iPos = 0; 
    while (el != null)
　　{
		iPos += el["offset" + sProp];
		el = el.offsetParent;
	} 
    return iPos;
}

var cur_idx = 0;
var menu_cmlayer_allow = true; 
var menu_type_div = "menu_type_div";

document.onclick = new Function("dclick()");
function dclick()  
{
	menu_showLayer(0, null, null, '', false, false)
	if(typeof lst_showLayer != 'undefined')
	{
		lst_showLayer(null, null, '');
	}
}
function menu_showLayer(idx, el, m, mname, w , h )  
{
	if(m) 
	{
		if((m.style.visibility == "visible") && (cur_idx == idx))
		{
			m.style.visibility = "hidden";
			menu_cmlayer_allow = true;
			cur_idx = 0;
			return;
		}
		
		var l = menu_getPos(el,"Left");
		var t = menu_getPos(el,"Top") ;
		if(w)
		{
            l += el.offsetWidth; 
		}
		if(h)
		{
		    t += el.offsetHeight;
		}
		
		if (document.layers)
		{
			oo(mname).left = l;
			oo(mname).top = t;
		}
		else if (document.all)
		{
			oo(mname).style.left=l;
			oo(mname).style.top=t;
		}
		else if (document.getElementById)
		{
			document.getElementById(mname).style.left=l + "px";
			document.getElementById(mname).style.top=t + "px";
		}
		m.style.visibility = "visible";
		
		menu_cmlayer_allow = false;
		window.setTimeout("menu_allow_show()", 100);
	}
	
	if(cur_idx)
	{
		if(! menu_cmlayer_allow) return;
		oo(menu_type_div).style.visibility = "hidden"; 			
		menu_cmlayer_allow = true;
	}
	
	cur_idx = idx;
}
function menu_allow_show()
{
	menu_cmlayer_allow = true;
}
function show_menu(idx, el, m, mname, w , h )
{
	oo(mname).innerHTML = menu_type[idx];
	menu_showLayer(idx, el, m, mname, w, h);
}

//判断用户的浏览器是不是IE，是则返回true，否则返回false
var agent = navigator.userAgent;


String.prototype.inc = function(k1, k2)
	{
		return k2 == null ? this.indexOf(k1) > -1 ? true : false : (k2 + this + k2) .indexOf(k2 + k1 + k2) > -1 ? true : false;
	};



var is_IE5 = agent.inc("IE 5") || agent.inc("IE 4");


//根据ID取对象
function oo(obj)
{
	return typeof(obj) != "string" ? obj : (is_IE5 ? document.all(obj) : document.getElementById(obj));
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}