﻿// JScript 文件

function CarateTopLeft(divID) {
//    debugger;
    var traitHtml;
    if(typeof(loginUserName) != 'undefined' && loginUserName!= '')
        traitHtml='<tr><td height="42" valign="bottom">' + 
                    '<table width="130" border="0" cellpadding="0" cellspacing="0">' +
                        '<tr><td width="77" valign="bottom"><span class="bold_red_13">Hello</span> <span class="red_13">'+ loginUserName +'</span></td>' +
                            '<td align="right" class="blue_13"><input name="button3" type="button" onclick="swerveUrl(\''+applicationPath+'/chn/Default.aspx?type=exit\')" class="botton_blue" onFocus="this.blur();" id="button3" value="  登出  " /></td></tr>' + 
                        '<tr><td colspan="2"><img src="'+applicationPath+ '/img/line_c.gif" width="136" height="15"></td></tr></table>' + 
                  '</td></tr>';
    else
        traitHtml='<tr><td>&nbsp;</td></tr>' + '<tr><td height="23" class="blue_13_d"><a href="'+applicationPath+'/chn/d/d_login.aspx" onFocus="this.blur();">會員登入</a></td></tr>';
        
    document.getElementById(divID).innerHTML = '<table width="183" border="0" cellspacing="0" cellpadding="0">' +
        '<tr><td height="25">&nbsp;</td></tr>' +
        '<tr><td><a href="http://www.ceramics.tpc.gov.tw/" target="_blank" onfocus="this.blur();"><img src="'+applicationPath+'/img/bk_login_logo.gif" width="127" height="71" border="0"></a></td></tr>' + traitHtml +
        '<tr><td height="23" class="blue_13_d"><a href="'+applicationPath+'/chn/shop.aspx" onmouseover="showMenu(\'menuShop\',this,1,6,-6)" onmouseout="hiddenMenu(\'menuShop\')" onFocus="this.blur();">購物服務</a></td></tr>'+
        '<tr><td height="23" class="blue_13_d"><a href="'+applicationPath+'/chn/service.aspx" onmouseover="showMenu(\'menuService\',this,1,6,-6)" onmouseout="hiddenMenu(\'menuService\')" onFocus="this.blur();">客服中心</a></td></tr></table>';
}

function swerveUrl(u){location.href=u;}
function AllAroundSearch(cn,ct)
{
    if(!cn ||!document.getElementById(cn))return;
    var v = document.getElementById(cn).value;
    if(v != ""){
        swerveUrl(applicationPath + "/chn/g/search.aspx?t=" + document.getElementById(ct).value + "&c=" + escape(v));
    }
    else 
    {
        alert('請輸入搜索的條件！');
    }
    return false;
}
function showMenuMain(cn,xyCol){
    rootName = cn.substring(0,cn.search('_')+1);
    var popMode,valueX,valueY;
    if(rootName == cn){popMode = 0;valueX = 0;valueY = 0;}
    else {popMode = 1;valueX = 0;valueY = 0;}
    showMenu(cn,xyCol,popMode,valueX,valueY);
}
function showMenu(cn,xyCol,popMode,valueX,valueY){
    var vc = eGet(cn);
    if(vc == null) vc = menuCreate(cn);//menuTopLeft(cn);
    if(vc.style.display == 'block'){
        if(endShowMenu == cn)
            clearTimeout(menu1timer);
        else{
            endShowMenu = cn;
            setTimeout("eGet('"+cn+"').style.display == 'block'",200);
        }
        return;
    }    
    if(xyCol != null){        
        var tempV = getDim(xyCol);
        valueX = (valueX == null)?0:valueX;
        valueY = (valueY == null)?0:valueY;
        if(popMode == 0){//向下彈出
            valueX = tempV.x + valueX;
            valueY = tempV.y + xyCol.offsetHeight + valueY;
        }else{//向右彈出
            valueX = tempV.x + xyCol.offsetWidth + valueX;
            valueY = tempV.y + valueY;            
        }
        vc.style.top = valueY + "px";
        vc.style.left = valueX + "px";
    }
    endShowMenu = cn;
    setTimeout("eGet('"+cn+"').style.display = 'block'",200);
}
function hiddenMenu(cn){
    menu1timer = setTimeout("eGet('"+cn+"').style.display='none';",200);
}
function eGet(cn){ return document.getElementById(cn); }
function getDim(el){
 for (var lx=0,ly=0;el!=null;
   lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent)
   {
       if(el.tagName.toLowerCase()=="div" && el.style.position=="relative")
       {
           ly = ly - el.offsetTop;   
           ly = ly + (el.offsetTop - el.scrollTop);
       }
   };
 return {x:lx,y:ly}
}

