﻿
    var xmlhttp;
    
    function getAlbumList( si){

        var url;
        
        url = '../xml/xml_kkbox_album_list.aspx?si=' + si;

        if( window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
        else if( window.ActiveXObject) xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
        
        xmlhttp.open( 'GET', url, false);
              
        if( navigator.appName == 'Netscape'){

            xmlhttp.send( null);
            setAlbumList();
        
        }
        
        else{

            xmlhttp.onreadystatechange = setAlbumList;
            xmlhttp.send( null);
            
        }

    }

    function setAlbumList(){

        var i, j;
        var total;
        var classify, id, name, code, artist, thumb;
        var xmlroot;
        var content;

        if( xmlhttp.readyState == 4 && xmlhttp.status == 200){ 

            xmlroot = xmlhttp.responseXML.documentElement;

            classify = xmlroot.selectSingleNode('./result/classify').firstChild.nodeValue;

            total = parseInt( xmlroot.selectNodes('./result/single').length);

            content = '<table width="632" border="0" cellspacing="0" cellpadding="0">';
            content += ' <tr><td valign="top" class="enttit"><div class="titend"><img src="../images/kk_tit01.gif" width="254" height="28" style="float:left;" /></div></td></tr>';
            content += ' <tr>';
            content += '  <td height="225" align="center" valign="middle" bgcolor="#FFFFFF">';
            content += '   <table width="616" border="0" cellpadding="0" cellspacing="0">';
            content += '    <tr>';

            if( classify == '2'){

                content += '     <td height="21"><a href="javascript: getAlbumList(1);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-release\', \'../images/kkhot_tabover1.gif\');"><img src="../images/kkhot_tab1.gif" width="154" height="21" border="0" id="new-release" /></td>';
                content += '     <td><img src="../images/kkhot_tabover2.gif" width="154" height="21" border="0" id="new-chinese" /></a></td>';
                content += '     <td><a href="javascript: getAlbumList(3);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-english\', \'../images/kkhot_tabover3.gif\');"><img src="../images/kkhot_tab3.gif" width="154" height="21" border="0" id="new-english" /></a></td>';
                content += '     <td><a href="javascript: getAlbumList(4);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-japan\', \'../images/kkhot_tabover4.gif\');"><img src="../images/kkhot_tab4.gif" width="154" height="21" border="0" id="new-japan" /></a></td>';
                
            }
            
            else if( classify == '3'){

                content += '     <td height="21"><a href="javascript: getAlbumList(1);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-release\', \'../images/kkhot_tabover1.gif\');"><img src="../images/kkhot_tab1.gif" width="154" height="21" border="0" id="new-release" /></a></td>';
                content += '     <td><a href="javascript: getAlbumList(2);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-chinese\', \'../images/kkhot_tabover2.gif\');"><img src="../images/kkhot_tab2.gif" width="154" height="21" border="0" id="new-chinese" /></a></td>';
                content += '     <td><img src="../images/kkhot_tabover3.gif" width="154" height="21" border="0" id="new-english" /></td>';
                content += '     <td><a href="javascript: getAlbumList(4);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-japan\', \'../images/kkhot_tabover4.gif\');"><img src="../images/kkhot_tab4.gif" width="154" height="21" border="0" id="new-japan" /></a></td>';
                
            }
            
            else if( classify == '4'){

                content += '     <td height="21"><a href="javascript: getAlbumList(1);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-release\', \'../images/kkhot_tabover1.gif\');"><img src="../images/kkhot_tab1.gif" width="154" height="21" border="0" id="new-release" /></a></td>';
                content += '     <td><a href="javascript: getAlbumList(2);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-chinese\', \'../images/kkhot_tabover2.gif\');"><img src="../images/kkhot_tab2.gif" width="154" height="21" border="0" id="new-chinese" /></a></td>';
                content += '     <td><a href="javascript: getAlbumList(3);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-english\', \'../images/kkhot_tabover3.gif\');"><img src="../images/kkhot_tab3.gif" width="154" height="21" border="0" id="new-english" /></a></td>';
                content += '     <td><img src="../images/kkhot_tabover4.gif" width="154" height="21" border="0" id="new-japan" /></td>';
                
            }
            
            else{

                content += '     <td height="21"><img src="../images/kkhot_tabover1.gif" width="154" height="21" border="0" id="new-release" /></td>';
                content += '     <td><a href="javascript: getAlbumList(2);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-chinese\', \'../images/kkhot_tabover2.gif\');"><img src="../images/kkhot_tab2.gif" width="154" height="21" border="0" id="new-chinese" /></a></td>';
                content += '     <td><a href="javascript: getAlbumList(3);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-english\', \'../images/kkhot_tabover3.gif\');"><img src="../images/kkhot_tab3.gif" width="154" height="21" border="0" id="new-english" /></a></td>';
                content += '     <td><a href="javascript: getAlbumList(4);" onmouseout="ImageRestore();" onmouseover="ImageOver( \'new-japan\', \'../images/kkhot_tabover4.gif\');"><img src="../images/kkhot_tab4.gif" width="154" height="21" border="0" id="new-japan" /></a></td>';

            }

            content += '    </tr>';
            content += '    <tr>';
            content += '     <td height="171" colspan="4" align="center" valign="top" bgcolor="#BBBBBB">';
            
            if( total > 0){

                content += '      <table width="614"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="text-align:center;">';
                content += '       <tr>';
        
                for( i = 0; i < total; i ++){

                    id = xmlroot.selectNodes('./result/single/id')[i].firstChild.nodeValue;
                    name = xmlroot.selectNodes('./result/single/name')[i].firstChild.nodeValue;
                    code = xmlroot.selectNodes('./result/single/code')[i].firstChild.nodeValue;
                    artist = xmlroot.selectNodes('./result/single/artist')[i].firstChild.nodeValue;
                    thumb = xmlroot.selectNodes('./result/single/thumb')[i].firstChild.nodeValue;
        
                    content += '        <td width="102" height="145" align="center" valign="bottom">';
                    content += '         <table width="82" border="0" cellspacing="0" cellpadding="0" class="gr12" style="text-align:center;">';
                    content += '          <tr><td><a href="album_content.aspx?id=' + id + '"><img src="' + thumb + '" width="80" height="80" border="0" class="picb1" title="' + name + '" /></a></td></tr>';
                    content += '          <tr><td height="50"><a href="album_content.aspx?id=' + id + '" class="u_gr12bm" title="' + name + '">' + name.cutting(5) + '</a><br /><a href="artist_profile.aspx?id=' + code + '" class="u_gr12m" title="' + artist + '">' + artist.cutting(5) + '</a></td></tr>';
                    content += '         </table>';
                    content += '        </td>';

                }

                content += '       </tr>';
                content += '       <tr>';
                content += '        <td height="25">&nbsp;</td>';
                content += '        <td>&nbsp;</td>';
                content += '        <td>&nbsp;</td>';
                content += '        <td>&nbsp;</td>';
                content += '        <td>&nbsp;</td>';
                content += '        <td><img src="../images/bluarr.gif" width="9" height="9"/><a href="album_list.aspx" class="u_blu12">更多發燒新碟</a></td>';
                content += '       </tr>';
                content += '      </table>';

            }

            content += '     </td>';
            content += '    </tr>';
            content += '   </table>';
            content += '  </td>';
            content += ' </tr>';
            content += '</table>';

            document.getElementById('kkbox-album').innerHTML = content;

        }    
    
    }    

