<%@ Page Language="C#" MasterPageFile="~/Admin/MainPage.Master" AutoEventWireup="true"
    ValidateRequest="false" Codebehind="JobPostEdit.aspx.cs" Inherits="PPFOR.Admin.ContentArea.Job.JobPostEdit"
    Title="修改招聘职位" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PPFOR_mainContent" runat="server">
    <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="/ckfinder/ckfinder.js"></script>    
    <script type="text/javascript" src="../../js/ajax.js"></script>
    <script src="../../JS/popup.js" type="text/javascript"></script>  
  
<script language="javascript" type="text/javascript">
var finder = new CKFinder();
finder.BasePath = '/ckfinder/';
finder.ResourceType="Images";
finder.RememberLastFolder=true;
finder.PrintWaterImage=false;
function BrowseImage()
{		
    finder.SelectFunction = SetImageField;	
	finder.Popup();
}
function SetImageField(fileUrl)
{
    var obj=document.getElementById("<%=PPFOR_jobPostSmallImage.ClientID %>");
	if(obj!=null)
	{
	    obj.value = fileUrl;
        if(document.all)
        {
            obj.fireEvent("onchange");
        }
        else
        {
            var evt = document.createEvent('HTMLEvents');   
             evt.initEvent('change',true,true);   
             obj.dispatchEvent(evt);   
        }       
    }
}
var editor; 
function changeEditor(id)
{
	if ( editor )
	{
		editor.destroy();
    }
	editor = CKEDITOR.replace(id);
} 
function show(obj){
    if(obj!=null && obj.type=='checkbox')
    {
        var target1=document.getElementById('divSeo1');
        var target2=document.getElementById('divSeo2');
        target1.style.display=(obj.checked==true)?'':'none';  
        target2.style.display=(obj.checked==true)?'':'none'; 
    }
}
function readable(obj,targetid){
    var target=document.getElementById(targetid);    
    if(obj!=null && obj.type=='checkbox' && target!=null)
    {
        target.readOnly=obj.checked;
        if(!obj.checked)
        {
            target.select();
        }
    }
}
function showSection(checked){
    var obj=document.getElementById("<%=PPFOR_memberDegrees.ClientID %>");
    if(obj && obj.style) obj.style.display=checked ? '' : 'none';
}