function menuTopLeft(cn)
{
    var oDiv = document.createElement("DIV"); 
    oDiv.id = cn;
    oDiv.style.position = 'absolute';
    oDiv.style.display = 'none';
    oDiv.onmouseover = function(){showMenu(this.id,null);};
    oDiv.onmouseout = function(){hiddenMenu(this.id);};
    if(cn == 'menuShop')
        oDiv.innerHTML = 
        '<table border="0" cellpadding="0" cellspacing="0" class="table_frame_blue_btn" style="font-size: 9pt; color: #009bd2; font-family: Arial">'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/f/f_cart_01.aspx" onfocus="this.blur();">我的購物車</a></td></tr>'
        +'    <tr style="color: #0000ff; text-decoration: underline"><td background="'+applicationPath+'/img/line_b.gif" valign="middle"><img height="1" src="'+applicationPath+'/img/spacer.gif" width="5" /></td></tr>'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/f/f_statement.aspx" onfocus="this.blur();">購物說明</a></td></tr>'
        +'    <tr style="color: #0000ff; text-decoration: underline"><td background="'+applicationPath+'/img/line_b.gif" valign="middle"><img height="1" src="'+applicationPath+'/img/spacer.gif" width="5" /></td></tr>'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/f/f_return.aspx" onfocus="this.blur();">退換貨申請</a></td></tr>'
        +'    <tr style="color: #0000ff; text-decoration: underline"><td background="'+applicationPath+'/img/line_b.gif" valign="middle"><img height="1" src="'+applicationPath+'/img/spacer.gif" width="5" /></td></tr>'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/f/f_order.aspx" onfocus="this.blur();">歷史交易紀錄</a></td></tr>'
        +'    <tr style="color: #0000ff; text-decoration: underline"><td background="'+applicationPath+'/img/line_b.gif" valign="middle"><img height="1" src="'+applicationPath+'/img/spacer.gif" width="5" /></td></tr>'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/f/f_wish.aspx" onfocus="this.blur();">我的最愛</a></td></tr>'
        +'</table>'; 
     else
        oDiv.innerHTML = 
        '<table border="0" cellpadding="0" cellspacing="0" class="table_frame_blue_btn" style="font-size: 9pt; color: #009bd2; font-family: Arial">'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/g/g_join_01.aspx" onfocus="this.blur();">活動報名</a></td></tr>'
        +'    <tr style="color: #0000ff; text-decoration: underline"><td background="'+applicationPath+'/img/line_b.gif" valign="middle"><img height="1" src="'+applicationPath+'/img/spacer.gif" width="5" /></td></tr>'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/g/g_join_achieved.aspx" onfocus="this.blur();">報名進度查詢</a></td></tr>'
        +'    <tr style="color: #0000ff; text-decoration: underline"><td background="'+applicationPath+'/img/line_b.gif" valign="middle"><img height="1" src="'+applicationPath+'/img/spacer.gif" width="5" /></td></tr>'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/g/g_opinion_01.aspx" onfocus="this.blur();">意見交流</a></td></tr>'
        +'    <tr style="color: #0000ff; text-decoration: underline"><td background="'+applicationPath+'/img/line_b.gif" valign="middle"><img height="1" src="'+applicationPath+'/img/spacer.gif" width="5" /></td></tr>'
        +'    <tr><td height="25" nowrap="nowrap" valign="middle"><a class="blue_blue_cho_13" href="'+applicationPath+'/chn/g/g_opinion_achieved.aspx" onfocus="this.blur();">意見進度查詢</a></td></tr>'
        +'</table>'; 
    
    document.body.appendChild(oDiv);   
    return oDiv;  
}

