﻿
var count=0;
 function getcitychkValue(obj,sid)
 {
 var chList=document.getElementById('divcity_show').value.replace("选择工作地点   >>",""); //已选择列表
 if(document.getElementById('divcity_show').value=="选择/修改" || document.getElementById('divcity_show').value=="不限")
 {
    chList="";
 }
// if(chList="请选择城市")
// {chList="";}
 var strlistinfo=chList;
  if(document.getElementById(obj).checked)
  {
// if(count>=5)
// {
//    alert("最多选择5个城市");
//    document.getElementById(obj).checked=false;
//    return false;
// }
 count+=1;
   strlistinfo+=sid+",";//新增选择
  }
  else
  {
 count-=1;
   strlistinfo=strlistinfo.replace(sid+",","");//取消选择
  }  
  document.getElementById('divcity_show').value=strlistinfo;
    document.getElementById("divcity_show").title=strlistinfo;
  if(document.getElementById("hid_city"))
  {
    document.getElementById("hid_city").value=strlistinfo;
  }
 }
  
  function clearCityAll()
  {
    document.getElementById('divcity_show').value="";
    document.getElementById('divcity_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
  }
  
  var CitysArray;
 function selCityStation2(CitysArray,locationid,e)
 {
 
      var strlist="<div align=\"right\" ><a onclick=\"chide('"+locationid+"');chide('blockCitydiv1');\"  style=\"cursor:pointer;\">[确认]</a></div>";
      strlist+="<table width=\"180px\" border=\"0\"><tr>";
        for(var i=0;i<CitysArray.length;i++)
       {
    var ss="";
    var NumV=CitysArray[i][0].split("|")[0];
         ss="<td style=\"width:90px;overflow:hidden;text-align:left;\" align=\"left\"  valign=\"top\"><a href=\"javascript:void(0)\"  onclick=\"selCityStation('"+NumV+"','blockCitydiv1',event,'"+CitysArray[i][0].split("|")[1]+"')\">"+CitysArray[i][0].split("|")[1]+"&nbsp;&nbsp;</a></td>";

        strlist+=ss;
//         strlist+="<td style=\"width:140px;overflow:hidden;text-align:left;\" align=\"left\"  valign=\"top\"><a href=\"javascript:void(0)\"  onclick=\"selCityStation("+CitysArray[i][0].split("|")[0]+",'blockCitydiv1',event)\">"+CitysArray[i][0].split("|")[1]+"&nbsp;&nbsp;</a></td>";
            if((i+1)%2==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 selCityStation(childCitysArray,locationid,e,strproName){
 // alert("childCitysArray="+childCitysArray+";locationid="+locationid+";strproName="+strproName);
 var chList=document.getElementById('divcity_show').value.split(',');
      var strlist="<div align=\"right\" ><a onclick=\"chide('"+locationid+"');\"  style=\"cursor:pointer;\">[确认]</a></div>";
      strlist+="<table width=\"160px\" border=\"0\"><tr>";
      for(var k=0;k<CitysArray.length;k++)
      {
          if(childCitysArray==CitysArray[k][0].split("|")[0])
          {
                    for(var j=1;j<CitysArray[k].length;j++)
                    { 
                        var ischeckStr="";
                        for(var y=1;y<chList.length;y++)
                        {
                            if(chList[y-1]==CitysArray[k][j].split("|")[1])
                            {
                                 ischeckStr="checked=\"checked\"";
                            }
                        }
                       strlist+="<td style=\"width:80px;overflow:hidden;text-align:left;\" align=\"left\"  valign=\"top\">";
                       strlist+="<input  id=\"chk_"+CitysArray[k][j].split("|")[0]+"\" "+ischeckStr;
                       strlist+=" onclick=\"getcitychkValue(this.id,'"+CitysArray[k][j].split("|")[1]+"')\" type=\"checkbox\" />";
                       strlist+="<a href=\"javascript:void(0)\" >"+CitysArray[k][j].split("|")[1]+"</a></td>";
                       if((j)%2==0 && j>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 cshow(locationid){
 document.getElementById(locationid).style.display="block";
 }
 function chide(locationid){
 document.getElementById(locationid).style.display="none";
 }

