<html>
<head>
<meta http-equiv=content-language content=zh-cn>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<style>
 td { padding:2px 5px 2px 5px;}
</style>
<script language=javascript src="../JS/CheckQuestion.js.php"></script>
<script language=javascript>
function Check_Form_Validator(theform)
{
	//处理当前选择的用户
	var theObj = document.getElementById("valueList");
	for(c = 0; c < theObj.options.length; c++) {
		  theObj.options[c].selected = true;
	}
	if(!CheckUserListNoSelect(Check_Form.valueList, "教师所在的教研组或学生所在班级")) {return false;}
}
function $(_sId){
	return document.getElementById(_sId);
}
//检测下拉必选
function CheckUserListNoSelect(objField, strText)
{
	for( i=0;i<objField.options.length;i++ ) {   
		if(objField.options[i].selected && objField.value != '') {   
		   return true;   
		}   
	} 
    alert( "请选择“" + strText + "”！");
	return false;
}
function move(fbox, tbox,type) {
	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var arrValue = new Array();
	var i;
	for (i = 0; i < tbox.options.length; i++) {
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrValue[i] = tbox.options[i].value;;
		arrTbox[i] = tbox.options[i].text;
	}
	var fLength = 0;
	var tLength = arrTbox.length;
	for(i = 0; i < fbox.options.length; i++) {
		arrLookup[fbox.options[i].text] = fbox.options[i].value;
		if (fbox.options[i].selected && fbox.options[i].value != "" && !isInArray(fbox.options[i].value,arrValue,type) ) {
			arrTbox[tLength] = fbox.options[i].text;
			tLength++;
		}
		else {
			arrFbox[fLength] = fbox.options[i].text;
			fLength++;
		}
	}
	//arrFbox.sort();
	//arrTbox.sort();
	fbox.length = 0;
	tbox.length = 0;
	var c;
	for(c = 0; c < arrFbox.length; c++) {
		var no = new Option();
		no.value = arrLookup[arrFbox[c]];
		no.text = arrFbox[c];
		fbox[c] = no;
	}
	for(c = 0; c < arrTbox.length; c++) {
		var no = new Option();
		no.value = arrLookup[arrTbox[c]];
		no.text = arrTbox[c];
		tbox[c] = no;
	}
}
function isInArray(valuea,arrayb,type)
{
	switch( type )
	{
		case 2:   //从选中到教师
			if( valuea.substr(0,1) != 't' ) return true;
		break;
		case 4:  //从选中到学生
			if( valuea.substr(0,1) != 's' ) return true;
		break;
	}	
	var isHaveValue = false;
	for(var i=0;i<arrayb.length;i++)
	{
	    if(Trim(arrayb[i]) == Trim(valuea) ) 
		{
		    isHaveValue = true;
			break;
		}
	}
	return isHaveValue;
}
</script>
<link href="../CSS/Base.css" rel=stylesheet>
<meta content="mshtml 6.00.3790.0" name=generator></head>
<body oncontextmenu="return false" style="margin-top:0px">
  <table class=datatable style="line-height: 150%;border-collapse:collapse;" cellspacing=0 cellpadding=0 bordercolor=#b5cfd9 border=1 width=100%>
   <form name="Check_Form" onsubmit="return Check_Form_Validator(this)" method="post" action="">
     <div class=position>位置：&nbsp; 我的问卷 &raquo; 设置调查问卷样本抽取规则</div>
      <tr><td bgcolor="#f5f5f5" colspan=2><b>设置调查问卷样本抽取规则</b></td></tr>
      <tr><td colspan=2> <SPAN class=red>*</SPAN> 调查问卷：{surveyTitle}</td></tr>
	  <tr><td colspan=2 bgcolor="#f1f1f1"><b>抽取教师所在的教研组或学生所在班级</b></td></tr>
	  <tr><td height="25" colspan=2><span style="float:left">可选择的组别清单</span><span style="float:right">已有的组别清单&nbsp;&nbsp;</span></td>
	  </tr>
	  <tr><td align=left colspan=2 style="margin:0px;padding:0px" valign=top><table cellspacing=0 cellpadding=0 valign=top><tr valign=top><td style="margin:0px;padding:0px" valign=top>&nbsp;&nbsp;教师所在的教研组：
			 　<select multiple name="theTeacherGroupList[]" id="theTeacherGroupList" size=6 style="width:276px;">
				   {theTeacherGroupList}
			   </select><br/>
			   &nbsp;&nbsp;学生所在的班级：
			 　<select multiple name="theStClassList[]" id="theStClassList" size=9 style="width:276px;">
				   {theStClassList}
			   </select>		 
			 </td>
			 <td style="margin:0px 2px 0px 2px;padding:0px 2px 0px 2px"  valign=top><br/><br/><input type="button" class=inputsubmit onClick="move(this.form.theTeacherGroupList,this.form.valueList,1)" value=">"><br/>
			 <input type="button" class=inputsubmit onClick="move(this.form.valueList,this.form.theTeacherGroupList,2)" value="<"><br/><br/><br/><br/><br/>
			 <input type="button" class=inputsubmit onClick="move(this.form.theStClassList,this.form.valueList,3)" value=">"><br/>
			 <input type="button" class=inputsubmit onClick="move(this.form.valueList,this.form.theStClassList,4)" value="<">
			 </td>
			 <td style="margin:0px;padding:0px" valign=top>
			 <select name="valueList[]" id="valueList" multiple size="18" style="width:276px;">
				  {valueList}
			 </select></td></tr></table>
	 </td></tr></table>
	 <table width=100%>
     <tr><td align=center>
			<input type="hidden" name="surveyTitle" value="{surveyTitle}">
			<input type="hidden" name="surveyID" value="{surveyID}">
		    <input type="hidden" name="Action" value="SurveyPanelRegSubmit"> 
            <input class=inputsubmit type="submit" name="submit" value="确定">&nbsp;<input class=inputsubmit type="button" name="close" value="关闭" onClick="javascript:parent.hidePopWin();"> 
        </td>
     </tr>
  </form></table>
</body></html>