function menuCreate(cn)
{
    if(cn == "menuShop" || cn == "menuService"){return menuTopLeft(cn);}
    var oDiv = document.createElement("DIV"); 
    oDiv.id = cn;
    oDiv.style.position = 'absolute';
    oDiv.style.display = 'none';
    oDiv.onmouseover = function(){showMenu(this.id,null);};
    oDiv.onmouseout = function(){hiddenMenu(this.id);};
    
//    debugger;
    var v,rootName,defaultHttp,vType,tableText;
    rootName = cn.substring(0,cn.search('_')+1);
    eval("v = " + cn + ";defaultHttp=" + rootName + "Http;vType=" + rootName + "Type;");
    if(vType == "MainMenu"){
        tableText = "<table border='0' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF' class='table_frame_gray'>";
        for(i = 2; i < v.length; i++){
            tableText += ("<tr><td height=\"30\" nowrap=\"nowrap\" valign=\"middle\"><a class=\"bold_blue_cho_13\" href=\""+ applicationPath + defaultHttp + v[i][0]+"\" onfocus='this.blur();'>"+ v[i][1] +"</a></td></tr><tr><td valign='middle' background='"+applicationPath+"/img/line_b.gif'><img src='"+applicationPath+"/img/spacer.gif' width='5' height='1' border='0' /></td></tr>");
        }
        tableText += "</table>";
    }
    oDiv.innerHTML = tableText;    
    document.body.appendChild(oDiv);   
    return oDiv;  
}

function openRootMenu(num){
    var v;
    if(num==0)v="/chn/a/a_index.aspx";else if(num==1)v="/chn/b/b_index.aspx";else if(num==2)v="/chn/c/c_news_index.aspx";else if(num==3)v="/chn/d/d_login.aspx";else v="/chn/e/e_index.aspx";
    location.href=(applicationPath + v);
}
function setCP(n){var v= document.getElementById(n);v.src=v.src.replace("a.gif","b.gif");}
function xUrl(s){ location.href=s; }

var c_Http='/chn/c/',c_Type='MainMenu';c_=nA_();c_[1]='陶博快訊菜單';
c_[2]=nA_();c_[2][0]='c_news_index.aspx';c_[2][1]='最新消息';
c_[3]=nA_();c_[3][0]='c_star_index.aspx';c_[3][1]='本月主打星';
c_[4]=nA_();c_[4][0]='c_sale_index.aspx';c_[4][1]='特賣商品';
var d_Http='/chn/d/',d_Type='MainMenu';d_=nA_();d_[1]='會員專區菜單';
var d_tempv = 1;
if(typeof(loginUserName) == 'undefined' || loginUserName == ''){
    d_tempv = 3;
    d_[2]=nA_();d_[2][0]='d_member_01.aspx';d_[2][1]='加入會員';
    d_[3]=nA_();d_[3][0]='d_login.aspx';d_[3][1]='會員登入';
}
d_tempv ++;d_[d_tempv]=nA_();d_[d_tempv][0]='d_modify_01.aspx';d_[d_tempv][1]='修改會員資料';
d_tempv ++;d_[d_tempv]=nA_();d_[d_tempv][0]='d_pwd_01.aspx';d_[d_tempv][1]='會員密碼查詢';
d_tempv ++;d_[d_tempv]=nA_();d_[d_tempv][0]='d_card_index.aspx';d_[d_tempv][1]='賀卡服務';
var e_Http='/chn/e/',e_Type='MainMenu';e_=nA_();e_[1]='商店介紹菜單';
e_[2]=nA_();e_[2][0]='e_index.aspx';e_[2][1]='「生活好美麗」文化商品概念店';
e_[3]=nA_();e_[3][0]='e_contact.aspx';e_[3][1]='聯絡我們';
