
    var xmlNews;
    
    function getNewsList( channel){

        setNewsMenu( channel);
       
        var url = './xml/xml_news_list.jsp?channel=' + channel;

        if( window.XMLHttpRequest) xmlNews = new XMLHttpRequest();
        else if( window.ActiveXObject) xmlNews = new ActiveXObject('Microsoft.XMLHTTP');
              
        // xmlNews = GetXmlHttpObject();
        xmlNews.open( 'GET', url, true);
        xmlNews.onreadystatechange = setNewsList;
        xmlNews.send( null);

    }
    
    function setNewsList(){

        var i, j;
        var total;
        var subject, notes, icon, url, paste, bgcolor;
        var html;
        
        if( xmlNews.readyState == 4 && xmlNews.status == 200){ 
           
            total = parseInt( xmlNews.responseXML.getElementsByTagName('total')[0].firstChild.nodeValue);
            
            if( total > 0){

                html = '                <table width="753" border="0" cellspacing="0" cellpadding="0">\n';
                html += '                 <tr>\n';
                
                j = 0;
                
                for( i = 0; i < total; i ++){

                    subject = xmlNews.responseXML.getElementsByTagName('subject')[i].firstChild.nodeValue;
                    url = xmlNews.responseXML.getElementsByTagName('url')[i].firstChild.nodeValue;
                    icon = xmlNews.responseXML.getElementsByTagName('icon')[i].firstChild.nodeValue;

                    if( icon.length == 3) icon = '<img src="./images/' + icon + '_01.gif">';
                    else icon = ''; 
                    
                    if( i == 0){

                        notes = xmlNews.responseXML.getElementsByTagName('notes')[i].firstChild.nodeValue;
                        paste = xmlNews.responseXML.getElementsByTagName('paste')[i].firstChild.nodeValue;

                        html += '                    <td width="399" height="100" align="center" valign="top">\n';
                        html += '                     <table width="399" border="0" cellspacing="0" cellpadding="0">\n';
                        html += '                      <tr><td width="106" height="100" rowspan="2" valign="top"><a href="' + url + '"><img src="' + paste + '" width="100" height="100" border="0"></a></td>\n';
                        html += '                          <td width="293" height="30"><a href="' + url + '"><a href="' + url + '" class="b_info">' + subject + '</a> ' + icon + '</td></tr>\n';
                        html += '                      <tr><td width="293" height="70" valign="top" class="gary12">' + notes + ' <a href="' + url + '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'N0601010001\',\'\',\'./images/more_02.gif\', 1)"><img src="./images/more_01.gif" name="N0601010001" width="37" height="13" border="0" id="N0601010001"></a></td></tr>\n';
                        html += '                     </table>\n';
                        html += '                    </td>\n';
                        html += '                    <td width="9" height="100" background="./images/arrow_06.gif"></td>\n';
                        
                    }
                    
                    else{
                    
                        bgcolor = j == 0 ? "#FFFFFF" : "#EEEEEE";

                        if( i == 1){

                            html += '                    <td width="345" height="100" align="center" valign="top">\n';
                            html += '                     <table width="345" border="0" cellspacing="0" cellpadding="0">\n';
                            
                        }

                        html += '                      <tr><td height="26" align="left" valign="middle" bgcolor="' + bgcolor + '" class="b_info">．<a href="' + url + '" class="b_info">' + subject + '</a> ' + icon + '</td></tr>\n';
                    
                        j ++;
                        
                        if( j == 2) j = 0;
                    
                        if( i == 5 || i == total - 1){

                            html += '                     </table>\n';
                            html += '                    </td>\n';
                            
                        }
                    
                    }

                }

                html += '                 </tr>\n';
                html += '                </table>\n';

                newslist.innerHTML = html;
               
            }

        }

    }

    function setNewsMenu( channel){

        var html;
        var menu = new Array();
        var icon = new Array();
        
        menu[0] = '<a href="javascript:;" onclick="javascript: getNewsList(1);" class="g_b">手機新聞</a>';
        menu[1] = '<a href="javascript:;" onclick="javascript: getNewsList(2);" class="g_b">電信新聞</a>';
        menu[2] = '<a href="javascript:;" onclick="javascript: getNewsList(3);" class="g_b">展場新聞</a>';
        menu[3] = '<a href="javascript:;" onclick="javascript: getNewsList(4);" class="g_b">綜合新聞</a>';
        menu[4] = '<a href="javascript:;" onclick="javascript: getNewsList(9);" class="g_b">配件新聞</a>';
        menu[5] = '<a href="javascript:;" onclick="javascript: getNewsList(8);" class="g_b">GOGO週報</a>';

        icon[0] = '3';
        icon[1] = '3';
        icon[2] = '3';
        icon[3] = '3';
        icon[4] = '3';
        icon[5] = '3';
        
        if( channel == 2){
            
            menu[1] = '<span class="org1201">電信新聞</span>';
            icon[1] = '2';
        
        }
        
        else if( channel == 3){
            
            menu[2] = '<span class="org1201">展場新聞</span>';
            icon[2] = '2';
        
        }    
        
        else if( channel == 4){
        
            menu[3] = '<span class="org1201">綜合新聞</span>';
            icon[3] = '2';
        
        } 

        else if( channel == 9){
        
            menu[4] = '<span class="org1201">配件新聞</span>';
            icon[4] = '2';
        
        } 
        
        else if( channel == 8){
            
            menu[5] = '<span class="org1201">GOGO週報</span>';
            icon[5] = '2';
        
        }
        
        else{
        
            menu[0] = '<span class="org1201">手機新聞</span>';
            icon[0] = '2';
        
        }
                
        html = '                <table width="430" border="0" cellspacing="0" cellpadding="0">\n';
        html += '                 <tr><td width="10" height="18"><img src="./images/arrow_0' + icon[0] + '.gif" width="4" height="7"></td>\n';
        html += '                     <td width="60" height="18">' + menu[0] + '</td>\n';
        html += '                     <td width="10" height="18"><img src="./images/arrow_0' + icon[1] + '.gif" width="4" height="7"></td>\n';
        html += '                     <td width="60" height="18">' + menu[1] + '</td>\n';
        html += '                     <td width="10" height="18"><img src="./images/arrow_0' + icon[2] + '.gif" width="4" height="7"></td>\n';
        html += '                     <td width="60" height="18">' + menu[2] + '</td>\n';
        html += '                     <td width="10" height="18"><img src="./images/arrow_0' + icon[3] + '.gif" width="4" height="7"></td>\n';
        html += '                     <td width="60" height="18">' + menu[3] + '</td>\n';
        html += '                     <td width="10" height="18"><img src="./images/arrow_0' + icon[4] + '.gif" width="4" height="7"></td>\n';
        html += '                     <td width="60" height="18">' + menu[4] + '</td>\n';
        html += '                     <td width="10" height="18"><img src="./images/arrow_0' + icon[5] + '.gif" width="4" height="7"></td>\n';
        html += '                     <td width="70" height="18">' + menu[5] + '</td></tr>\n';
        html += '                </table>\n';
        
        newsmenu.innerHTML = html;        
        
        html = '                <table width="753" border="0" cellspacing="0" cellpadding="0">\n';
        html += '                 <tr><td height="25"><span class="loading">Loading ...</td></tr>\n';
        html += '                </table>\n';

        newslist.innerHTML = html;

    }