var $Dialog_div;

function fnAlert(message, title) {
    $Dialog_div = $('<div id="external_popup">' + message + '</div>').prependTo('body');

    $Dialog_div = $('#external_popup').dialog({
        autoOpen: true,
        draggable: true,
        resizable: true,
        title: title,
        modal: true,
        stack: true,


        buttons: {
            "OK": function () {
                $(this).dialog("close");
            }
        }
    });
}
function fnOpenDialog(e) {
    e.preventDefault();
    // 
    $Dialog_div = $('<div id="external_popup">By clicking \"continue\", you will leave Landmark Credit Union\'s website and will be re-directed to a website that is not controlled by Landmark Credit Union. Landmark Credit Union does not endorse or guarantee the products, information or recommendations provided by the linked website and is not liable for any products, services, or content advertised on the linked website. The linked website may have a privacy policy that is different than that of Landmark Credit Union and that may provide less security; please consult the linked website\'s privacy policy for further information.</div>').prependTo('body');

    $Dialog_div = $('#external_popup').dialog({
        autoOpen: true,
        draggable: true,
        resizable: true,
        title: 'Third Party Site Disclaimer',
        modal: true,
        stack: true,


        buttons: {
            "Continue": function () {
                var newLocation = e.currentTarget.href;
                window.location = newLocation;
                $(this).dialog("close");
            },
            "Cancel": function (e) {
                e.preventDefault();
                $(this).dialog("close");
            }
        }
    });
}

function fnInputReset_Focus(item, defaultText) {
    var txtVal = $(item).val();
    if (txtVal == defaultText) {
        $(item).val("")
    }
}

function fnInputReset_Blur(item, defaultText) {
    var txtVal = $(item).val();
    if (txtVal == "") {
        $(item).val(defaultText)
    }
}

function doLeave() {
    document.calcsubmit.btnCallCalc.focus();
}

function showbuttons() {
    var agt = navigator.userAgent.toLowerCase();
    var IEMAC = ((agt.indexOf("msie") != -1) && agt.indexOf("mac") != -1);
    var N6 = (agt.indexOf("netscape6") != -1(agt.indexOf("netscape/6") != -1));

    if (N6) {
        return "Netscape 6 is unable to support our detailed reports. Please upgrade to Netscape 7 or higher.<P>";
    }
    if (IEMAC) {
        return "Internet Explorer for Macintosh is unable to support our detailed reports. Please use Safari or Firefox.<P>";
    }

    return "<P><FORM name=calcsubmit><INPUT TYPE='button' value='Calculate' Name='btnCallCalc' onClick='document.calculator.calculate()'><INPUT TYPE='button' value='View Report' Name='btnOpenNote' onClick='openNote()'></FORM>";

}

function openNote() {
    leftpos = 0;
    if (screen) {
        leftpos = screen.width / 2 - 480;
    }

    var OpenWindow = window.open("", "_blank", "toolbar=yes,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=960,height=" + (screen.height - 170) + ",left=" + leftpos + ",top=5");

    if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
        setTimeout(function () { openContinue(OpenWindow) }, 100);
    else
        openContinue(OpenWindow);
}

function openContinue(OpenWindow) {
    var s = " ";
    s = document.calculator.sJavaScriptReport('HTML');
    OpenWindow.document.write(s);
    OpenWindow.document.close();
    OpenWindow.focus();
}

$(document).ready(function () {
    $('.external_link').click(function (e) { fnOpenDialog(e) });
    $(".checking-options tbody tr:nth-child(2n+2)").addClass("odd");

    $("#login_button").click(function () {
        $('form').attr('method', 'post');
        $('form').attr('action', 'https://www.landmarkcuonline.com/onlineserv/HB/Login.cgi');

        if (runSubmit($('form')[0], $('#login_button')[0])) {
            $('#Login').submit();
        }

        return true;
    });

    // keypress handler in login form (catches enter)
    var loginKPHandler = function (e) {
        if (e.which == 13) {
            $("#login_button")[0].click();
            return false;
        }
    }

    $("#userNumber").keypress(loginKPHandler);
    $("#password").keypress(loginKPHandler);

    if (!document.Login) document.Login = theForm;
});


