<%@page import="org.xnap.commons.i18n.I18n,com.sapphireims.web.i18n.SapphireI18nUtil"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%  I18n i18n = SapphireI18nUtil.getI18nInstance((String) session.getAttribute("LANGUAGE_UNICODE"));
    String messageIn ="";
    String messageIn1="";
    String telantName= (String)session.getAttribute("TELANTNAME");
    IConfigSettingService configSettingService = (IConfigSettingService) SpringContextUtil.getBeanByName("configSettingService",Sapphire.applicationScope);
    String gssAuthentication = configSettingService.findBySettingKey("GSS_AUTHENTICATION");
%>
<%@ page language="java" import="java.io.*, java.sql.*,IMSPackage.*" %>
<%@ page import="java.util.Date,java.sql.*,java.util.Vector,sapphire.reports.*,org.apache.commons.logging.Log,org.apache.commons.logging.LogFactory" %>
<%@page import="com.sapphire.constant.Constant"%>
<%@ page import="org.jfree.data.*"%>

<%@ page import="java.io.Serializable"%>
<%@ include file="topPane.jsp" %>
<%@ include file="EXTJSIncludes-4.jsp" %>
<script type="text/javascript" src="TrimClass.js"></script>
<script type="text/javascript" src="assets/js/jquery.min.js" ></script>
<div id="sample">
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(function (){$j(document).ajaxSend(function(e, xhr, options) {xhr.setRequestHeader("X-CSRF-TOKEN", "${_csrf.token}");});});
var req;
var res;
var lastCartUpdate = 0;
function clearCustomOU(){
    document.getElementById("addOuDiv").innerHTML = "";
    if(document.AJAX.next!=null || document.AJAX.next != undefined){
        document.getElementById("next").disabled=false;   
        document.getElementById("next").className="addbuttons greenBtn";
    }    
    if(document.AJAX.Add!=null || document.AJAX.Add != undefined){        
        document.getElementById("Add").disabled=false;       
        document.getElementById("Add").className="addbuttons greenBtn";
    }
    if(document.AJAX.DomainControllerName!=null || document.AJAX.DomainControllerName != undefined){
        document.getElementById("DomainControllerName").value="";        
    }
}
 function ProfileMatching(){
    var profileid = document.getElementById("profile").value;
    document.getElementById("NotificationDiv").style.display ="none"; 
    document.getElementById("OUListing").value ="";
	if(document.getElementById("newUICheck") !== null){
     jQuery('#OUListing').multipleSelect('setSelects', ['']);
     }
    clearCustomOU();
    if(profileid == ""){
         document.getElementById("wintree").innerHTML ="";
         document.getElementById("ShowOragnizationaltab").style.display ="none";
          document.getElementById("OUListingRule").style.display ="none";
          document.getElementById("LDAPCustomOU").style.display ="none";
          document.getElementById("OUListing").value="";
         return;
    }
    if(window.XMLHttpRequest){
        req = new XMLHttpRequest();
    }else if(window.ActiveXObject){
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
        var url="";
        var urlparameters="";
        url="ADConfigurationRule?make="+profileid;
        req.open("POST", url, false);
        req.setRequestHeader("X-CSRF-TOKEN","${_csrf.token}");
        req.onreadystatechange = ValidationOfReq;
        req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        req.send(url);
        var isMatched=req.responseText;
        var splitValues = isMatched.split(",");
        req.abort();
         document.AJAX.PARAMS.value=isMatched;
         document.AJAX.PARAMS_PROTOCOL_TYPE.value=splitValues[1];
         document.AJAX.PARAMS_OS_TYPE.value=splitValues[2];
         if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==1){
                document.getElementById("schduler").style.display ="none";
                document.getElementById("DisplayIncMessage").style.display ="block";
                document.getElementById("ShowOragnizationaltab").style.display ="none";
                document.getElementById("schdulerSecond").style.display="none";
                document.getElementById("unixdiv").style.display ="block"; 
                document.getElementById("azurediv").style.display ="none";
                document.getElementById("windiv3").style.display ="none"; 
                document.getElementById("next1").disabled=false;
                document.getElementById("next1").className="addbuttons greenBtn";
                document.getElementById("next").disabled=true;
                document.getElementById("next").className="domains genBtn whiteBtn";
                document.getElementById("nextAzure").disabled=true;
                document.getElementById("nextAzure").className="addbuttons greenBtn";
             
         }else if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2){
                document.getElementById("schduler").style.display ="none";
                document.getElementById("ShowOragnizationaltab").style.display ="none";
                document.getElementById("DisplayIncMessage").style.display ="block";
                document.getElementById("schdulerSecond").style.display="none";
                document.getElementById("unixdiv").style.display ="none"; 
                document.getElementById("azurediv").style.display ="none";
                document.getElementById("windiv3").style.display ="block"; 
                document.getElementById("next1").disabled=true;
                document.getElementById("next1").className="domains genBtn whiteBtn";
                document.getElementById("next").disabled=false;
                document.getElementById("next").className="addbuttons greenBtn";
                document.getElementById("nextAzure").disabled=true;
                document.getElementById("nextAzure").className="addbuttons greenBtn";
                document.getElementById("customOU").innerHTML="Custom OU";
                document.getElementById("OUNameField").innerHTML="OU Name";
                document.getElementById("Add").value="Add OU";
                document.getElementById("customNote").innerHTML="Custom OU";
             if(document.getElementById("importId1").checked==true) {
                 document.getElementById("OUListingName").innerHTML="Organizational Unit";
             }else if(document.getElementById("importId2").checked==true){
                 document.getElementById("OUListingName").innerHTML="Group";
             }

         }else if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==3 || document.AJAX.PARAMS_PROTOCOL_TYPE.value==4 || document.AJAX.PARAMS_PROTOCOL_TYPE.value==5){
                document.getElementById("schduler").style.display ="none";
                document.getElementById("DisplayIncMessage").style.display ="block";
                document.getElementById("ShowOragnizationaltab").style.display ="none";
                document.getElementById("schdulerSecond").style.display="none";
                document.getElementById("unixdiv").style.display ="none"; 
                document.getElementById("azurediv").style.display ="block";
                document.getElementById("windiv3").style.display ="none"; 
                document.getElementById("next1").disabled=true;
                document.getElementById("next1").className="domains genBtn whiteBtn";
                document.getElementById("next").disabled=true;
                document.getElementById("next").className="domains genBtn whiteBtn";
                document.getElementById("nextAzure").disabled=false;
                document.getElementById("nextAzure").className="addbuttons greenBtn";
                document.getElementById("saveAzure").disabled=true;
                document.getElementById("saveAzure").className="domains genBtn whiteBtn";
                document.getElementById("OUImportFrom").style.display ="none";

         }
          if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2 && document.AJAX.PARAMS_OS_TYPE.value==2){
              if(document.getElementById("PARAMS_GSS_TYPE").value==0) {
                  document.getElementById("OUImportFrom").style.display = "block";
              }
            document.getElementById("OUListingRule").style.display ="block";
            document.getElementById("OUListing").value="";
            document.getElementById("wintree").innerHTML ="";
             document.getElementById("DomainController").style.display="block";
             document.getElementById("LDAPCustomOU").style.display ="none";
             var innerHTML="";
             innerHTML="<%=i18n.tr("Add OU's as comma separated, from which user(s) has to be imported.")%><br/><br/>"+
              "<%=i18n.tr("Example")%>: <font color='blue' class='floatNone'><b>[ <%=i18n.tr("OU from which user(s) has to be imported")%> ] , [<%=i18n.tr("Sub OU 1")%> ] , [ <%=i18n.tr("Sub OU 2")%> ] , . . .  , [ <%=i18n.tr("Parent OU")%> ]</b></font><br/><br/>"+
              "<%=i18n.tr("On adding, OU validation will happen against active directory.")%>";
      document.getElementById("customounote").innerHTML=innerHTML;
          }else if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2 && document.AJAX.PARAMS_OS_TYPE.value==1){
              document.getElementById("LDAPCustomOU").style.display ="block";
              document.getElementById("DomainController").style.display="none";
              document.getElementById("OUListingRule").style.display ="none";
              document.getElementById("wintree").innerHTML="";
              var innerHTML="";
              innerHTML='<%=i18n.tr("Example")%>'+":"+"<font color=\"blue\"class='floatNone'><b><%=i18n.tr("OU=People,DC=domainname,DC=com,...[Parent OU],[Domain Controller]")%></b></font>";
              document.getElementById("customounote").innerHTML=innerHTML;
              document.getElementById("OUImportFrom").style.display ="none";
          }else{
             document.getElementById("wintree").style.display ="none"; 
             document.getElementById("OUListingRule").style.display ="none"; 
             document.getElementById("LDAPCustomOU").style.display ="none";
          }
          
          if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==3 || document.AJAX.PARAMS_PROTOCOL_TYPE.value==4 || document.AJAX.PARAMS_PROTOCOL_TYPE.value == 5){
              document.getElementById("OUListingRule").style.display ="block";
              document.getElementById("DomainController").style.display ="none";
              var innerHTML="<%=i18n.tr("On adding, Group validation will happen against Azure Active Directory.")%>";
              if(document.AJAX.PARAMS_PROTOCOL_TYPE.value == 4){
                    innerHTML="<%=i18n.tr("On adding, Group validation will happen against OneLogin.")%>";
                }else if(document.AJAX.PARAMS_PROTOCOL_TYPE.value == 5){
                    innerHTML="<%=i18n.tr("On adding, Group validation will happen against Google Workspace.")%>";
 }
              document.getElementById("customounote").innerHTML=innerHTML;
              document.getElementById("customOU").innerHTML="Custom Group";
              document.getElementById("OUNameField").innerHTML='Group Name';
              document.getElementById("Add").value="Add Group";
              document.getElementById("customNote").innerHTML="Custom Group";
              document.getElementById("OUListingName").innerHTML="Group";
              document.getElementById("OUName").value="";
              
          }
          
 }
 function ValidationOfReq()
{
    if (req.readyState != 4)
    {
       return false;
    }
}
function selectImportFrom(){
    if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2 && document.AJAX.PARAMS_OS_TYPE.value==2 && document.getElementById("PARAMS_GSS_TYPE").value==0){
        if(document.getElementById("importId1").checked==true) {
            document.getElementById("OUListingName").innerHTML = "Organizational Unit";
            document.getElementById("customOU").innerHTML = "Custom OU";
            document.getElementById("OUNameField").innerHTML = "OU Name";
            document.getElementById("Add").value = "Add OU";
            innerHTML="<%=i18n.tr("Add OU's as comma separated, from which user(s) has to be imported.")%><br/><br/>"+
                "<%=i18n.tr("Example")%>: <font color='blue'><b>[ <%=i18n.tr("OU from which user(s) has to be imported")%> ] , [<%=i18n.tr("Sub OU 1")%> ] , [ <%=i18n.tr("Sub OU 2")%> ] , . . . . . , [ <%=i18n.tr("Parent OU")%> ]</b></font><br/><br/>"+
                "<%=i18n.tr("On adding, OU validation will happen against active directory.")%>";
            document.getElementById("ShowOragnizationaltab").innerHTML = "<br class=hiddenDisplay> Organizational Unit";
            document.getElementById("customounote").innerHTML=innerHTML;
            document.getElementById("customNote").innerHTML="Custom OU";
            document.getElementById("profile").disabled=false;
            document.getElementById("OUListing").disabled=false;
            if(document.getElementById("OUListing").value==0){
                ValidateExe();
            }else if(document.getElementById("OUListing").value==1) {
                document.getElementById("OUName").value="";
                ProfileMatching();
            }
        }else if(document.getElementById("importId2").checked==true){
            document.getElementById("OUListingName").innerHTML = "Group";
            document.getElementById("customOU").innerHTML = "Custom Group";
            document.getElementById("OUNameField").innerHTML = "Group Name";
            document.getElementById("Add").value = "Add Group";
            document.getElementById("ShowOragnizationaltab").innerHTML = "<br class=hiddenDisplay> Group";
            document.getElementById("profile").disabled=false;
            document.getElementById("OUListing").disabled=false;
            var innerHTML="";
            innerHTML="<%=i18n.tr("Add a group, from which user(s) has to be imported.")%><br/><br/>"+
                "<%=i18n.tr("Example")%>: <font color='blue'><b>[ <%=i18n.tr("Group from which user(s) has to be imported")%> ] , [<%=i18n.tr("Group")%> ] , [ <%=i18n.tr("Sub OU")%> ] , . . . [ <%=i18n.tr("Parent OU")%> ] </b></font><br/><br/>"+
                "<%=i18n.tr("On adding, Group validation will happen against active directory.")%>";
            document.getElementById("customounote").innerHTML=innerHTML;
            document.getElementById("customNote").innerHTML="Custom Group";
            if(document.getElementById("OUListing").value==0){
                ValidateExe();
            }else if(document.getElementById("OUListing").value==1) {
                document.getElementById("OUName").value="";
                ProfileMatching();
            }
        }
    }
}
function ValidateExe(){
    document.getElementById("NotificationDiv").style.display ="none";
    document.getElementById("schduler").style.display ="none";
    document.getElementById("schdulerSecond").style.display="none";
    document.getElementById("nextAzure").disabled=false;
    document.getElementById("nextAzure").className="addbuttons greenBtn";
    document.getElementById("saveAzure").disabled=true;
    document.getElementById("saveAzure").className="domains genBtn whiteBtn";
        if(document.getElementById("OUListing").value == ""){
                   document.getElementById("wintree").style.display ="none"; 
                   document.getElementById("ShowOragnizationaltab").style.display ="none";
                   document.getElementById("LDAPCustomOU").style.display ="none";
        }else{
            var listType ="";
            if(document.getElementById("OUListing").value == "0"){
                 document.getElementById("LDAPCustomOU").style.display ="none";
                 document.getElementById("profile").disabled=true;
                 document.getElementById("OUListing").disabled=true;
                if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2 && document.AJAX.PARAMS_OS_TYPE.value==2 && document.getElementById("PARAMS_GSS_TYPE").value==0) {
                    if (document.getElementById("importId1").checked == true) {
                        listType = 1;
                    } else if (document.getElementById("importId2").checked == true) {
                        listType = 2;
                    }
                }
                var isMatched ="";
                $j.ajax({
                    url: "LdapConfig_TreeStructure?make="+document.getElementById("profile").value+"&listType="+listType,
                    beforeSend: function( xhr ) {
                        initProgress();
                    }
                }).done(function( data ) {
                    if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==3 || document.AJAX.PARAMS_PROTOCOL_TYPE.value==4 || document.AJAX.PARAMS_PROTOCOL_TYPE.value==5){
                        document.getElementById("ShowOragnizationaltab").innerHTML ="<br class='hiddenDisplay'> Group";
                    }
                    isMatched = data.split("5EPARAT0R")[0];
                    data = data.split("5EPARAT0R")[1];  
                    if(isMatched == "yes"){
                        data =  Ext.JSON.decode(data);
                        document.getElementById("ShowOragnizationaltab").style.display ="block";
                        document.getElementById("wintree").innerHTML ="";
                        document.getElementById("wintree").style.display ="block"; 
                        document.getElementById("LDAPCustomOU").style.display ="none";
                        var store = Ext.create('Ext.data.TreeStore', {
                               root: data
                        });
                        var tree = Ext.create('Ext.tree.Panel', {
                            store: store,
                            border:2,
                            rootVisible: true,
                            useArrows: true,
                            renderTo: 'wintree',
                            height: 250,
                            listeners :{  
                                checkchange: function(node, checked) {
                                        node.expand();
                                        var records = tree.getView().getChecked();
                                        document.getElementById("SelectedOU").value =  "";
                                        Ext.Array.each(records, function(rec){
                                            if(rec.get('id')!="RootOFAllValue"){
                                                       if(document.getElementById("SelectedOU").value== ""){
                                                              document.getElementById("SelectedOU").value = rec.get('id');
                                                          }else{
                                                              document.getElementById("SelectedOU").value = document.getElementById("SelectedOU").value +"|$$|"+rec.get('id');
                                                          }
                                            }
                                      });

                               }
                          }
                        });             
                        document.getElementById("profile").disabled=false;
                        document.getElementById("OUListing").disabled=false;
                        resetProgress1();
                    }else if(isMatched == "no"){
                        document.getElementById("wintree").innerHTML =data;
                        document.getElementById("wintree").style.display ="block"; 
                        document.getElementById("ShowOragnizationaltab").style.display ="none";
                        document.getElementById("LDAPCustomOU").style.display ="none";  
                        document.getElementById("next").disabled=true;
                        
                        document.getElementById("profile").disabled=false;
                        document.getElementById("OUListing").disabled=false;
                        resetProgress();
                    }
                });
            }else if(document.getElementById("OUListing").value == "1"){
                document.getElementById("wintree").innerHTML ="";
                document.getElementById("wintree").style.display ="none"; 
                document.getElementById("ShowOragnizationaltab").style.display ="none";
                document.getElementById("LDAPCustomOU").style.display ="block";
                document.getElementById("errorCustomMsg").style.display ="none";
                document.getElementById("organizationunitheader").style.display ="none";
                 if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2 && document.AJAX.PARAMS_OS_TYPE.value==2){
                       if(document.AJAX.newlyaddedOUs!=null || document.AJAX.newlyaddedOUs == undefined){
                            document.getElementById("next").disabled=false;
                       }
                         if(document.getElementById("importId1").checked==true) {
                             document.getElementById("customOU").innerHTML = "Custom OU";
                             document.getElementById("OUNameField").innerHTML = "OU Name";
                             document.getElementById("Add").value = "Add OU";
                             document.getElementById("OUName").value="";
                             document.getElementById("DomainControllerName").value="";
                             if(document.getElementById("newlyaddedOUs")!==null) {
                                 document.getElementById("newOU").remove();
                             }
                             if(document.getElementById("error")!==null) {
                                 document.getElementById("error").style.display = "none";
                                 document.getElementById("error").remove();
                             }
                         }else if(document.getElementById("importId2").checked==true){
                             document.getElementById("customOU").innerHTML = "Custom Group";
                             document.getElementById("OUNameField").innerHTML = "Group Name";
                             document.getElementById("Add").value = "Add Group";
                             document.getElementById("OUName").value="";
                             document.getElementById("DomainControllerName").value="";
                             if(document.getElementById("newlyaddedOUs")!==null) {
                                 document.getElementById("newOU").remove();
                             }
                             if(document.getElementById("error")!==null) {
                                 document.getElementById("error").style.display = "none";
                                 document.getElementById("error").remove();
                             }
                             var innerHTML="";
                             innerHTML="<%=i18n.tr("Add a group, from which user(s) has to be imported.")%><br/><br/>"+
                                 "<%=i18n.tr("Example")%>: <font color='blue'><b>[ <%=i18n.tr("Group from which user(s) has to be imported")%> ] , [<%=i18n.tr("Group")%> ] , [ <%=i18n.tr("Sub OU")%> ] , . . . [ <%=i18n.tr("Parent OU")%> ] </b></font><br/><br/>"+
                                 "<%=i18n.tr("On adding, Group validation will happen against active directory.")%>";
                             document.getElementById("customounote").innerHTML=innerHTML;
                         }
                  }
             
            }
          }
    }
