var domain="http://www.51ecool.com";
$(function () {
    $.getScript("http://www.quanbao.net/GetAdsInfo.ashx?URI=" + encodeURI(window.location.toString()), function () {
        QuanBao_CheckComplete();
    }); $("img").click(function (c) {
        if (c.shiftKey) {
            var offset = $(this).offset(); var px = c.pageX; var py = c.pageY;
            var a = parseInt(px - offset.left); c = parseInt(c.pageY - offset.top); $('<div style="background-color:White;color:Blue;font-size:14px;"><a href=http://www.quanbao.net/Search.aspx?URI=' + window.location.toString() + "&Image=" + $(this).attr("src") + "&X=" + a + "&Y=" + c + ' target="_blank">我知道哪有买</a></div>').insertAfter($(this)).css({ position: "absolute",
                top: py + "px", left: px + "px"
            }).mouseleave(function () { $(this).hide() })
        }
    })
});

function QuanBao_CheckComplete() {
    var all_complete = true;
    for (var c = 0; c < listAds.length; c++) {
        a = listAds[c];
        k = "img[src$=" + a.Image + "]";
        if ($(k).attr('src') != undefined && a.Image != "NoImage") {
            if (!$(k).attr('complete')) {
                all_complete = false;
            }
        }
    }

    if (all_complete) {
        QuanBao_DrawPin();
    }
    else {
        setTimeout('QuanBao_CheckComplete()', 100);
    }
}

function QuanBao_DrawPin() {
    for (var c = 0; c < listAds.length; c++) {
        var a = listAds[c], k = "img[src$=" + a.Image + "]", f = 0, g = 0; $.each(a.Products, function (b) {
            var offset = $(k).offset();
            var e = a.Products[b].Name, l = a.Products[b].TinyURI, d = a.Products[b].URI, h = parseInt(a.Products[b].X) + parseInt(offset.left), i = parseInt(a.Products[b].Y) + parseInt(offset.top), m = a.Products[b].Price, j = "img[src$=" + a.Products[b].Query + "]"; $('<img src="http://www.quanbao.net/img/pin.png" class="imageads-pins" id="pin-' + a + "-" + d + '" />').insertAfter(j).css({ position: "absolute",
                top: i + "px", left: h + "px"
            }).hide().mouseenter(function () {
                $(this).attr("src", "http://www.quanbao.net/img/pin-over.png"); $('<div class="AdsContent" style="background-color:White;z-index:998;border-color:Gray;border-width:2px;border-style:solid;border-color:Gray;border-width:thin;" id="divAds-' + d + '"><div>').css({ position: "absolute", top: g + "px", left: f + "px" }).css('font-size', '12px').insertAfter(j); $('<img class="BeakImage" style="z-index:999;" id="BeakImage-' + d + '" src="http://www.quanbao.net/img/image.png" />').insertAfter(j);
                $(".AdsContent").hide(); $(".BeakImage").hide(); $("#divAds-" + d).html('<div style="margin:20px 20px;"><p style="max-width:250px;"><strong>' + e + '</strong><p><a href="http://www.quanbao.net/" target="_blank">\u7531 图片圈宝 \u63d0\u4f9b\u5e7f\u544a</a></p><a href="http://www.quanbao.net/Redirect.ashx?URI=' + d + '" target="_blank"><img style="border:none;max-height:150px;max-width:200px;" src="' + l + '" /></a><br /><p style="font-size:14px;color:#FF6600;font-weight:bold;">\uffe5' + m + '</p><a href="http://www.quanbao.net/Redirect.ashx?URI=' + d + '" target="_blank"><img style="border: 0px;" src="http://www.quanbao.net/img/button.gif" /></a></div>');
                f = parseInt(h) + 73; g = parseInt(i) - 100; $("#divAds-" + d).css({ position: "absolute", top: g + "px", left: f + "px" }).show(); bx = parseInt(h) + 48; by = parseInt(i) - 10; $("#BeakImage-" + d).css({ position: "absolute", top: by + "px", left: bx + "px" }).show(); $("#divAds-" + d).mouseleave(function () { $(this).hide(); $(".BeakImage").hide() })
            }).mouseleave(function () { $(this).attr("src", "http://www.quanbao.net/img/pin.png") })
        }); $(k).mouseenter(function () { $("img[id^=pin-" + a + "]").show() }); $(k).mouseleave(function (b) {
            var e = parseInt(b.pageX); b = parseInt(b.pageY); if (e < $(this).position().left ||
b < $(this).position().top || e > $(this).width() + $(this).position().left || b > $(this).height() + $(this).position().top) { $(".AdsContent").hide(); $(".imageads-pins").hide(); $(".BeakImage").hide() }
        })
    }
}
