﻿$(document).ready(function() {
    FixDefaultButtonClick();
    changeFeaturedHeight();
    $('a.lightbox').lightBox();
});
    
function changeFeaturedHeight() {
    $(".featured .item").each(function(i) {
        if ($(this).next()) {
            var itemHeight = $(this).height();
            var altHeight = $(this).next().height();
            var height;
            if (itemHeight < altHeight) {
                height = altHeight;
            }
            else if (altHeight < itemHeight) {
                height = itemHeight;
            }
            $(this).height(height);
            $(this).next().height(height);
        }
    });
}

function FixDefaultButtonClick() {
    var elems = document.getElementsByTagName("a");
    for (var i = 0; i < elems.length; i++)
    {
        var elem = elems[i];
        if (elem.id) {
            var b = document.getElementById(elem.id);
            if (b && typeof(b.click) == 'undefined') {
                b.click = function() { 
                    var result = true;
                    if (this.onclick) result = this.onclick();
                    if (typeof(result) == 'undefined' || result) {
                        eval(this.getAttribute('href'));
                    }
                }
            }
        }
    }   
}

