/*
*************************************************************************
* 
* CAPTUAL TECHNOLOGIES CONFIDENTIAL
* _________________________________
* 
*  2008 - 2011 Captual Technologies Inc. 
*  All Rights Reserved.
* 
* NOTICE:  All information contained herein is, and remains
* the property of Captual Technologies Incorporated and its suppliers,
* if any.  Dissemination of this information or reproduction of this 
* material is strictly forbidden unless prior written permission is 
* obtained from Captual Technologies Incorporated.
*
*************************************************************************
*/

/// <reference path="~/Content/js/lib/jquery/jquery.min.js" />

var submit_password_ok = false;

$(document).ready(function () {
    $(".locked_archive").click(function () {
        var folderId = $(this).find(".folder_id").val();

        $(".password_protected .lightbox .floating_window").showFloater(0.8, true);
        $("#event_password").attr("action", "/" + communityId + "/page/" + pageName + "/" + folderId + ".aspx");
        $("#FolderId").val(folderId);
        $("#FolderPassword").focus();        
        return false;
    });

    $("#folder_password").submit(function () {
        if (submit_password_ok) return true;

        $.post(siteRoot + "/" + communityId + "/Ajax/FolderPassword.aspx", { folderId: $(this).find("#FolderId").val(), password: $(this).find("#FolderPassword").val() },
        function (data) {
            if (data == "true") {
                submit_password_ok = true;

                window.location = siteRoot + "/" + communityId + "/page/" + pageName + "/" + $("#FolderId").val() + ".aspx";
            }
            else {
                submit_password_ok = false;

                $(".password_protected .lightbox .bottom").hide();
                $(".password_protected .errors").show();
                $(".password_protected .password_errors").html("Invalid password. Please try again.");
                return false;
            }
        });

        return false;
    });


});

