jQuery(function($) {
    $('#menu_locations tr:last td,#menu_company li:last-child,#menu_services li:last-child').css('border-bottom', '0 none');
    $('#global ul li').hover(
      function() { $(this).find(".super_menu").stop().show(); },
      function() { $(this).find(".super_menu").stop().hide(); }
    );
    if ($('.photos').length) {
		Shadowbox.init({
			overlayOpacity: 0.8
		});
        $('ul#photo_container img').each(function() {
            if ($(this).height() != 126) {
                $(this).css('margin-top', (126 - $(this).height()) / 2);
            }
        });
    }
    if ($('#slide_show').length) // home
    {
        var total = $('#slide_show img').length;
        var rand = Math.floor(Math.random() * total);
        $('#slide_show').cycle({
            startingSlide: rand,
            fx: 'fade'
        });
        $('#feature_3 ul').cycle({
            fx: 'fade',
            speed: 'fast',
            timeout: 0,
            prev: '#nc_prev',
            next: '#nc_next'
        });
    }
    if ($('.plans').length) {
        $('#floor_plan_filter li:first').addClass('current');
        $('#floor_plan_filter a').click(function() {
            $('#floor_plan_filter li').removeClass('current');
            $(this).parent().addClass('current');
            $('.floor_plan_container').css('display', 'none');
            return false;
        });
        $('.first a').click(function() { $('#plans_lofts').slideDown('slow'); });
        $('.second a').click(function() { $('#plans_bedroom_1').slideDown('slow'); });
        $('.third a').click(function() { $('#plans_bedroom_2').slideDown('slow'); });
        $('.fourth a').click(function() { $('#plans_bedroom_3').slideDown('slow'); });
    }
    if ($('.category ul').length) { $('.category ul').easyListSplitter({ colNumber: 2 }); }
    if ($('.contact').length) {
        $(".maintenance").hide();
        $(".leasingInfo").hide();
        $(".questionCommentMgr").hide();
        $(".questionCommentGeneral").hide();
        var reqType = getQuerystringVal('type','');
        if (reqType != '') {
            $(".reason").val(reqType);
        }
        //$(".reason").change();
        $(".reason").change(function() {
            $("." + this.value).show().siblings().hide();
        });
    }
});

function getQuerystringVal(key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}
