function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_tagPlay()
{var i,j=0,x,a=MM_tagPlay.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
   var font = x.parentNode.parentNode.nextSibling.nextSibling;
   font.style.display = "";
   var fonts = font.parentNode.parentNode.getElementsByTagName("font");
   for(var f=0;f<fonts.length;f++)
   {if(font.id!=fonts[f].id) fonts[f].style.display = "none";}
   }
}
function MM_tagShow(ul_id, a, li_type)
{
    var ul=document.getElementById(ul_id);
    var uls = ul.parentNode.getElementsByTagName("ul");
    for(var i = 0; i < uls.length; i++)
    {if(ul!=uls[i]) uls[i].style.display="none";}
    ul.style.display="";
    var li = a.parentNode;
    var lis = li.parentNode.getElementsByTagName("li");
    for(var j=0; j<lis.length; j++)
    {if(lis[j]!=li) lis[j].style.backgroundImage="url()"; lis[j].style.margin = "";lis[j].firstChild.style.color="";lis[j].firstChild.style.marginTop="";}
    switch(li_type)
    {
    case "top":
        li.style.backgroundImage="url(../images/affiche_menu.jpg)";
        li.firstChild.style.color="#000000";
        return;
    case "down":
        li.style.backgroundImage="url(../images/area_sub_bg.gif)";
        li.style.margin = "8px";
        li.firstChild.style.color="#000000";
        li.firstChild.style.marginTop="-8px";
        return;
    }
}
//处理div的onmouseout事件
function MouseOutDiv(e,o) { 
    /* FF 下判断鼠标是否离开DIV */
    if(window.navigator.userAgent.indexOf("Firefox")>=1) { 
    var x = e.clientX + document.body.scrollLeft;
    var y = e.clientY + document.body.scrollTop ;
    var left = o.offsetLeft;
    var top = o.offsetTop;
    var w = o.offsetWidth;
    var h = o.offsetHeight;
    
    if(y < top || y > (h + top) || x > left + w || x<left ) { 
        document.getElementById('menudiv').innerHTML='';
    }
    }

    /* IE */
    if(o.contains(event.toElement ) == false) 
    document.getElementById('menudiv').innerHTML='';
    }
