if(window.HTMLElement){
	
	
	//ourtHTML

    HTMLElement.prototype.__defineGetter__("menuIndex",function(){
     	var attr;
        var attrs=this.attributes;
        for(var i=0;i<attrs.length;i++){
            attr=attrs[i];
            if(attr.name.toLowerCase()=="menuindex") return attr.value;
        }
		return null;
	});
}

menuSelected=-1;

function buildMenu(){
	aMenu=new Array(
			new Array("首页","http://sh.sina.com.cn/dior/index.html"),
			new Array("迪奥快报","http://sh.sina.com.cn/action/dior/trends.html"),
			new Array("迪奥本季","http://sh.sina.com.cn/action/dior/now.html"),
			new Array("迪奥女人","http://sh.sina.com.cn/action/dior/woman.html",
				new Array(
					new Array("彩妆秘笈","http://sh.sina.com.cn/action/dior/woman_makeup.html"),
					new Array("香水宝典","http://sh.sina.com.cn/action/dior/woman_perfume.html"),
					new Array("女人Tips","http://sh.sina.com.cn/action/dior/tips.html"),
					new Array("迪奥收藏","http://sh.sina.com.cn/action/dior/download.html")
					)
			),
			new Array("迪奥圈","http://q.blog.sina.com.cn/diorcircle"),
			new Array("迪奥传奇","http://sh.sina.com.cn/action/dior/story.html")
	);


	s='';
	sub='';
	s+='<table border="0" cellpadding="0" cellspacing="0" class="Menu-bar" width="1000" align="center" id="menuTable">';
	s+='	<tr height="11" bgcolor="#000000"><td colspan="'+(aMenu.length*2)+'"></td></tr>';
	s+='	<tr bgcolor="#666666" height="25">';

	for(i=0;i<aMenu.length;i++)
	{
		s+='		<td class="'+((menuSelected.toString()==i.toString())?'Menu-button-active':'Menu-button')+'" menuIndex="'+i+'" onmouseover="javascript:showMenu(this,1,'+i+');" onmouseout="javascript:showMenu(this,0,'+i+');">';
		if(aMenu[i][1]!="") s+='<a href="'+aMenu[i][1]+'"'+((aMenu[i][1].indexOf("diorcircle")>=0)?' target="_blank"':'')+'>';
		s+=aMenu[i][0];
		if(aMenu[i][1]!="") s+='</a>';
		if(aMenu[i][2])
		{				
			sub+='				<table border="0" cellpadding="0" cellspacing="0" class="Menu-body" id="subMenu'+i+'">';
			sub+='					<tr>';
			sMenu=aMenu[i][2];
			for(ii=0;ii<sMenu.length;ii++)
			{
				sub+='						<td onmouseover="javascript:this.className=\'Menu-body-active\';" onmouseout="javascript:this.className=\'\';">';
				
				if(sMenu[ii][1]!="") sub+='<a href="'+sMenu[ii][1]+'"'+((sMenu[ii][1].indexOf("http://")>=0)?'':'')+'>';
				sub+=sMenu[ii][0];
				if(sMenu[ii][1]!="") sub+='</a>';

				sub+='</td>';
			}
			sub+='					</tr>';
			sub+='				</table>';
		}
		else
		{    
			s+='				<span id="subMenu'+i+'" style="width:0;height:0;display:none;"></span>';
		}
		s+='		</td>';
		if(i<(aMenu.length-1)) s+='<td width="1"><img src="http://sh.sina.com.cn/action/dior/images/line_menu.jpg" border="0" /></td>';
	}
	s+='		<td width="100%"></td>';
	s+='	</tr>';
	s+='	<tr height="25" bgcolor="#000000">';
	s+='<td colspan="'+(aMenu.length*2)+'"><span id="submenuheader" style="width:100px;"></span>'+sub+'</td>';
	s+='</tr>';
	s+='</table>';
	document.write(s);
	showMenu(menuTable.getElementsByTagName("TBODY")[0].rows[1].children[menuSelected*2],1,menuSelected,1);
}

function showMenu(o,s,i,toshowsubmenu)
{
	//if(toshowsubmenu){
	for(x=0;x<100;x++)
	{
		m=document.getElementById("subMenu"+x);
		if(!m) break;
		if(x==i){
			if(m.tagName=="TABLE")
			{
				//计算应该前面留多少相素距离
				pleft=0;
				for(n=0;n<o.parentElement.children.length;n++)
				{
					if(o.parentElement.children[n]==o) break;
					pleft+=o.parentElement.children[n].offsetWidth;
				}
				submenuheader.style.width=pleft;
				m.style.display="inline";
			}
		}
		else{
			m.style.display="none";
		}
	}
	//}
	if(o.menuIndex.toString()!=menuSelected.toString()) o.className=((s==0)?"Menu-button":"Menu-button-active");
}

//订阅电子报
function bookEDM(f){
	rec = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	if(!rec.test(f.Email.value)){
		alert("请正确输入EMAIL地址.");
		f.Email.focus();
		return;
	}
	f.submit();
}