﻿var focusButton=0;
var focusSecButton=0;
	
function secondMenu(n, enName, u, enUrl)
{
	this.name=n;
	this.name_en=enName;
	this.url=u;
	this.url_en=enUrl;
}

function menuItem(n, enName, u, enUrl)
{
	this.name=n;
	this.name_en=enName;
	this.url=u;
	this.url_en=enUrl;
	
	this.secondMenuList=new Array();
}

menuItem.prototype.addsecondMenu=function (secondmenu)
{
	this.secondMenuList.push(secondmenu);
}

menuItem.prototype.getsecondMenulength=function ()
{
    return this.secondMenuList.length;
}

function start(num,secnum,isIndex,isChinese)
{
    var CurrentButton=new Array(8);
    var buf="";
	
	/*---------------------------*/
	/*網頁選單的基本設定*/
	/*---------------------------*/
	
	/*請注意!!!! 本網頁架設有八個"固定"選單項目，超過或少於8個選項將使網頁出錯!!*/
	
	/*---------------------------*/
	/*網頁選單的新增修改*/
	/*---------------------------*/
	
	/*從這邊以下開始進行選單內容的新增*/
	/*一般置頂選單，如 關於我們、產品介紹、行情查詢、最新消息 等大項    --->均使用menuItem 物件*/
	/*其他附加選單(一般網頁左邊的小選單)，如關於我們、品質政策、環境政策、陽極磷銅、等小項  -->均使用secondMenu物件*/
	/*menuItem 新增方法*/
		/* menuItem("中文網項的名稱", "英文選項名稱", "中文選項連結", "英文選項連結")*/
	/*secondMenu 新增方法*/
		/*secondMenu("中文選項名稱", "英文選項名稱", "中文選項連結", "英文選項連結")*/
	
	/* !!!重要!!! */
		/*其他附加選單 必須 加入 一般置頂選單 才能夠產生 連結*/
		/*如: 大項"關於我們"  內有三個子網頁，分別為 "關於我們"、"品質政策"、"環境政策" 三個。*/
		/*則分別指定 內容後*/
		/* 大項"關於我們"(menuItem) 必須 將 三個子網頁加入*/
		/*方法如： menuItem名稱.addsecondMenu("子網頁的物件")*/
		/*詳細方法如下所示*/
	
	var menu1= new menuItem("關於我們","About us","about_1.html","en_about_1.html");
		var secondmenu11=new secondMenu("關於我們","About us","about_1.html","en_about_1.html");
		var secondmenu12=new secondMenu("品質政策","Quality policy","about_2.html","en_about_2.html");
		var secondmenu13=new secondMenu("環境政策","Environment policy","about_3.html","en_about_3.html");

    menu1.addsecondMenu(secondmenu11);
    menu1.addsecondMenu(secondmenu12);
    menu1.addsecondMenu(secondmenu13);

	/*以上為參考設定方法*/
	/*相關設定上的問題如無法解決，請來電 0911639125 林正偉 或 email: rnrn41@mail2000.com.tw*/	
	
    var menu2= new menuItem("產品介紹","Product","product_1.html","en_product_1.html");
	    var secondmenu21=new secondMenu("無氧銅/純銅","Oxygen-Free / High Purity Copper Anode","product_1.html","en_product_1.html");
                  var secondmenu22=new secondMenu("陽極磷銅","Phosphor Copper Anode","product_2.html","en_product_2.html");
		var secondmenu23=new secondMenu("黃銅陽極","Brass Anode","product_3.html","en_product_3.html");
	         var secondmenu24=new secondMenu("矽青銅線","Silicon Bronze Wire","product_4.html","en_product_4.html");
		var secondmenu25=new secondMenu("磷青銅線","Phosphor Bronze Wire","product_5.html","en_product_5.html");
		var secondmenu26=new secondMenu("洋白銅線","Nickel Silver Wire","product_6.html","en_product_6.html");
		var secondmenu27=new secondMenu("黃銅線","Brass Wire","product_7.html","en_product_7.html");
		var secondmenu28=new secondMenu("鋁青銅線","Aluminum Bronze Wire","product_8.html","en_product_8.html");
		var secondmenu29=new secondMenu("氧化銅粉","Copper Oxide","product_9.html","en_product_9.html");
		var secondmenu30=new secondMenu("銅粒","Copper Slot","product_10.html","en_product_10.html");
		var secondmenu31=new secondMenu("特殊銅合金錠","Special Copper Alloy Ingot","product_11.html","en_product_11.html");
		var secondmenu32=new secondMenu("電子級硫酸銅","Electronic Grade Copper Sulfate","product_13.html","en_product_13.html");
		var secondmenu33=new secondMenu("試藥級硫酸銅","Reagent Grade Copper Sulfate","product_14.html","en_product_14.html");
		var secondmenu34=new secondMenu("微米與次微米級銅粉","Micron / Sub-Micron Copper Powder","product_15.html","en_product_15.html");
                  var secondmenu35=new secondMenu("扁線","Flat Wire","product_12.html","en_product_12.html");
                  var secondmenu36=new secondMenu("導電膠","Conductive adhesive","product_16.html","en_product_16.html");

    menu2.addsecondMenu(secondmenu21);
    menu2.addsecondMenu(secondmenu22);
    menu2.addsecondMenu(secondmenu23);
	menu2.addsecondMenu(secondmenu24);
	menu2.addsecondMenu(secondmenu25);
	menu2.addsecondMenu(secondmenu26);
	menu2.addsecondMenu(secondmenu27);
	menu2.addsecondMenu(secondmenu28);
	menu2.addsecondMenu(secondmenu29);
	menu2.addsecondMenu(secondmenu30);
	menu2.addsecondMenu(secondmenu31);
	menu2.addsecondMenu(secondmenu32);
	menu2.addsecondMenu(secondmenu33);
	menu2.addsecondMenu(secondmenu34);
         menu2.addsecondMenu(secondmenu35);
         menu2.addsecondMenu(secondmenu36);

    var menu3=new menuItem("行情查詢","Market Price","login.html","en_login.html");
    var menu4=new menuItem("最新消息","News","news.html","en_news.html");
    var menu5=new menuItem("員工專區","Staff","staff.html","en_staff.html");
	var menu6=new menuItem("投資人服務","Investor Relations","investor.html","en_investor.html");
	var menu7=new menuItem("技術園地","Technology Support","technology.html","en_technology.html");
	var menu8=new menuItem("網站連結","Links","links.html","en_links.html");
    //var menu6=new menuItem("聯絡我們","Contact","contact.html","en_contact.html");
    //var menu7=new menuItem("網站連結","Links","links.html","en_links.html");
    //var menu8=new menuItem("回到首頁","Home","index.html","en_index.html");


    CurrentButton[0]=menu1;
    CurrentButton[1]=menu2;
    CurrentButton[2]=menu3;
    CurrentButton[3]=menu4;
    CurrentButton[4]=menu5;
    CurrentButton[5]=menu6;
    CurrentButton[6]=menu7;
    CurrentButton[7]=menu8;
	
	if(num!=8)  //表示在首頁
	{
	
		/*判斷中英文網頁切換的文字內容 及 連結網址*/
		if(isChinese==1 || isChinese==null)
		{
			document.getElementById("contacts").innerHTML="<a href=\"contact.html\" style=\"color:#EAEAEA; text-decoration: none;\">聯絡我們</a>";
			document.getElementById("home").innerHTML="<a href=\"index.html\" style=\"color:#EAEAEA; text-decoration: none;\">回首頁</a>";
			document.getElementById("langChange").innerHTML="<a href=\""+CurrentButton[num].url_en+"\" style=\"color:#ee2222; \">English</a>";
		}
		else
		{
			document.getElementById("contacts").innerHTML="<a href=\"en_contact.html\" style=\"color:#EAEAEA; text-decoration: none;\">contacts</a>";
			document.getElementById("home").innerHTML="<a href=\"en_index.html\" style=\"color:#EAEAEA; text-decoration: none;\">Home</a>";
			document.getElementById("langChange").innerHTML="<a href=\""+CurrentButton[num].url+"\" style=\"color:#ee2222; \">切換中文網頁</a>";
		}
		/*網頁上排選單產生*/
		for(var i=0;i<CurrentButton.length;i++)
		{
		    
			if(isChinese==1 || isChinese==null)
			{
				document.getElementById("menu"+i).innerHTML=	"<div style=\"padding-top:40px; \"><a id=\"menucolor"+i+"\" href=\""+CurrentButton[i].url+
															"\" style=\"color:#EAEAEA;text-decoration: none;\">"+
															CurrentButton[i].name+
															"</a></div>";
			}
			else
			{
				document.getElementById("menu"+i).innerHTML=	"<div style=\"padding-top:40px; \"><a id=\"menucolor"+i+"\" href=\""+CurrentButton[i].url_en+
															"\" style=\"color:#EAEAEA;text-decoration: none;\">"+
															CurrentButton[i].name_en+
															"</a></div>";
			}
			document.getElementById("menu"+i).style.background="url(pic/menu.jpg)";
		}
		
		document.getElementById("menucolor"+num).style.color="#FFFFFF";
		document.getElementById("menu"+num).style.background="url(pic/menu_sele.jpg)";
	}
	else
	{
		/*判斷中英文網頁切換的文字內容 及 連結網址*/
		if(isChinese==1 || isChinese==null)
		{
			document.getElementById("contacts").innerHTML="<a href=\"contact.html\" style=\"color:#EAEAEA; text-decoration: none;\">聯絡我們</a>";
			document.getElementById("home").innerHTML="<a href=\"index.html\" style=\"color:#EAEAEA; text-decoration: none;\">回首頁</a>";
			document.getElementById("langChange").innerHTML="<a href=\"en_index.html\" style=\"color:#ee2222; \">English</a>";
		}
		else
		{
			document.getElementById("contacts").innerHTML="<a href=\"en_contact.html\" style=\"color:#EAEAEA; text-decoration: none;\">contacts</a>";
			document.getElementById("home").innerHTML="<a href=\"en_index.html\" style=\"color:#EAEAEA; text-decoration: none;\">Home</a>";
			document.getElementById("langChange").innerHTML="<a href=\"index.html\" style=\"color:#ee2222; \">切換中文網頁</a>";
		}
		
		/*網頁上排選單產生*/
		for(var i=0;i<CurrentButton.length;i++)
		{
		    
			if(isChinese==1 || isChinese==null)
			{
				document.getElementById("menu"+i).innerHTML=	"<div style=\"padding-top:40px; \"><a id=\"menucolor"+i+"\" href=\""+CurrentButton[i].url+
															"\" style=\"color:#EAEAEA;text-decoration: none;\">"+
															CurrentButton[i].name+
															"</a></div>";
			}
			else
			{
				document.getElementById("menu"+i).innerHTML=	"<div style=\"padding-top:40px; \"><a id=\"menucolor"+i+"\" href=\""+CurrentButton[i].url_en+
															"\" style=\"color:#EAEAEA;text-decoration: none;\">"+
															CurrentButton[i].name_en+
															"</a></div>";
			}
			document.getElementById("menu"+i).style.background="url(pic/menu.jpg)";
		}
	}
	/*相關參數設定*/
	focusButton=num;
	focusSecButton=secnum;
	
	
	/*非主頁時以下內容才會成立*/
	if(isIndex==0) 
	{
		buf="<div style='margin-bottom:5px;'><table border='0' cellpadding='5' cellspacing='3'>";

		if(isChinese==1 || isChinese==null)
		{
		    
		    if(CurrentButton[focusButton].getsecondMenulength()==0)
		    {
		        buf+="<tr bgcolor=\"#3B3944\"><td style='width:195px;text-align:center;color:#aaaaaa;background:#F17B24;color:#ffffff;'>"+CurrentButton[focusButton].name+"</td></tr>";
		    }
		    else
		    {
		        for(var i=0;i<CurrentButton[focusButton].getsecondMenulength();i++)
		        {
		            if(secnum==i)
		                buf+=   "<tr style=\"background:#F17B24;\" onMouseOver=\"this.style.backgroundColor='#DEF8FA'\" onMouseOut=\"this.style.backgroundColor='#F17B24'\">"+
		                        "<td style='width:195px;text-align:center;'><a href=\""+CurrentButton[focusButton].secondMenuList[i].url+"\" style=\"color:#ffffff;text-decoration: none;\">"+CurrentButton[focusButton].secondMenuList[i].name+"</a></td></tr>";
		            else
		                buf+=   "<tr style=\"background:#3B3944;\" onMouseOver=\"this.style.backgroundColor='#DEF8FA'\" onMouseOut=\"this.style.backgroundColor='#3B3944'\">"+
		                        "<td style='width:195px;text-align:center;'><a href=\""+CurrentButton[focusButton].secondMenuList[i].url+"\" style=\"color:#999999;text-decoration: none;\">"+CurrentButton[focusButton].secondMenuList[i].name+"</a></td></tr>";
		        }
		    }
		}
		else
		{
			if(CurrentButton[focusButton].getsecondMenulength()==0)
		    {
		        buf+="<tr bgcolor=\"#3B3944\"><td style='width:195px;text-align:center;color:#aaaaaa;background:#F17B24;color:#ffffff;'>"+CurrentButton[focusButton].name_en+"</td></tr>";
		    }
		    else
		    {
		        for(var i=0;i<CurrentButton[focusButton].getsecondMenulength();i++)
		        {
		            if(secnum==i)
		                buf+=   "<tr style=\"background:#F17B24;\" onMouseOver=\"this.style.backgroundColor='#DEF8FA'\" onMouseOut=\"this.style.backgroundColor='#F17B24'\">"+
		                        "<td style='width:195px;text-align:center;'><a href=\""+CurrentButton[focusButton].secondMenuList[i].url_en+"\" style=\"color:#ffffff;text-decoration: none;\">"+CurrentButton[focusButton].secondMenuList[i].name_en+"</a></td></tr>";
		            else
		                buf+=   "<tr style=\"background:#3B3944;\" onMouseOver=\"this.style.backgroundColor='#DEF8FA'\" onMouseOut=\"this.style.backgroundColor='#3B3944'\">"+
		                        "<td style='width:195px;text-align:center;'><a href=\""+CurrentButton[focusButton].secondMenuList[i].url_en+"\" style=\"color:#999999;text-decoration: none;\">"+CurrentButton[focusButton].secondMenuList[i].name_en+"</a></td></tr>";
		        }
		    }
		}
		
		buf+="</table></div>";
		
	    document.getElementById("secondMenu").innerHTML=buf;   
	}		
}

function changePIC(num)
{
	document.getElementById("menu"+num).style.background="url(pic/menu_sele.jpg)";
	document.getElementById("menucolor"+num).style.color="#FFFFFF";
}

function releasePIC(num)
{
	if(focusButton!=num)
	{
		document.getElementById("menu"+num).style.background="url(pic/menu.jpg)";
		document.getElementById("menucolor"+num).style.color="#F4F4F4";
	}
}

