﻿(function ($) {
    $.fn.equalHeights = function(px) {
        var currentTallest = 0;
	    $(this).each(function(){
		    $(this).each(function(i){
			    if ($(this).innerHeight() > currentTallest) { currentTallest = $(this).innerHeight(); }
		    });
	    });
        $(this).each(function(){ $(this).css({'height': currentTallest}); });
        
	    return this;
    };
})(jQuery);

$(function () {

    // history
    var origContent = "";
    function loadItems(hash) {
        if (hash != "") {
            if (hash.substring(0, 1) == "!") {
                var split = hash.split('/');
                if (split[1] == 'kategori') {
                    $.fancybox({
                        'titleShow': false,
                        //'orig'			: $(this),
                        'padding': 0,
                        'href': '#kategori-picker-' + split[2],
                        'height': 'auto',
                        'transitionIn': 'elastic',
                        'transitionOut': 'elastic',
                        'onComplete': function () {
                            $.fancybox.center();
                        },
                        'onClosed': function () {
                            $('.item-small-hover').hide();
                            document.location.href = '#';
                        }
                    });
                } else if (split[1] == 'med') {
                    loadItemId('#item2', split[2]);
                }
            }
            return;
        } else {
            $.fancybox.close();
            resetItemView();
        }
    }
    $(document).ready(function () {
        $.history.init(loadItems);

        //$('#slider').nivoSlider({ controlNavThumbs: false, controlNav: false });
    });

    


    initAddButtons();

    Minneslista.lank();

    // fix for ie
    $('#navigation ul li:last-child a').css('border', 'none');

    $('input[type=submit],input[type=button],.button').button();




});


