﻿$(document).ready(function () {
    $(".submenu").slideToggle(0);
    $(".left.menu a").click(function () {
        $(this).toggleClass('active');
    });
    $("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 600,
        'speedOut': 200,
        'titlePosition': 'over',
        'overlayShow': true
    });
    $("a.tygbibliotek").fancybox({
        'width': 550,
        'height': 500,
        'type': 'iframe',
        'autoScale': 'false'
    });
    $("a.byggDinEgenSoffa").fancybox({
        'width': '95%',
        'height': '95%',
        'type': 'iframe',
        'autoScale': 'false',
        'scrolling': 'false'
    });
    $("a.komfort").fancybox({
        'width': 550,
        'height': 500,
        'type': 'iframe',
        'autoScale': 'false'
    });
    $("a.fullscreen").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 600,
        'speedOut': 200,
        'titlePosition': 'over',
        'overlayShow': true,
        'cyclic': true,
        'showNavArrows': true

    });
    $("a.productPopup").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 600,
        'speedOut': 200,
        'titlePosition': 'over',
        'overlayShow': true,
        'width': 500,
        'height': 400,
        'cyclic': true,
        'showNavArrows': true,
        'autoDimensions': false
    });

    equalCols('.productInfo', '.productIcons', -49);
});

function showMenu(divId, countSubItems) {
    thisPane = "#" + divId;
    $(thisPane).slideToggle("fast", function () {
        if (countSubItems)
            openPage(thisPane);
    });
}

function openPage(menu) {
    var numberOfSubMenuItems = $(menu).find('ul li').size();
    if (numberOfSubMenuItems == 1) {
        var url = $(menu).find('ul li').find('a').attr('href');
        self.location = url;
    }
}


function clearField(theInput) {
    if (document.getElementById(theInput).defaultValue == document.getElementById(theInput).value) {
        document.getElementById(theInput).value = "";
    }
}
function equalCols(elem, offsetElem, offset) {
    var biggestHeight = 0;
    $(elem).each(function () {
        if ($(this).height() > biggestHeight) {
            biggestHeight = $(this).height();
        }
    });
    if ($.browser.msie) {
        offset += -11;
    }
    $(offsetElem).css("padding-top", biggestHeight + offset);
    $(offsetElem).css("padding-top", biggestHeight + offset);
}

