<%@ Page Title="" Language="C#" AutoEventWireup="false" MasterPageFile="~/SiteMaster.Master"
    CodeBehind="RiskCustomViewPage.aspx.cs" MaintainScrollPositionOnPostback="true"
    Inherits="MKInsight.Online.RRAM2.RiskDesign.RiskCustomViewPage" %>

<%@ Register Src="../UIControls/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="../UIControls/MessageBox.ascx" TagName="MessageBox" TagPrefix="uc2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<%@ Register Src="../UIControls/PopupPanel.ascx" TagName="PopupPanel" TagPrefix="uc15" %>
<%@ Register Src="../UIControls/PopupsHandler.ascx" TagName="PopupsHandler" TagPrefix="uc16" %>
<%@ Register Assembly="UIWebControls" Namespace="UIWebControls" TagPrefix="cc4" %>
<%@ Register Src="../UIControls/RisksControls/RiskButtonActions.ascx" TagName="RiskButtonActions"
    TagPrefix="uc3" %>
<%@ Register Src="../UIControls/RisksControls/RiskNavigationMenu.ascx" TagName="RiskNavigationMenu"
    TagPrefix="uc4" %>
<%@ Register Src="../UIControls/RisksControls/RiskInfoControl.ascx" TagName="RiskInfoControl"
    TagPrefix="uc6" %>
<%@ Register Src="../UIControls/FileAttachments/FileAttachmentsControl.ascx" TagName="FileAttachmentsControl"
    TagPrefix="uc7" %>
