function showBooks(iRows, iCols) {
    var oData = new JSATOM.Connection({
        method : 'get',
        url : 'books.txt',
        events : {
            onsuccess : function(oXmlHttp) {
                var aImages = eval('(' + oXmlHttp.responseText + ')');
                var iBooks = iRows * iCols;
                var iRandomBooks = aImages.length>iBooks?iBooks:aImages.length;
                iRandomBooks = (iRandomBooks%2==0)?iRandomBooks:iRandomBooks-1;
                iRandomBooks = (iRandomBooks>0)?iRandomBooks:0;
                // shuffle books
                for (var i=0;i<aImages.length*5;i++) {
                    var i1 = parseInt(aImages.length*Math.random(), 10);
                    var i2 = parseInt(aImages.length*Math.random(), 10);
                    var oTmp = aImages[i1];
                    aImages[i1] = aImages[i2];
                    aImages[i2] = oTmp;
                }
                for (var i=0;i<iRandomBooks;i++) {
                    var iRow = parseInt(i/iCols);
                    var oTd = N$('row' + iRow, 'td', {'class' : 'boxheaderbook'});
                    oTd.style.backgroundImage = 'url(books/' + aImages[i]['thumbnail'] + ')';
                    var oLink = N$(oTd, 'a', {'id' : 'link' + i, 'href' : '#'});
                    E$(oLink, 'mouseover', function(e) {
                        var oSrc = P$(S$(e), 'a');
                        var iId = parseInt(oSrc.id.replace('link', ''), 10);
                        //stm_(aImages[iId]['text'], '<img src="books/' + aImages[iId]['image'] + '" />', Style[1]);
			show_popup(aImages[iId]['text'], '<img src="books/' + aImages[iId]['image'] + '" />');
                    });
                    E$(oLink, 'mouseout', function() {
                        //htm();
			hide_popup();
                    });
                    var oImg = N$(oLink, 'img', {'src' : 'images/book_frame' + (aImages[i]['bestseller']==1?'_bs':'') + '.gif', 'style' : 'width:103px;height:154px;border-width:0px;'});
                }
            }
        }
    });
    oData.send();
}

function showQuotes() {
    function paintQuote(oQuote, sId) {
        var oP = N$(sId, 'p');
        oP.innerHTML = '&ldquo;' + oQuote['quote'] + '&rdquo;'
        var oBq = N$(sId, 'blockquote');
        var oP2 = N$(oBq, 'p');
        var oStrong = N$(oP2, 'strong');
        var oSpan = N$(oP2, 'span');
        oStrong.innerHTML = oQuote['author'];
        oSpan.innerHTML = ', ' + oQuote['title'];
    }
    var oData = new JSATOM.Connection({
        method : 'get',
        url : 'quotes.txt',
        events : {
            onsuccess : function(oXmlHttp) {
                var aQuotes = eval('(' + oXmlHttp.responseText + ')');
                var iRandomQuotes = aQuotes.length>2?2:aQuotes.length;
                iRandomQuotes = (iRandomQuotes%2==0)?iRandomQuotes:iRandomQuotes-1;
                iRandomQuotes = (iRandomQuotes>0)?iRandomQuotes:0;
                // shuffle quotes
                for (var i=0;i<aQuotes.length*5;i++) {
                    var i1 = parseInt(aQuotes.length*Math.random(), 10);
                    var i2 = parseInt(aQuotes.length*Math.random(), 10);
                    var oTmp = aQuotes[i1];
                    aQuotes[i1] = aQuotes[i2];
                    aQuotes[i2] = oTmp;
                }
                if (iRandomQuotes > 0 && $$('quote0')) {
                    paintQuote(aQuotes[0], 'quote0');
                }
                if (iRandomQuotes > 1 && $$('quote1')) {
                    paintQuote(aQuotes[1], 'quote1');
                }
            }
        }
    });
    oData.send();
}

// popup simplu

var aMouseInfo = [];
E$(document, 'mousemove', function(e) {
    aMouseInfo = M$(e);
    update_popup();
});

function show_popup(sTitle, sContent) {
    var oBody = Q$('body(0)');
    var oDivPopup = N$(oBody, 'div', {'class' : 'popup_box', 'id' : 'popup_box'});
    var oDivTitle = N$(oDivPopup, 'div', {'class' : 'popup_title'});
    var oDivContent = N$(oDivPopup, 'div', {'class' : 'popup_content'});
    oDivTitle.innerHTML = sTitle;
    oDivContent.innerHTML = sContent;
    update_popup();
}

function update_popup() {
    if (oDivPopup=$$('popup_box')) {
        var aSizeInfo = JSATOM.Window.getSize();
        var aScrollInfo = JSATOM.Window.getScroll();
        var iLeft = aMouseInfo[0] + 20;
        var iTop = aMouseInfo[1] + aScrollInfo[1] + 20;

        if (iLeft < 0) { iLeft = 0; }
        if (iTop < 0) { iTop = 0; }
        if (iLeft + W$(oDivPopup) - aScrollInfo[0] > aSizeInfo[0]) { iLeft = aMouseInfo[0] + aScrollInfo[0] - W$(oDivPopup) - 20; }
        if (iLeft < 0) { iLeft = aSizeInfo[0] - W$(oDivPopup) - 20; }
        if (iTop + H$(oDivPopup) - aScrollInfo[1] > aSizeInfo[1]) { iTop = aMouseInfo[1] + aScrollInfo[1] - H$(oDivPopup) - 20; }
        if (iTop < 0) { iTop = aSizeInfo[1] - H$(oDivPopup) - 20; }

        oDivPopup.style.left = iLeft + 'px';
        oDivPopup.style.top = iTop + 'px';
    }
}

function hide_popup() {
    n$('popup_box');
}
