$(document).ready(function() { 
          getPersonLogin();  
          getCompanyLogin();  
         //getPersonCount();
         //getIndexBanner();
         //grid_GetData();
         //getWebCity();
         getPersonResumeCount();
          
    });

    function getPersonCount(){
       $.ajax({
                type: "POST",
                   url: "interface/getPersonCount.joinren",
                   cache:false,
                   async:true,
                   contentType: "application/x-www-form-urlencoded",
                   dataType:'json',
                   data:"",
                   beforeSend: function() {
                        },
                        error: function(request) {
                        },
                success: function(msg) {
                var date=msg;
                $("#datacount")[0].innerHTML=date.data.personcount;
               	}
             });
             setTimeout("getPersonCount()",60000);
    }
    
function getuserName(){
   $.ajax({
        type: "POST",
        url: "interface/getUserName.joinren",
       contentType: "application/x-www-form-urlencoded",
        dataType: "json",
        success: function(msg) {
          $("#loginName").val(msg.more.pername);
          if(msg.more.autoLogin=="1")$("#autoLogin").attr("checked","checked");
          $("#huiYuanMing").val(msg.more.comname);$("#yongHuMing").val(msg.more.cloginname);
          
          if(msg.more.comautoLogin=="1")$("#comautoLogin").attr("checked","checked");
        }
     });
   }
   
    function selectArea(areaId){
	 $.ajax({
                url: 'interface/updateAreaToSession.joinren', 
                cache:false,
                async:true,
                contentType: "application/x-www-form-urlencoded",
                dataType:'json',
                data:"areaId="+areaId + "",
                type: 'POST', 
                beforeSend: function() {
                },
                error: function(request) {
                },
                success: function(data) {
                  getWebCity();
                  hideArea();
                }
        });
	}
	
   function getWebCity(){
	 $.ajax({
                url: 'interface/getWebCity.joinren', 
                cache:false,
                async:true,
                contentType: "application/x-www-form-urlencoded",
                dataType:'json',
                data:"",
                type: 'POST', 
                beforeSend: function() {
                },
                error: function(request) {
                },
                success: function(data) {
                 var areaId;
                 if(null == data.data){
                   areaId = 2;     //默认为上海
                 }else{
                    if(undefined == data.data.webcity){
                       areaId = 2;
                    }else{
                    areaId = data.data.webcity;
                   }
                 }
                $("#webcity")[0].innerHTML=traversalArea(areaId+"");
               }
        });
	}
    
    
    function trylogin(){
        if($("#loginName").val()==""){
                showmes("请输入用户名!");
                $("#loginName").focus();
                return false;
            }
            if($("#password").val()==""){
                showmes("请输入密码!");
                $("#password").focus();
                return false;
            }
         return true;
    }
    
    function trycomlogin(){
        if($("#huiYuanMing").val()==""){
                showmes("请输入会员名!");
                $("#huiYuanMing").focus();
                return false;
            }
            if($("#yongHuMing").val()==""){
                showmes("请输入用户名!");
                $("#huiYuanMing").focus();
                return false;
            }
            if($("#compassword").val()==""){
                showmes("请输入密码!");
                $("#password").focus();
                return false;
            }
         return true;
    }
function clearKeyword(obj) {
  var keywordValue = obj.value.replace(/(^\s*)|(\s*$)/g, "");
  if (keywordValue == "输入关键词") {
    obj.value = "";
  }
}    

  function personRegister(){
    window.location.href = "personCommon/toPersonRegister.joinren";
  }
    function showArea(){
    $("#selectAea").show();
  }
  
  function hideArea(){
   $("#selectAea").hide();
  }
  
  
   function showPersount(sender){
			{
				$("#showpersounts").show();
				var leftpos = 0,toppos = 0;
				var pObject = sender.offsetParent;
				if (pObject)
				{
					leftpos += pObject.offsetLeft;
					toppos += pObject.offsetTop;
				}
				while(pObject=pObject.offsetParent )
				{
					leftpos += pObject.offsetLeft;
					toppos += pObject.offsetTop;
				};
				document.getElementById("showpersounts").style.left = (sender.offsetLeft + leftpos - 269) + "px";
				document.getElementById("showpersounts").style.top = (sender.offsetTop + toppos + sender.offsetHeight - 2) + "px";
			}
  }
  
  function hidePersount(){
    $("#showpersounts").hide();
  }
  
      function showArea(){
    $("#selectAea").show();
  }
  
  function hideArea(){
   $("#selectAea").hide();
  }


 var resumecounts=0;  
 function getPersonResumeCount(){
        $.ajax({
                 type: "POST",
                    url: "interface/getPersonResumeCount.joinren",
                    cache:false,
                    async:true,
                    contentType: "application/x-www-form-urlencoded",
                    dataType:'json',
                    data:'',
                    beforeSend: function() {
                         },
                         error: function(request) {
                         },
                 success: function(msg) {
                 resumecounts=msg.more;
                 }
              });
   }
   