<%@ Register Src="~/UIControls/Metabase/MetabaseViewer.ascx" TagPrefix="uc1" TagName="MetabaseViewer" %>
<%@ Register Assembly="MKinsight.Online.UIServices" Namespace="Geekees.Common.Controls" TagPrefix="ct" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        
    <script type="text/javascript" src="../scripts/jquery/jquery_min.js"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.box-min.js"></script>

    <script type="text/javascript" src="../scripts/ASTJavascript/astreeview/astreeview_packed.js"></script>
    <link rel="stylesheet" type="text/css" href="../scripts/ASTJavascript/astreeview/astreeview.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/ASTJavascript/asdropdowntreeview/dropdowntreeview.css" />

    <script type="text/javascript">
        function setdata(value) {
            PageMethods.SetData(value);
		}

    </script>
    <script type="text/javascript">

        function removeSdata() {
            PageMethods.RemoveSData(OnRemoveSDataComplete, OnRemoveSDataError);
		}

        function OnRemoveSDataError(error, userContext, methodName) { }
        function OnRemoveSDataComplete(result, userContext, methodName) { }
        
        function resizeIframe2(obj) {        
            obj.style.height = obj.contentWindow.document.body.scrollHeight +20+ 'px';
        }

    //    $(function () {
    //        var stickyHeaderTop = $('#stickytypeheader').offset().top;

    //        $(window).scroll(function () {
    //            if ($(window).scrollTop() > stickyHeaderTop) {
    //                $('#stickytypeheader').css({ position: 'fixed', top: '-2px' });
    //                $('#sticky').css('display', 'block');
    //            } else {
    //                $('#stickytypeheader').css({ position: 'static', top: '0px' });

    //                $('#sticky').css('display', 'none');
    //                $('#spacediv').css('height', '10px');
				//}
    //        });
    //    });

    </script>

    <script type="text/javascript">
        function postbackOnCheck() {
            var o = window.event.srcElement;
            if (o.tagName == 'INPUT' && o.type == 'checkbox' && o.name != null && o.name.indexOf('CheckBox') > -1) {
				__doPostBack("<%:uptr.ClientID%>", "");
			}
		}
    </script>
    <script>
        $(document).bind('cbox_open', function () {
            $('html').css({ overflow: 'hidden' });
        }).bind('cbox_closed', function () {
            $('html').css({ overflow: 'auto' });
        });


    </script>
    <link rel="stylesheet" type="text/css" href="../scripts/jquery/jqbox.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="c_M" runat="server">

    <script type="text/javascript">
		// It is important to place this JavaScript code after ScriptManager1
        var xPos, yPos;
        var prm = Sys.WebForms.PageRequestManager.getInstance();

        function BeginRequestHandler(sender, args) {

			if ($get('<%:pmT.ClientID%>') != null) {

				// Get X and Y positions of scrollbar before the partial postback
				xPos = $get('<%:pmT.ClientID%>').scrollLeft;
				yPos = $get('<%:pmT.ClientID%>').scrollTop;
			}
		}

        function EndRequestHandler(sender, args) {

			if ($get('<%:pmT.ClientID%>') != null) {

				// Set X and Y positions back to the scrollbar
				// after partial postback
				$get('<%:pmT.ClientID%>').scrollLeft = xPos;
				$get('<%:pmT.ClientID%>').scrollTop = yPos;
			}
		}

        prm.add_beginRequest(BeginRequestHandler);
        prm.add_endRequest(EndRequestHandler);
    </script>
    
    <asp:UpdatePanel ID="q" runat="server">
        <ContentTemplate>

            <uc1:Header ID="u_H" runat="server" />

            <uc2:MessageBox ID="u_M" runat="server" />
            <uc4:RiskNavigationMenu ID="u_RV" runat="server" />
            <uc6:RiskInfoControl ID="u_I" runat="server" />
                        

                <uc3:RiskButtonActions ID="u_T" runat="server" />
                        

            <asp:MultiView ID="mv" runat="server">
                <asp:View ID="vdetail" runat="server">
                    <div id="sticky"></div>
            
                    <table cellspacing="0" cellpadding="0" border="0" style="border: 1px solid #A0A0A0; border-radius: 0; border-right: none; border-bottom: none; border-top: none;">
                        <tr>
                            <td style="vertical-align: top;">
                                <table cellspacing="0" cellpadding="0" border="0" style="border-radius: 0;">
                                    <tr>
                                        <td class="par" style="width: 500px;">
                                            <asp:Label ID="lbl_Title" runat="server" Style="padding-left: 5px;"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <br />

                                            <asp:Panel ID="p_C" runat="server" Style="padding-left: 4px;">
                                            </asp:Panel>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td style="border-right: 1px solid #A0A0A0;"></td>
                            <td style="vertical-align: top;width:100%;">
                                
                                <asp:Literal ID="lit_assessment" runat="server" ></asp:Literal>
                                

                                <asp:Panel ID="p_assessment" runat="server" Visible="false" Width="500" >

                                    <div id="RAS" class="loading">
                                        <asp:Label ID="lbl_loadAssessment" runat="server"> Loading risk assessment...</asp:Label>
                                        <div>
                                            <br />
                                        </div>
                                        <div>
                                            <br />
                                        </div>
                                        <div>
                                            <br />
                                        </div>
                                    </div>
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </asp:View>
                <asp:View ID="vmeta" runat="server">
                    <asp:Panel ID="pn_meta" runat="server">
                        <uc1:MetabaseViewer runat="server" ID="mb_Viewer" />
                    </asp:Panel>
                </asp:View>
                <asp:View ID="vtree" runat="server">
                    <div id="ruLinks" runat="server">
                        <asp:RadioButtonList ID="rbl_RULinks" runat="server" RepeatDirection="Horizontal"
                            Visible="False">
                            <asp:ListItem Selected="True" Value="0">Unchanged</asp:ListItem>
                            <asp:ListItem Value="1">Attach risk to all process universe levels</asp:ListItem>
                            <asp:ListItem Value="2">Remove all links to risk universe</asp:ListItem>
                        </asp:RadioButtonList>
                        <hr class="ee" />
                    </div>


                    <asp:UpdatePanel ID="uptr" runat="server">
                        <ContentTemplate>
                            <asp:Panel ID="pmT" runat="server" Height="550px" ScrollBars="Both">
                                <div style="float: right;">
                                    <asp:Button ID="btn_TreeTopOk" runat="server" OnClick="OnOK" />
                                </div>

                                <asp:TreeView ID="PoupTree" runat="server" ExpandDepth="1" OnTreeNodePopulate="PopulateNode"
                                    onclick="postbackOnCheck()" PathSeparator="|" ShowCheckBoxes="All" EnableClientScript="False"
                                    PopulateNodesFromClient="False">
                                </asp:TreeView>
                            </asp:Panel>
                        </ContentTemplate>
                    </asp:UpdatePanel>

                    <br />

                    <br />
                    <div class="footer">
                        <asp:Button ID="btn_TreeOK" runat="server" />
                    </div>
                </asp:View>
                <asp:View ID="v_RH" runat="server">
                    <asp:Literal ID="lit_HistoryPage" runat="server"></asp:Literal>
                </asp:View>
                <asp:View ID="r_VC" runat="server">
                    <asp:Literal ID="lit_RiskControlsPage" runat="server"></asp:Literal>
                </asp:View>
                <asp:View ID="v_RAC" runat="server">
                    <asp:Literal ID="lit_RiskActions" runat="server"></asp:Literal>
                </asp:View>
                <asp:View ID="v_RA" runat="server">
                    <asp:Literal ID="lit_RiskAssessment" runat="server"></asp:Literal>
                </asp:View>
                <asp:View ID="v_RAS" runat="server">
                    <asp:Literal ID="lit_AuditScore" runat="server"></asp:Literal>
                </asp:View>
                <asp:View ID="v_RF" runat="server">
                    <uc7:FileAttachmentsControl ID="usc_FA" runat="server" />
                </asp:View>
                <asp:View ID="v_AU" runat="server">
                    <asp:Literal ID="lit_AuditTrail" runat="server"></asp:Literal>
                </asp:View>
                <asp:View ID="v_AN" runat="server">

                    <div style="width: 99%; padding-left: 5px; padding-right: 5px; padding-top: 7px;">
                        <asp:Panel ID="p_s" runat="server" CssClass="panelheader">
                            <div style="padding: 7px;">
                                <asp:Label ID="lbl_addNotes" runat="server"></asp:Label>
                            </div>
                        </asp:Panel>
                        <div class="panelouterlines" runat="server" id="p_PS">
                            <br />

                                   <%-- <cc1:HtmlEditorExtender ID="html_Notes" runat="server" TargetControlID="txt_NotesBox"></cc1:HtmlEditorExtender>--%>
                                    <asp:TextBox ID="txt_NotesBox" runat="server" TextMode="MultiLine" Height="400" Width="98%" Rows="100"></asp:TextBox>
                                    <asp:Label ID="lbl_Notes_Readonly" runat="server"></asp:Label>
                            
                        </div>
                    </div>
                </asp:View>
                <asp:View ID="vNewRisk" runat="server">
                    <table width="100%">
                        <tr>
                            <td>
                                <p>
                                    <asp:Literal ID="lit_LFollowingRiskCreated" runat="server" />
                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="lbl_NewRisk" runat="server" Font-Bold="True"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="ee">
                                <hr class="ee" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Button ID="btn_NewCreate" runat="server" />
                                <asp:Button ID="btn_NewDelete" runat="server" />
                                <asp:Button ID="btn_NewAmend" runat="server" />
                                <asp:Button ID="btn_CancelNewRisk" runat="server" />
                                <asp:Button ID="btn_NewAssess" runat="server" Visible="false" />
                            </td>
                        </tr>
                    </table>
                </asp:View>
            </asp:MultiView>



            <cc1:ModalPopupExtender ID="mdp" runat="server" TargetControlID="btn_pHandler" PopupControlID="Pxc"
                BackgroundCssClass="modalBackground">
            </cc1:ModalPopupExtender>
            <cc1:DragPanelExtender ID="dpE" runat="server" DragHandleID="pnlHeader" TargetControlID="pxc" />
            <div>
                <uc3:RiskButtonActions ID="u_B" runat="server" />
            </div>
            <asp:Button ID="btn_pHandler" runat="server" Text="Button" Style="display: none;" />

            <asp:Panel ID="Pxc" runat="server" CssClass="frame" Style="display: none;">
                <div class="overlay">
                    <div style="float: right; margin-top: -28px; margin-right: -10px;">
                        <asp:ImageButton ID="ImageButton1" ImageUrl="~/images/jq/close.png" runat="server" />
                    </div>
                    <div style="float: right; margin-top: -28px; margin-right: -10px;">
                        <asp:ImageButton ImageUrl="~/images/jq/close.png" runat="server" />
                    </div>
                    <div class="floatright">
                        <asp:Button ID="btn_TopOK" runat="server" OnClick="OnOK" />
                    </div>
                    <div id="div_scroll">
                        <uc15:PopupPanel ID="usc_PP" runat="server" />
                    </div>


                    <div class="divpok">
                        <asp:Button ID="btn_POK" runat="server" />
                    </div>
                </div>
            </asp:Panel>

        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:UpdateProgress ID="pr" runat="server" AssociatedUpdatePanelID="q" DisplayAfter="20">
        <ProgressTemplate>
            <div class="UpdateProgressBackground">
                <center>
                    <div class="UpdateProgressContent">
                        <h3>
                            <asp:Label ID="lbl_Wait" runat="server"></asp:Label></h3>
                        <br />
                        <img id="Img1" src="~/images/ajax.gif" alt="" runat="server" />
                    </div>
                </center>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>

    <script>

        try {
            $(document).ready(function () {

                var xPos1, yPos1, timer1;

                var prm = Sys.WebForms.PageRequestManager.getInstance();
                prm.add_beginRequest(BeginRequestHandler);
                prm.add_endRequest(EndRequestHandler);

                function BeginRequestHandler(sender, args) {

                    try {
                        yPos1 = $(window).scrollTop();
                    } catch (err) { }
				}

                function EndRequestHandler(sender, args) {
                    try {
                        $(window).scrollTop(yPos1);
                        timer1 = window.setTimeout(function () { $(window).scrollTop(yPos1); }, 100);

                        $(window).scrollTop(yPos1);
					}
                    catch (err) { }
				}

            });
		}
        catch (err) { }

    </script>
</asp:Content>
