﻿// JScript 文件
var CompanyIndustryNum;
var BtIndustryName;//确定行业名字的控件Id
var BtIndustryIdList;//确定行业名称的空间Id
var SelectedNum=0;//可以选择的数目
var x,y;
function SearchCompanyIndustry(Nowx,Nowy,NowBtIndustryName,NowBtIndustryIdList,NowSelectedNum)
   {
   document.getElementById('SearchDiv').innerHTML='';
   SelectedNum=NowSelectedNum;
   CompanyIndustryNum=0;
   x=Nowx;
   y=Nowy;
   BtIndustryName=NowBtIndustryName;
   BtIndustryIdList=NowBtIndustryIdList;
   startRequest('/SearchPost/SearchCompanyIndustry.html',Industrycallback);
   }
   
   //显示行业列表以供搜索
   
   
   function Industrycallback()
   {
  
    if(y.length>1)
   {
   document.getElementById('SearchDiv').style.top=y;
   }
    if(x.length>1)
   {
     document.getElementById('SearchDiv').style.left=x;
   }
   //创建显示全部行业的层
   var ShowDiv2=document.createElement("Div");
   var NowId='SearchPostDiv';
   ShowDiv2.id=NowId;
   ShowDiv2.style.position="relative";//
   ShowDiv2.style.backgroundColor="#FFFFFF";
//   ShowDiv.style.height="300px";
//   ShowDiv.style.width="300px";
  // ShowDiv.style.border="#ffff00 2px solid";
   ShowDiv2.style.width="900px";
   ShowDiv2.style.top='10px';
   ShowDiv2.style.left='10px';
   ShowDiv2.style.textAlign="left";
   ShowDiv2.style.fontSize="12px"
   ShowDiv2.style.lineHeight="25px"
   ShowDiv2.style.padding="0px"
   ShowDiv2.style.marginLeft="25px"
   ShowDiv2.style.zIndex="100"
   //加载行业内容以及关闭按钮
   ShowDiv2.innerHTML=''+returnDom;
   document.getElementById('SearchDiv').appendChild(ShowDiv2);
   }
   
 //除行业DIV(大层)的方法
   function CompanyIndustryRemoveBigDiv()
   {
    var RemovePostDiv=document.getElementById('SearchPostDiv');
   document.getElementById('SearchDiv').removeChild(RemovePostDiv);
   }
   
   function RemoveCheck(id)
   {
   var CheckDom=document.getElementById(id);
   document.getElementById('SearchDiv').removeChild(CheckDom);

   }
   
 var IndustryList='';//选定行业名称列表
 var IndustryIdList=''; //选定行业Id列表
 
//增加搜索参数
function ab22(PostId,PostName)
{
var Ck='ck'+PostId;//CheckBox的编号

if(document.getElementById(Ck).checked==true)
{

   if(CompanyIndustryNum<SelectedNum)
    {
     var ShowCheck=document.createElement("Div")
     ShowCheck.id='D'+PostId;
 
     ShowCheck.innerHTML="<div style='float:left; height:18px;'><input type=checkbox style='height:18px' onclick='RemoveSelected("+PostId+")'  id='C"+PostId+"' value='"+PostName+"' title='"+PostName+"'checked=true></div><div style='float:left;height:18px;padding-left:2px;'><span style='line-height:17px;margin:0px;color:#ff7505'>【"+PostName+"】</span></div><div style='clear:both'></div>";
     ShowCheck.style.width='220px';
     //ShowCheck.style.backgroundColor="#000000";
     ShowCheck.style.height='18px';
	 ShowCheck.style.paddingTop='2px';
	 //ShowCheck.class='hj';
	   if(navigator.userAgent.indexOf("Firefox")!=-1)
    {
         ShowCheck.style.cssFloat="left";
     }
     else
    {
          ShowCheck.style.styleFloat="left";
    }
	 
     //ShowCheck.style.border='#ffff00 2px solid';
     document.getElementById('ShowCompanyIndustrySelected').appendChild(ShowCheck);
     //IndustryList+=PostName+',';
     //alert(IndustryList);
     CompanyIndustryNum=CompanyIndustryNum+1;

    }
     else
    {
    document.getElementById(Ck).checked=false;
     alert('最多只能选'+SelectedNum+'个');
     }
}
else
{
RemoveSelected(PostId)
}
}

//确定搜索参数
function CheckIndustry()
{
IndustryList='';
IndustryIdList='';
var a=document.getElementById('SearchPostDiv').getElementsByTagName('div');
for(i=0;i<a.length;i++)
{
line=a[i].id;
if(line.indexOf('D')>-1)
{
StatrLine=a[i].innerHTML.indexOf('【')+1;
OverLine=a[i].innerHTML.indexOf('】');

IndustryList+=a[i].innerHTML.substring(StatrLine,OverLine)+',';
IndustryIdList+=a[i].id.substring(1)+',';
}
}
if(IndustryIdList.length>1)
{
document.getElementById(BtIndustryName).value=IndustryList;
if(document.getElementById('IndustrySeverName')!=null)
{
document.getElementById('IndustrySeverName').value=IndustryList;
}
document.getElementById(BtIndustryIdList).value=IndustryIdList;
CompanyIndustryRemoveBigDiv();
}
else
{
alert('至少选择一个行业');
}

}

 //去除已选定的行业
function RemoveSelected(PostId)
{
var Del='D'+PostId;
var DelDiv=document.getElementById('D'+PostId);
document.getElementById('ShowCompanyIndustrySelected').removeChild(DelDiv);
document.getElementById('ck'+PostId).checked=false;
CompanyIndustryNum=CompanyIndustryNum-1;
}

//去除大层
function CompanyIndustryRemoveBigDiv()
{
 CompanyIndustryNum=0;
 var RemovePostDiv=document.getElementById('SearchPostDiv');
 document.getElementById('SearchDiv').removeChild(RemovePostDiv);
}
