﻿$(document).ready(function () {
    $('#ilCloseBtn').click(function () {
        var email = $('#frmInsuredLogin').find("input[name='email']");
        var pw = $('#frmInsuredLogin').find("input[name='password']");

        email.val('');
        pw.val('');
        $('#divinsuredlogin').fadeOut();
    });

    $('#btnInsuredSignIn').click(function () {
        $('#frmInsuredLogin').submit();
    });

    $('#frmInsuredLogin input').keypress(function (e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            $('#btnInsuredSignIn').click();
            return false;
        } else {
            return true;
        }
    });
});

function toggleInsuredLoginBox(elem) {
    if ($("#divinsuredlogin").css('display') == 'none') {
        elem = $(elem);
        //get the position of the placeholder element
        var pos = elem.offset();
        var width = elem.width();
        var height = elem.height();
        //show the menu directly over the placeholder
        $("#divinsuredlogin").css({ "left": (pos.left + width - 5) + "px", "top": pos.top + "px" });
        $('#divinsuredlogin').fadeIn();
    }
    else {
        $('#divinsuredlogin').fadeOut();
    }

    return false;
    
}
