﻿var productPopupComplete = function(args, i) {
    var containerId = $(args[i]).attr("href");
    var newHeight = $(containerId + " div.product-image-container").css("height");
    $("#fancybox-left").height(newHeight);
    $("#fancybox-left").css("top", 20).css("bottom", null);
    $("#fancybox-right").height(newHeight);
    $("#fancybox-right").css("top", 20).css("bottom", null);
};

$(function () {
    $("#q").addPlaceholder();
    $("#slideshow").nivoSlider({ pauseTime: 3200 });

    $("a[rel=popup_product]").fancybox({
        onComplete: productPopupComplete
    });

    $(".navigation-left-top-categories a.more").fancybox();
    $(".popup-product a.more").fancybox();
    $("#categories").html($("#bottomCategoriesMenu").html());

    $("#gallery").click(function () {
        var items = [];
        $('.galery-product').each(function (item) {
            var href = this.id.toString();
            items.push({ 'href': '#' + href });
        });
        $.fancybox(items, { onComplete: productPopupComplete });
    });

    $("a.popupLink").fancybox();
});


function createCookie(name, value) {
    var date = new Date();
    date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
    var expires = "; expires=" + date.toGMTString();
    document.cookie = name + "=" + value + expires + "; path=/";
}
