$(document).ready(function() {
    /* Mega Dropdown */
    $(".one li").hover(function() {
        $(".one li a").removeClass("emg_select");
        $(this).children().addClass("emg_select");
        $(this).children().next().show();
    }, function() {
        $(this).children().removeClass("emg_select");
        $(this).children().next().hide();
    });
    /* End  Mega DropDown */

    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //$("#tab6").show();

    //On Click Event
    $(".tabpane ul li").click(function() {


        $(".tabpane ul li a").removeClass("tab_select");
        $(".tabpane ul li a span").removeClass("tab_selected");
        $(this).children().addClass("tab_select");
        $(this).children().children().addClass("tab_selected");

        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content

        $(activeTab).show(); //Fade in the active ID content

        //        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        //        $(this).addClass("active"); //Add "active" class to selected tab
        //        $(".tab_content").hide(); //Hide all tab content

        //        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        //        $(activeTab).fadeIn(); //Fade in the active ID content

        if (('#tab4' == $(this).find("a").attr("href") || '#tab2' == $(this).find("a").attr("href")) && mapLoad)
            mapLoad();

        return false;
    });

    $('#ctl00_txtSearch').focus(function() { $(this).val(""); });
    //$('#Quickfinder').focus(function() { $(this).val(""); });

    /* Begin fix page title width */
    $.fn.textWidth = function() {
        var html_org = $(this).html();
        var html_calc = '<span>' + html_org + '</span>'
        $(this).html(html_calc);
        var width = $(this).find('span:first').width();
        $(this).html(html_org);
        return width;
    };
    var H1txtWidth = ($("h1").textWidth() + 20);
    if (H1txtWidth < 400) {
        $("h1").width(380);
    } else {

        if ($("#rightnav").length > 0) {
            // we have a right side element so can't expand:
            $("h1").width(380);
        } else {
            // there is not right side so free to expand:
            if (H1txtWidth > 710) {
                $("h1").width(710);
            } else {
                $("h1").width(H1txtWidth);
            }
        }
    }
    /* End fix page title width */

    //    /* JTabpne */
    //    $(".tabpane ul li").each(function(i) {
    //        i = i + 1;
    //        $(this).click(function() {
    //            $(".tabpane ul li a").removeClass("tab_select");
    //            $(".tabpane ul li a span").removeClass("tab_selected");
    //            $(".tap_display").hide();
    //           
    //            $("#tab_" + i).show();
    //            return false;
    //        });
    //    });
    //    /* End JTabpane */

    /* Light Box index */
    $(".resident_containt").each(function(j) {
        j = j + 1;

        var maskHeight = $(".link_containt").height();
        var maskWidth = $(".link_containt").width();
        var winH = $(".link_containt").height();
        var winW = $(".link_containt").width();

        $(this).click(function() {

            $(".light_box").css({ 'width': maskWidth - 20, 'height': maskHeight + 250 });
            $(".light_box").fadeIn(1000);
            $(".light_box").fadeTo("slow", 0.8);
            $(".light_container").fadeIn(1000);
            $(".light_container").css('top', '-165px');
            $(".light_container").css('left', '30px');
            $(".light_box").show();
            $(".light_container").show();

            $(".close_bt a").click(function() {
                $(".light_box").hide();
                $(".light_container").hide();
            });

        });
    });
    /* End Light Box  index*/

    /* Light Box inner4 */

    var propsLength = $(".prop_view").length;

    $(".prop_view").each(function(k) {


        k = k + 1;
        var winH = $(".prop_view").height();
        var winW = $(".prop_view").width();
        if (k < propsLength) {
            $(this).hover(function() {
                $(".popup_arrow").css("top", "42px");
                $("#popup_" + k).css({ "top": "0px" });
                $("#popup_" + k).show();
            }, function() {
                $("#popup_" + k).hide();
            });
        }
        else if (k === propsLength)
            $(this).hover(function() {
                $(".popup_arrow").css("top", "300px");
                $("#popup_" + k).css({ "top": "-235px" });
                $("#popup_" + k).show();
            }, function() {
                $("#popup_" + k).hide();
            });
    });
    /* End Light Box  inner4 */


    $("#slider").easySlider({
        auto: true,
        continuous: true
    });
    /* End Slider */

    /* Slider */
    //    $("#propdetails_slider").easySlider({
    //        prevId: 'det_slide_previous',
    //        prevText: '',
    //        nextId: 'det_slide_next',
    //        nextText: '',
    //        auto: false,
    //        continuous: true,
    //        controlsShow: true,
    //        indicator: true,
    //        indicatorId: 'indicatorId'
    //    });

    /*Begin Quickfinder slide down menu*/
    $("#QuickLinksContainer").click(function() {
        //When trigger is clicked...
        $("ul.quick_dropdown").css("border-bottom", "1px solid #000");
        $(this).parent().find("ul.quick_dropdown").slideDown('fast').show(); //Drop down the subnav on click
        $("#Quickfinder").attr("readonly", true);
        /*slide up off focus*/
        $(this).parent().hover(function() {
        }, function() {
            $("ul.quick_dropdown").css("border-bottom", "0px");
            $(this).parent().find("ul.quick_dropdown").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
            $("#Quickfinder").attr("readonly", false);
        });
    });
    $("#contactusContainer").click(function() {
        //When trigger is clicked...
        $("ul.ResidentContactUS_dropdown").css("border-bottom", "1px solid #000");
        $(this).parent().find("ul.ResidentContactUS_dropdown").slideDown('fast').show(); //Drop down the subnav on click
        $("#txtcontactus").attr("readonly", true);
        /*slide up off focus*/
        $(this).parent().hover(function() {
        }, function() {
            $("ul.ResidentContactUS_dropdown").css("border-bottom", "0px");
            $(this).parent().find("ul.ResidentContactUS_dropdown").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
            $("#readonly").attr("readonly", false);
        });
    });

    $('#ticker').innerfade({
        animationtype: 'fade',
        speed: 'slow',
        timeout: 2000,
        type: 'sequence',
        containerheight: 'auto'
    });

})

