var jcartNo			= getCartNo();
var icartNo  = "";
var icartNo1 = "";
if ( jcartNo != "" ){
    //var icartNo = "?cartno=" + jcartNo;
    //var icartNo1 = "&cartno=" + jcartNo;
}
var j_url  = "";

//2007/01/05 sam ???
if (location.href.indexOf("http://twtest.ttnet.net") == 0 || location.href.indexOf("http://cntest.ttnet.net") == 0) {
    j_url = "";
} else if (location.href.indexOf("https") == 0 || (location.href.indexOf("http://") == 0 && location.href.indexOf("http://tw.ttnet.net") != 0 ) ){
    j_url = "http://tw.ttnet.net";
}


var top_index_url = new Array();
var top_index_nme = new Array();
var top_index_img = new Array();
var top_index_color = new Array();
var top_index_color_img = new Array();
var top_index_code = new Array();

top_index_url[0]= j_url+'/index.html'+icartNo;
top_index_nme[0]="首頁";
top_index_img[0]="http://images.ttnet.net/pi/cimages/index/1.jpg";
top_index_color[0]="#C61C2E";
top_index_color_img[0]="red";
top_index_code[0]="A";

//top_index_url[1]= j_url+'/cbuyer.shtml'+icartNo;
top_index_url[1]= j_url+'/cttnet-bin/cbuyer_center.cgi?cooklang=1'+icartNo1;
top_index_nme[1]="買主服務";
top_index_img[1]="http://images.ttnet.net/pi/cimages/index/buyers1.gif";
top_index_color[1]="#8C9D45";
top_index_color_img[1]="bu";
top_index_code[1]="B";

top_index_url[2]= j_url+'/cttnet-bin/csupplier.cgi?cooklang=1'+icartNo1;
top_index_nme[2]="廠商服務";
top_index_img[2]="http://images.ttnet.net/pi/cimages/index/suppliers1.gif";
top_index_color[2]="#2D64B5";
top_index_color_img[2]="su";
top_index_code[2]="C";

top_index_url[3]= j_url+'/cttnet-bin/cstockboard.cgi?code=&dateup=3&cooklang=1'+icartNo1;
top_index_nme[3]="買賣看板";
top_index_img[3]="http://images.ttnet.net/pi/cimages/index/stockboardnew1.gif";
top_index_color[3]="#D86336";
top_index_color_img[3]="st";
top_index_code[3]="D";

top_index_url[4]= j_url+'/zh-tw/c_trade_shows/index.html'+icartNo;
top_index_nme[4]="展覽資訊";
top_index_img[4]="http://images.ttnet.net/pi/cimages/index/show_07191.gif";
top_index_color[4]="#9D633E";
top_index_color_img[4]="sh";
top_index_code[4]="E";

top_index_url[5]= j_url+'/trade_publications/publications_ch.html';
top_index_nme[5]="貿易專刊";
top_index_img[5]="http://images.ttnet.net/pi/cimages/index/pubook1.gif";
top_index_color[5]="#2F9AB2";
top_index_color_img[5]="pu";
top_index_code[5]="F";

top_index_url[6]= 'http://cnews.ttnet.net/cgi-bin/cnews.cgi?list=Y&src=news&cooklang=1'+icartNo1;
top_index_nme[6]="商貿資訊";
top_index_img[6]="http://images.ttnet.net/pi/cimages/index/news1.gif";
top_index_color[6]="#A839A5";
top_index_color_img[6]="ne";
top_index_code[6]="G";

top_index_url[7]= j_url+'/cttnet-bin/cetraining.cgi?show=Y'+icartNo1;
top_index_nme[7]="商業服務";
top_index_img[7]="http://images.ttnet.net/pi/cimages/index/cbusiness2.jpg";
top_index_color[7]="#707070";
top_index_color_img[7]="bs";
top_index_code[7]="H";



var top_max = top_index_url.length;
var index_url  = new Array(top_max);
var index_nme  = new Array(top_max);
var top_i = 0;
for(top_i=0;top_i<top_max;top_i++){
    index_url[top_i] = new Array();
    index_nme[top_i] = new Array();
}

