function intFill(i)

{

	var s = "";

	var k = parseInt(i,10);

	if(k < 10) s = "0" + k;

	else s = k.toString();

	return s;

};

function swapSecMenu(nav1,nav2)

{

	//获取第一个参数，对应一级菜单序列号

	var iNavFir = parseInt(nav1,10);

	if(isNaN(iNavFir))

	{

		return;

	}



	//获取第二个参数，对应二级菜单的序列号

	var iNavSec = 0;

	if(nav2)

	{

		iNavSec = parseInt(nav2,10);

	}

	else if(top.g_iMallNo)

	{

		iNavSec = parseInt(top.g_iMallNo.toString().substr(3,2),10);

	}



	var sNavFir = intFill(iNavFir);

	var sNavSec = intFill(iNavSec);



	//设置形象风格

	var iItemType = 0;

	if('undefined' != typeof(QUSER))

	{

		iItemType = parseInt(QUSER.getStyle());

	}



	//动态生成二级菜单

	var objRoot = document.getElementById("navSecond");

	if(objRoot)objRoot.innerHTML = "";

	else return;

	var sMallNo = (iItemType+1).toString() + sNavFir + "010000";

	var iMallNo = parseInt(sMallNo,10);

	var iSelect = 0;

	var iLast = 0;

	var iFirst = 0;

	if(top.g_iMallNo) iFirst = parseInt(top.g_iMallNo.toString().substr(1,2),10);

	while(mallMenu[iMallNo])

	{

		if(mallMenu[iMallNo][4].length ==0 || mallMenu[iMallNo][4] == QUSER.getAvSex())

		{

			if((iNavSec == parseInt(((iMallNo%1000000)/10000),10))&&(iFirst == parseInt(sMallNo.substr(1,2),10))) iSelect = 1;

			else iSelect = 0;

			var oLi = createLi(iMallNo,iSelect);

			oLi.setAttribute("no",iMallNo);

			objRoot.appendChild(oLi);

		}

		iMallNo += 10000;

	}

	if(iNavFir == 6 && iItemType == 0)

	{

		document.getElementById("ID_navSecond").setAttribute("class", "navSecond u61");
		document.getElementById("ID_navSecond").setAttribute("className", "navSecond u61");

	}

	else if(iNavFir == 7 && iItemType == 0)

	{

		document.getElementById("ID_navSecond").setAttribute("class", "navSecond u71");

		document.getElementById("ID_navSecond").setAttribute("className", "navSecond u71");

	}

	else

	{

		document.getElementById("ID_navSecond").setAttribute("class", "navSecond u"+(iNavFir+1));

		document.getElementById("ID_navSecond").setAttribute("className", "navSecond u"+(iNavFir+1));

	}

	if(iMallNo%1000000 == 0)

	{

		var oLi = document.createElement("li");

		objRoot.appendChild(oLi);

	}

	//二级菜单的最后一项需要设置CSS

	var aObj = objRoot.getElementsByTagName("LI");

	if(aObj.length > 0)

	{

		var css = aObj[aObj.length - 1].getAttribute("class") + " last";

		aObj[aObj.length - 1].setAttribute("class",css);

		aObj[aObj.length - 1].setAttribute("className",css);

	}

	return;

};



