/*
Style[...]=[TitleColor,TextColor,TitleBgColor,TextBgColor,TitleBgImag,TextBgImag,TitleTextAlign,TextTextAlign, TitleFontFace, TextFontFace, TipPosition, StickyStyle, TitleFontSize, TextFontSize, Width, Height, BorderSize, PadTextArea, CoordinateX , CoordinateY, TransitionNumber, TransitionDuration, TransparencyLevel ,ShadowType, ShadowColor]
*/

var FiltersEnabled = 0 
Style[1]=["#7c201f","","#e7e5be","#ffffff","","","","","","Arial","right","","2","2",,"",5,0,20,5,"","","","",""]
applyCssFilter();


/*
script de la adi
*/

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]);
                    });
                    E$(oLink, 'mouseout', function() {
                        htm();
                    });
                    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();
}