function ShowADSI(){
   
     document.getElementById("save").disabled=false;
     document.getElementById("save").className="addbuttons greenBtn";
     document.getElementById("next1").disabled=true;
     document.getElementById("next1").className="domains greenBtn genBtn";
     document.getElementById("ShowOragnizationaltab").style.display ="none";
     document.getElementById("schduler").style.display ="block";
     
     
     
}

function ShowAzure(){
    if(regex2.test(document.AJAX.Configname.value))
    {	<%messageIn=i18n.tr("Enter the configuration name");%>
        showErrorMessageLdap("<%=messageIn%>","Configname");
            return;
    }
    var groupCustomOrList = document.getElementById("OUListing").value;
    if(groupCustomOrList==""){
        <%messageIn=i18n.tr("Please choose the Group");%>
        showErrorMessageLdap("<%=messageIn%>","OUListing");
        return;
    }
//    var ouName = document.getElementById("OUName").value.trim();
    if(document.getElementById("OUListing").value === "1"){
        if(document.getElementById("newlyaddedOUs") == null){
            <%messageIn=i18n.tr("Please enter atleast one Group name");%>
            showErrorMessageLdap("<%=messageIn%>","OUName");
            return;
        }
    }else{
        if(document.AJAX.SelectedOU.value ==""){
            <%messageIn=i18n.tr("Please select atleast one Group");%>
            displayAlertPopUpMsg("<%=messageIn%>");
            return;
        }
    }
     document.getElementById("saveAzure").disabled=false;
     document.getElementById("saveAzure").className="addbuttons greenBtn";
     document.getElementById("nextAzure").disabled=true;
     document.getElementById("nextAzure").className="domains genBtn whiteBtn";
     document.getElementById("ShowOragnizationaltab").style.display ="none";
     document.getElementById("schduler").style.display ="block";
     document.getElementById("schdulerSecond").style.display="block";
     document.getElementById("NotificationDiv").style.display ="block";    
}