function mainFrameChange(mallno)
{	
	function openAndGoMain(sUrl,sTarget)
	{
		window.open(sUrl,sTarget);
		if(top.mainfra&&top.mainfra.document&&top.leftfra&&top.leftfra.document&&(top.leftfra.location.href.indexOf("inc/sidebar.html")!=-1)){
			if(top.mainfra.location.href.indexOf("/inc/main") == -1)
			top.mainfra.location.href	=	"/inc/main.html";
		}
		return;
	}
	
	var iItemType = 1;
	if("undefined"!=typeof(QUSER)) iItemType = parseInt(QUSER.getStyle());
	var sMallNo = mallno;
	sMallNo = (iItemType+1)+mallno.toString().substr(1,8);
	var iNo = parseInt(sMallNo,10);
	if(isNaN(iNo)) return;

	//做mallno转换，如果是一级菜单，则将其对应到其第一项
	if (mallMenu[iNo])
	{
		while((parseInt(iNo.toString().substr(3,2),10)==0&&mallMenu[iNo+10000]) ||((mallMenu[iNo][4]!="N")&&(mallMenu[iNo][4].length>0&&mallMenu[iNo][4]!=QUSER.getAvSex())))
		{
			//针对一级菜单"主题"下面的第一个菜单"主题首页"要隐藏而做的特殊处理。并不完善
			if(parseInt(iNo.toString().substr(3,2),10)==0&&mallMenu[iNo+10000]&&mallMenu[iNo+10000][4]=="N")
			{
				iNo = iNo + 20000;
				while(mallMenu[iNo]&& mallMenu[iNo][4]=="N")
				{
					iNo += 10000;
				}
				if('undefined' == typeof(mallMenu[iNo]))
				{
						iNo = 101010000;
						break;
				}	
				sMallNo = iNo .toString();
	  		iNo = parseInt(sMallNo,10);
			}
			else
			{
		  	sMallNo = (iNo + 10000).toString();
		  	iNo = parseInt(sMallNo,10);
		  }
		}
	}
	//防止做风格切换时，两种不同风格菜单导致js错误
	if('undefined' == typeof(mallMenu[iNo]))
	{
		iNo = 101010000;
	}
	//载入页面模版
	var sUrl = "/inc/main.html";

	if(mallMenu[iNo][2]!=""&&mallMenu[iNo][2].length<5){
		var idx=mallMenu[iNo][2];
		if(mall_url[idx]){
			if(mall_url[idx][1]=="mainfra"){
				sUrl=mall_url[idx][0]+"?mallno="+iNo+"&mallId="+mallMenu[iNo][0];
			}
			else if(mall_url[idx][1].length>0){
				return openAndGoMain(mall_url[idx][0],mall_url[idx][1]);
			}
		}
	}

	else if(mallMenu[iNo][2].length>5){

		if(mallMenu[iNo][3] == "mainfra"){

			sUrl = mallMenu[iNo][2] + "#mallno="+iNo;

		}

		else if(mallMenu[iNo][3].length > 0){

			if(mallMenu[iNo][3]=="OPEN"){

				window.open(mallMenu[iNo][2],"_blank");

				return;

			}

			else{

				return openAndGoMain(mallMenu[iNo][2],mallMenu[iNo][3]);

			}

		}

	}

	else{

		sUrl = "/mall/inc/item.html?mallno="+iNo+"&mallid="+mallMenu[iNo][0];

	}

	try{

		if(top.mainfra&&top.mainfra.document&&top.leftfra&&top.leftfra.document&&(top.leftfra.location.href.indexOf("inc/sidebar.html")!=-1))

		{

			 top.mainfra.location.href = sUrl;

		}

		else

		{

			sUrl = "/mall/inc/item.html?mallno="+iNo+"&mallid="+mallMenu[iNo][0];

			if((mallMenu[iNo][2].length>5)&&(mallMenu[iNo][3] == "mainfra"))

			{

				sUrl = mallMenu[iNo][2] + "#mallno="+iNo;

			}

			top.location.href ="/show.html?MUrl="+sUrl.escUrl();

			return;

		}

	}

	catch(e)

	{

		top.location.href = "/show.html?MUrl="+sUrl.escUrl();

	}

	//记录上一次onclick时的mallno

	top.g_iMallNo = iNo;

	if (mallMenu[iNo][4]!="N")

	    strongFir();

	return;

};

function strongFir()

