$(function () {
    var hoverColour = "#e1e6e9";
    $("#nav li, .lb-ddbutton, .sbutton, .bbutton, .lm-h li, .lm li").hover(function () {}).hover(function () {
        $(this).addClass("hover")
    }, function () {
        $(this).removeClass("hover")
    });
    $("#nav li.navitm").append("<div><div><div><div></div></div></div></div>");
    $("#nav li.navitm").show("fast", function () {
        $(this).children().hover(function () {
            if ($(this).attr("rel") == "") {
                $(this).attr("rel", $(this).css("color"))
            }
            $(this).parent().children("div").stop().css({
                "display": "none",
                "opacity": "1"
            }).fadeIn(150);
            $(this).stop().css({
                "color": $(this).attr("rel")
            }).animate({
                "color": hoverColour
            }, 350)
        }, function () {
            $(this).parent().children("div").stop().fadeOut(300);
            $(this).stop().animate({
                "color": $(this).attr("rel")
            }, 250)
        })
    })
});
$(document).ready(function () {
    $(".lm-h li, .lm li a, .lm-off li a").append("<div></div><span></span>");
    $(".img-fancybox,.tab_content ul li, .br-tc li").append("<div></div>");
    $(".img-fancybox, .lm-h li, .lm li a, .lm-off li a,  .br-tc li").hover(function () {
        $(this).children("div").stop().css({
            "display": "none",
            "opacity": "1"
        }).fadeIn(400)
    }, function () {
        $(this).children("div").stop().fadeOut(400)
    })
});
$(document).ready(function() {
				$(".lm li").not( $(".lm li").has('ul') ).children('a').click( function(){
					$(".lm li").removeClass('ui-state-active');
					var content = $(this).attr('href');
					$(this).parent().addClass('ui-state-active');
					if(content.indexOf('#') > 0){
						$('.tab_content').hide();
						$(content.substr(content.indexOf('#'))).show().find('#submenu a').eq(0).click();
						return false;
					}
				});

				$('.tab_content').click( function(){
					$(this).show();
				});
				
                $(".lm li").has('ul').children('a').click( function(){
					if($(this).parent().hasClass('ui-active')){
						$(this).next().slideUp('fast');
						$(this).parent().removeClass('ui-active');
					} else {
						$(this).parent().addClass('ui-active');
						$(this).next().slideDown('fast');
					}
					return false;
                });
            });
$(document).ready(function () {
    $('.lb-dropdown').hide();
    $('.lb-ddbutton').click(function () {
        if ($('.lb-dropdown').is(":hidden")) {
            $('.lb-ddbutton').addClass("click");
            $('.lb-dropdown').slideDown(500)
        } else {
            $('.lb-ddbutton').removeClass("click");
            $(".lb-dropdown").slideUp("fast")
        }
    })
});

function setEqualHeight(columns) {
    var tallestcolumn = 0;
    columns.each(function () {
        currentHeight = $(this).height();
        if (currentHeight > tallestcolumn) {
            tallestcolumn = currentHeight
        }
    });
    columns.height(tallestcolumn)
}
$(document).ready(function () {
    setEqualHeight($(".wi-row.first .wi-box"));
    setEqualHeight($(".wi-row.secound .wi-box"))
});
