$(document).ready(function() 
{
    var base_url = 'http://www.perfect-wool.com/shop/';

    $('.product-price span').each(function(index) {
        var productPrice = $(this).html();
        var unitPrice = productPrice.substr(0, productPrice.indexOf('.'));
        var decimalPrice = productPrice.substr(productPrice.indexOf('.'));
        $(this).html('<span style="font-size:20px;">' + unitPrice + '</span>' + decimalPrice);
    });

    $("#imageWrap a").fancybox();

    $(".productThumbs img").click(function() {

            if ($(this).hasClass("thumbActive")) {return;}

            var url = $(this).attr("src").replace("thumb", "info");
            $("#imageWrap a").attr("href", $(this).attr("src").replace("thumb", "large"));

            var wrap = $("#imageWrap").fadeTo("medium", 0.5);
            var img = new Image();

            img.onload = function() {

                    wrap.fadeTo("fast", 1);

                    wrap.find("img").attr("src", url);

            };

            img.src = url;

            $(".productThumbs img").removeClass("thumbActive");
            $(this).addClass("thumbActive");

    }).filter(":first").click();

    $("#add-review[rel]").overlay({effect: 'apple'});
    $("#send-question[rel]").overlay({effect: 'apple'});

    $("#like-box").mouseenter(function () {
        $(this).stop(true).animate({right: 0});
    }).mouseleave(function() {
        $(this).stop(true).animate({right: '-294px'});
    });

});