{

	var iNo = top.g_iMallNo?top.g_iMallNo:101010000;

	var iFirNav = parseInt(iNo.toString().substr(1,2),10);

	var oFirNav = document.getElementById("navFirst");

	if(!oFirNav) return;

	var aA = oFirNav.getElementsByTagName("a");

	for(var i=0;i<aA.length;i++)

	{

		if(aA[i].no	==	iFirNav)

		{

			aA[i].setAttribute("class","selected");

			aA[i].setAttribute("className","selected");

		}

		else

		{

			aA[i].setAttribute("class","");

			aA[i].setAttribute("className","");

		}

	}

	swapSecMenu(parseInt(iNo.toString().substr(1,2),10),parseInt(iNo.toString().substr(3,2),10));

	strongSec();

};

function strongSec()

{

	var iNo = top.g_iMallNo?top.g_iMallNo:101010000;

	var obj = document.getElementById("navSecond");

	if(!obj) return;

	var oLi = obj.getElementsByTagName("li");

	for(var i=0;i<oLi.length;i++)

	{

		if(iNo.toString().substr(1,4) == oLi[i].getAttribute("no").toString().substr(1,4))

		{

			oLi[i].setAttribute("class","selected");

			oLi[i].setAttribute("className","selected");

		}

		else

		{

			oLi[i].setAttribute("class","");

			oLi[i].setAttribute("className","");

		}

		if(i == (oLi.length-1))

		{

			var css = oLi[i].getAttribute("class") + " last";

			oLi[i].setAttribute("class",css);

			oLi[i].setAttribute("className",css);

		}

	}

};

function createLi(mallno,iselect)

{

	var iNo = parseInt(mallno,10);

	var item = mallMenu[iNo];

	var objTextNode = document.createTextNode(item[1]);



	//创建链接

	var objA = document.createElement("a");

	objA.setAttribute("href","javascript:mainFrameChange("+iNo+");");

	var iFirNav = parseInt(mallno.toString().substr(1,2),10);

	var iSecNav = parseInt(mallno.toString().substr(3,2),10);

	objA.appendChild(objTextNode);



	var objLi = document.createElement("li");

	objLi.appendChild(objA);

	//突出显示

	if((iselect)&&(parseInt(iselect,10)==1))

	{

		objLi.setAttribute("class","selected");

		objLi.setAttribute("className","selected");

	}

	return objLi;

};

function initHeader()

{

	if(!document.getElementById("nav").onmouseover)

	{

		document.getElementById("nav").onmouseover = function()

		{

			if(this.timer)

			{

				clearTimeout(this.timer);

				this.timer = null;

			}

		};

	}

	if(!top.g_iMallNo) top.g_iMallNo = 101010000;

	var sMallNo = top.g_iMallNo.toString();

	var iFir = parseInt(sMallNo.substr(1,2),10);

	var iSec = parseInt(sMallNo.substr(3,2),10);

	var iNo = parseInt(sMallNo,10);

	strongFir();

	swapSecMenu(iFir,iSec);

	var aObj = document.getElementById("navFirst").getElementsByTagName("a");

	for(var i = 0;i <= 12;i++)

	{

		var sMallNo = "";

		if(aObj[i])

		{

			sMallNo	=	parseInt(aObj[i].getAttribute("mallno"), 10);

			if(i<13)

			{

				aObj[i].onmouseover=function()

				{

					swapSecMenu(this.getAttribute("no"));

				};

			}

			aObj[i].href="javascript:mainFrameChange("+sMallNo+");";

		}

	}

	if(!document.getElementById("nav").onmouseout)

	{

		document.getElementById("nav").onmouseout = function()

		{

			this.timer= setTimeout("initHeader()",3000);

		};

	}

	if('function' == typeof(setHeaderCartNum))

	{

		setHeaderCartNum();

	}

};



/*just a copy of function about viprank in public.js */

function getVipCookie()

{

	var vData = new Object();

	var viprank = getCookie("viprank");

	var cols = viprank.split("|");

	vData.vip = cols[0];

	vData.level = cols[1];

	vData.score = cols[2];

	vData.sequence = cols[3];

	vData.scoreLeft = cols[4];

	vData.levelDis = cols[5];

	vData.initScore = cols[6];

	return vData;

}