var idArray=new Array();
var valueArray=new Array();
function getParamList(obj,lanId)
{
    var isError=false;
    var defaultValue=obj.getAttribute("defaultValue");
    var typeId=obj.options[obj.selectedIndex].value;
    
    if(confirm("更改招聘职位所属类型将重新加载扩展属性，确认更改吗？")==true)
    {        
        obj.setAttribute("defaultValue",typeId);        
        var xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null)
        {
            alert ("您的浏览器不支持AJAX！");            
            isError=true;
        }
        else
        {
            var url="JobParamList.aspx?tid=" + typeId + "&lanId=" + lanId;

            var idReg=/paramValue_[\d]*/i;
            var selObjs=document.getElementsByTagName("input");
            if(selObjs!=null)
            {
                for(var index=0;index<selObjs.length;index++)
                {
                    if(selObjs[index].type=='text' && idReg.test(selObjs[index].id))
                    {
                        var j=0;
                        for(;j<idArray.length;j++)
                        {
                            if(idArray[j]==selObjs[index].id)
                            {
                                valueArray[j]=selObjs[index].value;
                                break;
                            }
                        }
                        if(j==idArray.length)
                        {
                            idArray[j]=selObjs[index].id;
                            valueArray[j]=selObjs[index].value;
                        }
                    }
                }
            }
            var areaObjs=document.getElementsByTagName("textarea");
            if(areaObjs!=null)
            {
                for(var index=0;index<areaObjs.length;index++)
                {
                    if(idReg.test(areaObjs[index].id))
                    {
                        var j=0;
                        for(;j<idArray.length;j++)
                        {
                            if(idArray[j]==areaObjs[index].id)
                            {
                                valueArray[j]=areaObjs[index].value;
                                break;
                            }
                        }
                        if(j==idArray.length)
                        {
                            idArray[j]=areaObjs[index].id;
                            valueArray[j]=areaObjs[index].value;
                        }
                    }
                }
            }
            xmlHttp.onreadystatechange=function(){
                if (xmlHttp.readyState==4)
                {                  
                    var tbody=document.getElementById('showParamList');
                    for(var i=tbody.rows.length -1; i >=0; i--){ 
                        tbody.deleteRow(i); 
                    }
                            
                    var xmlDoc=xmlHttp.responseXML || xmlHttp.responseXML.documentElement;
                    if(xmlDoc!=null)
                    {          
                        var rows=xmlDoc.getElementsByTagName("Rows");  
                        if(rows!=null && rows.length==1)
                        {                
                          objTRs = rows[0].getElementsByTagName("Row");
                          if(objTRs!=null && objTRs.length>0)
                          {                             
                            for(var j=0;j<objTRs.length;j++)
                            {                                
                                var iRow=tbody.insertRow(j);
                                objTDs=objTRs[j].getElementsByTagName("Column");
                                var objTD1=iRow.insertCell(-1);
                                objTD1.align='right';
                                objTD1.innerHTML=objTDs[0].firstChild.nodeValue;
                                var objTD2=iRow.insertCell(-1);
                                objTD2.innerHTML=objTDs[1].firstChild.nodeValue;
                            }
                            for(var index=0;index<idArray.length;index++)
                            {
                                var obj=document.getElementById(idArray[index]);
                                if(obj!=null && valueArray[index]!=null && valueArray[index]!='' && valueArray[index]!='<br />')
                                {
                                    obj.value=valueArray[index];
                                }
                            } 
                          }
                        }                     
                    }                  
                }
            };
            xmlHttp.open("GET",url,true);
            xmlHttp.send(null);
        }
    }
    else if(defaultValue!=null)
    {
        for(var i=0;i<obj.options.length;i++)
        {
            if(obj.options[i].value==defaultValue)
            {
                obj.selectedIndex=i;
                break;
            }
        }
    }
    else
    {
        isError=true;
    }
    if(isError==true)
    {
        location.href="JobPostAdd.aspx?id=" + typeId;
    }
}
function displayOptions(ids,cobj)
{
    var oids=ids.split(",");
    if(oids!=null && oids.length>0)
    {
        for(var i=0;i<oids.length;i++)
        {
            var obj=document.getElementById(oids[i]);
            if((cobj.type=="radio" && cobj.value==1) || (cobj.type=="checkbox" && cobj.checked==true))
            {
                obj.style.display="";
            }
            else
            {
                obj.style.display="none";
            }
        }    
    }
}
function toDateTime(strTime) 
{
      var temp=new Array();
      strTime.replace(/(\d+)/g,function(a,b){temp.push(b)});
            
      var varDate= new Date(temp[0],(parseInt(temp[1],10)-parseInt(1)),temp[2],temp[3],temp[4]);
      if(varDate!=null)
      {
            return varDate.getTime();
      }
      else
      {
            return 0;
      }
}
function validateFormTimeEnd(source,args)
{
    var obj=document.getElementById("displayTimeStart");
    if(obj.style.display=="none")
    {
        args.IsValid=true;
    }
    else
    {
        var timeStart=toDateTime(document.getElementById('<%=PPFOR_postTimeStart.ClientID %>').value);
        var timeEnd=toDateTime(document.getElementById('<%=PPFOR_postTimeEnd.ClientID %>').value);
        if(timeStart!=0 && timeEnd!=0)
        {
            if (timeEnd>timeStart)
            {
                args.IsValid=true;
            }
            else
            {
                args.IsValid=false;
            }
        }
        else
        {
            args.IsValid=false;
        }
    } 
}
function openModelFilesForSelect(id)
{
    popup_show("选择模板文件","<iframe id='fileFrame' src='/Admin/CustomView/filemanager.aspx?rid=" + document.getElementById(id).getAttribute("rid") + "' scrolling='yes' width='100%' height='100%' frameborder='0' ></iframe>",520,360);
}
function openTimeStartForSelect()
{
   popup_show("选择开始时间","<iframe id='dtFrame' src='/Admin/CustomView/datetime.aspx?rid=" + document.getElementById('<%=PPFOR_postTimeStart.ClientID %>').getAttribute("rid") + "' scrolling='yes' width='100%' height='100%' frameborder='0' ></iframe>",400,285);
}
function openTimeEndForSelect()
{
   popup_show("选择终止时间","<iframe id='dtFrame' src='/Admin/CustomView/datetime.aspx?rid=" + document.getElementById('<%=PPFOR_postTimeEnd.ClientID %>').getAttribute("rid") + "' scrolling='yes' width='100%' height='100%' frameborder='0' ></iframe>",400,285);
} 
function openTimeForSelect(id)
{
   popup_show("选择发布时间","<iframe id='dtFrame' src='/Admin/CustomView/datetime.aspx?rid=" + document.getElementById(id).getAttribute("rid") + "' scrolling='yes' width='100%' height='100%' frameborder='0' ></iframe>",400,285);
} 
</script>
    <form id="form1" runat="server" onsubmit="return checkGoodsSpecValues();">
        <table width="100%" id="jobPostInfoTable" border="0" cellpadding="0" cellspacing="0" class="fortable">
        <thead>
            <tr>
                <td colspan="2">修改招聘职位</td>
            </tr>
        </thead>  
        <tr>
            <td style="width:15%" align="right">招聘职位名称：</td>
            <td>
                <asp:TextBox ID="PPFOR_jobPostName" runat="server" Width="300px" MaxLength="200"></asp:TextBox> *                  
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" SetFocusOnError="true" ValidationExpression="^.{2,200}$" Display="Dynamic" ControlToValidate="PPFOR_jobPostName"><br />招聘职位名称长度必须在2至200个字符之间</asp:RegularExpressionValidator>
              <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" SetFocusOnError="true" Display="Dynamic" ControlToValidate="PPFOR_jobPostName"><br />招聘职位名称不能为空</asp:RequiredFieldValidator>
            </td>
        </tr>       
         <tr>
            <td align="right">职位静态文件名：</td>
            <td style="white-space:normal;">
                <asp:Label ID="PPFOR_htmlName" runat="server"></asp:Label>&nbsp;
            </td>
        </tr>   
         <tr>
            <td align="right">简历静态文件名：</td>
            <td style="white-space:normal;">
                <asp:Label ID="PPFOR_resumeHtmlName" runat="server"></asp:Label>&nbsp;
            </td>
        </tr>                  
        <tr>
            <td align="right">所属类型：</td>
            <td>
                <asp:DropDownList ID="PPFOR_jobTypeList" runat="server" Width="300px">
                </asp:DropDownList>
                <asp:Label ID="PPFOR_jobPostId" runat="server" Enabled="false" Visible="false"></asp:Label>
                <asp:Label ID="PPFOR_jobPostBelongMenu" runat="server" Enabled="false" Visible="false"></asp:Label>
                <asp:Label ID="PPFOR_returnURL" runat="server" Enabled="false" Visible="false"></asp:Label> 
            </td>
        </tr>
        <tr>
            <td align="right">招聘职位简介：</td>
            <td>
                <asp:TextBox ID="PPFOR_jobPostIntroduction" TextMode="MultiLine" runat="server" Height="80px" Width="98%"></asp:TextBox><br />
                <asp:CheckBox ID="PPFOR_jobPostIntroductionAuto" runat="server" Text="自动获取" Checked="true"/>
            </td>
        </tr> 
        <tr>
            <td align="right">招聘职位介绍：</td>
            <td>
                <asp:TextBox ID="PPFOR_jobPostDescription" runat="server" TextMode="MultiLine" Height="80px" Width="99%"></asp:TextBox>
                    <script type="text/javascript">
                       editor = CKEDITOR.replace("<%=PPFOR_jobPostDescription.ClientID%>");       
                    </script>
            </td>
        </tr> 
        <tbody id="showParamList">
        <%=PPFOR_jobPostParamList %>
        </tbody>
        <tr>
            <td align="right">招聘职位模板：</td>
            <td>
                <asp:TextBox ID="PPFOR_jobPostTemplate" runat="server" Width="300px" MaxLength="255"></asp:TextBox>
                <input type="button" value="选择模板" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'" onclick="openModelFilesForSelect('<%=PPFOR_jobPostTemplate.ClientID %>');" />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" SetFocusOnError="true" ValidationExpression='^[/][^\\<>*?:|\"]{3,254}$' Display="Dynamic" ControlToValidate="PPFOR_jobPostTemplate"><br />模板文件路径必须以“/”开头，且长度必须在4至255个字符之间，且不能包含以下字符之一： \ < > | " ? : *</asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" SetFocusOnError="true" Display="Dynamic" ControlToValidate="PPFOR_jobPostTemplate"><br />招聘职位模板文件路径不能为空</asp:RequiredFieldValidator>
            </td>
        </tr>        
        <tr>
            <td align="right">招聘职位图片：</td>
            <td>               
                <asp:TextBox ID="PPFOR_jobPostSmallImage" runat="server" Width="300px" MaxLength="255"></asp:TextBox>      
                <input type="button" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'" value="选择图片" onclick="BrowseImage();" />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" SetFocusOnError="true" ValidationExpression='^[/][^\\<>*?:|\"]{3,254}$' Display="Dynamic" ControlToValidate="PPFOR_jobPostSmallImage"><br />图片文件路径必须以“/”开头，且长度必须在4至255个字符之间，且不能包含以下字符之一： \ < > | " ? : *</asp:RegularExpressionValidator>
            </td>
        </tr>          
         <tr>
            <td align="right">发布时间：</td>
            <td>
                <asp:TextBox ID="PPFOR_publishDate" runat="server" Width="150px"></asp:TextBox><img src="../../Images/s.gif" alt="选择发布时间" border="0" style="cursor:pointer;" onclick="openTimeForSelect('<%=PPFOR_publishDate.ClientID%>');" />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" ControlToValidate="PPFOR_publishDate" Display="Dynamic" SetFocusOnError="true" ValidationExpression="^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]((((0?[13578])|(1[02]))[\-\/\s]((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]((((0?[13578])|(1[02]))[\-\/\s]((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|(2[0-3])|(1[0-9]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))?))?$"><br />日期时间格式不正确</asp:RegularExpressionValidator>
            </td>
        </tr>      
        <tr>
            <td align="right">招聘职位排序：</td>
            <td>
                <asp:TextBox ID="PPFOR_sort" runat="server" Text="0" MaxLength="4"></asp:TextBox>
                <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="PPFOR_sort" Display="Dynamic" SetFocusOnError="true" Type="Integer" MinimumValue="-999" MaximumValue="9999">排序顺序只能填写-999至9999之间的整数</asp:RangeValidator>
            </td>
        </tr>
        <tr>
            <td align="right">是否显示：</td>
            <td>
                <asp:CheckBox ID="PPFOR_show" runat="server" Checked="true"/>
            </td>
        </tr>
        <tr>
          <td align="right">启用时间限制：</td>
          <td><asp:RadioButtonList ID="PPFOR_postTimeLimit" CssClass="innertable" runat="server" RepeatDirection="Horizontal">          
            </asp:RadioButtonList>
          </td>
        </tr>
        <tr id="displayTimeStart" style="display:<%=PPFOR_displayTimeOption %>;">
            <td align="right">起始时间：</td>
            <td><asp:TextBox ID="PPFOR_postTimeStart" runat="server"></asp:TextBox><img src="../../Images/s.gif" alt="选择开始时间" border="0" style="cursor:pointer;" onclick="openTimeStartForSelect();" /></td>
        </tr>
        <tr id="displayTimeEnd" style="display:<%=PPFOR_displayTimeOption %>;">
            <td align="right">终止时间：</td>
            <td><asp:TextBox ID="PPFOR_postTimeEnd" runat="server"></asp:TextBox><img src="../../Images/s.gif" alt="选择终止时间" border="0" style="cursor:pointer;" onclick="openTimeEndForSelect();" /><br /> 
                <asp:CustomValidator ID="CustomValidator2" runat="server" Display="Dynamic" SetFocusOnError="true" ControlToValidate="PPFOR_postTimeEnd" ClientValidationFunction="validateFormTimeEnd" ValidateEmptyText="true">起始时间和终止时间均不能为空，且终止时间必须大于起始时间</asp:CustomValidator></td>
        </tr>
        <tr>
            <td align="right">开放权限：</td>
            <td>
                <asp:RadioButton ID="PPFOR_publicSection" runat="server" GroupName="fileSection" Text="无限制" Checked="true" />&nbsp;&nbsp;&nbsp;
                <asp:RadioButton ID="PPFOR_memberSection" runat="server" GroupName="fileSection" Text="限制会员等级" />&nbsp;&nbsp;&nbsp;
                <asp:CheckBoxList ID="PPFOR_memberDegrees" CssClass="innertable" runat="server" RepeatColumns="2" RepeatDirection="Horizontal"></asp:CheckBoxList>               
            </td>
        </tr>                
       <tr>
            <td colspan="2" style="background-color: #f2f2f2" align="left">                
                <input type="checkbox" id="PPFOR_ckeSeo" runat="server" checked="checked" onclick="show(this)" />Seo 优化设置 & 其它
            </td>
        </tr>     
        <tr id="divSeo1">
            <td align="right">Meta关键字：</td>
            <td>
                <asp:TextBox ID="PPFOR_pageKeyWord" runat="server" Width="98%" MaxLength="255"></asp:TextBox><br />
                <input type="checkbox" id="PPFOR_pageKeyWordAuto" runat="server" checked="checked" />自动获取
            </td>
        </tr>
        <tr id="divSeo2">
            <td align="right">Meta描述：</td>
            <td>
                <asp:TextBox ID="PPFOR_pageDescription" runat="server" Width="98%" MaxLength="255"></asp:TextBox><br />                         
                <input type="checkbox" id="PPFOR_pageDescriptionAuto" runat="server" checked="checked" />自动获取
            </td>                  
        </tr>              
        <tr>
            <td colspan="2" style="width:100%; height:50px; display:none" align="center" valign="middle">
                <asp:Button ID="PPFOR_updateJobPost" CssClass="inputbutton" runat="server" Text="提交" OnClick="PPFOR_updateJobPostClick"/>
                <input name="reset" type="reset" id="reset1" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'" value="重置" onclick="location.reload();" />
                    <script type="text/javascript">
                        addButtonArray("<%= PPFOR_updateJobPost.ClientID %>","reset1");
                    </script> 
            </td>
        </tr> 
        </table>
    </form>
</asp:Content>