function ShowLDAP(){
    
    if(regex2.test(document.AJAX.Configname.value))
    {	<%messageIn=i18n.tr("Enter the configuration name");%>
        showErrorMessageLdap("<%=messageIn%>","Configname");
            return;
    }
    if(document.getElementById("profile").value==""){
        <%messageIn=i18n.tr("Please choose the LDAP rule");%>
        showErrorMessageLdap("<%=messageIn%>","profile");
        return;
    }
    if(document.getElementById("OUListing").value == "0"){
        if(document.AJAX.SelectedOU.value ==""){
            var ouname="";
            if (document.getElementById("importId1").checked == true) {
                ouname = "organizational unit";
            } else if (document.getElementById("importId2").checked == true) {
                ouname = "group";
            }
            <%messageIn=i18n.tr("Please select atleast one ");%>
            displayAlertPopUpMsg("<%=messageIn%>"+ouname);
            return;
        }
    }else{
        if (document.getElementById("newlyaddedOUs") == null) {
            var ouname="";
            if (document.getElementById("importId1").checked == true) {
                ouname = "organizational unit";
            } else if (document.getElementById("importId2").checked == true) {
                ouname = "group";
            }
            <%messageIn=i18n.tr("Please add atleast one ");%>
            displayAlertPopUpMsg("<%=messageIn%>"+ouname);
            return;
        }
    }
    var ouCustomOrList = document.getElementById("OUListing").value;
    if(ouCustomOrList=="" && document.AJAX.PARAMS_OS_TYPE.value==2){
        <%messageIn=i18n.tr("Please choose the organizational unit");%>
        showErrorMessageLdap("<%=messageIn%>","OUListing");
        return;
    }else{
        document.getElementById("schduler").style.display ="block";
                    document.getElementById("DisplayIncMessage").style.display ="block";
                    document.getElementById("schdulerSecond").style.display="block";
                    document.getElementById("unixdiv").style.display ="none"; 
                    document.getElementById("azurediv").style.display ="none";
                    document.getElementById("windiv3").style.display ="block"; 
                    document.getElementById("NotificationDiv").style.display ="block"; 
                    document.getElementById("next1").disabled=true;
                    document.getElementById("next1").className="domains genBtn whiteBtn";
                    document.getElementById("next").disabled=false;
                    document.getElementById("next").className="addbuttons greenBtn";
                    document.getElementById("save1").disabled=false;
                    document.getElementById("save1").className="addbuttons greenBtn";
                    document.getElementById("next").disabled=true;
                    document.getElementById("next").className="domains genBtn whiteBtn";
                    document.getElementById("nextAzure").disabled=true;
                    document.getElementById("nextAzure").className="domains genBtn whiteBtn";
                    document.getElementById("saveAzure").disabled=true;
                    document.getElementById("saveAzure").className="domains genBtn whiteBtn";
    }
    
    if(ouCustomOrList == "0"){
    if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2){
        if(document.AJAX.PARAMS_OS_TYPE.value==2){
  
                    document.AJAX.SelectedOU.value = document.AJAX.SelectedOU.value.trim();
                    if(document.AJAX.SelectedOU.value ==""){
                        <%messageIn=i18n.tr("Please select atleast one organizational unit");%>
                        displayAlertPopUpMsg("<%=messageIn%>");
                        return;
                    }
                    document.getElementById("schduler").style.display ="block";
                    document.getElementById("DisplayIncMessage").style.display ="block";
                    document.getElementById("schdulerSecond").style.display="block";
                    document.getElementById("unixdiv").style.display ="none"; 
                    document.getElementById("azurediv").style.display ="none";
                    document.getElementById("windiv3").style.display ="block"; 
                    document.getElementById("NotificationDiv").style.display ="block"; 
                    document.getElementById("next1").disabled=true;
                    document.getElementById("next1").className="domains genBtn whiteBtn";
                    document.getElementById("next").disabled=false;
                    document.getElementById("next").className="addbuttons greenBtn";
                    document.getElementById("save1").disabled=false;
                    document.getElementById("save1").className="addbuttons greenBtn";
                    document.getElementById("next").disabled=true;
                    document.getElementById("next").className="domains genBtn whiteBtn";
                    document.getElementById("nextAzure").disabled=true;
                    document.getElementById("nextAzure").className="domains genBtn whiteBtn";
                    document.getElementById("saveAzure").disabled=true;
                    document.getElementById("saveAzure").className="domains genBtn whiteBtn";
                    
        }else{
           
                        document.getElementById("schduler").style.display ="block";
                        document.getElementById("DisplayIncMessage").style.display ="block";
                        document.getElementById("schdulerSecond").style.display="block";
                        document.getElementById("NotificationDiv").style.display ="none"; 
                        document.getElementById("unixdiv").style.display ="none"; 
                        document.getElementById("azurediv").style.display ="none";
                        document.getElementById("windiv3").style.display ="block"; 
                        document.getElementById("next1").disabled=true;
                        document.getElementById("next1").className="domains genBtn whiteBtn";
                        document.getElementById("next").disabled=true;
                        document.getElementById("next").className="domains genBtn whiteBtn";
                        document.getElementById("save1").disabled=false;
                        document.getElementById("save1").className="addbuttons greenBtn";
                        document.getElementById("nextAzure").disabled=true;
                        document.getElementById("nextAzure").className="domains genBtn whiteBtn";
        }
        
    }
    }else{
        if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2 && document.AJAX.PARAMS_OS_TYPE.value==2){
           
                    if(document.getElementById("newlyaddedOUs")==null ){
                        var ouname="";
                        if (document.getElementById("importId1").checked == true) {
                            ouname = "organizational unit";
                        } else if (document.getElementById("importId2").checked == true) {
                            ouname = "group";
                        }
                          <%messageIn=i18n.tr("Please add atleast one ");%>
                        showErrorMessageLdap("<%=messageIn%>"+ouname,"OUName");
                          return;
                    }
                    document.getElementById("schduler").style.display ="block";
                    document.getElementById("DisplayIncMessage").style.display ="block";
                    document.getElementById("schdulerSecond").style.display="block";
                    document.getElementById("unixdiv").style.display ="none"; 
                    document.getElementById("azurediv").style.display ="none";
                    document.getElementById("windiv3").style.display ="block"; 
                    document.getElementById("NotificationDiv").style.display ="block"; 
                    document.getElementById("next1").disabled=true;
                    document.getElementById("next1").className="domains genBtn whiteBtn";
                    document.getElementById("next").disabled=false;
                    document.getElementById("next").className="addbuttons greenBtn";
                    document.getElementById("save1").disabled=false;
                    document.getElementById("save1").className="addbuttons greenBtn";
                    document.getElementById("next").disabled=true;
                    document.getElementById("next").className="domains genBtn whiteBtn";
                    document.getElementById("nextAzure").disabled=true;
                    document.getElementById("nextAzure").className="domains genBtn whiteBtn";
        }
    }
    
}	

function ChangePort()
{
	if(document.AJAX.Chk2.checked==true)
	{
		document.AJAX.port.value="636";		
	}
	else
	{
		document.AJAX.port.value="389";	
	}
}

function initProgress() { 
  Element.show('progressMsg');
  document.getElementById("next").disabled=true;
}
function initProgress1() { 
  Element.show('progressMsg1');
  document.getElementById("next").disabled=true;
}
function reportError() {
  
   if ($('model').options.length == 0) {
       <%messageIn=i18n.tr("CallOut busted!");%>  
      $('errorMsg').innerHTML = "<%=messageIn%>";
  }
  
  <%messageIn=i18n.tr("Html content busted!");%>  
  $('errorMsg').innerHTML = "<%=messageIn%>";
  Element.show('errorMsg');
  setTimeout("Effect.DropOut('errorMsg')", 25000);
}

var regex1=/(^\d\d*)([ ]*)$/;	
var regex2=/(^[ ]*)$/;
 var onsave=0;
  function validate()
  {     
  		if(regex2.test(document.AJAX.Configname.value))
		{	<%messageIn=i18n.tr("Enter the configuration name");%>
            showErrorMessageLdap("<%=messageIn%>","Configname");
			return;
		}
		
  		var title_validations=document.getElementById('Config_name_exits');
		var Config_temp_title_count=document.getElementById('Config_temp_title_count').value;
  		
  		
 if(title_validations != null && title_validations != 'undefined' ){
		if(Config_temp_title_count>1){
		
		var keys=document.AJAX.Config_name_exits;  
		var key=document.AJAX.Configname.value;
		 for(var i=0;i<keys.length;i++)
		 {		   		   
		   if(keys[i].value==key)
		   {
                    <%messageIn=i18n.tr("Duplicate 'Configuration Name',it should be unique");%>
               showErrorMessageLdap("<%=messageIn%>","Configname");
		   return;
		   }
		 }    
		}
		else{
		
			var keys=document.AJAX.Config_name_exits.value;  
			var key=document.AJAX.Configname.value;
			
			if(keys==key){
                           <%messageIn=i18n.tr("Duplicate 'Configuration Name',it should be unique");%>
                showErrorMessageLdap("<%=messageIn%>","Configname");
			   return;
			
			}
		
		}
}
  if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2){
        if(document.AJAX.PARAMS_OS_TYPE.value==2){
            if(document.getElementById("OUListing").value == "0"){
                document.AJAX.SelectedOU.value=document.AJAX.SelectedOU.value.trim();					 	  
                if(document.AJAX.SelectedOU.value==""){
                 <%messageIn=i18n.tr("Please select atleast one organizational unit");%>
                    displayAlertPopUpMsg("<%=messageIn%>");
                 return;
                }
            }else{
            if(document.AJAX.PARAMS_OS_TYPE.value==2){
               var dc = document.getElementById("DomainControllerName").value.trim();
               if(dc==""){
                     <%messageIn=i18n.tr("Please enter the domain controller name ");%>
                   showErrorMessageLdap("<%=messageIn%>","DomainControllerName");
                     return;
                }
                if(dc.indexOf(".")== -1){
                    <%messageIn=i18n.tr("Please enter the domain controller name as specified in your server");%>
                    showErrorMessageLdap("<%=messageIn%>","DomainControllerName");
                     return;
                }
                }
                if(document.getElementById("newlyaddedOUs")==null ){
                    <%messageIn=i18n.tr("Please add atleast one organizational unit");%>
                    showErrorMessageLdap("<%=messageIn%>","OUName");
                    return;
                 }
            }
        }
  }
    
         var compregex=/(^\+?\d\d*)$/;
		  if(document.AJAX.port.value!="")
    	  {
		    if(!compregex.test(document.AJAX.port.value))
			  {
                          <%messageIn=i18n.tr("Port cannot contain charaters or special characters or spaces");%>
                  showErrorMessageLdap("<%=messageIn%>","port");
			  	return;
			  }
	       }
                if(document.AJAX.checkNotify.checked ==true && document.AJAX.Notify.value ==""){
                <%messageIn=i18n.tr("Please choose the notification profile");%>
                    showErrorMessageLdap("<%=messageIn%>","Notify");
                        return;
	        }
                if(document.AJAX.LDAPConfig_IncSync[0].checked){
                    if(submitjob() != true){
                        return;
		  }
                    if(retryCountRetryIntervalValidate("RetryCount","RetryInterval") != true){
		    return;
		  }
                }else{
                    document.getElementById("RetryCount").value="0";
                    document.getElementById("RetryInterval").value="15";                    
                    document.getElementById("enable").value="0";
  }
                if(document.AJAX.FullSync[0].checked){
                    if(submitjobldap() != true){
                        return;
                    }
                    if(retryCountRetryIntervalValidate("RetryCount1","RetryInterval1") != true){
                        return;
                    }
                }else{
                    document.getElementById("RetryCount1").value="0";
                    document.getElementById("RetryInterval1").value="15";
                    document.getElementById("enableldap").value="0";
                }                
                document.AJAX.submit();                
}
function showIncSync(checkedVaue){
    if(checkedVaue == "1"){
        document.AJAX.enable.value="1";
                     document.getElementById('block_div').style.display='block';
                     document.getElementById('retry_div').style.display='block';
    }else{
        document.AJAX.enable.value="0";
                    document.getElementById('block_div').style.display='none';
                    document.getElementById('retry_div').style.display='none';
                }
        }
function showFullSync(checkedVaue){
    if(checkedVaue == "1"){
        document.AJAX.enableldap.value="1";
        document.getElementById('block_divldap').style.display='block';
        document.getElementById('retry_div1').style.display='block';
    }else{
        document.AJAX.enableldap.value="0";
                     document.getElementById('block_divldap').style.display='none';
                     document.getElementById('retry_div1').style.display='none';
                }
        }
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>


<script language="JavaScript" src="calendar.js"></script>


<SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup_combined.js"></SCRIPT>
	<SCRIPT LANGUAGE="JavaScript">

	var cal_from = new CalendarPopup(); 
	cal_from.showNavigationDropdowns();

	var cal_to = new CalendarPopup(); 
	cal_to.showNavigationDropdowns();


</SCRIPT>

<style>
<!--
BODY{

scrollbar-face-color:#999999 ;
scrollbar-arrow-color:indigo;
scrollbar-track-color:#FFFFFF;
scrollbar-shadow-color:'';
scrollbar-highlight-color:'';
scrollbar-3dlight-color:'';
scrollbar-darkshadow-Color:'';
}
-->
</style>


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="sapphire.css" rel="stylesheet" type="text/css">
<link href="sap.css" rel="stylesheet" type="text/css">



<link href="CalendarControl.css" rel="stylesheet" type="text/css">
<script src="CalendarControl.js" language="JavaScript" type="text/javascript"></script>


<script language="JavaScript" src="calendar.js"></script>

  <script type="text/javascript" src="<%=request.getContextPath()%>/js/prototype.js"></script>
  <script type="text/javascript" src="js/scriptaculous.js"></script>
  