function GetVipRankImg(vip, iLevel, isHeader)

{

	if((vip == 2 || vip == 0) && iLevel != undefined)

	{

		var isVip = (vip==0);

		var code = '<a id="lva" href="javascript:ChangeMainFrame(\'/community/viprank/level_desc.html\')" onmouseover="ShowVipRankDiv(arguments[0]||window.event, ' + isHeader + ')"  onmouseout="HideVipRankDiv1()" class="vip_lv'+(isVip?"":"_gray")+'">';

		code += '<span>lv</span>';

		code += '<span class="lv lv' + iLevel +'">' + iLevel + '</span>';

		code += '</a>';

		return code;

	}

	return "";

}

function ChangeMainFrame(url)

{

	top.mainfra.location = url;

}

function CreateVipRanKDiv(iLevel, iScore, iSeq, iScoreLeft, iDis, iFuin, iVip)

{

	if(!document.getElementById("VIPRANK_DIV"))

	{

		var e = document.createElement("DIV");

		e.id="VIPRANK_DIV";

		e.style.position="absolute";

		e.style.display="none";

		e.style.zIndex = 1001;

		e.className="lv_tip";

		e.onmouseover= EnterVipRankDiv;

		e.onmouseout = HideVipRankDiv2;

	var code = '<h3>等级信息</h3><ul>';

		code += '<li>红钻等级<strong class="em">Lv' + iLevel + '</strong></li>';

		code += '<li>红钻积分<strong class="em" id="LAST_SCORE">' + iScore + '</strong></li>';

		if(iSeq > 0)

			code += '<li>红钻排名<strong class="em">' + iSeq + '</strong></li>';



		if(iLevel >= 7&&iVip==0)

		{

			code += '<li class="lv_bar">';

			code += '<span>恭喜您已到最高级别</span>';

			code += '<strong style="width:100%"></strong>';

			code +='</li>';

		}else

		{

			code += '<li class="lv_bar">';

			var arrow = (iVip==0?"↑":"↓");

	                if(iVip!=2)
	                {			    code += '<span>Lv' + iLevel + arrow + '&nbsp;差' + iScoreLeft + '分升级</span>';
	                }
	                else
                        {
                           if(iLevel!=1)
                           code += '<span>Lv' + iLevel + arrow + '&nbsp;差' + getDegradeDay(iScore) + '天降级</span>';
                           else
	                   code += '<span>Lv' + iLevel + arrow + '&nbsp;差' + getDegradeDay(iScore) + '天积分清0</span>';
                         }

		                var persent = (100-iScoreLeft*100/iDis) + "%";
			code += '<strong style="width:' + persent + '">进度:' + persent + '</strong>';

			code +='</li>';

		}

		if(iFuin)
                {
			code +='<li><a class="em" href="javascript:ChangeMainFrame(\'/community/viprank/friend_level.html?uin=' + iFuin + '\')" class="em">查看好友的红钻等级详情&gt;&gt;</a></li>';
                        if(iVip==2)
			code +='<li><a class="em" href="http://paycenter.qq.com/qqshow/index_send.html" class="em" target="_blank" class="em">帮Ta开通红钻贵族&gt;&gt;</a></li>';
                }		else
               {
                        code +='<li><a class="em" href="javascript:ChangeMainFrame(\'/community/viprank/my_level.html\')" class="em">查看我的红钻等级详情&gt;&gt;</a></li>';                        if(iVip==2)
			code +='<li><a class="em" href="http://paycenter.qq.com/qqshow/index.html" class="em" target="_blank">开通红钻贵族&gt;&gt;</a></li>';
               }		code +='</ul>';

		e.innerHTML=code;

		document.body.appendChild(e);

	}

}



var vip_rank_div_timer = null;

function getLeft(e)
{
	var offset=e.offsetLeft;
	if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
	return offset;
}