index_url[0][0]=j_url+'/html/csearch/csearch_keyword.htm?'+icartNo1;
index_nme[0][0]="關鍵字搜尋";
index_url[0][1]=j_url+'/zh-tw/c_directory/';
index_nme[0][1]="分類搜尋";
index_url[0][2]=j_url+'/cttnet-bin/cprod_wanted.cgi?form=Y&cooklang=1'+icartNo1;
index_nme[0][2]="代客搜尋";
index_url[0][3]=j_url+'/cttnet-bin/cregister_index.cgi?'+icartNo1;
index_nme[0][3]="加入會員";
index_url[0][4]=j_url+'/cttnet-bin/c_epaper.cgi?cooklang=1'+icartNo1;
index_nme[0][4]="訂閱電子報";

index_url[1][0]=j_url+'/cttnet-bin/cbuyer_center.cgi?cooklang=1&login=Y'+icartNo1;
index_nme[1][0]="買主會員中心";
index_url[1][1]=j_url+'/html/csearch/csearch_keyword.htm?'+icartNo1;
index_nme[1][1]="關鍵字搜尋";
index_url[1][2]=j_url+'/zh-tw/c_directory/';
index_nme[1][2]="分類搜尋";
index_url[1][3]=j_url+'/cttnet-bin/cprod_wanted.cgi?form=Y&cooklang=1'+icartNo1;
//index_url[1][3]=j_url+'/for_buyers/p_wanted/p_wanted.htm?'+icartNo1;
index_nme[1][3]="代客搜尋";
index_url[1][4]=j_url+'/cttnet-bin/cuser_edit.cgi?edit=Y&cooklang=1'+icartNo1;
index_nme[1][4]="資料修改";
index_url[1][5]=j_url+'/cttnet-bin/cinq_manager.cgi?inqtabl.x=Y&cooklang=1'+icartNo1;
index_nme[1][5]="詢價紀錄";
index_url[1][6]=j_url+'/cttnet-bin/clovemain.cgi?showhtml=Y&cooklang=1'+icartNo1;
index_nme[1][6]="我的廠商名錄";
index_url[1][7]=j_url+'/cttnet-bin/cbiz_alert.cgi?alert02=Y&cooklang=1'+icartNo1;
index_nme[1][7]="線上商品推薦";


index_url[2][0]=j_url+'/cttnet-bin/csupplier.cgi?cooklang=1&login=Y'+icartNo1;
index_nme[2][0]="廠商會員中心";
index_url[2][1]=j_url+'/cttnet-bin/cfree_html.cgi?preview=Y&cooklang=1'+icartNo1;
index_nme[2][1]="資料修改";
index_url[2][2]=j_url+'/cttnet-bin/chomepage.cgi?stho=Y&cooklang=1'+icartNo1;
index_nme[2][2]="專屬站台";
index_url[2][3]=j_url+'/cttnet-bin/cshowroom.cgi?mt=Y&cooklang=1'+icartNo1;
index_nme[2][3]="私密展覽室";
index_url[2][4]=j_url+'/cttnet-bin/cinq_history.cgi?inq_history.x=Y&cooklang=1'+icartNo1;
index_nme[2][4]="報價管理";
index_url[2][5]=j_url+'/cttnet-bin/cinq_send.cgi?prd_inqu=Y&selstyle=Y&cooklang=1'+icartNo1;
index_nme[2][5]="寄送型錄";
index_url[2][6]=j_url+'/cttnet-bin/cinq_send.cgi?ad_inqu=Y&cooklang=1'+icartNo1;
index_nme[2][6]="商務開發函";
index_url[2][7]=j_url+'/cttnet-bin/cstockboard.cgi?cooklang=1&message=Y'+icartNo1;
index_nme[2][7]="商情發佈";
index_url[2][8]=j_url+'/cttnet-bin/ce_myset.cgi?cooklang=1'+icartNo1;
index_nme[2][8]="我的文筆";