<!--  
  <script type="text/javascript" src="js/overlibmws.js"></script>
-->  
  
  <script type="text/javascript" src="<%=request.getContextPath()%>/js/ajaxtags-1.2-beta1.js"></script>
  
  
  <link rel="stylesheet" type="text/css" href="css/ajaxtags.css" />
  <link rel="stylesheet" type="text/css" href="css/displaytag.css" />


<%
if(new Sapphire().checkModuleAccess((String)session.getAttribute("login"),"Settings",telantName) == 0){
%>
<jsp:forward page="login_page.htm"></jsp:forward>
<%} %>
<script language="JavaScript" type="text/JavaScript">

var duplicate_val=0;

function Validation(validXML){						
			  	var cart = validXML.getElementsByTagName("Root")[0];
				var generated = cart.getAttribute("generated");
				var value=0;
				var rowdata=cart.getElementsByTagName("Row-Data");
				var nrows = rowdata.length;
				var resp = "";
				for (var I = 0 ; I < nrows; I++) {
					var item = rowdata[I];
					value = item.getElementsByTagName("Row-Value")[0].firstChild.nodeValue;
				}
			//	Eariler they were checking for the value==1 and for the first time when the value 
			//  will be retruned as one so it was showing duplicate value for the name
				
			   	if(value==-1)
	            {
				  duplicate_val=1;
                                  <%messageIn=i18n.tr("Config Name Should not be Duplicate");%>
                    showErrorMessageLdap("<%=messageIn%>","Configname");
                  return;
				}
				else if(onsave!=1)
	            {
				 onsave=0;
				 var url="Ldap_ViewUser.jsp?temp_domid="+value;
                                 <%messageIn=i18n.tr("LDAP Integration");%>
                 popUpPage(url,779,300,'<%=messageIn%>');
				}
}



function _setValues()
{

	var radio = document.AJAX.id1;
	for(var i=0;i<radio.length;i++)
	{
		if(radio[i].value==1 && radio[i].checked==true)	
			{
				document.getElementById("schduler").style.display="none";
				document.getElementById("schdulerSecond").style.display="none";				
		        document.AJAX.status_enable.value ="enable";				
				document.AJAX.searchtype.value = 1;				
				document.getElementById("unixdiv").style.display ="block"; 
                                document.getElementById("azurediv").style.display ="none";
				document.getElementById("windiv3").style.display ="none"; 				
			    document.getElementById("wintree").style.display ="none"; 
			    document.getElementById("operating").style.display ="none";
			    document.getElementById("advanced").style.display ="none"; 
			    document.getElementById("addsett").style.display ="none"; 				
				document.getElementById("save").disabled=true;
                                document.getElementById("save").className="domains genBtn whiteBtn";
				document.getElementById("next1").disabled=false;
                                document.getElementById("next1").className="addbuttons greenBtn";
				document.getElementById("DisplayIncMessage").style.display ="none";
				
				 
		    }
			else if(radio[i].value==2 && radio[i].checked==true)
			{
				document.AJAX.searchtype.value = 2;				
				document.getElementById("windiv3").style.display ="block"; 
				document.getElementById("unixdiv").style.display ="none"; 								
                                document.getElementById("azurediv").style.display ="none";
				document.getElementById("operating").style.display ="block"; 
				document.getElementById("advanced").style.display ="block"; 
				document.getElementById("save").disabled=false;
                                document.getElementById("saveAzure").disabled=true;
				document.getElementById("save1").disabled=true;
				document.getElementById("next").disabled=false;
                                document.getElementById("nextAzure").disabled=true;
				document.getElementById("schduler").style.display ="none";				
				document.getElementById("schdulerSecond").style.display="none";
				document.getElementById("DisplayIncMessage").style.display ="none";
				if(document.getElementById("Chk1").checked==true)
				{	
					document.getElementById("addsett").style.display ="block";
				}
				var radio=document.AJAX.osid1;
				for(var i=0;i<radio.length;i++)
				{
					if(radio[i].value=="1" && radio[i].checked==true)
					{
						document.getElementById("wintree").style.display ="none";
						document.getElementById("DisplayIncMessage").style.display ="none";
						document.AJAX.displayschduler.value=1;
						document.AJAX.displaySecondschduler.value=1;
						return;
					}										
				}
				if(document.AJAX.status_type  != null && document.AJAX.status_type  != 'undefined')
				{	
				  if(document.AJAX.status_type.value == "yes")
			       {
			      		document.AJAX.displaySecondschduler.value=0;
			       		document.AJAX.displayschduler.value=1;
			       		document.getElementById("DisplayIncMessage").style.display ="none";     		
			       }
				}
				else
				{
					document.AJAX.displaySecondschduler.value=1;						
					document.AJAX.displayschduler.value=0;
					document.getElementById("DisplayIncMessage").style.display ="none";
				}
								
				document.getElementById("wintree").style.display ="block";
		    	
		    }else if(radio[i].value==3 && radio[i].checked==true)	
                        {
				document.getElementById("schduler").style.display="block";
				document.getElementById("schdulerSecond").style.display="block";				
                                document.AJAX.status_enable.value ="enable";				
				document.AJAX.searchtype.value = 1;				
				document.getElementById("unixdiv").style.display ="none"; 
                                document.getElementById("azurediv").style.display ="block";
                                document.getElementById("saveAzure").disabled=false;
                                document.getElementById("nextAzure").disabled=false;
				document.getElementById("windiv3").style.display ="none"; 				
			    document.getElementById("wintree").style.display ="none"; 
			    document.getElementById("operating").style.display ="none";
			    document.getElementById("advanced").style.display ="none"; 
			    document.getElementById("addsett").style.display ="none"; 				
				document.getElementById("save").disabled=false;
                                document.getElementById("save").className="domains genBtn whiteBtn";
				document.getElementById("next1").disabled=false;
                                document.getElementById("next1").className="addbuttons greenBtn";
				document.getElementById("DisplayIncMessage").style.display ="none";	 
		    }
	}
	
}

function disabledtree()
{	
	
	document.getElementById("next").disabled=false;
	document.getElementById("save1").disabled=true;
	document.getElementById("wintree").style.display ="none";
	document.getElementById("schduler").style.display ="none";
	document.getElementById("schdulerSecond").style.display="none";
	document.getElementById("DisplayIncMessage").style.display ="none";
	document.AJAX.displayschduler.value=0;
	document.AJAX.displaySecondschduler.value=1;	
}

function enabletree()
{
	
	if(document.AJAX.status_type  != null && document.AJAX.status_type  != 'undefined')
		{	
				  if(document.AJAX.status_type.value == "yes")
			       {
			      		document.AJAX.displaySecondschduler.value=0;
			       		document.AJAX.displayschduler.value=1;     		
			       }
		}
		else
		{					
				document.AJAX.displayschduler.value=0;
				document.AJAX.displaySecondschduler.value=1;				
		}
	   
	document.getElementById("next").disabled=false;
	document.getElementById("save1").disabled=true;
	document.getElementById("wintree").style.display ="block";
	document.getElementById("schduler").style.display ="none";	
	document.getElementById("schdulerSecond").style.display="none";
	document.getElementById("DisplayIncMessage").style.display ="none";	
}

function advancesetting()
{
    if(document.AJAX.Chk1.checked==true)
	{
	  document.getElementById("addsett").style.display ="block"; 
	}
	else
	{
	 document.getElementById("addsett").style.display ="none"; 
	}
}

var chkInc=0;
function checkTree()
{ 
	if(document.AJAX.temp.checked==true)
	{
     chkInc++;
	
	}
	else if(document.AJAX.temp.checked==false)
	{
     chkInc--;
	}	
}
function resetProgress1(){
    Effect.Fade('progressMsg');
    document.AJAX.next.disabled=false;
}
function resetProgress2(){
    Effect.Fade('progressMsg1');
    document.AJAX.next.disabled=false;
}
function resetProgress()
{	
     document.getElementById("wintree").style.display ="block"; 
     document.getElementById("ShowOragnizationaltab").style.display ="block";
        if(document.AJAX.status_type.value=="No")
        {
                Effect.Fade('progressMsg');
                document.getElementById("save1").disabled=true;
                document.getElementById("save1").className="domains genBtn whiteBtn";
	        document.AJAX.next.disabled=false;
                document.getElementById("next").className="addbuttons greenBtn";
        	document.AJAX.displayschduler.value=0;
        }       
		else
		{			      
			  Effect.Fade('progressMsg');			  
			  document.AJAX.next.disabled=false;
                          document.getElementById("next").className="addbuttons greenBtn";
              document.getElementById("save1").disabled=true;
              document.getElementById("save1").className="domains genBtn whiteBtn";
              document.AJAX.displaySecondschduler.value=0;
    	}

		if(document.AJAX.status_enable.value =="enable")
       {     					
			document.getElementById("save1").disabled=true;
                        document.getElementById("save1").className="domains genBtn whiteBtn";
			document.AJAX.next.disabled=false;
                        document.getElementById("next").className="addbuttons greenBtn";
       }
	   else
	   { 		
	   		document.AJAX.next.disabled=false;
                        document.getElementById("next").className="addbuttons greenBtn";
	   		document.AJAX.displaySecondschduler.value=0;         
	   }	  
           if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2 && document.AJAX.PARAMS_OS_TYPE.value==2){
              
                if(document.AJAX.ous==undefined){
                     document.getElementById("next").disabled=true;
                     document.getElementById("next").className="domains genBtn whiteBtn";
                }
           }
}

function LoadMain_Page()
{
  window.location.href="LDAPConfig_List";
}
			
