<apex:page id="Page" controller="SearchVisitorController" sidebar="false" showHeader="false" >
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <!-- 20220217 Li Jun for PIPL start -->
    <apex:includeScript value="{!URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
    <!-- 20220217 Li Jun for PIPL End -->
    <script type="text/javascript">
        AWSService.sfSessionId = '{!GETSESSIONID()}';
        function addContact(){
            window.opener.showModal();
            
            var setVisitor = new Array();

            setVisitor[0] = new Array();
            setVisitor[0][0] = '{!id1}';
            setVisitor[0][1] = '{!hId1}';
            
            setVisitor[1] = new Array();
            setVisitor[1][0] = '{!id2}';
            setVisitor[1][1] = '{!hId2}';
                
            setVisitor[2] = new Array();
            setVisitor[2][0] = '{!id3}';
            setVisitor[2][1] = '{!hId3}';

            setVisitor[3] = new Array();
            setVisitor[3][0] = '{!id4}';
            setVisitor[3][1] = '{!hId4}';

            setVisitor[4] = new Array();
            setVisitor[4][0] = '{!id5}';
            setVisitor[4][1] = '{!hId5}';
            
            var sltList = new Array();
            var j = 0;

            for(var i=0; i<5; i++){
                if(j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddHiddenId')).value() != ''){
                    sltList[j] = new Array();
                    //Add by Li Jun for PIPL 20220218 Start
                    let accountId = j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddHiddenId')).value();
                    sltList[j][0] = contactInfo[sfIdToAWSIdMapValue.get(accountId)].lastName;
                    //Add by Li Jun for PIPL 20220218 End
                    //sltList[j][0] = document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddName').innerHTML; // Commented by Li Jun for PIPL
                    sltList[j][1] = accountId;
                    j++;
                }
            }
            
            for(var i=j; i<5; i++){
                sltList[j] = new Array();
                sltList[j][0] = '';
                sltList[j][1] = '';
                j++;
            }
            
            for(var a=0; a<5; a++){
                //Updated by Li Jun 20220228
                if(window.opener.document.getElementById(setVisitor[a][0])&&window.opener.document.getElementById(setVisitor[a][1])){
                    window.opener.document.getElementById(setVisitor[a][0]).value = sltList[a][0];
                    window.opener.document.getElementById(setVisitor[a][1]).value = sltList[a][1];
                }               
            }

            window.close();
        }
        
        function sltContact(index){
            var addId = j$(escapeVfId('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idHiddenId')).value();
            var addName = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idName').innerHTML;
            var addDep = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idDep').innerHTML;
            var addJob = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idJob').innerHTML;
            var addPhone = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idPhone').innerHTML;
            var addMyDr = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idMyDr').innerHTML;
            var addPlease_Delete = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idPlease_Delete').innerHTML;
            
            for(var i=0; i<5; i++){
                if(j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddHiddenId')).value() == addId){
                    alert('{!$Label.Error_Message45}');
                    return;
                }
            }
                    
            for(var i=0; i<5; i++){
                if(document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddName').innerHTML == '　'){
                    j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddHiddenId')).val(addId);
                    document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddName').innerHTML = addName;
                    document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddDep').innerHTML = addDep;
                    document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddJob').innerHTML = addJob;
                    document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddPhone').innerHTML = addPhone;
                    document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddMyDr').innerHTML = addMyDr;                  
                    break;
                }
            }
        }
        
        function delContact(index){
            j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddHiddenId')).val("");
            document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddName').value = null;
            document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddName').innerHTML = '　';
            document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddDep').innerHTML = '　';
            document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddJob').innerHTML = '　';
            document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddPhone').innerHTML = '　';
            document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddMyDr').innerHTML = '<img src=\"/img/checkbox_unchecked.gif\" width=\"16\" height=\"16\" class=\"checkImg\" />';
        }

        //Add By Li Jun 20220228 Start for PIPL
        // var sfIdToAWSContact = new Object();
        var staticResources = JSON.parse('{!staticResource}');
        var contactAWSIds = JSON.parse('{!contactAWSIds}');
        var searchByLastName = '';
        var contactInfo = {};
        var sfIdToAWSIdMapValue = new Map();
        var aws_result = {};
        var selectedEditIndex = 0;
        var selectedAwsDataId = '';
        searchContactAll();
        function preparePayloadForSearchContact(){
            let searchPayload = new Object();
            searchPayload.dataIds = contactAWSIds;
            searchPayload.contactName = searchByLastName;
            return JSON.stringify(searchPayload);
        }

        //Search Contact From AWS
        function searchContactAll(){
            let data = preparePayloadForSearchContact();
            let searchCallBack = function searchCallBack(result){
                let contacts = result.object;
                if(contacts == null){
                    return;
                }
                for(var i=0;i<contacts.length;i++){
                    let temp = {}
                    temp.lastName = contacts[i].lastName?contacts[i].lastName:'';
                    temp.phone = contacts[i].phone?contacts[i].phone:'';
                    temp.doctorDivision1 = contacts[i].doctorDivision1? contacts[i].doctorDivision1:'';
                    temp.type = contacts[i].type? contacts[i].type:'';
                    contactInfo[contacts[i].dataId] = temp;
                    if(contacts[i].sfRecordId){
                        sfIdToAWSIdMapValue.put(contacts[i].sfRecordId,contacts[i].dataId);
                    }                    
                }
                console.log('AWS Contact Result:'+JSON.stringify(contactInfo));
            };
            AWSService.search(staticResources.searchUrl,data,searchCallBack,staticResources.token);
        }

        function queryContactProcess(){
            console.log('Query Contact process.');         
            //1. get contact name from search box     
            let searchByLastName = document.getElementById('Page:mainForm:idSearchVisitor:searchContactName').value; 
            //2. inovke aws service
            let contactAwsIds = new Set();
            for(var key in contactInfo){
                if(contactInfo[key].lastName.indexOf(searchByLastName) != -1){
                    contactAwsIds.add(key);
                }
            }
            if(contactAwsIds.size == 0){
                clearLineInfoList();
                return;
            }
            searchContactAll();
            //3. render the current page 
            serContact(JSON.stringify(Array.from(contactAwsIds)));
        }

        function showPIDiv(dataId,obj){ 
            console.log('Selected Record:'+dataId);
            //check sf id
            let awsDataId = dataId;
            if(dataId.length == 1){
                let sfId = j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + dataId + ':idAddHiddenId')).val()
                awsDataId = sfIdToAWSIdMapValue.get(sfId); 
            }
            if(awsDataId){               
                console.log('AWS Data Id:'+ awsDataId);
                console.log('AWS Data Info:'+ JSON.stringify(contactInfo));
                let parentNode = document.getElementById(obj.id);
                let createDiv = document.createElement("div");  
                createDiv.id = parentNode.id+"_PI";  
                let piInformation = '{!$Label.Visitor_Name}:'+contactInfo[awsDataId].lastName +'\n{!$ObjectType.Contact.fields.Doctor_Division1__c.Label}:'+contactInfo[awsDataId].doctorDivision1+'\n{!$ObjectType.Lead.fields.Phone.Label}:'+contactInfo[awsDataId].phone
                createDiv.innerText = piInformation;
                let x=window.event.x;
                let y=window.event.y; 
                createDiv.style.left=x;  
                createDiv.style.top=y;  
                createDiv.style.background = "#dddddd";
                createDiv.style.position = "absolute";
                parentNode.appendChild(createDiv);  
                parentNode.style.position = "relative";
            }            
        }

        function hidePIDiv(obj){
            document.getElementById(obj.id+'_PI').remove();
        }
       
        function setSelectedEditIndex(index){          
            selectedEditIndex = index;
            console.log('Selected edit index:'+selectedEditIndex);
        }
    
        function assignDencrypted(){
            let selectedEditSFId = j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + selectedEditIndex + ':idAddHiddenId')).val()
            selectedAwsDataId = sfIdToAWSIdMapValue.get(selectedEditSFId);
            console.log('edit awsId:'+selectedAwsDataId);
            document.getElementById('Page:mainForm:AWS_Data_Id__c').value = selectedAwsDataId;         
            if(contactInfo.hasOwnProperty(selectedAwsDataId)){
                let selectedAWSData = contactInfo[selectedAwsDataId];
                let contactTypeNode = document.getElementById("Page:mainForm:idSearchVisitor:updateContactType");
                contactTypeNode.value = selectedAWSData.type;
                if(contactTypeNode.value){
                    jQuery(contactTypeNode).change();
                }
                document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value = selectedAWSData.lastName;
                document.getElementById("Page:mainForm:idSearchVisitor:updateContactPhone").value = selectedAWSData.phone;
                document.getElementById("Page:mainForm:idSearchVisitor:updateContactDoctorDivision").value = selectedAWSData.doctorDivision1;
            }
        }

        function GetAWSResultObj(){
            if(aws_result && aws_result.object && aws_result.object.length > 0){
                return aws_result.object[0];
            }
            return null;
        }

        function SetEditObj(){
            let obj = GetAWSResultObj();
            if(obj){
                console.log('Result from AWS:'+JSON.stringify(obj));
                document.getElementById('Page:mainForm:AWS_Data_Id__c').value = obj.dataId;
                
                document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value = obj.lastName;
                document.getElementById("Page:mainForm:LastName_Encrypted__c").value = obj.lastNameEncrypt;

                document.getElementById("Page:mainForm:idSearchVisitor:updateContactPhone").value = obj.phone;
                document.getElementById("Page:mainForm:Phone_Encrypted__c").value = obj.phoneEncrypt;

                document.getElementById("Page:mainForm:idSearchVisitor:updateContactType").value = obj.type;
                document.getElementById("Page:mainForm:Type_Encrypted__c").value = obj.typeEncrypt;

                document.getElementById("Page:mainForm:idSearchVisitor:updateContactDoctorDivision").value = obj.doctorDivision1;
                document.getElementById("Page:mainForm:Doctor_Division1_Encrypted__c").value = obj.doctorDivision1Encrypt;
            }
            
        }

        function ProcessPIForAWS(sobjJson, payloadForNewPI) {
            let url = staticResources.newUrl
            let moduleName = AWSService.insertModule;
            if (selectedAwsDataId) {
                moduleName = AWSService.updateModule;
            	url = staticResources.updateUrl
            }
            console.log('Payload for AWS:'+payloadForNewPI + ' Module Name:'+moduleName);
            AWSService.postAWS(url,moduleName, payloadForNewPI, function(result){
                aws_result = result;
                SetEditObj();
                saveNew();
            }, staticResources.token);
        }

        function GetEditObj(){
            return JSON.stringify([{
                lastName : document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value,
                phone : document.getElementById("Page:mainForm:idSearchVisitor:updateContactPhone").value,
                dataId:selectedAwsDataId
            }]);
        }

        function saveContactForAWS(){
            document.getElementById("errorMsg").innerHTML = '';
            if(!document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value){
                document.getElementById("errorMsg").innerHTML = '<strong>错误:</strong> 必须填写。';
                return;
            }
            blockme();
            ProcessPIForAWS({},GetEditObj());
        }
        function Trans(){
            AWSService.postAWS(staticResources.transactionUrl,AWSService.confirmTrans, JSON.stringify({
                    "txId":aws_result.txId,
                    "sfRecordId":"",
                    "isSuccess":1
            }), function(result){
                window.location.reload();
            }, staticResources.token);
        }
        
        //Add By Li Jun 20220228 for PIPL End
    </script>
    <style type="text/css">
        div#iframelike {
            color: #fff;
            height: 210px;
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        div#iframelike2 {
            color: #fff;
            height: 185px;
            overflow-y: auto;
            overflow-x: hidden;
        }
    </style>
    <apex:outputPanel id="all">
        <apex:form id="mainForm">
        <!-- Search Contact By Li Jun 20220214 Start-->
        <apex:actionFunction name="serContact" action="{!serContact}" rerender="idRezultVisitor">
            <apex:param name="awsContactIds" assignTo="{!awsContactIds}" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="clearLineInfoList" action="{!clearLineInfoList}" rerender="mainForm" onComplete="unblockUI();">
        </apex:actionFunction>
        <!-- Search Contact By Li Jun 20220214 End-->
        <apex:actionFunction name="updContactP" action="{!updContactP}" rerender="idRezultVisitor,idRegistration">
        <apex:param name="index" assignTo="{!index}" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="updContactM" action="{!updContactM}" rerender="idRezultVisitor">
        <apex:param name="index" assignTo="{!index}" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="editVistor" action="{!editVistor}" rerender="idRegistration" oncomplete="assignDencrypted();setButtonDisable(document.getElementById('Page:mainForm:idSearchVisitor:idRegSave'), false);">
            <apex:param name="index" assignTo="{!index}" value=""/>
        </apex:actionFunction>
        <apex:actionFunction name="saveNew" action="{!regContact}" rerender="idRegistration,idRezultVisitor,idAddVisitor,idMessage" onComplete="Trans();">
        </apex:actionFunction>
         <!-- Add By Li Jun for PIPL 20220228 Start -->
         <apex:inputHidden id="LastName_Encrypted__c" value="{!rc.LastName_Encrypted__c}"/>
         <apex:inputHidden id="Phone_Encrypted__c" value="{!rc.Phone_Encrypted__c}"/>

         <apex:inputHidden id="Type_Encrypted__c" value="{!rc.Type_Encrypted__c}"/>
         <apex:inputHidden id="Doctor_Division1_Encrypted__c" value="{!rc.Doctor_Division1_Encrypted__c}"/>

         <apex:inputHidden id="AWS_Data_Id__c" value="{!rc.AWS_Data_Id__c}"/>
         <!-- Add By Li Jun for PIPL 20220221 End -->
            <apex:pageBlock id="idSearchVisitor" >
                <table width="1060" height="50" border="0">
                    <tr>
                      <th style="font-size:15px;">{!$Label.Search_Personnel}</th>
                      <td width="700px" >
                          <apex:outputPanel id="idMessage">
                            <apex:pageMessages />
                          </apex:outputPanel>
                      </td>
                      
                    </tr></table>
                <table width="1060" border="0" style="background-color:#DCDCDC">
                    <colgroup>
                        <col width="20" />
                        <col width="90" />
                        <col width="20" />
                        <col width="90" />
                        <col width="90" />
                        <col width="20" />
                        <col width="145" />
                        <col width="20" />
                        <col width="145" />
                        <col width="20" />
                        <col width="120" />
                        <col width="20" />
                        <col width="95" />
                        <col width="20" />
                        <col width="120" />
                    </colgroup>
                    <tr>
                        <td>&nbsp;</td>
                        <th>{!$Label.Search_Condition}</th>
                        <td>&nbsp;</td>
                        <th>{!$Label.Last_Name}</th>
                        <!-- <th>{!$Label.First_Name}</th> -->
                        <td>&nbsp;</td>
                        <th>{!$Label.Attribute}</th>
                        <td>&nbsp;</td>
                        <th>{!$Label.Post}</th>
                        <td>&nbsp;</td>
                        <th>{!$Label.MyDr}</th>
                        <td>&nbsp;</td>
                        <th>&nbsp;</th>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <!-- Add Id for pipl by Li Jun 20220214 -->
                        <td><apex:inputText id="searchContactName" value="{!sc.Search_LastName__c}" style="width:80px" required="false"/></td>
                        <!-- <td><apex:inputText value="{!sc.Search_FirstName__c}" style="width:80px" required="false"/></td>  commented for pipl by Li Jun 20220214--> 
                        <td>&nbsp;</td>
                        <th><apex:inputField value="{!sc.Type__c}" /></th>
                        <td>&nbsp;</td>
                        <th><apex:inputField value="{!sc.Doctor_Division1__c}" /></th>
                        <td>&nbsp;</td>
                        <th><apex:inputField value="{!sc.MyDr_Flg__c}" /></th>
                        <td>&nbsp;</td>
                        <th>&nbsp;</th>
                        <td>&nbsp;</td>
                        <!-- Updated By Li Jun for PIPL 20220214 -->
                        <td><input class="btn" type="Button" value="{!$Label.Search}" onclick="queryContactProcess()" style="width:100px" /></td>
                        <!-- <td><apex:commandButton value="{!$Label.Search}" action="{!serContact}" style="width:100px" rerender="idRezultVisitor" /></td> -->
                    </tr>
                    <tr>
                        <td style="border-bottom: 1px solid #888;" colspan="15">&nbsp;</td>
                    </tr>
                </table>
                <table width="1060" border="0" style="background-color:#DCDCDC">
                    <tr>
                        <td>
                        <div id="iframelike">
                        <apex:pageBlockTable id="idRezultVisitor" value="{!scwl}" var="scw" border="1" columns="8" columnsWidth="47px,90px,,90px,180x,90px,40px,200px">
                            <apex:column >
                                <apex:facet name="header">{!$Label.Selected}</apex:facet>
                                <input type="button" id="idSlt" value="{!$Label.Selected}" onclick="sltContact('{!scw.index}');"  class="btn" style="width:40px"/>
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$Label.Visitor_Name}</apex:facet>
                                <apex:outputLink onmouseover="showPIDiv('{!scw.con.AWS_Data_Id__c}',this)"  onmouseout="hidePIDiv(this)" value="/{!scw.con.Id}" id="idName" target="_blank">{!scw.con.Name}</apex:outputLink>
                                <apex:inputText id="idHiddenId" value="{!scw.conid}" style="display:none" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$Label.Department_Name}</apex:facet>
                                <apex:outputText id="idDep" value="{!IF(scw.con.Account.Name==null,'　',scw.con.Account.Name)}" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$ObjectType.Contact.fields.Doctor_Division1__c.Label}</apex:facet>
                                <apex:outputText id="idJob" value="{!IF(scw.con.Doctor_Division1__c==null,'　',scw.con.Doctor_Division1__c)}" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$ObjectType.Lead.fields.Phone.Label}</apex:facet>
                                <apex:outputText id="idPhone" value="{!IF(scw.con.Phone==null,'　',scw.con.Phone)}" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">MyDr</apex:facet>
                                <apex:inputField id="idMyDr" value="{!scw.con.MyDr_Flg__c}" onclick="this.disabled=true;updContactM('{!scw.index}');"/>
                            </apex:column>
                            <!--2014/6/16__yu追加-->
                            <apex:column id="Delete">
                                <apex:facet name="header" >Delete</apex:facet>
                                <apex:inputField id="idPlease_Delete" value="{!scw.con.Please_Delete__c}" onclick="this.disabled=true;updContactP('{!scw.index}');" />
                            </apex:column>
                            <!--2016/10/10__ZHAO追加-->
                            <apex:column id="Reason">
                                <apex:facet name="header" >删除理由</apex:facet>
                                <apex:inputField id="DeleteReason" value="{!scw.con.Delete_Reason__c}"/>
                            </apex:column>
                        </apex:pageBlockTable>
                        </div>
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>{!$Label.Add_List}</b>　</td>
                    </tr>
                    <tr>
                        <td>
                        <div id="iframelike2">
                        <apex:pageBlockTable id="idAddVisitor" value="{!acwl}" var="acw" border="1" columns="7" columnsWidth="47px,90px,,90px,180x,90px,40px">
                            <apex:column >
                                <apex:facet name="header">{!$Label.Back}</apex:facet>
                                <input type="button" id="idDel" value="{!$Label.Back}" onclick="delContact('{!acw.index}');" class="btn" style="width:40px"/>
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$Label.Visitor_Name}</apex:facet>
                                <!-- <apex:outputText id="idAddName" value="{!IF(acw.con.Name==null,'　',acw.con.Name)}" /> -->
                                <apex:outputLink onmouseover="showPIDiv('{!acw.index}',this)"  onmouseout="hidePIDiv(this)" value="/{!acw.conid}" id="idAddName" target="_blank">{!IF(acw.con.Name==null,'　',acw.con.Name)}</apex:outputLink>
                                <apex:inputText id="idAddHiddenId" value="{!acw.conid}" style="display:none" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$Label.Department_Name}</apex:facet>
                                <apex:outputText id="idAddDep" value="{!IF(acw.con.Account.Name==null,'　',acw.con.Account.Name)}" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$ObjectType.Contact.fields.Doctor_Division1__c.Label}</apex:facet>
                                <apex:outputText id="idAddJob" value="{!IF(acw.con.Doctor_Division1__c==null,'　',acw.con.Doctor_Division1__c)}" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$ObjectType.Lead.fields.Phone.Label}</apex:facet>
                                <apex:outputText id="idAddPhone" value="{!IF(acw.con.Phone==null,'　',acw.con.Phone)}" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">MyDr</apex:facet>
                                <apex:outputField id="idAddMyDr" value="{!acw.con.MyDr_Flg__c}" />
                            </apex:column>
                            <apex:column >
                                <apex:facet name="header">{!$Label.Edit}</apex:facet>
                                <input type="button" id="idEdit" value="{!$Label.Edit}" onclick="setSelectedEditIndex('{!acw.index}');setButtonDisable(document.getElementById('Page:mainForm:idSearchVisitor:idRegSave'), true);editVistor('{!acw.index}');" class="btn" style="width:40px"/>
                            </apex:column>
                        </apex:pageBlockTable>
                        </div>
                        </td>
                    </tr>
                    <tr><td>
                        <table width="880" border="0" style="background-color:#DCDCDC"><tr>
                            <td>
                                <apex:commandButton value="{!$Label.Clear}" action="{!clearRC}"  style="width:40px" rerender="idRegistration" />
                            </td>
                            <td style="text-align:center">
                                <input type="button" value="{!$Label.Set}" onclick="addContact();" class="btn"/>
                            </td>
                            <td style="text-align:right">
                                <apex:commandButton id="idRegSave" value="{!$Label.Registration}" onclick="saveContactForAWS();" style="width:60px" rerender="dummy" />
                            </td>
                        </tr></table>
                    </td></tr>
                    <!-- <tr><td align="center"><input type="button" value="{!$Label.Set}" onclick="addContact();" class="btn" style="width:80px" /></td></tr> -->
                </table>
                <br></br>
                
                <apex:outputPanel id="idRegistration">

                <table class="formtable" width="1060" border="0">
                    
                    <tr>
                        <td width= "20">&nbsp;</td>
                        <th width= "80">{!$Label.Attribute}</th>
                        <th width= "80" ><apex:inputField id="updateContactType" value="{!rc.Type__c}" style="width:66px"/></th>
                        <th width= "80" style="text-align:right">{!$Label.Last_Name}</th>
                        <td width= "80" ><span><div class="requiredInput"><div class="requiredBlock"></div><apex:inputField id="updateContactLastName" value="{!rc.Search_LastName__c}" style="width:70px" /><div id="errorMsg" class="errorMsg"></div></div></span></td>
                        <!-- <th width= "80" style="text-align:right">{!$Label.First_Name}</th>
                        <td width= "160" colspan="2" rowspan="2"><apex:inputField value="{!rc.FirstName}" style="width:150px" /></td> -->
                        <th width= "80" style="text-align:right">{!$ObjectType.Lead.fields.Phone.Label}</th>
                        <td width= "80"><apex:inputField id="updateContactPhone" value="{!rc.phone}" style="width:110px" /></td>
                        <th width= "80" style="text-align:right">{!$ObjectType.Contact.fields.Supplement__c.Label}</th>
                        <th width= "130" colspan="2" rowspan="3"><apex:inputField value="{!rc.Supplement__c}" style="width:130px" /></th>
                        
                    </tr>
                    <tr></tr>
                    <tr>
                        <td>&nbsp;</td>
                        <th colspan="2">{!$ObjectType.Contact.fields.Doctor_Division1__c.Label}</th>
                        <th colspan="2"><apex:inputField id="updateContactDoctorDivision" value="{!rc.Doctor_Division1__c}" style="width:150px"/></th>
                        <th style="text-align:right">{!$Label.Department_Name}</th>
                        <th colspan="3"><apex:inputField value="{!rc.Account_Visitor_Search__c}" style="width:280px" /></th>
                        <th>{!$Label.MyDr}</th>
                        <th style="text-align: left;"><apex:inputField value="{!rc.MyDr_Flg__c}" /></th>
                        
                        
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td colspan="3">{!$ObjectType.Contact.fields.Ignore_Same_Name__c.Label}</td>
                        <th style="text-align: left;"><apex:inputField value="{!rc.Ignore_Same_Name__c}" /></th>
                    </tr>
                </table>
            </apex:outputPanel>
            </apex:pageBlock>
        </apex:form>
    </apex:outputPanel>
</apex:page>