﻿$(document).ready(function () {
    $('ul.mainlist').each(function () {
        var $ul = $(this);
        var $liArr = $ul.children('li.a');
        $liArr.sort(function (a, b) {
            var temp = parseInt(Math.random() * 10);
            var isOddOrEven = temp % 2;
            var isPosOrNeg = temp > 5 ? 1 : -1;
            return (isOddOrEven * isPosOrNeg);
        })
    .appendTo($ul);
    });

    $('.home .mainlist li:nth-child(4n)').addClass("nom");
    $('.artist-content .mainlist li:nth-child(3n)').addClass("nom");
    $('.shop-content .product-item:nth-child(3n)').addClass("nom");   
    $('.product-images li:nth-child(4n)').addClass("last");
    
    $('ul.mainlist li.a').hoverIntent(
        function () {
            $(this).children(".ai").css('z-index', '1').fadeIn('fast');
        },
        function () {
            $(this).children(".ai").css('z-index', '-1').fadeOut('slow');
        });

    //var loadedImage = $('ul.gallery_list li:first img').attr("height");
    //if (loadedImage > 1) {
    //    $('ul.gallery_list').masonry({ columnWidth: 210, itemSelector: 'li' });
    //}
    //else { doMasonry(); }

    $("img").error(function () {
        $(this).unbind("error").attr("src", "../content/images/foo.gif");
    });


    var pathname = window.location.pathname;
    $('#side-nav li a').each(function () {
        if ($(this).attr('href') == pathname) {
            $(this).addClass('selected');
        }
    });
});
