﻿
var countJob=0;
 function getchkValue(obj,sid)
 { 
 var chList=document.getElementById('div_show').value.replace("选择职位类别   >>",""); //已选择列表
 var strlistinfo=chList;
  if(document.getElementById(obj).checked)
  {
// if(countJob>=5)
// {
//    alert("最多选择5个职位");
//    document.getElementById(obj).checked=false;
//    return false;
// }
 countJob+=1;
   strlistinfo+=sid+",";//新增选择
  }
  else
  {
  
 countJob-=1;
   strlistinfo=strlistinfo.replace(sid+",","");//取消选择
  }  
  document.getElementById('div_show').value=strlistinfo;
  document.getElementById('div_show').title=strlistinfo;
 }
  function clearAll()
  {
    document.getElementById('div_show').value="";
    document.getElementById('div_show').title="";
    	var frm=document.forms[0];
					for (var i=0;i<frm.elements.length;i++)
					{
						var e=frm.elements[i];
						if ((e.type=='checkbox'))
						{
						e.checked=false;
						}//endif
					}//endfor
  }
  
  function SelectAll()
  {
    	var frm=document.forms[0];
					for (var i=0;i<frm.elements.length;i++)
					{
						var e=frm.elements[i];
						if ((e.name != 'chkchild') && (e.type=='checkbox'))
						{
						e.checked=true;
						}//endif
					}//endfor
				//	alert("13213");
  }
  
  var JobArr;
 function selStation2(JobArr,locationid,e)
 {
 
      var strlist="<div align=\"right\" ><a style=\"cursor:pointer;\" onclick=\"clearAll();\">[清空]</a>&nbsp;&nbsp;&nbsp;&nbsp;<a onclick=\"chide('"+locationid+"');chide('blockCity1');\"  style=\"cursor:pointer;\">[确认]</a></div>";
      strlist+="<table width=\"420px\" border=\"0\"><tr>";
        for(var i=0;i<JobArr.length;i++)
       {
         strlist+="<td style=\"width:140px;overflow:hidden;text-align:left;\" align=\"left\"  valign=\"top\"><a href=\"javascript:void(0)\"  onclick=\"selStation("+JobArr[i][0].split("|")[0]+",'blockCity1',event)\">"+JobArr[i][0].split("|")[1]+"&nbsp;&nbsp;</a></td>";
            if((i+1)%3==0 && i>0)
            {
                strlist+="<tr/><tr>";
            }
 }
 strlist+="</tr></table>";
     var onecount,locationid,strlist;
     onecount=0;
     subcat = new Array();
     subcat[0]=new Array(strlist,locationid);
     onecount=1;
     var Obj = document.getElementById(locationid);
     document.getElementById(locationid).innerHTML = "";
     for (var i=0;i < onecount; i++)
     {
        if (subcat[i][1] == locationid)
         {
             document.getElementById(locationid).innerHTML += subcat[i][0]+"<br />";
             if(e==null){e=window.event;}
             var mX = e.x ? e.x : e.pageX;
             var mY = e.y ? e.y : e.pageY;
             document.getElementById(locationid).style.left =mX+"px";
             document.getElementById(locationid).style.top =mY + document.documentElement.scrollTop -0+"px";
             document.getElementById(locationid).style.display = "block";
         } 
     }
 }
 
 function selStation(childJobArr,locationid,e){
 var chList=document.getElementById('div_show').value.split(',');
      var strlist="<div align=\"right\" ><a style=\"cursor:pointer;\" onclick=\"SelectAll();\"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a onclick=\"chide('"+locationid+"');\"  style=\"cursor:pointer;\">[确认]</a></div>";
      strlist+="<table width=\"300px\" border=\"0\"><tr>";
      for(var k=0;k<JobArr.length;k++)
      {
          if(childJobArr==JobArr[k][0].split("|")[0])
          {
                    for(var j=1;j<JobArr[k].length;j++)
                    { 
                        var ischeckStr="";
                        for(var y=1;y<chList.length;y++)
                        {
                            if(chList[y-1]==JobArr[k][j].split("|")[1])
                            {
                                 ischeckStr="checked=\"checked\"";
                            }
                        }
                       strlist+="<td style=\"width:150px;overflow:hidden;text-align:left;\" align=\"left\"  valign=\"top\">";
                       strlist+="<input name=\"chkchild\" id=\"chk_"+JobArr[k][j].split("|")[0]+"\" "+ischeckStr;
                       strlist+=" onclick=\"getchkValue(this.id,'"+JobArr[k][j].split("|")[1]+"')\" type=\"checkbox\" />";
                       strlist+="<a href=\"javascript:void(0)\" >"+JobArr[k][j].split("|")[1]+"</a></td>";
                       if((j)%2==0 && j>0)
                        {
                            strlist+="</tr><tr>";
                        }
                   
                    }
          }
      }
      strlist+="</tr></table>";
    //  alert(strlist);
     var onecount,locationid,strlist;
     onecount=0;
     subcat = new Array();
     subcat[0]=new Array(strlist,locationid);
     onecount=1;
     var Obj = document.getElementById(locationid);
     document.getElementById(locationid).innerHTML = "";
     for (var i=0;i < onecount; i++)
     {
        if (subcat[i][1] == locationid)
         {
             document.getElementById(locationid).innerHTML += subcat[i][0]+"<br />";
             if(e==null){e=window.event;}
             var mX = e.x ? e.x : e.pageX;
             var mY = e.y ? e.y : e.pageY;
             document.getElementById(locationid).style.left =mX+"px";
             document.getElementById(locationid).style.top =mY + document.documentElement.scrollTop -0+"px";
             document.getElementById(locationid).style.display = "block";
         } 
     }
 }

 function cshow(locationid){
 document.getElementById(locationid).style.display="block";
 }
 function chide(locationid){
 document.getElementById(locationid).style.display="none";
 }

