
$(function() {

    $('#pslider').html('<ul><li id="dotw_list_1"></li><li id="dotw_list_2"></li><li id="dotw_list_3"></li><li id="dotw_list_4"></li></ul>');

    $('.prr_slide_main_box').show('fast');
    $("#pslider").easySlider();



    $.ajax(
        {
            type: "GET",
            url: "/xmlservice/books/XmlGroupOfBooks.aspx?sid=best&page=1&pagesize=48",
            dataType: "xml",
            success: function(xml) {
                $(xml).find('book').each(function() {
                    var id_text = $(this).attr('id');
                    var author_name = $(this).find('author').text();
                    var title = $(this).find('title').text();
                    var isbn = $(this).find('isbn').text();
                    var cover = $(this).find('cover').text();
                    var link = $(this).find('link').text();
                    var price = $(this).find('price').text();
                    var save = $(this).find('save').text();
                    var rank = $(this).find('rank').text();
                    var save_percent = parseInt($(this).find('save-percent').text());

                    var slideNo = 1;
                    if ((rank > 12) && (rank <= 24)) {
                        slideNo = 2;
                    }
                    else if ((rank > 24) && (rank <= 36)) {
                        slideNo = 3;
                    }
                    else if ((rank > 36) && (rank <= 48)) {
                        slideNo = 4;
                    }

                    var tip = '<div class="prr_cover_box"><div class="tooltip"><div class="toolspan">' + title + '</div><div class="toolspace"></div><div class="toolspan_auth">' + author_name + '</div><div class="tooltip_price">&pound;' + price + '</div><div class="tooltip_delivery">FREE DELIVERY WORLDWIDE</div></div>';

                    if (save_percent > 0) {
                        tip = tip + '<div class="prr_save_label">' + save_percent + '&#37;</div>';
                    }

                    tip = tip + '<a href="' + link + '" class="prr_cover" ><img src="' + cover + '" alt="Book cover" /></a></div>';

                    $('<div></div>')
                    .html(tip)
                    .appendTo('#pslider ul li#dotw_list_' + slideNo);
                }); //close each


                $(".prr_cover_box").each(function() {
                    $(this).hover(function(e) {
                        $().mousemove(function(e) {
                            var tipY = e.pageY + 16;
                            var tipX = e.pageX + 16;
                            $("#ToolTipDiv").css({ 'top': tipY, 'left': tipX });

                        });
                        $("#ToolTipDiv").stop(true, true);
                        $("#ToolTipDiv")
                        .html($(this).find('.tooltip').html())
                        .fadeIn("fast");
                        
                        $(this).removeAttr('title');
                    }, function() {
                        $("#ToolTipDiv").stop(true, true);
                        $("#ToolTipDiv").fadeOut("fast");
                        //$(this).attr('title', $("#ToolTipDiv").html());
                    });
                });

            }

        }); //close ajax_01		

});               //close all