function showblock1()
{
  showblock();
}
function showblockldap()
{
  showblockldap1();
}
function Test(type)
{   
	
	if(type=="2")
	{
		if(regex2.test(document.AJAX.Configname.value))
		{	<%messageIn=i18n.tr("Enter the configuration name");%>
            showErrorMessageLdap("<%=messageIn%>","Configname");
			return;
		}	
		if(regex2.test(document.AJAX.hostName.value))
		{       <%messageIn=i18n.tr("Enter the host name");%>
            showErrorMessageLdap("<%=messageIn%>","hostName");
			return;
		}
		
	  if(document.AJAX.displayschduler.value==0)
		{			
					
			document.AJAX.displayschduler.value=1;
			var radio=document.AJAX.osid1;	
			for(var i=0;i<radio.length;i++)
				{
					if(radio[i].value=="1" && radio[i].checked==true)
					{
						document.getElementById("schduler").style.display ="block";						
						document.getElementById("DisplayIncMessage").style.display ="none";
						document.getElementById("schdulerSecond").style.display="none";	
						document.getElementById("next").disabled=true;
						document.getElementById("save1").disabled=false;
					}
					if(radio[i].value=="2" && radio[i].checked==true)
					{
					    removeJerk();
					}
				}
				
		    return;	
		
		}
		
		if(document.AJAX.displayschduler.value=="1")
		{
	
	  	   var Os_radio = document.AJAX.osid1;
		   var radio = document.AJAX.id1;
	
			 for(var i=0;i<radio.length;i++)
			{
				if(radio[i].value==2 && radio[i].checked==true)	
			    {			    					    		
						for(var j=0;j<Os_radio.length;j++)
								{
										if(Os_radio[j].value==2 && Os_radio[j].checked==true)
										{
												if(document.AJAX.status_type  != null && document.AJAX.status_type  != 'undefined')
										    	{	
										    		if(document.AJAX.status_type.value=="No")
													  {
															document.AJAX.displayschduler.value=0;
                                                                                                                        <%messageIn=i18n.tr("Enter correct values");%>
															alert("<%=messageIn%>");
															document.getElementById("save1").disabled=true;
															document.AJAX.next.disabled=false;
                                                                                                                        document.getElementById("next").className="addbuttons greenBtn";
															return;			
											     	  }			    		
									    		 }
									    		 
                var OUcheck=document.AJAX.ous;							 	  
													 	  
                    var flag=0;
                    if(OUcheck.value==undefined)
                     {
                       for(var i=0;i<OUcheck.length;i++)
                            {
                              if(OUcheck[i].checked==true)
                               { 
                                            flag=1;
                               }
                            }
                    }
                    else
                    {
                             if(OUcheck.checked==true)
                             { 
                              flag=1;
                             }
                }
                        }
        }												  
	       	    }
		   }
                    
	        
                    if(flag==0)
                    {
                    <%messageIn=i18n.tr("Please select atleast one organizational unit");%>
                        displayAlertPopUpMsg("<%=messageIn%>");
                     return;
                    }
				
				document.getElementById("schduler").style.display ="block";
				document.getElementById("DisplayIncMessage").style.display ="block";
				if(document.AJAX.displaySecondschduler.value==1)
				{	
                                document.getElementById("DisplayIncMessage").style.display ="none";
                                document.getElementById("schdulerSecond").style.display="none";	
					document.AJAX.displaySecondschduler.value=0;	
				}
				else
				{	
					document.getElementById("DisplayIncMessage").style.display ="block";					
					document.getElementById("schdulerSecond").style.display="block";
					document.AJAX.displaySecondschduler.value=1;
				}
				
				document.getElementById("save1").disabled=false;
				document.getElementById("next").disabled=true;			
				document.AJAX.displayschduler.value=0;
		}
		return;
                document.getElementById("save1").disabled=false;
				document.getElementById("next").disabled=true;	
	}
	
	if(type=="1")
	{
		
		if(regex2.test(document.AJAX.Configname.value))
		{	<%messageIn=i18n.tr("Enter the configuration name");%>
            showErrorMessageLdap("<%=messageIn%>","Configname");
			return;
		}
		if(regex2.test(document.AJAX.hostName.value))
		{       <%messageIn=i18n.tr("Enter the host name");%>
            showErrorMessageLdap("<%=messageIn%>","hostName");
			return;
		}	
		document.getElementById("schduler").style.display ="block";
		document.getElementById("DisplayIncMessage").style.display ="none";
		document.getElementById("schdulerSecond").style.display="none";		
		document.getElementById("save").disabled=false;
                document.getElementById("save").className="addbuttons greenBtn";
		document.getElementById("next1").disabled=true;	
                document.getElementById("next1").className="domains genBtn whiteBtn";
	}
	
}
function removeDiv(selectedDivToDelete){
  var d = document.getElementById('addOuDiv');
  var olddiv = document.getElementById(selectedDivToDelete);
  d.removeChild(olddiv);
    
}
function showNotify()
{

    if(document.AJAX.checkNotify.checked)
    {
       document.getElementById('Notify_div').style.display='block';
    }
    else
    {
       document.getElementById('Notify_div').style.display='none';
    }

}
var filterCount = 0;
function addCustomOU(){
    if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==3 || document.AJAX.PARAMS_PROTOCOL_TYPE.value==4 || document.AJAX.PARAMS_PROTOCOL_TYPE.value==5){
        document.getElementById("profile").disabled=true;
        document.getElementById("OUListing").disabled=true;
        var groupName = document.getElementById("OUName").value.trim();
        if(groupName == ""){
            <%messageIn=i18n.tr("Please enter Group name");%>
            showErrorMessageLdap("<%=messageIn%>","OUName");
            return;
        }
        
        $j.ajax({
            url: "LdapConfig_TreeStructure?validateGroup=yes&groupName="+groupName+"&RuleID="+document.getElementById("profile").value,
            beforeSend: function( xhr ) {
                initProgress1();
            }
        }).done(function( data ) {
            var groupFoundOrNot = data;
            var tempArray = groupFoundOrNot.split(",");
            for (var i=0;i< tempArray.length;i++) {
                var group = tempArray[i].split("|&&|"); 
                groupName = group[1];
                if(group[0] == "yes"){
                    resetProgress2();
                    document.getElementById("profile").disabled=false;
                    document.getElementById("OUListing").disabled=false;            
                    document.getElementById("nextAzure").disabled=false;
                    document.getElementById("Add").disabled = false;
                    var divIdName = "OUdiv"+filterCount;

                    var newdiv = document.createElement('div');
                    newdiv.setAttribute("id",divIdName);
                    newdiv.setAttribute("class","aligncontent")

                    <%messageIn=i18n.tr("Delete OU");%>
                    newdiv.innerHTML = "<table border=\"0\" width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" height=\"25\"><tr><td width=\"20%\" class=\"formfield\" align='right' onclick=\"removeDiv('OUdiv"+filterCount+"')\"><span style=\"cursor: pointer\"><img src=\"fault_x.gif\" title=\"<%=messageIn%>\" class='deleteRule'>&nbsp;&nbsp;</span><input type=\"hidden\" name=\"newlyaddedOUs\" id=\"newlyaddedOUs\" value=\""+groupName+"\"/><input type=\"hidden\" name=\"newlyaddedGroupId\" id=\"newlyaddedGroupId\" value=\""+group[2]+"\"/></td><td width=\"80%\" class=\"formfield txtstyle1\" align=\"left\">"+groupName+"</td></tr></table>";
                    document.getElementById("addOuDiv").appendChild(newdiv);

                    filterCount++;
                    document.getElementById("OUName").value ="";


                    if(document.AJAX.newlyaddedOUs == undefined || document.AJAX.newlyaddedOUs == null){
                            document.getElementById("next").disabled=false;

                    }
                    if(document.getElementById("NotificationDiv").style.display == "block"){

                            document.getElementById("next").disabled=true;
                    }else{

                        document.getElementById("next").disabled=false;
                    }                
                }else{
                    resetProgress2();
                    document.getElementById("profile").disabled=false;
//                    document.getElementById("addOuDiv").innerHTML = "";
                    document.getElementById("OUListing").disabled=false;  
                    document.getElementById("OUName").value ="";
                    document.getElementById("nextAzure").disabled=false;                    
                    document.getElementById("nextAzure").className="addbuttons greenBtn";
                    document.getElementById("saveAzure").disabled=true;
                    document.getElementById("saveAzure").className="domains genBtn whiteBtn";
                    document.getElementById("Add").disabled = false;
                    document.getElementById("Add").className="addbuttons greenBtn";
                    document.getElementById("errorCustomMsg").style.display ="block";
                }
            }
        });
    }else{
    if(document.AJAX.PARAMS_OS_TYPE.value==2){
        document.getElementById("profile").disabled=true;
        document.getElementById("OUListing").disabled=true;
        var dc = document.getElementById("DomainControllerName").value.trim();
        if(dc==""){
           <%messageIn=i18n.tr("Please enter the domain controller name ");%>
            showErrorMessageLdap("<%=messageIn%>","DomainControllerName");
            return;
        }
        if(dc.indexOf(".")==-1){
            <%messageIn=i18n.tr("Please enter the domain controller name as specified in your server");%>
            showErrorMessageLdap("<%=messageIn%>","DomainControllerName");
            return;
        }
        var ouName = document.getElementById("OUName").value.trim();
        var fieldName= document.getElementById("OUNameField").innerHTML;
        if(ouName == "" && fieldName=="OU Name"){
            <%messageIn=i18n.tr("Please enter OU name");%>
            showErrorMessageLdap("<%=messageIn%>","OUName");
            return;
        } else if(ouName == "" && fieldName=="Group Name"){
            <%messageIn=i18n.tr("Please enter Group name");%>
            showErrorMessageLdap("<%=messageIn%>","OUName");
            return;
        }
        var listType ="";
        if(document.AJAX.PARAMS_PROTOCOL_TYPE.value==2 && document.AJAX.PARAMS_OS_TYPE.value==2 && document.getElementById("PARAMS_GSS_TYPE").value==0) {
            if (document.getElementById("importId1").checked == true) {
                listType = 1;
            } else if (document.getElementById("importId2").checked == true) {
                listType = 2;
            }
        }
        $j.ajax({
            url: "LdapConfig_TreeStructure?testOU=yes&DC="+dc+"&OU="+encodeURIComponent(ouName)+"&RuleID="+document.getElementById("profile").value+"&listType="+listType,
            beforeSend: function( xhr ) {
                initProgress1();
            }
        }).done(function( data ) {
            var ouFoundOrNot = data;        
            var tempAry = ouFoundOrNot.split("|&&|");        
            if(tempAry[0] == "yes"){
                resetProgress2();
                document.getElementById("profile").disabled=false;
                document.getElementById("OUListing").disabled=false;            
                document.getElementById("next").disabled=false;
                document.getElementById("Add").disabled = false;
				if(document.getElementById("error")!==null) {
                    document.getElementById("error").style.display = "none";
                }
                var divIdName = "OUdiv"+filterCount;

                var newdiv = document.createElement('div');
                newdiv.setAttribute("id",divIdName);
                newdiv.setAttribute("class","aligncontent")

                <%messageIn=i18n.tr("Delete OU");%>
                newdiv.innerHTML = "<table  id=\"newOU\" border=\"0\" width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" height=\"25\"><tr><td width=\"20%\" class=\"formfield\" align='right' onclick=\"removeDiv('OUdiv"+filterCount+"')\"><span style=\"cursor: pointer\"><img src=\"fault_x.gif\" title=\"<%=messageIn%>\" class='deleteRule'>&nbsp;&nbsp;</span><input type=\"hidden\" name=\"newlyaddedOUs\" id=\"newlyaddedOUs\" value=\""+ouName+"\"/></td><td width=\"80%\" class=\"formfield txtstyle1\" align=\"left\">"+ouName+"</td></tr></table>";
                document.getElementById("addOuDiv").appendChild(newdiv);


                filterCount++;
                document.getElementById("OUName").value ="";


                if(document.AJAX.newlyaddedOUs == undefined || document.AJAX.newlyaddedOUs == null){
                        document.getElementById("next").disabled=false;

                }
                if(document.getElementById("NotificationDiv").style.display == "block"){

                        document.getElementById("next").disabled=true;
                }else{

                    document.getElementById("next").disabled=false;
                }                
            }else{
                resetProgress2();
                document.getElementById("profile").disabled=false;
                document.getElementById("OUListing").disabled=false;  
                document.getElementById("OUName").value ="";
                if(tempAry[0] == "no"){
                    if(document.getElementById("Add").disabled){
                        document.getElementById("Add").disabled = false;
                    }
                    <%messageIn=i18n.tr("is not found in your domain controller");%>
                    showErrorMessageLdap(ouName+" <%=messageIn%> "+dc,"OUName");
                    return;
                }else{
                    document.getElementById("next").disabled=false;
 					document.getElementById("addOuDiv").innerHTML = "";
                     document.getElementById("next").className="domains genBtn whiteBtn";
                     document.getElementById("save1").disabled=false;
                    document.getElementById("save1").className="domains genBtn whiteBtn";
                    document.getElementById("Add").disabled = false;
                    document.getElementById("Add").className="addbuttons greenBtn";
                    if(tempAry[0] == undefined || tempAry[0] == "undefined" || tempAry[0] == ""){
                        tempAry[0] = "<%=i18n.tr("Failed to retrieve OU. Something wrong with cloud connector")%>";
                    }   
					if(document.getElementById("error")!==null) {
                        document.getElementById("error").style.display = "none";
                        document.getElementById("error").remove();
                    }					
                    var htmlcontents ="";
                    <% messageIn=i18n.tr("Error");%>
                    htmlcontents = "<table id=\"error\" border=\"0\" width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" height=\"25\" align=\"center\"style=\"display: block;\"><tr><td width=\"20%\" class=\"formfield bgTransparent\" align='right'><font color = \"Red\"><b> <%=messageIn%> :</b></font></td><td width=\"80%\" class=\"formfield erralign1\" align=\"left\">"+tempAry[0]+"</td></tr></table>";
                    document.getElementById("addOuDiv").innerHTML +=htmlcontents;
                    return;
                }
            }
        });
        
    }else{
          var ouName = document.getElementById("OUName").value.trim();
        var fieldName= document.getElementById("OUNameField").innerHTML;
        if(ouName == "" && fieldName=="OU Name"){
            <%messageIn=i18n.tr("Please enter OU name");%>
            showErrorMessageLdap("<%=messageIn%>","OUName");
            return;
        } else if(ouName == "" && fieldName=="Group Name"){
            <%messageIn=i18n.tr("Please enter Group name");%>
            showErrorMessageLdap("<%=messageIn%>","OUName");
            return;
        }
          document.getElementById("next").disabled=false;
                    document.getElementById("Add").disabled = false;
                var divIdName = "OUdiv"+filterCount;

                var newdiv = document.createElement('div');
                newdiv.setAttribute("id",divIdName);
                newdiv.setAttribute("class","aligncontent")
                <%messageIn=i18n.tr("Delete OU");%>
                newdiv.innerHTML = "<table id=\"newOU\" border=\"0\" width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" height=\"25\"><tr><td width=\"20%\" class=\"formfield\" align='right' onclick=\"removeDiv('OUdiv"+filterCount+"')\"><span style=\"cursor: pointer\"><img src=\"fault_x.gif\" title=\"<%=messageIn%>\" class='deleteRule'>&nbsp;&nbsp;</span><input type=\"hidden\" name=\"newlyaddedOUs\" id=\"newlyaddedOUs\" value=\""+ouName+"\"/></td><td width=\"80%\" class=\"formfield txtstyle1\" align=\"left\">"+ouName+"</td></tr></table>";
                document.getElementById("addOuDiv").appendChild(newdiv);
                
               
                filterCount++;
                document.getElementById("OUName").value ="";
             
                
                if(document.AJAX.newlyaddedOUs == undefined || document.AJAX.newlyaddedOUs == null){
                        document.getElementById("next").disabled=false;
                         
                }
                if(document.getElementById("NotificationDiv").style.display == "block"){
                    
                        document.getElementById("next").disabled=true;
                }else{
                    
                    document.getElementById("next").disabled=false;
                }
          }
}
}  

