// x1.js

// book/book2.html

function write_menu3_page (_rows, col) {	
    var n = _rows.length;
    var row = Math.floor ((n + col - 1) / col);
    var _width = Math.floor (800 / col);
    with (document) {
    	writeln ('<table id=xtable class=table3><tr id=xrow valign=center align=center><td>');
    	writeln ('<p class=title1 id=xtitle>' + _title + '</p>');
    	if (typeof(sub) != "undefined" && sub != "") writeln ('<p class=sub id=xsub>' + sub + '</p>');        
        writeln ('<table class=table4 cellpadding=3 border=1 cellspacing=1>');
        writeln (' <tr valign=center align=center> ');
        for (var j = 0; j < col; j++) {
            writeln (' <td class=cell4 width=' + _width + 'px align=left valign=top>' );
            for (var k = 0; k < row; k++) {
            	var i = j*row + k;
            	if (i < n)
            	    writeln ('<a class=a6 href="' + _rows[i][0] + '">' + (i+0) + '. ' + _rows[i][1] + '</a><br>');
            }
            writeln (' </td> ' );
        }
        writeln (' </tr> ');
        writeln ('</table> ');
        writeln ('</td></tr></table> ');
    }
    document.title=_title;  
    document.body.style.overflow='auto'; 
    xtitle.style.fontSize='30px';
    xtitle.style.color='ivory';
    if (typeof(sub) != "undefined" && sub != "") {
        xsub.style.color='ivory';
    	xsub.style.fontSize='15px';
    }
    document.body.style.margin='0px';
    document.body.style.overflow='auto';    
}

// service/Items.html

function write_menu_page (_rows) {	
    var n = _rows.length;
    with (document) {
    	writeln ('<table id=xtable class=table3><tr id=xrow valign=center align=center><td>');
    	writeln ('<p class=title1 id=xtitle>' + _title + '</p>');
    	if (typeof(sub) != "undefined" && sub != "") writeln ('<p class=sub id=xsub>' + sub + '</p>');        
        writeln ('<table class=table4 cellpadding=3 border=1 cellspacing=1">');
        writeln ('<tr valign=center align=center> ');
        writeln ('  <td class=cell4 width=100px align=center>' + menu_title   + '</td> ');
        writeln ('  <td class=cell4 width=700px align=center>' + menu_content + '</td> ');
        writeln ('</tr>');           
        for (var i = 0; i < n; i++) {
            writeln (' <tr valign=center align=center> ');
            writeln ('   <td class=cell4 width=100px align=center>' + _rows[i][0] + '</td> ');
            writeln ('   <td class=cell4 width=700px align=left>');
            if (_rows[i][1] != "") writeln (_rows[i][1] + '<br>');
            for (var j = 0; j < example[i].length; j++) {
            	writeln ('<a class=a5 href="' + example[i][j][0] + '">' + example[i][j][1] + '</a>');
            }	
            writeln ('   </td>');
            writeln (' </tr>');
        }
        writeln ('  </table>');
        writeln ('</td></tr></table>');
    }
    xtitle.style.fontSize = '30px';
    xtitle.style.color = 'ivory';
    if (typeof(sub) != "undefined" && sub != "") {
        xsub.style.color='ivory';
    	xsub.style.fontSize='13px';
    }
    document.body.style.margin = '0px';
    document.body.style.overflow = 'auto'; 
}

// memo/memo.html

function write_menu2_page (_rows) {	
    var n = _rows.length;
    with (document) {
    	writeln ('<table id=xtable class=table3><tr id=xrow valign=center align=center><td>');
    	writeln ('<p class=title1 id=xtitle>' + _title + '</p>');
    	if (typeof(sub) != "undefined" && sub != "") writeln ('<p class=sub id=xsub>' + sub + '</p>');
        writeln ('<table class=table4 cellpadding=3 border=1 cellspacing=1">');
        writeln ('<tr valign=center align=center> ');
        writeln ('  <td class=cell4 width=100px align=center>' + menu_title   + '</td> ');
        writeln ('  <td class=cell4 width=800px align=center>' + menu_content + '</td> ');
        writeln ('</tr>');           
        for (var i = 0; i < n; i++) {
            writeln (' <tr valign=center align=center> ');
            writeln ('   <td class=cell4 width=100px align=center>' + _rows[i][0] + '</td> ');
            writeln ('   <td class=cell4 width=800px align=left>' + _rows[i][1] + '<br>');
            write_all_element (example[i], _rows[i][2]);
            writeln ('   </td>');
            writeln (' </tr>');
        }
        writeln ('  </table>');
        writeln ('</td></tr></table>');
    }
    xtitle.style.fontSize = '30px';
    xtitle.style.color = 'ivory';
    if (typeof(sub) != "undefined" && sub != "") {
        xsub.style.color='ivory';
    	xsub.style.fontSize='13px';
    }
    document.body.style.margin = '0px';
    document.body.style.overflow = 'auto'; 
}

function write_all_element (_list, col) {
    var _num = _list.length;
    var row = Math.floor ((_num + col - 1) / col);
    with (document) {   	
    	writeln ('<table class=table1 cellpadding=2 border=0 cellspacing=0>');
    	for (var j = 0; j < row; j++) {
    	    writeln('<tr>' );
    	    for (var i = j*col; (i < j*col+col) && i < _num; i++) {
            	writeln ('<td><a class=a5 href="' + _list[i][0] + '">' + _list[i][1] + '</a></td>');
    	    }	
    	    writeln('</tr> '); 	
    	}
    	writeln('   </table>');
    }
}