function ShowVipRankDiv(objEvent, isHeader, vData, iFuin)

{

	if(vip_rank_div_timer)	{

		window.clearTimeout(vip_rank_div_timer);

	}

	var e = objEvent;

	if(!e)

	{

		return false;

	}

	var isFriendTip = false;

	if(!vData)

	{

		vData = getVipCookie();

	}

	else

	{

		isFriendTip = true;

	}

	var objTips = document.getElementById("VIPRANK_DIV");

	if(!vData.level || (vData.level =="undefined"))

		return false;



	if(objTips && (document.getElementById("LAST_SCORE").innerHTML != vData.score || isFriendTip))

	{

		document.body.removeChild(objTips);

		objTips = null;

	}



	if(!objTips)

	{

		CreateVipRanKDiv(vData.level, vData.score, vData.sequence, vData.scoreLeft, vData.levelDis, iFuin, vData.vip);

		objTips = document.getElementById("VIPRANK_DIV");

	}



	if(objTips.style.display=="")

		return true;



	if(isHeader)

	{

		objTips.style.top = 5+"px";
		var sp=document.getElementById('lva');
		objTips.style.left = getLeft(sp)+sp.clientWidth+30+"px";
	}

	else

	{

		var wTipDiv = objTips.scrollWidth;

		var wBody = document.body.clientWidth;

		var xPos = typeof(e.clientX)!="undefined" ? e.clientX : (e.pageX-document.documentElement.scrollLeft);

		xPos = (xPos+wTipDiv<=wBody) ? (xPos+document.documentElement.scrollLeft+10) : (xPos+document.documentElement.scrollLeft-10-wTipDiv);



		var hTipDiv = objTips.scrollHeight;

		var hBody = document.body.clientHeight;

		var yPos = typeof(e.clientY)!="undefined" ? e.clientY : (e.pageY-document.documentElement.scrollTop);

		yPos = (yPos+hTipDiv<=hBody) ? (yPos+document.documentElement.scrollTop+10) : (yPos+document.documentElement.scrollTop-10-hTipDiv);

		objTips.style.top = yPos+"px";

		objTips.style.left = xPos+"px";

	}

	objTips.style.display = "";

	return true;

}



function HideVipRankDiv()

{

	if (document.getElementById("VIPRANK_DIV"))

	{		document.getElementById("VIPRANK_DIV").style.display="none";

		window.clearTimeout(vip_rank_div_timer);

	}	return true;};



function HideVipRankDiv1()

{

	if(vip_rank_div_timer)

	{

		window.clearTimeout(vip_rank_div_timer);

	}

	vip_rank_div_timer = window.setTimeout(HideVipRankDiv, 200);

}

function HideVipRankDiv2()

{

	if(vip_rank_div_timer)

	{

		window.clearTimeout(vip_rank_div_timer);

	}

	vip_rank_div_timer = window.setTimeout(HideVipRankDiv, 200);

}



function EnterVipRankDiv()

{

	if(vip_rank_div_timer)

	{

		window.clearTimeout(vip_rank_div_timer);

	}

	var obj = document.getElementById("VIPRANK_DIV");
}
function getDegradeDay(score)
{
    if(score>=7000)
    {
        return countFromBase(7000);
    }
    else if(score>=5000)
    {

        return countFromBase(5000);
    }
    else if(score>=3000)
    {
        return countFromBase(3000);
    }
    else if(score>=1600)
    {

        return countFromBase(1600);
    }
    else if(score>=800)
    {

        return countFromBase(800);
    }
    else if(score>=400)
    {

        return countFromBase(400);
    }
    else
    {

        return countFromBase(0);
    }


function countFromBase(baseNum)
{
    var tempNum=(score-baseNum)/10;
    if(tempNum.toString().indexOf(".")!=-1)
    {
        tempNum=parseInt(tempNum)+1;
    }
    return tempNum;
}
}
/*the end*/



/*  |xGv00|80372278cbf18c157ce4a8bffc6bcb52 */