var url=location.href;

var link=new Array("about","products","service","contact")
var menu=new Array("About Us","Products","Our Service","Contact Us")

var about=new Array("Our History","Our Mission","Capability")
var products=new Array("PolyAid&reg; Additives","Specialty Chemicals","Flavors & Fragrances ")
var service=new Array()
var contact=new Array("Contact Info","Feedback")

/*********判断当前二级栏目内页(cur)*********/
var url=location.href
var position=url.lastIndexOf("/");
cur=url.substring(position+1,position+2);
/*********判断结束*********/
function shower(obj){
	obj1=document.getElementById(obj)
	oDiv=document.getElementById("menubar")
	divArray=oDiv.getElementsByTagName("div")
	for(i=0;i<divArray.length;i++) divArray[i].style.display="none"
	if(obj1){
		obj1.style.display="block"
		obj1.previousSibling.className="curmenu"
	}
	//alert(obj1.previousSibling.tagName)
}
function hider(){
	oDiv=document.getElementById("menubar")
	if(oDiv){
		divArray=oDiv.getElementsByTagName("div")
		for(i=0;i<divArray.length;i++) divArray[i].style.display="none"
	}
}
function ifIE(){//判断浏览器是否为IE
	if(navigator.appVersion.indexOf("MSIE")!=-1) return true
	else return false
}
function defMenu(){
	var str="<ul>"
	for(i=0;i<link.length;i++){
		if(url.indexOf("/"+link[i]+"/")!=-1) {
			oS=' style="color: yellow;"'
			document.title=menu[i]+" - [ Welcome to Dannier Group ]"
		}
		else oS=''
		str+='<li onmouseover="shower(\'showdiv'+i+'\')"><a href="../'+link[i]+'/"'+oS+'>'+menu[i]+'</a></li>'
		menu2=eval(link[i])
		if(menu2.length>0){
			if(ifIE()) alpha="filter:alpha(opacity=70) progid:DXImageTransform.Microsoft.gradient(startColorStr=#FF144250,endColorStr=#9EFFFFFF)"
			else alpha="" //判断浏览器版本，IE用ALPHA滤镜
			if(i==1) ms=" menudiv_2"
			else ms="menudiv"
			str+='<div id="showdiv'+i+'" onmouseover="shower(\'showdiv'+i+'\')" onmouseout="hider()" class="'+ms+'" style="left:'+(265+124*i)+'px;'+alpha+'">'
			for(j=0;j<menu2.length;j++){
				str+='<p><a href="../'+link[i]+'/'+j+'.asp">&bull; '+menu2[j]+'</a></p>'
			}
			str+='</div>'
		}
	}
	str+="</ul>"
	document.write (str)
}
function defSail(){ //导航栏添加
	str='<b>Your Position:</b> <a href="../">Home</a> &#187; ';
	for(i=0;i<link.length;i++){
		if(url.indexOf("/"+link[i]+"/")!=-1){
			menu2=eval(link[i])
			if(menu2.length>0){
				str+='<a href="../'+link[i]+'/">'+menu[i]+'</a>'
				if(cur!="") str+=' &#187; <span class="cursail">'+menu2[cur]+'</span>'
			}
			else str+='<span class="cursail">'+menu[i]+'</span>'
		}
	}
	document.write (str)
}
function defSubMenu(){ //子菜单添加
	for(i=0;i<link.length;i++){
		if(url.indexOf("/"+link[i]+"/")!=-1){
			obj=document.getElementById("left")
			obj.style.backgroundImage='url("../images/'+link[i]+'_bg.gif")'
			menu2=eval(link[i])
			if(menu2.length>0){
				str='<ul>'
				for(j=0;j<menu2.length;j++){
					if(j==cur) oS=' style="color: #FF3300;background: url(../images/icon02.gif) no-repeat 2px 13px; text-decoration:underline;"'
					else oS=''
					str+='<li><a href="'+j+'.asp"'+oS+'>'+menu2[j]+'</a></li>'
				}
				str+='</ul>'
			}
			else {
				str='<div style="height:150px;background:url(../images/bg_'+i+'.gif) no-repeat center center"></div>'
			}
		}
	}
	document.write (str)
}
function drawFlash(width,height,src,wmode){
	/*
		width:	宽度
		height:	高度
		src:	Flash路径
		wmode:	0-透明;1-不透明;2-默认值
	*/
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">')
	document.writeln('<param name="movie" value="'+src+'" />')
	document.writeln('<param name="quality" value="high" />')
	if(wmode==0) {
		document.writeln('<param name="wmode" value="transparent" />')
		componse=' wmode="transparent"'
	}
	if(wmode==1) {
		document.writeln('<param name="wmode" value="opaque" />')
		componse=' wmode="opaque"'
	}
	if(wmode==2) {
		componse=''
	}

	document.writeln('<embed src="'+src+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"'+componse+'></embed>')
	document.writeln('</object>')
}

function insertLine(){
	obj=document.getElementById("text")
	if(obj) {
		if(obj.clientHeight<200) obj.style.height="200px"
	}
}
function img_pop(imgname){
    openwin=window.open ("","imgpop","width=100,height=100,left=0,top=0");
    openwin.document.write("<html><head>")
	openwin.document.write("<title>Image Preview</title>")
	openwin.document.write("</head>")
	openwin.document.write("<body style='margin:0;padding:0;'>") 
	openwin.document.write("<a href='javascript:window.close()' onfocus='this.blur()'><img src='"+imgname+"' border='0' alt='Loading......' onload='javascript:window.resizeTo(this.width+10,this.height+28);this.alt=\"Click to Close\"'></a>") 
	openwin.document.write("</body>") 
	openwin.document.write("</html>") 
	openwin.document.close();
	openwin.focus();
 }
 function winpop(url,popname){ //Defind Popwin
	if(typeof popname=="undefined") popname="pop"
	var popwidth=520;popheight=500 //defind the size of the popwin
	poptop=(screen.availHeight-popheight)/2
	popleft=(screen.availWidth-popwidth)/2
	var oWin=window.open(url,popname,"width="+popwidth+",height="+popheight+",scrollbars=yes,top="+poptop+",left="+popleft)
	oWin.focus()
}

function duct(){ //1024+分辨率下填补衍生空间
	var width=document.body.clientWidth
	if (width>800) document.write('<div id="duct"></div>')
}

function checkBlank(obj){ //检测表单，不能全空
	var e=obj.elements; //表单内元素集合
	var totlevalue="";
	for (i=0;i<e.length-2;i++) totlevalue+=e[i].value
	if (totlevalue==""){
		alert("At Least One Condition!");
		return false;
	}
}
function fomulaFmt(str){ //格式化化学式
	newstr=""
	reg=/\d/
	l=str.length
	if(reg.test(str)){
		for(i=0;i<l;i++){
			substr=str.substring(i,i+1)
			if(reg.test(substr) && str.substring(i-1,i)!=".") substr="<sub>"+substr+"</sub>"
			newstr+=substr
		}
	}
	else newstr=str
	document.write (newstr)
}
function turnPage(page,argu,pagecount){ //直接翻页
	reg=/^[0-9]+$/; //验证数字
	if(reg.test(page) && event.keyCode==13) {
		if(page>pagecount) page=pagecount
		location="?"+argu+"curpage="+page
	}
}
function drawHR(){
	str='<hr size="1" noshade="noshade" />';
	if(!ifIE()) str='<br />'+str
	document.write(str)
	
}
function proLoadImg(){ //图片预载
	img1=new Image();
	img1.src="../images/menu_bg.gif";
}
function init(){ //封装预载单元
	insertLine();
	proLoadImg();
}
window.onload=init
document.onclick=hider