index_url[3][0]='/cttnet-bin/cstockboard.cgi?code=&dateup=3&cooklang=1'+icartNo1;
index_nme[3][0]="所有訊息";
index_url[3][1]='/cttnet-bin/cstockboard.cgi?code=B&dateup=90&cooklang=1'+icartNo1;
index_nme[3][1]="採購需求";
index_url[3][2]='/cttnet-bin/cstockboard.cgi?code=S&dateup=3&cooklang=1'+icartNo1;
index_nme[3][2]="銷售訊息";
index_url[3][3]='/cttnet-bin/cstockboard.cgi?code=W&dateup=30&cooklang=1'+icartNo1;
index_nme[3][3]="庫存買賣";
index_url[3][4]='/cttnet-bin/cstockboard.cgi?code=O&dateup=30&cooklang=1'+icartNo1;
index_nme[3][4]="二手設備";
index_url[3][5]='/cttnet-bin/cstockboard.cgi?code=T&dateup=30&cooklang=1'+icartNo1;
index_nme[3][5]="產品代理";
index_url[3][6]='/cttnet-bin/cstockboard.cgi?code=M&dateup=30&cooklang=1'+icartNo1;
index_nme[3][6]="業務合作";
index_url[3][7]='/cttnet-bin/cstockboard.cgi?f=send&cooklang=1'+icartNo1;
index_nme[3][7]="訊息與刊登";
index_url[3][8]='/cttnet-bin/cstockboard.cgi?f=class&cooklang=1'+icartNo1;
index_nme[3][8]="分類搜尋";


index_url[4][0]='/zh-tw/c_trade_shows/trade-shows-pramot/trade-shows-pramot.html'+icartNo1;
index_nme[4][0]="全球參展推廣表";
index_url[4][1]='/zh-tw/c_trade_shows/shows-schedule/shows-schedule.html'+icartNo;
index_nme[4][1]="展覽情報";
index_url[4][2]='/zh-tw/c_trade_shows/show-attend/show-attend.html'+icartNo;
index_nme[4][2]="展覽招商";
index_url[4][3]='/zh-tw/c_trade_shows/show-explore/show-explore.html'+icartNo;
index_nme[4][3]="展覽考查";
index_url[4][4]='/zh-tw/c_trade_shows/show-news/show-news.html1'+icartNo1;
index_nme[4][4]="展覽報導";
index_url[4][5]='/zh-tw/c_trade_shows/show-report/show-report.html'+icartNo;
index_nme[4][5]="展覽見聞";
index_url[4][6]='/trade_shows/canton_fair/106th/index.html';
index_nme[4][6]="106屆廣交會";


index_url[5][0]=j_url+'/trade_publications/publications_ch.html';
index_nme[5][0]="中文刊物";
index_url[5][1]=j_url+'/trade_publications/publications_en.html';
index_nme[5][1]="英文刊物";
index_url[5][2]=j_url+'/cttnet-bin/cpublication.jsp?show=publication';
index_nme[5][2]="出版訊息";
index_url[5][3]=j_url+'/cttnet-bin/cpublication.jsp?show=expire';
index_nme[5][3]="截稿通知";


index_url[6][0]='http://cnews.ttnet.net/cgi-bin/cnews.cgi?list=Y&src=news&cooklang=1'+icartNo1;
index_nme[6][0]="經貿要聞";
index_url[6][1]=j_url+'/zh-tw/c_finance/index.html'+icartNo1;
index_nme[6][1]="商管新知";
//index_url[6][2]=j_url+'/t-channel1.htm?'+icartNo1;
index_url[6][2]=j_url+'/cttnet-bin/c_channel.cgi?cooklang=1'+icartNo1;
index_nme[6][2]="貿易頻道";
//index_url[6][3]='http://cnews.ttnet.net/cgi-bin/emc.cgi?cooklang=1'+icartNo1;
//index_nme[6][3]="企管學院";
index_url[6][3]=j_url+'/cttnet-bin/c_epaper.cgi?cooklang=1'+icartNo1;
index_nme[6][3]="訂閱電子報";


//index_url[7][0]=j_url+'/cttnet-bin/cbusiness.cgi?cooklang=1'+icartNo1;
//index_nme[7][0]="貿易助手";
//index_url[7][2]=j_url+'/cttnet-bin/cetraining.cgi?show=Y'+icartNo1;
//index_nme[7][2]="企業訓練";

