﻿var logged_in = false;
var activated = false;

$(document).ready(function() {
    initialEvents(); //Display appropriate popups, add click events, etc
});

function initialEvents()
{
    
    
    $("a.lnkMyMihomes").click(function(event) {
        var menu = $("#MyPortalControl");
        if (menu.is(":visible") == false)
            event.preventDefault();
        if (activated == true)
        {
            showPopupIFrame("PopupIFrameLoggedIn", 380, 474, null, null, null);
            menu.slideDown("fast");
        }
    });
    
    $("img#OpenMenuArrow").click(function(event) {
        if (activated == true)
        {
            showPopupIFrame("PopupIFrameLoggedIn", 380, 474, null, null, null);
            $("#MyPortalControl").slideToggle("fast");
        }
    });
    
    //Setup the close buttons on Flash messages
    $(".FlashNotice, .FlashError").click(function() {
        $(this).fadeOut("slow");
    });
    
    
    //Setup all of the CLOSE buttons
    $(".popup-but-close").click(function(event) {
        event.preventDefault();
        $(this).parents(".popup").fadeOut("fast");
        $(".PopupIFrame").hide();
    });
    

}

function showPopupIFrame(frameId, height, width, top, right, left)
{
    var isIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
    if (isIE6)
    {
        var iframe = $("#" + frameId);
        if (iframe.is(":visible"))
            iframe.hide();
        else
        {
            iframe.css({height:"", width:"", top:"", right:"", left:""});
            if (height != null)
                iframe.css("height", height);
            if (width != null)
                iframe.css("width", width);
            if (top != null)
                iframe.css("top", top);
            if (right != null)
                iframe.css("right", right);
            if (left != null)
                iframe.css("left", left);
            iframe.show();
        }
    }
}