function inputResume(){
 if(resumecounts >=1){
  showmes("您已经创建了简历，不能再导入!"); return;
    //if(!confirm("导入简历将覆盖第一份简历,您确定要导入简历？")) return;
   }
    $("#exportresume").click();
}


function grid_GetData() {
/**
      $.ajax({
                url: 'interface/getFriendCompany.joinren', 
                cache:false,
                async:true,
                contentType: "application/x-www-form-urlencoded",
                dataType:'json',
                data:'',
                type: 'POST',
                beforeSend: function() {
                },
                error: function(request) {
                },
                success: function(data) {
                        grid_applytemplate(data);
                }
        });
**/
    }
    
    var json_result=null;
    function grid_applytemplate(msg) {
        if(msg=="null")return;
        json_result = JSON.parse(msg);
        if(json_result.rows.length==0)
        {
            $("#grid_pagereccount").val(json_result.rows);
        }
      /*$('#Container').setTemplateURL('Template/RSSTable.htm',
                                     null, { filter_data: false });
      */
                $("#Container").setTemplateElement("template");
                $('#Container').processTemplate(json_result.rows);
    }
    

 function getIndexBanner(){
       $.ajax({
                type: "POST",
                   url: "interface/getIndexBanner.joinren",
                   cache:false,
                   async:true,
                   contentType: "application/x-www-form-urlencoded",
                   dataType:'json',
                   data:"",
                   beforeSend: function() {
                        },
                        error: function(request) {
                        },
                success: function(msg) {
                var date=msg;
                $("#adv1").attr("src",date.data.advsrc);
                $("#adv1").attr("title",date.data.advdesc);
                if(date.data.advurl.length>0){
                  $("#adv_href").attr("href",date.data.advurl);
                 }
               	}
             });
    }
    
 //获取表单参数
 function getSearchCond(){
        tmpmatch="";    
        var tmpparam="1=1";
        var tmpstr= "";
        var work_nature1=0;
        var work_nature2=0;
        if($("#keyword").val()!="" && $("#keyword").val()!="结果中包含关键词"){
        	tmpparam+="&keyword="+$("#keyword").val();
        	var keyt=$("input[name='cond_keyscope'][@checked]").val();
        	var kn="(全文)"
        	if(keyt==2)
        	{
        		kn="(职位)"
        	}
        	if(keyt==3)
        	{
        		kn="(公司)"
        	}
        	tmpstr+=$("#keyword").val()+kn;
        }
        if($("#work_area").val()!=""){
        	tmpparam+="&work_area="+$("#work_area").val();
        	if(tmpstr=="")
        	{
        		tmpstr+=$("#txtLoc").val();
        	}
        	else
        	{
        		tmpstr+="+"+$("#txtLoc").val();
        	}
        }
        if($("#position_level").val()!=""){
        	tmpparam+="&position_level="+$("#position_level").val();
        	if(tmpstr=="")
        	{
        		tmpstr+=$("#txtCat").val();
        	}
        	else
        	{
        		tmpstr+="+"+$("#txtCat").val();
        	}
        }
        if($("#industry").val()!=""){
        	tmpparam+="&industry="+$("#industry").val();
        	if(tmpstr=="")
        	{
        		tmpstr+=$("#txtInd").val();
        	}
        	else
        	{
        		tmpstr+="+"+$("#txtInd").val();
        	}
        }
        tmpparam+="&keywordtype="+$("input[name='cond_keyscope'][@checked]").val();
        return tmpparam;
    } 
           
    //搜索
    function sub()
    {
  		
  		var tmpparam = getSearchCond();
  	    document.location.href=encodeURI("search/searchJob.joinren?"+tmpparam);
    }
     
     function getOpenDiv(type,txtval,idval){
	   PopupSelector.popup(type,$("#"+txtval)[0],idval);
	 }
	 
	function getPersonLogin(){
     $.ajax({
                type: "POST",
                   url: "interface/getPersonLogin.joinren",
                   cache:false,
                   async:true,
                   contentType: "application/x-www-form-urlencoded",
                   dataType:'json',
                   data:"",
                   beforeSend: function() {
                        },
                        error: function(request) {
                        },
                success: function(msg) {
                $("#person_login_info").html(msg.codeDesc);
               	}
             });
   } 
   
   function getCompanyLogin(){
     $.ajax({
                type: "POST",
                   url: "interface/getCompanyLogin.joinren",
                   cache:false,
                   async:true,
                   contentType: "application/x-www-form-urlencoded",
                   dataType:'json',
                   data:"",
                   beforeSend: function() {
                        },
                        error: function(request) {
                        },
                success: function(msg) {
 //              alert( msg.codeDesc );
                $("#company_login_info").html(msg.codeDesc);
               	}
             });
   }  