function emptyError(){
    if(document.getElementById("errorCustomMsg")) {
        document.getElementById("errorCustomMsg").style.display = "none";
    }
    if( document.getElementById("error")) {
        document.getElementById("error").style.display = "none";
    }
}
function showErrorMessageLdap(message,elementId){
    if(document.getElementById("newUICheck") !== null){
        var selecterJ = jQuery("#"+elementId);
        selecterJ.closest("td").addClass('posRelative');
        displayErrorMessage("#"+elementId, message);
        hideCalendarControl();
        if (jQuery("#"+elementId).next("div").hasClass("ms-parent")) {
            scrollTarget = jQuery("#"+elementId).next("div");
        } else {
            scrollTarget = jQuery("#"+elementId);
        }
        jQuery('html, body').animate({
            scrollTop: scrollTarget.offset().top - 100
        }, 500);
        if( selecterJ.next("div").hasClass("ms-parent")) {
            jQuery(".ms-parent").off('click').on('click', function () {
                selecterJ.next("div").removeClass('errField');
                selecterJ.closest("td").removeClass('posRelative');
                jQuery(".ms-parent").off('click');
                jQuery(".fldErr").remove();
            });
        }
        selecterJ.click(function(){
            removeMessage(elementId);
        })
        selecterJ.on('input',function(){
            removeMessage(elementId);
        });
    }else{
        alert(message);
        document.getElementById(elementId).focus();
    }
}
function displayAlertPopUpMsg(messageIn){
    if(document.getElementById("newUICheck") !== null){
        displayUserMessageAlter(messageIn,0);
        var offset = jQuery('.confirmBlk').offset().top - 100;
        jQuery('html, body').animate({
            scrollTop: offset
        }, 500)
        jQuery("#okayBtn").on("click", function () {
            jQuery(".confirmBlk").slideUp();
        });
    }else{
        alert(messageIn);
    }
}
</script>



<script type="text/javascript" src="cookies.js"></script>

<%!
   private static final Log logger1 = LogFactory.getLog(Constant.SAPPHIRE_LOGGER);
  
%>

<%@ include file="AJAXPopup.jsp" %>
</head>


<%

	
	response.setDateHeader ("Expires", 0); 


%>


<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >


 
<%@ include file="toptable.jsp" %>  
  
<div id="mainContentArea1" class="ldapConfigMain">
<form id="AJAX" name="AJAX" method="post" action="LDAPImpotUser" >
<security:csrfInput/>
    <input type="hidden" id="showNewUiAlert">
<table width="100%" height="70%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" align="center" valign="top" class="inbg">
      <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
        <tr align="center" valign="top"> 
          <td colspan="3"> 
           



    <table width="100%"  border="0" cellpadding="0" cellspacing="0">
        
        <tr>
       
          <td valign="top">

   <!---channged to new template-->
   
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" align="center" valign="top">
   
        
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
               <tr> 
	                <td colspan="3">
	                <table width="100%" width="100%" border="0" cellspacing="0" cellpadding="0">

<tr> 

     <td>
<div style="width:99.5%" > 
       <table width="100%" border="0" cellspacing="0" cellpadding="0" id="subTabNavigation">
	 <tr>
	   <td height="24" valign="bottom">
	   <table width="150" border="0" cellspacing="0" cellpadding="0" class="wid100">
	       <tr>
		 <td><ul><li class="selected"><a href="#" ><%=i18n.tr("LDAP Configuration")%></a><span></span></li></ul>

		 </td>
		 
</tr>
</table>

</td>
</tr>


	
 </table>
