<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("classIDList");
	for(c = 0; c < theObj.options.length; c++) {
		  theObj.options[c].selected = true;
	}
	if(!CheckUserListNoSelect(Check_Form.classIDList, "学生的选修课班级")) {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) {
	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) ) {
			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)
{
	var isHaveValue = false;
	for(var i=0;i<arrayb.length;i++)
	{
	    if(Trim(arrayb[i]) == Trim(valuea) ) 
		{
		    isHaveValue = true;
			break;
		}
	}
	return isHaveValue;
}
var http_request = false;
function AjaxRequest(url)
{
	http_request = false;
	if(window.ActiveXObject)
	{
		try  // IE
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	else if(window.XMLHttpRequest)
	{
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
	}
	
	if (!http_request)
	{
		alert("Cannot create an XMLHTTP instance");
		return false;
	}
	http_request.onreadystatechange = AlertContents;
	http_request.open('GET', url, true);
	http_request.send(null);
}

function AlertContents()
{
	if (http_request.readyState == 4)
	{
		if(http_request.status == 200)
		{
			$("randText").innerHTML = http_request.responseText;
		}
		else
		{
			alert('网络传输问题');
		}
	}
}
function chgUserClass()
{
	var theValue = getRadioCheckBoxValue(document.Check_Form.groupID);
	AjaxRequest("../System/AjaxChgCourses.php?usersGender={usersGenderValue}&studentID={studentID}&groupID="+theValue+"&randid="+Math.random());
}
</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; 学生 &raquo; 定义学生的选修课</div>
      <tr> 
         <td colspan="2" bgcolor="#f5f5f5"><b>定义学生的选修课</b></td>
      </tr>
     <tr><td colspan=2> <SPAN class=red>*</SPAN> 院系：{depName} | <SPAN class=red>*</SPAN> 专业：{gradeName} | <SPAN class=red>*</SPAN> 班级：{className}<br/> <SPAN class=red>*</SPAN> 学号：{usersNum} | <SPAN class=red>*</SPAN> 学生姓名：{nickName} | <SPAN class=red>*</SPAN> 性别：{usersGender}<br/>  </td></tr>
	  <tr><td colspan=2 bgcolor="#f1f1f1"><b>选择学生的选修课</b></td></tr>
	   <tr><td colspan="2" height="25" style="margin:0px;padding:0px"><span style="float:left"><select name="groupID" id="groupID" onchange="javascript:chgUserClass();">
			   <option value='all'>选择选修课课程...</option>
			   {coursesList}
			   </select> 可选择的选修课班级列表</span><span style="float:right">已有的选修课班级&nbsp;&nbsp;</td></tr>
	   <tr><td align=left colspan=2 style="margin:0px;padding:0px">
		  <table cellspacing=0 cellpadding=0><tr><td style="margin:0px;padding:0px">
			 <div id="randText"><select multiple name="theClassIDList[]" id="theClassIDList" size=16 style="width:276px;">
				   {theClassIDList}
			 </select></div></td>
			 <td style="margin:0px 2px 0px 2px;padding:0px 2px 0px 2px"><input type="button" class=inputsubmit onClick="move(this.form.theClassIDList,this.form.classIDList)" value=">"><br/>
			 <input type="button" class=inputsubmit onClick="move(this.form.classIDList,this.form.theClassIDList)" value="<"></td>
			 <td style="margin:0px;padding:0px">
			 <select name="classIDList[]" id="classIDList" multiple size="16" style="width:276px;">
				  {classIDList}
			 </select></td></tr></table>
	   </td></tr>
	  </table>
	 <table width=100%>
     <tr><td align=center>
			<input type="hidden" name="nickName" value="{nickName}">
		    <input type="hidden" name="studentID" value="{studentID}">
		    <input type="hidden" name="Action" value="DataAddCoursesSubmit"> 
            <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>
