﻿//圖片按比例縮放 調用：<img src="圖片" onload="javascript: DrawImage(this)">
var flag=false;
function DrawImage(ImgD,ImgW,ImgH){
    var image=new Image();
    var iwidth = ImgH; //定義允許圖片寬度
    var iheight = ImgH; //定義允許圖片高度
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
        flag=true;
        if(image.width/image.height>= iwidth/iheight){
            if(image.width>iwidth){
                ImgD.width=iwidth;
                ImgD.height=(image.height*iwidth)/image.width;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
            //ImgD.alt=image.width+"×"+image.height;
        }
        else{
            if(image.height>iheight){
                ImgD.height=iheight;
                ImgD.width=(image.width*iheight)/image.height;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
            //ImgD.alt=image.width+"×"+image.height;
        }
    }
}

function doShowdshg(showid,obj)
{
    //導航塊   
    var nacnt = document.getElementById("dshg_navigation").getElementsByTagName("li").length;
    for(var i=0;i<nacnt;i++)
    {
        if(document.getElementById("dshg_navigation").getElementsByTagName("li")[i]==obj)
            document.getElementById("dshg_navigation").getElementsByTagName("li")[i].style.backgroundColor = "#EEF6F9";
        else
            document.getElementById("dshg_navigation").getElementsByTagName("li")[i].style.backgroundColor = "#FFC10E";
    }
    
    //內容塊
    var cnt = document.getElementById("dshgList").getElementsByTagName("ul").length;
    for(var x=0;x<cnt;x++)
    {
        if(document.getElementById("dshgList").getElementsByTagName("ul")[x].id==showid)
            document.getElementById("dshgList").getElementsByTagName("ul")[x].style.display = "";
        else
            document.getElementById("dshgList").getElementsByTagName("ul")[x].style.display = "none";
    }
}