﻿//jQuery.noConflict();

$(document).ready(function () {

    // Zoom Special Offer Images on Hover if an image size is specified
    $(".offer").each(function () {
        var size = $(this).find(".floating-size").val();
        if (size > 0) {
            $(this).find(".offerImage img").tooltip({
                delay: 0,
                showURL: false,
                track: true,
                fixPNG: true,
                bodyHandler: function () {
                    //Get Location of Zoom Image
                    var imageLoc = this.src.replace("max=78", "width=" + size);
                    imageLoc = imageLoc.replace("_large", "");
                    return $("<img/>").attr("src", imageLoc);
                }
            });
        }
    })

    //Make Whole Offer Box Clickable
    $(".offer").click(function () {
        window.location.href = $(this).find("a.moreInfo").attr("href");
    });

    // Zoom Auction Images on Hover if an image size is specified
    $(".auction-item").each(function () {

        var size = $(this).find(".floating-size").val();
        if (size > 0) {
            $(this).find(".auctionImage").tooltip({
                delay: 0,
                showURL: false,
                track: true,
                fixPNG: true,
                bodyHandler: function () {
                    //Get Location of Zoom Image
                    var imageLoc = this.src.replace("height=", "width=");
                    imageLoc = imageLoc.replace("width=88", "width=" + size);
                    imageLoc = imageLoc.replace("_small", "");
                    return $("<img/>").attr("src", imageLoc);
                }
            });
        }
    })

    //Zoom Quick Link Images on Hover
    $(".quickLinkImage").tooltip({
        delay: 0,
        showURL: false,
        track: true,
        fixPNG: true,
        bodyHandler: function () {

            //Get Location of Zoom Image
            var endPoint = this.src.lastIndexOf(".");
            var imageLoc = this.src.substring(0, endPoint);
            imageLoc = imageLoc + "_large.jpg";

            return $("<img/>").attr("src", imageLoc);

        }
    });

    //Zoom Associated Product Images on Hover
    $(".assocImage").tooltip({
        delay: 0,
        showURL: false,
        track: true,
        fixPNG: true,
        bodyHandler: function () {

            //Get Location of Zoom Image
            var endPoint = this.src.lastIndexOf(".");
            var imageLoc = this.src.substring(0, endPoint);
            imageLoc = imageLoc + "_large.jpg";

            return $("<img/>").attr("src", imageLoc);

        }
    });

    //Set Up 'Self Serve' Hover Reveal  

    $("li.self-serve").hoverIntent({
        over: makeTall,
        timeout: 100,
        out: makeShort
    });

    function makeTall() { $(".ssFeatures").slideDown("fast"); }
    function makeShort() { $(".ssFeatures").slideUp("fast"); }


    //    $(".selfServe").hover(
    //      function () {
    //        $(".ssFeatures").slideDown("fast");
    //      },
    //      function () {
    //        $(".ssFeatures").slideUp("fast");
    //      }
    //    );

    //Make Whole Offer Box Clickable
    $(".newWindow").click(function () {
        window.open(this.href);
        return false;
    });

    //Make All Category Columns Equal in Height
    var cat1Height = $(".categoryCol1 ul").height();
    var cat2Height = $(".categoryCol2 ul").height();
    var cat3Height = $(".categoryCol3 ul").height();
    var maxHeight = cat1Height;

    if (cat2Height > maxHeight) {
        maxHeight = cat2Height;
    }

    if (cat3Height > maxHeight) {
        maxHeight = cat3Height;
    }


    $(".categoryCol ul").height(maxHeight);

});
          

