﻿/// <reference path="../library/jquery-1.3.1.js" />
/// <reference path="../jQueryFunctions.js" />
/// <reference path="../common.js" />

$(document).ready(function() {

    var trackingCategory = "Produkter";

    $(".ProductInformation p.h4x .Popup").mouseenter(function() {
        var DlTitle = $(this).text();
        var DlDesc = $(this).next().html();

        if ($(this).parent().hasClass('h4xwiz')) {
            //
        } else {
            $(".ProductInformation p.h4x div:visible").hide();
            $(".ProductInformation p.h4x").removeClass("h4xwiz");
            $(".ProductInformation #DlPopup").remove();
            $(this).parent().append("<div id='DlPopup'><div class='Content'><strong>" + DlTitle + "</strong><br />" + DlDesc + "</div><div class='Shadow'>&#160;</div></div>").addClass('h4xwiz');
        }
    });

    $(".ProductInformation p.h4x .Popup").mouseleave(function() {
        $(".ProductInformation #DlPopup").remove();
        $(".ProductInformation p.h4x").removeClass("h4xwiz");
    });

    RegisterChooseArticleChangeEvent("div.ProductInformation div.CompareAndBuy div.ChooseArticelCont select");

    $("div.ProductInformation div.CompareAndBuy div.ChooseArticelCont select").change(function() {
        $(".LaggIKundvagnknapp[ArtikelNr]").attr("ArtikelNr", $(this).val());
        $(".PrisSaldoFraga[ArtikelNr]").attr("ArtikelNr", $(this).val());
    });

    $("div.MultimediaContainer .ShowYouTube").click(function(e) {
        e.preventDefault();
        showCustomDialog("YouTubeCont", "En film från Cylinda", 425, 358, true);
        TrackEvent(trackingCategory, 'Visa film', $(this).attr("productname"));
    });

    ShowPopupOnMouseEnter(".FurtherProductInformation", "Dela med dig av cylinda.se");

    TrackSharingEvents(trackingCategory);

    $("a.jqbookmark").click(function(event) {
        event.preventDefault();
        var url = this.href;
        var title = this.title;

        if (window.sidebar) { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(title, url, "");
        } else if (window.external) { // IE Favorite
            window.external.AddFavorite(url, title);
        } else {
            alert('Tyvärr stöder inte webbläsaren denna funktion. Vänligen lägg till bokmärke manuellt.');
        }
    });
});

$(window).load(function() {
    alignRelatedProducts();
});

function alignRelatedProducts() {
    $("div.ProductPage div.PrimaryColLarge div.ItemSmall > a").wrap("<div>");
    equalHeight($("div.ProductPage div.PrimaryColLarge div.ItemSmall div"));
    $("div.ProductPage div.PrimaryColLarge div.ItemSmall img").css("position", "absolute");
}