index_url[7][0]=j_url+'/cttnet-bin/cetraining.cgi?show=Y'+icartNo1;
index_nme[7][0]="企業訓練";
index_url[7][1]=j_url+'/tradingtools.jsp/SS/'+icartNo1;
index_nme[7][1]="貿易百寶箱";
index_url[7][2]=j_url+'/cttnet-bin/cecard.cgi?cooklang=1&cardcenter=Y?'+icartNo1;
index_nme[7][2]="賀卡中心";
//index_url[7][3]=j_url+'/cttnet-bin/cbusiness.cgi?cooklang=1'+icartNo1;
//index_nme[7][3]="貿易助手";
//index_url[7][3]=j_url+'/cttnet-bin/c_guild.cgi?web=0&gid=1'+icartNo1;
//index_nme[7][3]="食品機械公會";



function html_top_new(top_index,jj_url,j_gif,j_width){
    var index_now_url  = new Array();
    var index_now_nme  = new Array();

    index_now_url  = index_url[top_index];
    index_now_nme  = index_nme[top_index];

    if (jj_url == '') {
        jj_url = top_index_url[top_index];
    } else if ( jj_url.indexOf("http://") == 0 ){

    } else if (jj_url.indexOf("?") != -1) {
        jj_url = j_url+jj_url+icartNo1;
    } else {
        jj_url = j_url+jj_url+icartNo;
    }

    if(j_gif == ''){
        j_gif = top_index_img[top_index];
    }else if(j_gif.indexOf("http") == -1){
        j_gif = 'http://images.ttnet.net/pi/cimages/'+j_gif;
    }

    //2007/01/05 sam ???
    if(j_width == '' || j_width == undefined){
        j_width = '775';
    }

    document.writeln('<style type="text/css">');
    document.writeln('<!--');
    document.writeln('.vig_g {  font-family: "細明體"; font-size: 12px; color: '+top_index_color[top_index]+'}');
    document.writeln('-->');
    document.writeln('</style>');

    document.writeln('<table cellspacing=0 cellpadding=0 width='+j_width+' align=center border=0>');
    document.writeln('  <tr>');
    document.writeln('    <td width=155 valign=top align=center><a href="'+j_url+'/index.html'+icartNo+'" target="_top"><img src="http://images.ttnet.net/images/tw/index/ttnet_logo.jpg" border=0></a></td>');

    var a_width = j_width - 155;
    document.writeln('    <td height=48 width='+a_width+'>');
    document.writeln('      <table width="100%" border="0" cellpadding="0" cellspacing="0" background="http://images.ttnet.net/pi/cimages/index/bk-1.jpg" height="40">');
    document.writeln('        <tr>');
    document.writeln('          <td valign="bottom"><a href='+jj_url+' target="_top"><img src="'+j_gif+'" border="0"></a></td>');
    document.writeln('          <td valign=bottom align=right>');
    document.writeln('            <table border="0" cellpadding="0" cellspacing="0" width="0" height="25">');
    document.writeln('              <tr valign=middle>');
    var j_id = GetCookie("CNEWSID");
    if (j_id == null || j_id == 'null'){
        document.writeln('            <td align=middle width=53 height=19><a class=j-1 href="'+j_url+'/cttnet-bin/clogin.cgi?log=Y&cooklang=1'+icartNo1+'" target="_top">會員登入</a></td>');
        document.writeln('            <td align=middle width=7 height=19><font color=#00659a size=2>|</font></td>');
        document.writeln('            <td align=middle width=53 height=19><a class=j-1 href="'+j_url+'/cttnet-bin/cregister_index.cgi?'+icartNo1+'" target="_top">加入會員</a></td>');
        document.writeln('            <td align=middle width=7 height=19><font color=#00659a size=2>|</font></td>');
    }else{
        document.writeln('            <td align="center" width="26" height="19"><a href="'+j_url+'/cttnet-bin/c_logout.cgi'+icartNo+'" class="j-1" target="_top">登出</a></td>');
        document.writeln('            <td align="center" width="7" height="19"><font size="2" color="#00659A">|</font></td>');
        document.writeln('            <td align=middle width=63 height=19><a class=j-1 href="/cttnet-bin/c_faq.cgi?service=y">與我們聯絡</a></td>');
        document.writeln('            <td align=middle width=7 height=19><font color=#00659a size=2>|</font></td>');
    }
    document.writeln('                <td align=middle width=53 height=19><a class=j-1 href="http://tw.ttnet.net/home/customer_service_center/index.html" target="_top">服務總覽</a> </td>');
    document.writeln('              </tr>');
    document.writeln('            </table>');
    document.writeln('          </td>');
    document.writeln('        </tr>');
    document.writeln('      </table>');
    document.writeln('    </td>');
    document.writeln('  </tr>');
    document.writeln('  <tr>');
    document.writeln('    <td height=10 colspan="2"></td>');
    document.writeln('  </tr>');
    document.writeln('  <tr>');
    document.writeln('    <td colspan=2 valign=top align=center>');
    document.writeln('      <table width="100%" align=center border="0" cellpadding="0" cellspacing="0" height="26">');
    document.writeln('        <tr>');
    document.writeln('          <td align=center>');
    document.writeln('            <table border="0" cellpadding="0" cellspacing="0">');
    document.writeln('              <tr> ');
    document.writeln('                <td valign="top" align="right" width=75></td>');

    var top_i = 0;
    var top_nme_width = 0;
    for(top_i=0;top_i<top_max;top_i++){
        top_nme_width = top_index_nme[top_i].length * 10 + 20;
        if(top_i == top_index){
            document.writeln('        <td width="4" valign="bottom"><u><img src="http://images.ttnet.net/pi/cimages/index/r_'+top_index_color_img[top_i]+'_1.gif" width="4" height="26"></u></td>');
            document.writeln('        <td width="'+top_nme_width+'" valign="bottom"> ');
            document.writeln('          <table width="100%" border="0" cellspacing="0" cellpadding="0" height="26" background="http://images.ttnet.net/pi/cimages/index/r_'+top_index_color_img[top_i]+'_3.gif">');
            document.writeln('            <tr> ');
            document.writeln('              <td> ');
            document.writeln('                <div align="center"><a href="'+top_index_url[top_i]+'" class="vig_g" style="text-decoration:none;" target="_top"><font class="c">'+top_index_nme[top_i]+'</font></a></div>');
            document.writeln('              </td>');
            document.writeln('            </tr>');
            document.writeln('          </table>');
            document.writeln('        </td>');
            document.writeln('        <td width="4" valign="bottom"><img src="http://images.ttnet.net/pi/cimages/index/r_'+top_index_color_img[top_i]+'_2.gif" width="4" height="26"></td>');
        }else{
            document.writeln('        <td width="4" valign="bottom"> ');
            document.writeln('          <div align="center"><img src="http://images.ttnet.net/pi/cimages/index/r-1-1.jpg" width="4" height="26"></div>');
            document.writeln('        </td>');
            document.writeln('        <td width="'+top_nme_width+'" align="center" valign="bottom"> ');
            document.writeln('          <table width="100%" border="0" cellspacing="0" cellpadding="0" height="26" background="http://images.ttnet.net/pi/cimages/index/rbk-1.jpg">');
            document.writeln('            <tr> ');
            document.writeln('              <td> ');
            document.writeln('                <div align="center"><a href="'+top_index_url[top_i]+'" class="vig_g" target="_top">'+top_index_nme[top_i]+'</a></div>');
            document.writeln('              </td>');
            document.writeln('            </tr>');
            document.writeln('          </table>');
            document.writeln('        </td>');
            document.writeln('        <td width="4" valign="bottom"> ');
            document.writeln('          <div align="center"><img src="http://images.ttnet.net/pi/cimages/index/r-2-1.jpg" width="4" height="26"></div>');
            document.writeln('        </td>');
        }
    }
    document.writeln('              </tr> ');
    document.writeln('            </table>');
    document.writeln('          </td>');
    document.writeln('          <td valign="top" align="right" width=75>');
    document.writeln('            <table border="0" cellpadding="0" cellspacing="0" height="20">');
    document.writeln('              <tr valign="bottom">');
    var j_cart = GetCookie("CCARTCNT");
    if (j_cart == null || j_cart == 'null' || j_cart == 'N'){
        document.writeln('            <td width="25" align="center"><a href="'+j_url+'/cttnet-bin/cinq_manager.cgi?chkcart=Y&cooklang=1'+icartNo1+'" target="_top"><img src="http://images.ttnet.net/pi/cimages/index/car0.gif" width="19" height="17" border="0"></a></td>');
    }else{
        document.writeln('            <td width="25" align="center"><a href="'+j_url+'/cttnet-bin/cinq_manager.cgi?chkcart=Y&cooklang=1'+icartNo1+'" target="_top"><img src="http://images.ttnet.net/pi/cimages/index/car1.gif" width="19" height="17" border="0"></a></td>');
    }
    document.writeln('                <td width="50" align="center">');
    document.writeln('                  <a href="'+j_url+'/cttnet-bin/cinq_manager.cgi?chkcart=Y&cooklang=1'+icartNo1+'" class="j-1" target="_top">詢價車..</a>');
    document.writeln('                </td>');
    document.writeln('              </tr>');
    document.writeln('            </table>');
    document.writeln('          </td>');
    document.writeln('        </tr>');
    document.writeln('      </table>');
    document.writeln('    </td>');
    document.writeln('  </tr>');
    document.writeln('</table>');

    document.writeln('<table border="0" align="center" cellpadding="0" cellspacing="0" height="23" bgcolor="'+top_index_color[top_index]+'" width="'+j_width+'">');
    document.writeln('  <tr>');
    document.writeln('    <td align="center">');
    document.writeln('      <table border="0" align="center" cellpadding="0" cellspacing="0" height="18">');
    document.writeln('        <tr valign="bottom">');

    var top2_i = 0;
    var top2_max = index_now_url.length;

    for(top2_i;top2_i<top2_max;top2_i++){
        if(top2_i > 0){
            document.writeln('  <td bgcolor="'+top_index_color[top_index]+'" width="14" align="center"><font color="#CCCCCC">|</font></td>');
        }
        document.writeln('      <td bgcolor="'+top_index_color[top_index]+'" align="center"><font color="#CCCCCC"><a href="'+index_now_url[top2_i]+'" class="bm2" target="_top">'+index_now_nme[top2_i]+'</a></font></td>');
    }

    // 網頁點閱紀錄
    //var j_pv	= getPV();
    //if ( j_pv != "" ){
    //   var conv = new Array();
    //   conv = j_pv.split(".");
    //   if (conv[1] == undefined) conv[1] = "";
    //   var str1 = '<td width=1><img src="http://tw.ttnet.net/cttnet-bin/c_pageview.cgi?img=Y&cooklang=1&page_code='+conv[0]+'&from_code='+conv[1]+'" border=0></td>';
    //   document.writeln(str1);
    //}

    document.writeln('        </tr>');
    document.writeln('      </table>');
    document.writeln('    </td>');
    document.writeln('  </tr>');
    document.writeln('</table>');



}

//擷取Cookie
function GetCookie(name) {
    var result = null;
    var myCookie = document.cookie + ";";
    var searchName = name + "=";
    var startOfCookie = myCookie.indexOf(searchName);
    var endOfCookie;
    if (startOfCookie != -1) {
        startOfCookie += searchName.length;
        endOfCookie = myCookie.indexOf(";",startOfCookie);
        result = unescape(myCookie.substring(startOfCookie, endOfCookie));
    }
    return result;
}

function getPV(){
   var result = "";
   var handyString = window.location.search;
   var startOfSource = handyString.indexOf( "PV=" );
   if (startOfSource != -1 ){
       var endOfSource = handyString.indexOf( "&", startOfSource + 3 );
       if ( endOfSource == -1 ) endOfSource = handyString.length;
       result = handyString.substring( startOfSource + 3, endOfSource );
   }
   return result;
}

