$(document).ready(function() {
    $("li.parent").hover(
        function() {
            $(this).addClass('hover');
        },
        function() {
            $(this).removeClass("hover");
        }
    );

    // hidden editiontag needs the same value as the edition dropdown and sitebitwise needs to be either DW or ABS
    $("#edition").change(function() {
        switch ($("#edition").val()) {
            case "1":
                $("#editiontag").val("1");
                $("#sitebitwise").val("8");
                break;
            case "2":
                $("#editiontag").val("2");
                $("#sitebitwise").val("8");
                break;
            case "4":
                $("#editiontag").val("4");
                $("#sitebitwise").val("8");
                break;
            case "8":
                $("#editiontag").val("8");
                $("#sitebitwise").val("8");
                break;
            case "64":
                $("#editiontag").val("64");
                $("#sitebitwise").val("8");
                break;
            case "abs":
                // ABS
                $("#editiontag").val("");
                $("#sitebitwise").val("256");
                break;
            default:
                $("#editiontag").val("2");
                $("#sitebitwise").val("8");
                break;
        }
    });

    $(".dwlogin").click(function() {
        var sErrorMsg = "";

        // check the username password and edition
        var sSelectedEdition = $(".loginedition > option:selected").attr("value");
        var sUsername = $(".loginname").val();
        var sPassword = $(".loginpassword").val();

        if (sUsername == "") {
            sErrorMsg = "Please enter a Username.\n";
        }
        if (sPassword == "") {
            sErrorMsg = sErrorMsg + "Please enter a Password.\n";
        }

        if (sSelectedEdition == "") {
            sErrorMsg = sErrorMsg + "Please select an Edition.";

        }

        if (sErrorMsg.length > 0) {
            alert(sErrorMsg);
            return false;
        }
        else {
        }
    });

});