//获取元素坐标
function getElementPos(elementId)
{
    var ua = navigator.userAgent.toLowerCase();
    var isOpera = (ua.indexOf('opera') != -1);
    var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
    var el = elementId;
    if(el.parentNode === null || el.style.display == 'none') 
    {
        return false;
    }
    var parent = null;
    var pos = [];     
    var box;
    if(el.getBoundingClientRect)    //IE
    {         
        box = el.getBoundingClientRect();
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
        return {x:box.left + scrollLeft, y:box.top + scrollTop};
    }
    else if(document.getBoxObjectFor)    // gecko    
    {
        box = document.getBoxObjectFor(el); 
        var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0; 
        var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0; 
        pos = [box.x - borderLeft, box.y - borderTop];
    }
    else    // safari & opera    
    {
        pos = [el.offsetLeft, el.offsetTop];  
        parent = el.offsetParent;   
          
        if (parent != el) 
        { 
            while (parent) 
            {  
                pos[0] += parent.offsetLeft; 
                pos[1] += parent.offsetTop; 
                parent = parent.offsetParent;
            }  
        } 
  
        if (ua.indexOf('opera') != -1 || ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' )) 
        { 
            pos[0] -= document.body.offsetLeft;
            pos[1] -= document.body.offsetTop;         
        }    
    } 
                 
    if (el.parentNode) 
    { 
        parent = el.parentNode;
    } 
    else 
    {
        parent = null;
    }
    
    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') 
    { // account for any scrolled ancestors
        pos[0] -= parent.scrollLeft;
        pos[1] -= parent.scrollTop;
        
        if (parent.parentNode) 
        {
            parent = parent.parentNode;
        } 
        else 
        {
            parent = null;
        }
    }
    
    return {x:pos[0], y:pos[1]};
}
//hasMouseOverLi标示鼠标是否在Li上
//hasMouseOverMenuDiv表示鼠标是否在二级菜单上
var hasMouseOverLi=0;
var hasMouseOverMenuDiv=0;
function show2Menu(li,type)
{
if(hasMouseOverLi==0)
{
var menudiv=document.getElementById('menudiv');

menudiv.style.top=getElementPos(li).y+62+"px";
menudiv.style.visibility="visible";
menudiv.style.position="absolute";
switch(type)
{
    case 1:
	menudiv.style.left=getElementPos(li).x-25+"px";
        menudiv.innerHTML="<div class=\"menu_float\"><div class=\"menu_float_l\"></div><div class=\"menu_float_m\"><ul><li><a href=\"/news/gg/index.html\" target=\"_blank\" class=\"white_l\">公告</a></li><li><a href=\"/news/hd/index.html\" target=\"_blank\" class=\" white_l\">活动</a></li><li><a href=\"/news/xw/index.html\" target=\"_blank\" class=\" white_l\">新闻</a></li></ul></div><div class=\"menu_float_r\"></div></div>"
        break;
    case 2:
	menudiv.style.left=getElementPos(li).x-95+"px";
        menudiv.innerHTML="<div class=\"menu_float\"><div class=\"menu_float_l\"></div><div class=\"menu_float_m\"><ul><li><a href=\"http://pass.dipan.com/reg\" target=\"_blank\" class=\"white_l\">注册帐号</a></li><li><a href=\"javascript:void(0);\" target=\"_blank\" class=\" white_l\">进入游戏</a></li><li><a href=\"/news/option/200906/20090604143247.html\" target=\"_blank\" class=\" white_l\">基本操作</a></li><li><a href=\"/news/pro/index.html\" target=\"_blank\" class=\" white_l\">常见问题</a></li><li><a href=\"/news/tech/200906/2009060317208.html\" target=\"_blank\" class=\" white_l\">发展指南</a></li></ul></div><div class=\"menu_float_r\"></div></div>"
        break;
    case 3:
	menudiv.style.left=getElementPos(li).x-125+"px";
        menudiv.innerHTML="<div class=\"menu_float\"><div class=\"menu_float_l\"></div><div class=\"menu_float_m\"><ul><li><a href=\"/news/jc/index.html\" target=\"_blank\" class=\"white_l\">基础</a></li><li><a href=\"/news/js/200906/20090602165516.html\" target=\"_blank\" class=\" white_l\">军事</a></li><li><a href=\"/news/kj/index.html\" target=\"_blank\" class=\" white_l\">科技</a></li><li><a href=\"/news/nz/index.html\" target=\"_blank\" class=\" white_l\">内政</a></li><li><a href=\"/news/jz/index.html\" target=\"_blank\" class=\"white_l\">建筑</a></li><li><a href=\"/news/zc/index.html\" target=\"_blank\" class=\" white_l\">战场</a></li><li><a href=\"/news/lm/index.html\" target=\"_blank\" class=\" white_l\">联盟</a></li><li><a href=\"/news/rw/index.html\" target=\"_blank\" class=\" white_l\">任务</a></li><li><a href=\"/news/renwu/index.html\" target=\"_blank\" class=\" white_l\">人物</a></li></ul></div><div class=\"menu_float_r\"></div></div>"
        break;
    case 4:
	menudiv.style.left=getElementPos(li).x-135+"px";
        menudiv.innerHTML="<div class=\"menu_float\"><div class=\"menu_float_l\"></div><div class=\"menu_float_m\"><ul><li><a href=\"http://pass.dipan.com/reg\" target=\"_blank\" class=\"white_l\">注册帐号</a></li><li><a href=\"http://pass.dipan.com/m.aspx?cn=PassportInfo\" target=\"_blank\" class=\" white_l\">我的帐号</a></li><li><a href=\"http://pass.dipan.com/m.aspx?cn=payselect\" target=\"_blank\" class=\" white_l\">帐号充值</a></li><li><a href=\"javascript:void(0);\" class=\" white_l\">帐号激活</a></li><li><a href=\"http://pass.dipan.com/m.aspx?cn=PassEdit\" target=\"_blank\" class=\" white_l\">密码修改</a></li></ul></div><div class=\"menu_float_r\"></div></div>"
        break;
}
hasMouseOverLi=1;
hasMouseOverMenuDiv=1;
}
}

function hide2Menu()
{
hasMouseOverLi=0;
hasMouseOverMenuDiv=0;
}

function CheckMenuDiv()
{
	if(!hasMouseOverMenuDiv)
    {
        document.getElementById('menudiv').style.position="absolute";
	    document.getElementById('menudiv').innerHTML='';
    }
}