</div>
</td>
</tr>
    <td >
    <div class="contentBlock noMargin"> 
    <div class="widgetOuterWrapper"> 
    <div class="widgetInnerWrapper"> 
           <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr >
                   
                 <td valign="top" class="wid100">
                    <table width="100%" border="0" cellspacing="0" cellpadding="4" class="formfield bgTransparent">
                        <c:if test="${NEW_UI_CHECK ne null}">
                            <tr>
                                <td class="BlockDiv" ><div class="confirmBlk hideTable"  style="width:100%!important;"></div></td>
                            </tr>
                        </c:if>
                        <tr>
                            <td height='25' class='copyhdr leftPadd' colspan='3'>
                                <%=i18n.tr("LDAP Configuration")%>
                            </td>
                        </tr>
                        <tr>
                            <td class="formfield wid100 noPadding" colspan="3">
                                <table width="100%"><tr>
                             <td width="20%" align="right"  class="formtext"><%=i18n.tr("Configuration Name")%><font color="red">*</font></td>
                             <td width="45%" align="left"  class="formfield wid100 ldapError"><input name="Configname" id="Configname" type="text" class="mcopy" size="45" ></td>
                             <input type="Hidden" name="SelectedOU" id="SelectedOU" value=""/>
                              <td class="border wid100 floatLeft noBorder" width="35%"  valign="top"  >
                                
                                 <table class="formfield bgTransparent">
                                    <tr>
                                       <td class="generalNote noTopMargin noLeftMargin">
                                           <img src='Note.gif'/><font class="domains"><%=i18n.tr("Default User Role")%>:</font>
                                          <br>
                                              <br>
                                       </td>
                                   </tr>
                                   <tr class="formfield bgTransparent generalNote noLeftMargin">
                                       <td>
                                           <%=i18n.tr("The default behaviour will map all LDAP users to Users role. Selecting a role will always map the users to the selected role.")%>
                                           <%=i18n.tr("LDAP sync and local role changes will not be preserved.")%>
                                       </td>
                                   </tr>
                                 </table>
                             </td>
                        </tr></table></td></tr>
                                
    			<tr class="topMargin5">
                            <td width="20%" align="right"  class="formtext"><%=i18n.tr("Default User Role")%></td>
                            <td width="80%" align="left"  class="formfield wid100">
                                                <table border="0">
                                                    <tr>
                                                        <td width="15%" align="left"  class="domains setwid1">
                         <select name="ldapprofileid" id="ldapprofileid" class="mcopy">
                             <option value="0" selected>---<%=i18n.tr("choose")%>---</option>
					    <%
						
								connection myConn = null;
								Connection conn   = null;
								PreparedStatement pstmt = null;
								ResultSet rs      = null;	

								   try{	

									myConn = new connection();
									conn = myConn.getConnection(telantName);
                                                                        pstmt=conn.prepareStatement("SELECT AccessID,AccessType FROM usermgmt_details");
                                                                        rs=pstmt.executeQuery();
                                                                        while(rs.next()){
                                                                        %>
                                                                        <option value="<%=rs.getString(1)%>"><%=i18n.tr(rs.getString(2))%></option>
                                                                        <%
                                                                        }rs.close(); pstmt.close();
					    		 %>
                                                    </select>
                                                            <c:if test="${NEW_UI_CHECK ne null}">
                                                                <script type="text/javascript">
                                                                    jQuery(function(){
                                                                        jQuery("#ldapprofileid").multipleSelect({
                                                                            single:true,
                                                                            filter:true
                                                                        });
                                                                    });
                                                                </script>
                                                            </c:if>
                                                        </td>
                                                    
                                                    </tr>
                                                </table>
                                                    </td>
			          </tr>
                                      <tr>
     					<td width="20%" align="right"  class="formtext topMargin5"><%=i18n.tr("LDAP Rule")%><font color="red">*</font></td>
					    <td width="80%" align="left"  class="formfield wid100 ldapError setwid1">
					     <select name="profile" id="profile" class="mcopy" onchange="ProfileMatching()">
                                                 <option value="">---<%=i18n.tr("Choose")%>---</option>
					    <%
						
								
									int Config_name_count=0;
									pstmt=conn.prepareStatement("SELECT distinct LdapConfigMasterID, LdapConfigurationName FROM ldapconfigmaster");
                                                                        rs=pstmt.executeQuery();
									while(rs.next()){
	
								 %>
					   
					    <option value="<%=rs.getString(1)%>"><%=rs.getString(2)%></option>
					    		 <%}rs.close();	pstmt.close();				 							
					    		 %>
					    </select>
                            <c:if test="${NEW_UI_CHECK ne null}">
                                <script type="text/javascript">
                                    jQuery(function(){
                                        jQuery("#profile").multipleSelect({
                                            single:true,
                                            filter:true
                                        });
                                    });
                                </script>
                            </c:if>
					    <%
					    		String jobname="";
					    		pstmt=conn.prepareStatement("Select JobName from jobsmaster jm,jobsmasterdetail jmd where jm.SchedularID=jmd.SchedularID and jmd.jobtypeid=17016 and jm.IsVisible=1");
                                                        rs=pstmt.executeQuery();
					    		while(rs.next())
					    		{
					    		jobname=rs.getString(1);
					    		%>
					    		<input type="hidden" name="Config_name_exits" id="Config_name_exits" value="<%= jobname %>" >
					    		<%
					    		Config_name_count++;
					    		}rs.close(); pstmt.close();
					    		
					    %>
					    		
					    		<input type="hidden" name="Config_temp_title_count" id="Config_temp_title_count" value="<%= Config_name_count %>" >
					    		
					 
					    				    
					    </td>
                                      </tr>
                        <tr>
                                        <td colspan="3" class="wid100 topMargin5 floatLeft">
                            <div id="OUImportFrom" name="OUImportFrom" style=" display:  none">

                                <table width="100%">
                                    <tr>
                                        <td width="20%" align="right"  class="formtext"><%=i18n.tr("Import from")%></td>
                                        <td width="80%" align="left"  class="formfield">
                                            <table>
                                                <tr>
                                                    <td>
                                                    <td  class="gen">
                                                    <input type="radio" id="importId1" name="importId" value="1" class="mcopy" checked onclick="selectImportFrom()"/>
                                                    <label class="customRadCheck" for="importId1"><span><span></span></span></label>
                                                    <td style="padding: 3px"> <span class="notifyLabel"><%=i18n.tr("OU")%></span></td>
                                                    </td>
                                                    <td  class="gen">
                                                        <input type="radio" id="importId2" name="importId" value="2" class="mcopy" onclick="selectImportFrom()"/>
                                                        <label class="customRadCheck" for="importId2"><span><span></span></span></label>
                                                    <td style="padding: 3px"> <span class="notifyLabel"><%=i18n.tr("Group")%></span></td>
                                                    </td>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            </td>
                        </tr>

                                     <tr>
                                        <td colspan="3" class="wid100 topMargin5 floatLeft">
                                            <div id="OUListingRule" name="OUListingRule" style=" display:  none">
                                              <table width="100%">
                                                <tr>
                                                        <td id="OUListingName" width="20%" align="right" class="formtext">
                                                            <%=i18n.tr("Organizational Unit")%>
                                                        </td>
                                                    <td width="80%" align="left"  class="formfield ldapError1 setwid1">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <select name="OUListing" id="OUListing" class="mcopy" onchange="ValidateExe()">
                                                                        <option value="">----<%=i18n.tr("Choose")%>----</option>
                                                                        <option value="0"><%=i18n.tr("List")%></option>
                                                                        <option value="1"><%=i18n.tr("Custom")%></option>
                                                                    </select>
                                                                    <c:if test="${NEW_UI_CHECK ne null}">
                                                                        <script type="text/javascript">
                                                                            jQuery(function(){
                                                                                jQuery("#OUListing").multipleSelect({
                                                                                    single:true,
                                                                                    filter:true
                                                                                });
                                                                            });
                                                                        </script>
                                                                    </c:if>
                                                                    <span id="progressMsg" style="display:none;float:right;margin-left:5px"><img alt="Indicator" src="<%=request.getContextPath()%>/img/indicator.gif" /> <%=i18n.tr("Loading")%>...
                                                                    </span>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>                                                    
                                                </tr>
                                              </table>
                                            </div>
                                        </td>
                                      </tr>   
                                        <tr>
                                         <td colspan="3" class="wid100">
                                         <div id="LDAPCustomOU" name="LDAPCustomOU" style=" display:  none">
                                           <table width="100%" border="0">
                                               <tr>
                                                   <td colspan="3" class="wid100">
                                                       <table width="100%" border="0">
                                                           <tr>
                                                               <td colspna="3" class="wid100">
                                                                   <div id="DomainController" name ="DomainController" style=" display:  none">
                                                                       <table width="100%" border="0">
                                                                           <tr>
                                                                <td width="20%" align="right" class="formtext topMargin5">
                                                                  <%=i18n.tr("Domain Controller")%><font color="red">*</font>
                                                                </td>
                                                                <td  width="45%" align="left"  class="formfield wid100 ldapError4">
                                                                    <input type="text" name="DomainControllerName" id="DomainControllerName" value=""/>
                                                                </td>
                                                                <td class="border wid100 floatLeft noBorder autoHt" width="35%" height="15">
                                
                                                                  <table class="formfield bgTransparent wid100 applytBody100">
                                 
                                                                     <tr>
                                                                        <td class="generalNote noLeftMargin">
                                                                            <img src='Note.gif'/><font class="domains noLeftMargin"><%=i18n.tr("Domain Controller")%>:</font>
                                                                           <br>
                                                                               <br>
                                                                        </td>
                                                                    </tr>
                                                                    <tr class="formfield bgTransparent generalNote noLeftMargin noPadding">
                                                                        <td>
                                                                            <%=i18n.tr("Enter the domain controller name as specified in active directory.")%><br/><br/>
                                                                            <%=i18n.tr("Example")%>: <font color='blue' class="floatNone"><b><%=i18n.tr("domainname.co.in")%></b></font><br/><br/>
                                                                        </td>
                                                                    </tr>
                                                                  </table>
                                                              </td>
                                                         </tr>
                                                                        </table>
                                                                        </div>
                                                                        </td>
                                                                        </tr>
                                                       </table>
                                                   </td>
                                               </tr>
                                                 <tr>
                                                    <td id="customOU" height="25"  class='copyhdr leftPadd wid100' colspan='3' >
                                                         <%=i18n.tr("Custom OU")%>
                                                    </td>
                                                </tr>          
                                               <tr>
                                                   <td id="OUNameField" width="20%" align="right" class="formtext">
                                                     <%=i18n.tr("OU Name")%>
                                                   </td>
                                                   <td  width="45%" align="left"  class="formfield ldapError1">
                                                       <input type="text" name="OUName" id="OUName" value="" size="45" onfocus="emptyError()"/>
                                                       <%messageIn=i18n.tr("Add OU");%>
                                                       <input  type="button"  name="Add" id="Add" value="<%=messageIn%>"  class="addbuttons"  onclick="addCustomOU()">
                                                       &nbsp;
                                                       <span id="progressMsg1" style="display:none;">
                                                           <img alt="Indicator" src="<%=request.getContextPath()%>/img/indicator.gif" /> <%=i18n.tr("Loading")%>...
                                                        </span>
                                                   </td>
                                                   <td class="border wid100 floatLeft noBorder autoHt" width="35%"  valign="top"  >
                                                        <table class="formfield bgTransparent wid100 applytBody100">

                                                           <tr>
                                                              <td class="generalNote noLeftMargin">
                                                                  <img src='Note.gif'/><font class="domains noLeftMargin" id="customNote"><%=i18n.tr("Custom OU")%>:</font>
                                                                 <br>
                                                                     <br>
                                                              </td>
                                                          </tr>
                                                          <tr class="formfield bgTransparent generalNote noLeftMargin noPadding">
                                                              <td id="customounote" name="customounote">
                                                                  <%=i18n.tr("Add OU's as comma separated, from which user(s) has to be imported.")%><br/><br/>
                                                                  <%=i18n.tr("Eg")%>: <font color='blue' class="floatNone"><b>[ <%=i18n.tr("OU from which user(s) has to be imported")%> ] , [<%=i18n.tr("Sub OU 1")%> ] , [ <%=i18n.tr("Sub OU 2")%> ] , . . . . . , [ <%=i18n.tr("Parent OU")%> ]</b></font><br/><br/>
                                                                  <%=i18n.tr("On adding, OU validation will happen against active directory.")%>
                                                              </td>
                                                          </tr>
                                                        </table>
                                                   </td>
                                               </tr>
                                               <tr>
                                                   <td colspan="2">
                                                       <div id="errorCustomMsg" name ="errorCustomMsg" style="display:none">
                                                            <table border="0" width="100%" cellspacing="2" cellpadding="2" height="25" align="center">
                                                                <tr>
                                                                    <td width="50%" class="formfield textalignLeft widAuto" align='right'>
                                                                        <font color = "Red" class="noLeftMargin"><b> Error :</b></font>
                                                                    </td>
                                                                    <td width="80%" class="formfield textalignLeft widAuto erralign1" align="left">Entered Group Name not found
                                                                    </td>
                                                                </tr>

                                                           </table>
                                                        </div>
                                                    </td>
                                                </tr>
                                               <tr>
                                                <td colspan="6">
                                                    <table border="0" width="100%" cellspacing="0" cellpadding="0">
                                                        <tr id="organizationunitheader" name="organizationunitheader">
                                                            <td width="20%" class="copyhdr"  align="left"><%=i18n.tr("Organizational&nbsp;Unit")%> </td>
                                                            <td width="80%" class="copyhdr"  align="left">&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2">
                                                                <div id="addOuDiv">
                                                                    
                                                                    
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                           </table>
                                        </div>
                                   </td>
                               </tr>
                                             <input type="hidden" name ="hostName" id="hostName" value=""/>
                                             <input type="hidden" name ="port" id="port" value=""/>
                                             <input type="hidden" name ="filter" id="filter" value=""/>
                                             <input type="hidden" name ="Chk2" id="Chk2" value=""/>
                                                
    <table width="100%" border="0" cellspacing="0" cellpadding="0"  valign="bottom">
        <tr>
            <td height="25" id="ShowOragnizationaltab"  style="display:none" class='copyhdr leftPadd wid100' colspan='2' >
                <br class="hiddenDisplay">
             <%=i18n.tr("Organizational Unit")%>
            </td>
            </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0"  >
		 <tr class="formfield bgTransparent">
                     <td width="20%" class="hiddenDisplay"></td>
			<td width="45%">
			  <div  id='wintree' style="width:100%">
					<input type="hidden"  name="status_enable" value=""/>
			  </div>
			 </td>
                     <td width="35%" class="hiddenDisplay"></td>
		   </tr>
	 </table>
	 
	 
	         
              <div id="NotificationDiv" name="NotificationDiv" style='display:none;width:"98%"'>
                 
                    <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
                    <tr>
                        <td height="25"  class='copyhdr leftPadd' colspan='3' >
                             <%=i18n.tr("Notification")%>
                        </td>
                    </tr>
                    <tr>
                        <td width="20%" align="right"  class="formtext"><%=i18n.tr("Notify On User Status Change/Task Finished")%></td>
                         <td width="45%" align="left"  class="formfield">
                            <input type='checkbox' name='checkNotify' id='checkNotify' value='' onclick='showNotify()'>
                            <label class="customRadCheck" for="checkNotify"><span><span></span></span></label>&nbsp;
                        </td>
                         <td class="border wid100 floatLeft noBorder autoHt" width="34%"  valign="top"  >
                                 <table class="formfield bgTransparent wid100 applytBody100">
                                             <tr>
                                                <td class="generalNote noLeftMargin">
                                                    <img src='Note.gif'/><font class="domains noLeftMargin"><%=i18n.tr("User status alert notification")%>:</font><br><br>
                                                </td>
                                            </tr>
                                            <tr class="formfield bgTransparent generalNote noLeftMargin noPadding">
                                                <td>
                                                    <%=i18n.tr("Enable global settings to get notification on change of user status.")%>
                                                    <%=i18n.tr("Setting key - LDAP user status alert notification")%>
                                                    <%=i18n.tr("Category")%>- <%=i18n.tr("ServiceDesk")%>
                                                </td>
                                            </tr>
                                 </table>
                         </td>
                    </tr>
                </table>
                     
              </div>
                       
            <div id="Notify_div" name="Notify_div" style="display:none">
                <table border ="0" width="100%">
                    <tr>
                        <td width="20%" align="right"  class="formtext"><%=i18n.tr("Notify To")%><font color="red">*</font></td>
                        <td width="80%" align="left"  class="formfield ldapError1 setwid1">
                            <select id='Notify' name='Notify' class='mcopy'   style="width:200px">
                                <option value="">-----<%=i18n.tr("Choose")%>-----</option>
                                <% pstmt=conn.prepareStatement("SELECT NotifyID, DisplayName  FROM notify_detail where siteid =1");
                                   rs = pstmt.executeQuery();
                                   while(rs.next()){%>
                                     <option value="<%= rs.getString(1)%>"><%=rs.getString(2) %></option>
                                   <% }rs.close(); pstmt.close(); %>
                           </select>
                            <c:if test="${NEW_UI_CHECK ne null}">
                                <script type="text/javascript">
                                    jQuery(function(){
                                        jQuery("#Notify").multipleSelect({
                                            single:true,
                                            filter:true
                                        });
                                    });
                                </script>
                            </c:if>
                        </td>
                    </tr>
             </table>
          </div>
                           
                   
	   <%}catch(Exception e){
								
                logger1.error("Exception occurred in Ldap_Config.jsp ***** "+e.getMessage(),e);
                

            }finally{

            try
            {
                     if(pstmt!=null)
                        pstmt.close();
                         if(conn!=null)
                         conn.close();
            }catch(Exception ex){
                logger1.error("Exception occurred in Ldap_Config.jsp(finally block) ***** "+ex.getMessage(),ex);
                
            }

          } %>

                <div  id='schdulerSecond' name='schdulerSecond' style="display:none;">		
			 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
                              <tr>
                                    <td height='25' class='copyhdr leftPadd posRelativeInput' colspan='4' >
                                       <%=i18n.tr("Incremental Sync Scheduler")%>&nbsp;
                                          &nbsp;&nbsp;&nbsp;&nbsp;
                                         <input type="radio" id="IncSync" name="LDAPConfig_IncSync" value="1" checked onclick="showIncSync(this.value)"/><label class="customRadCheck topMargin10" for=""><span><span></span></span></label><span class="notifyLabel"><%=i18n.tr("Enable")%></span>
                                           &nbsp;&nbsp;&nbsp;&nbsp;
                                        <input type="radio" id="IncSync" name="LDAPConfig_IncSync" value="0" onclick="showIncSync(this.value)"/><label class="customRadCheck topMargin10" for=""><span><span></span></span></label><span class="notifyLabel"><%=i18n.tr("Disable")%></span>

                                      </td>
                                </tr>
                             
			 	<tr>
                                 
			 		<td  colspan="2" class="formfield wid100">
			 			<table width="100%" border="0" cellspacing="0" cellpadding="0" >
			 				<tr>
			 					
			 					<td width="60%" align="left" class="wid100">
                                                                    <br class="hiddenDisplay">				
                                                                <% messageIn = i18n.tr("Incremental Sync");%>                                                                            
                                                                    <jsp:include page="/Scheduler.jsp"> 
                                                                        <jsp:param name="SchedulerInfoID" value="" />	 	      	 	              
                                                                        <jsp:param name="FirstSchedulerDisplayName" value="<%=messageIn%>" />
                                                                        <jsp:param name="RetryCount" value="0" />
                                                                        <jsp:param name="RetryInterval" value="15" />
                                                                        <jsp:param name="isLDAPIncrementalSync" value="yes" />
                                                                    </jsp:include>
			 					</td>				
			 				</tr>
			 			</table>
			 		</td>	
		 			<td class="formfield" width="35%" align="left">
                                            <br class="hiddenDisplay">
		 				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="border noBorder">
			 				<tr>
				 				<td bgcolor="#FFFFFF" class="domains">
                                                                    <div>
					 				<tr class="formfield bgTransparentImp">
                                                                                        <td>
                                                                                            <br class="hiddenDisplay">
                                                                                            <font class="domains generalNote"> <img src='Note.gif'/>&nbsp;<%=i18n.tr("Incremental Sync Configuration")%>:</font>
                                                                                           <br>
                                                                                           <br>
                                                                                        </td>
                                                                                    </tr>
                                                                                    <tr class="formfield bgTransparentImp">
                                                                                        <td class="generalNote">
                                                                                              <%=i18n.tr("All users will be fetched when configuration is created for the first time.Incremental sync will add the new users which are created in AD as well as it will update the existing user info if anything got changed in AD.")%>
                                                                                                
                                                                                        </td>
                                                                                    </tr>  
                                                                    </div>
				 				</td>
							</tr>
						</table>
                                                <br>
		 			</td>			 		
			 	</tr>
                             <tr>
                                 <td>&nbsp;</td>
                             </tr>    
			</table>
		</div>
		<div  id='schduler' name='schduler' style="display:none;">
                    
			 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 		
			 	
                                    <tr>
                                    <td height='25' class='copyhdr leftPadd posRelativeInput' colspan='4'>
                                      <%=i18n.tr("Full Sync")%>&nbsp;Scheduler&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
                                        &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="IncSync" name="FullSync" value="1" checked onclick="showFullSync(this.value)"/><label class="customRadCheck" for=""><span><span></span></span></label><span class="notifyLabel lineNormal topMargin8"><%=i18n.tr("Enable")%></span>
                                           &nbsp;&nbsp;&nbsp;&nbsp;
                                        <input type="radio" id="FullSync" name="FullSync" value="0" onclick="showFullSync(this.value)"/><label class="customRadCheck" for=""><span><span></span></span></label><span class="notifyLabel lineNormal topMargin8"><%=i18n.tr("Disable")%></span>
                                    </td>
                                </tr>
                             <tr>
                                 
			 		<td  colspan="2" class="formfield wid100">
			 			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			 				<tr>
			 					
			 					<td width="60%" align="left" class="wid100">
			 						<br class="hiddenDisplay">	
                                                                <% messageIn = i18n.tr("Full Sync");%>
                                                                    <jsp:include page="/Ldap_Schedular.jsp"> 
                                                                      <jsp:param name="SchedulerInfoID" value="" />
                                                                      <jsp:param name="SecondSchedulerDisplayName" value="<%=messageIn%>" />
                                                                      <jsp:param name="RetryCount" value="0" />
                                                                      <jsp:param name="RetryInterval" value="15" />
                                                                   </jsp:include>
			 					</td>
			 				</tr>
			 			</table>
			 		</td>
                                
		 			<td width="35%" align="left" class="formfield">
		 				<table width="100%" border="0" cellspacing="0" cellpadding="0"  class="border noBorder">
			 				<tr>
				 				<td >
				 					<div id="DisplayIncMessage" name="DisplayIncMessage" style="display:none;">
                                                                        <tr class="formfield bgTransparentImp">
                                                                            <td>
                                                                                <br>
                                                                                <font class="domains generalNote"> <img src='Note.gif'/>&nbsp;<%=i18n.tr("Full Sync Configuration")%>:</font>
                                                                               <br>
                                                                               <br>
                                                                            </td>
                                                                        </tr>
                                                                        <tr class="formfield bgTransparentImp">
                                                                            <td class="generalNote">
                                                                                      <%=i18n.tr("Full sync will import the users from the selected OU's and")%> 
                                                                                      <%=i18n.tr("update all the user details.")%>  
                                                                            </td>
                                                                        </tr> 
                                                                                                                    </div>
                                                                                                                    &nbsp;
                                                                                                            </td>
                                                                                                    </tr>
                                                                                            </table>										         
                                                                                    </td>					
                                                                            </tr>
                                                                     </table>         
	    </div>
		 
		 
		<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"> 
		  <tr id='unixdiv'  style="display:none" >			
				<td width="40%">
		  		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		  		</td>
		  <td width="60%" align="center">
                      
				<br>
                                    <%messageIn=i18n.tr("Next");%>
                                    <input  type="button"  onClick="ShowADSI()" name="next1" id="next1" value="<%=messageIn%>"  class="domains" />
                                    <%messageIn=i18n.tr("Save");%>
                                    <input  type="button"  onClick="validate()" name="save" id="save" value="<%=messageIn%>"  class="domains"  disabled/>
                                    <%messageIn=i18n.tr("Cancel");%>
                                    <input  type="button"  ONCLICK="javascript:history.back()" value="<%=messageIn%>"  class="addbuttons" />
                     
			</td>
		  </tr>
		                				          
      </table>
      
      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
		  <tr id='azurediv' class="basicButtonFooter" style="display:none" >
				<td width="40%" class="hiddenDisplay">
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              </td>
              <td width="25%">
                  &nbsp;
              </td>

              <td width="55%"align="left" style="margin-right: -315px;">
                      
				<br>
                                    <%messageIn=i18n.tr("Next");%>
                                    <input  type="button"  onClick="ShowAzure()" name="nextAzure" id="nextAzure" value="<%=messageIn%>"  class="domains " />
                                    <%messageIn=i18n.tr("Save");%>
                                    <input  type="button"  onClick="validate()" name="saveAzure" id="saveAzure" value="<%=messageIn%>"  class="domains"  disabled/>
                                    <%messageIn=i18n.tr("Cancel");%>
                                    <input  type="button"  ONCLICK="javascript:history.back()" value="<%=messageIn%>"  class="addbuttons" />
                     
			</td>
		  </tr>
		                				          
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
      <tr id='windiv3'  style="display:block"  class="basicButtonFooter">
		  		<td width="20%" class="hiddenDisplay">
		  		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		  		</td>
          <td width="25%" class="hiddenDisplay">
              &nbsp;
          </td>
		  		
		<td width="55%"align="left">
				<br class="hiddenDisplay">
                                    <%messageIn=i18n.tr("Next");%>
                                    <input  type="button"  name="next" id="next" value="<%=messageIn%>"  class="addbuttons greenBtn"  onclick="ShowLDAP()" />
									<%messageIn=i18n.tr("Save");%>
                                    <input  type="button"  onClick="validate()" name="save1" id="save1" value="<%=messageIn%>"  class="domains genBtn whiteBtn"  disabled/>
					<input type="hidden" name="displayschduler" id="displayschduler" value='0'/>
					<input type="hidden" name="displaySecondschduler" id="displaySecondschduler" value='0'/>
                                        <%messageIn=i18n.tr("Cancel");%>
                                        <input  type="button"  ONCLICK="javascript:history.back()" value="<%=messageIn%>"  class="addbuttons" />
				</td>
			</tr> 
      </table>
		
		
          		<!-- Code Ends Here -->
          		
          		
		</td>
		</tr>
                                    
	  </table>
       </div></div></div>
	  
	
	<br>     <input type="HIDDEN" name ="PARAMS" id="PARAMS" value="" />
                 <input type="HIDDEN" name ="PARAMS_PROTOCOL_TYPE" id="PARAMS_PROTOCOL_TYPE" value="" />
                 <input type="HIDDEN" name ="PARAMS_OS_TYPE" id="PARAMS_OS_TYPE" value="" />
                 <input type="HIDDEN" name ="PARAMS_GSS_TYPE" id="PARAMS_GSS_TYPE" value="<%=gssAuthentication%>" />
  </td>
<c:if test="${NEW_UI_CHECK ne null}">
    <tr>
        <td class="BlockDiv"> <div class="hideTable" >  <a id="myanchor" href="#scrollable">click here</a> </div> </td>
    </tr>
</c:if>
</table>
                                   <div class="widgetFooter"></div>   
</td>
</tr>
<tr>
<td colspan="2" align="right" class="hiddenDisplay">
<img src="spacer.gif" width="1" height="12">

</td>
</tr>

</table>
      </table>
    </td>
  </tr>
</table>
         
  </td>
       
      
      
      </table>
      </td>
 
 
 </tr>
</table>
</tr>
</table>                    
 
                </tr>
                    <tr> 
                      <td colspan="3" align="right" class="hiddenDisplay"><img src="spacer.gif" width="1" height="12"></td>
                    </tr>
                  </table> 
			   </td>
                   <td width="8" valign="top"><img src="spacer.gif" width="8" height="1" class="hiddenDisplay"></td>
              </table>
			  </td>
            </tr>
      </table>
    </td>
  </tr>

   <tr>
    <td>
      
	   <div id="errorMsg" style="display:none;border:1px solid #e00;background-color:#fee;padding:20px;margin-top:25px;width:350px;font:normal 12px Arial;color:#900"></div>

    </td>
  </tr>

</table>
</form>
</div>
<%@ include file="Sapphire_Footer.jsp" %>
</body>
</html>

</div>
