//common function

function showInfo(){
	AddPage(Comp_MemberItem1,xue_memberitem);
	doShowPage(Comp_XinXi);
}

function showStudy(){
	AddPage(Comp_MemberItem2,xue_memberitem);
	doShowPage(Comp_CourseList);
}

function showKeTang(){
	AddPage(Comp_MemberItem3,xue_memberitem);
	doShowPage(Comp_COSLIST);
}

function showCount(){
	AddPage(Comp_MemberItem4,xue_memberitem);
	doShowPage(Comp_CountQuery);
}

//file store operation

function DownloadFile(id){
	//alert("down load it!");
	window.location="../showfile2.jsp?id="+id;
}

function DeleteFile(id){
	if (confirm("确定要删除此资源"))
		AddPage(Comp_File+"?function=del&id="+id,xue_showwindow);
}

function ShowDialog(url, width, height, optValidate) {
    var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no;");
    return arr;
}

function checkNum(keyW){
    if(keyW.match(/[^\d]/)){
		return false;
	}else{
	    return true;
    }
}

function checkDate(str){
	var data = str.split("-");
	var ret=true;
	if(data.length==3){
		if(!(data[0].length==4&&parseInt(data[0])>1900&&parseInt(data[0])<2004)){
			ret=false;
		}

		if(data[1].indexOf("0")==0){
				data[1]=data[1].substring(1,2);
		}
		if(!(data[1].length>=1&&parseInt(data[1])>0&&parseInt(data[1])<13)){
				ret=false;
		}
		
		if(data[2].indexOf("0")==0){
				data[2]=data[2].substring(1,2);
		}
		if(!(data[2].length>=1&&parseInt(data[2])>0&&parseInt(data[2])<31)){
			ret=false;
		}

	}else{
		ret=false;
	}
	
	return ret;
}

function doUpload(type){

	var sUrl=Comp_EditFile+"?id=0";
	try{
		if(type)
			sUrl+="&type="+type;
	}catch(e){}
		
	if(ShowDialog(sUrl,500,500,true))
			AddPage(Comp_File,xue_showwindow);
}

function EditFile(id){
	if(ShowDialog(Comp_EditFile+"?id="+id,450,300,true))
		AddPage(Comp_File,xue_showwindow);
}

function DoKaiKeApply(){
	if(m_cosname.value==""){
		alert("请填写课堂名称！");
		return ;
	}
	if(m_username.value==""){
		alert("请填写用户真实姓名！");
		return ;
	}
	
	if(!checkNum(m_year.value)){
		alert("教龄必须为数字！");
		return;
	}	
	
	if(m_phone.value==""){
		alert("请填写正确的电话号码！");
		return ;
	}
	
	var str=m_cosname.value
		+"<tag>"+m_username.value
		+"<tag>"+m_roleid.options[m_roleid.selectedIndex].value
		+"<tag>"+m_teachname.value
		+"<tag>"+m_year.value
		+"<tag>"+m_teachlevel.options[m_teachlevel.selectedIndex].value
		+"<tag>"+m_phone.value
		+"<tag>"+m_school.value
		+"<tag>"+m_abstract.value
		+"<tag>"+m_taocan.options[m_taocan.selectedIndex].value;
   	
   		getHttpPost(Comp_KaiKe,str,FinishKaiKe);	
}


function DoKTInfo(){
	if(m_cosname.value==""){
		alert("请填写课堂名称！");
		return ;
	}
	if(m_username.value==""){
		alert("请填写用户真实姓名！");
		return ;
	}
	
	if(!checkNum(m_year.value)){
		alert("教龄必须为数字！");
		return;
	}	
	
	if(m_phone.value==""){
		alert("请填写正确的电话号码！");
		return ;
	}
	
	var str=m_cosname.value
		+"<tag>"+m_username.value
		+"<tag>"+m_roleid.options[m_roleid.selectedIndex].value
		+"<tag>"+m_teachname.value
		+"<tag>"+m_year.value
		+"<tag>"+m_teachlevel.options[m_teachlevel.selectedIndex].value
		+"<tag>"+m_phone.value
		+"<tag>"+m_school.value
		+"<tag>"+m_abstract.value
		+"<tag>"+m_pic.value;
		
		
   	
   		getHttpPost(Comp_KTInfo,str,FinishKTInfo);	
}

function FinishKaiKe(e){
	if(e=="<ok>")
		window.location="kecheng.htm?type=3"
}

function FinishKTInfo(e){
	if(e=="<ok>")
		alert("保存成功!");
}

function viewCos(type,id){
	if(type==0)
		window.open("../course.jsp?id="+id);
	else if(type==1)
		window.open("../file.jsp?id="+id);	
	else if(type==2)	
		window.open("../showfile.jsp?id="+id);	
}

function viewDingYue(type,id){
	if(type==0)
		window.open("../course.jsp?id="+id);
	else if(type==1)
		window.open("../ketang.jsp?id="+id);		
}

function setLevel(rightid,buyid,type,id,score){
	var ret=ShowDialog("../gettext.htm",688,310,true);
	if(ret&&ret.length>0){
		var str="appraise"+"<tag>"+rightid+"<tag>"+buyid+"<tag>"+type+"<tag>"+id+"<tag>"+score+"<tag>"+ret;   	
   		getHttpPost(Comp_CourseList,str,FinishAppraise);
   	}
}

function FinishAppraise(e){
	xue_showwindow.innerHTML=e;
}

function delFavorit(id){
	if (confirm("确定要删除此收藏!"))
		AddPage(Comp_SouCang+"?function=del&id="+id,xue_showwindow);
}



//come from teacher
var TAG_STR="<tag>";

function checkFloat(e){
	i=e.indexOf(".");
	if(i>0)
		return checkNum(e.substring(0,i))&&checkNum(e.substring(i+1,e.length));
	else
		return checkNum(e);
}


function doAddNewCos(){
	AddPage(Comp_EditCos+"?tempstr=add",xue_showwindow);
}

function doSaveNote(){
	if(m_name.value==""){
		alert("请填写通知名称！");
		return ;
	}
	if(m_content.value==""){
		alert("请填写通知内容！");
		return ;
	}
	
	var str="save";
	str=str +TAG_STR+m_id.value;
	str=str +TAG_STR+m_name.value;
	str=str +TAG_STR+m_content.value;
	getHttpPost(Comp_NoteList,str,FinishSaveNote); 
	
}

function DelNote(id){	
	if (confirm("您确定要删除选择的通知!")){	
		var str="del";
		str=str +TAG_STR+id;	
		getHttpPost(Comp_NoteList,str,FinishSaveNote); 
	}
}

function EditNote(id){	
	
	var str="edit";
	str=str +TAG_STR+id;	
	getHttpPost(Comp_NoteList,str,FinishEditNote); 
	
}

function FinishEditNote(e){
	i=e.indexOf(TAG_STR);
	m_id.value=e.substring(0,i);
	e=e.substring(i+TAG_STR.length,e.length);
	
	i=e.indexOf(TAG_STR);	
	m_name.value=e.substring(0,i);
	e=e.substring(i+TAG_STR.length,e.length);
	
	m_content.value=e;

}

function FinishSaveNote(e){
	if(e=="<ok>")
		AddPage(Comp_NoteList,xue_showwindow);
}
 
function SaveCos(){
	if(m_name.value==""){
		alert("请填写课程名称！");
		return ;
	}
	if(m_fenlei.value<0){
		alert("请选择课程分类！");
		return ;
	}
	
	if(m_book.value==""){
		alert("请填写课程教科书！");
		return ;
	}
	
	if(m_keyword.value==""){
		alert("请填写关键字！");
		return ;
	}
	
	if(!checkNum(m_circle.value)){
		alert("学习周期必须为数字！");
		return;
	}	
	
	
	if(m_opencode.checked&&m_code==""){
		alert("请填写授权码！");
		return ;
	}
	
	var str="save";
		
	str=str+TAG_STR+m_id.value
			+TAG_STR+m_name.value
			+TAG_STR+m_fenlei.value
			+TAG_STR+m_book.value
			+TAG_STR+m_keyword.value;
	var obj=document.all.m_danwei;	
	
	if(!checkFloat(m_price.value)){
		alert("价格格式不正确！");
		return;
	}		
	
	if(obj[0].checked==true){
		str=str+TAG_STR+(-m_price.value);
	}else{
		if(!checkNum(m_price.value)){
			alert("积分必须为整数!");
			return;
		}
		str=str+TAG_STR+(m_price.value*10);
	}
			
	str=str +TAG_STR+m_circle.value;
	
	if(m_opencode.checked){
			str=str +TAG_STR+m_code.value;	
			obj=document.all.m_pcdanwei;	
			if(!checkFloat(m_pricecode.value)){
				alert("授权价格格式不正确！");
				return;
			}	
			if(obj[0].checked==true){
				str=str+TAG_STR+(-m_pricecode.value);
			}else{
				if(!checkNum(m_pricecode.value)){
					alert("积分必须为整数!");
					return;
				}
				str=str+TAG_STR+(m_pricecode.value*10);
			}					
   	}else{
   		str=str +"<tag><tag>0";
   	}
   	
   	if(m_openscore.checked)
   		str=str +"<tag>1";
   	else
   		str=str +"<tag>0";	
   		
   	getHttpPost(Comp_EditCos,str,FinishSaveCos);	
}

function DeleteCos(id){
	if (confirm("选则操作后系统将会定时清除您的课程！")){
		str="del<tag>"+id;
		getHttpPost(Comp_EditCos,str,FinishSaveCos);
	}
}

function FinishSaveCos(e){
	try{
		if(e=="<ok>")
			AddPage(Comp_COSLIST,xue_showwindow);
	}catch(ex){
		alert("ok");
	}
}

function GoBackCos(){
	try{
		AddPage(Comp_COSLIST,xue_showwindow);
	}catch(ex){
		history.go(-1);
	}
}

function ShowFenLei(){
	var ret=ShowDialog(Comp_ShowSort,400,100,true);
//	alert(ret);
	if(ret){
		i=ret.indexOf(TAG_STR);
		if(i>0){
			fenlei.value=ret.substring(0,i);
			m_fenlei.value=ret.substring(i+TAG_STR.length,ret.length);
		}
	}
}

function AdminCos(id){	
	AddPage(Comp_AdminCos+"?cosid="+id,xue_showwindow);
}


var timer=null;

function checkStatus(){
	
	if(timer)
		clearTimeout(timer);
	res=qwput.GetStatus();
	
	if(res!=7&&res!=-1){
		finishedsend(res);
		qwput.Reset();
		divProcessing.style.display="none";	
		timer=null;
	}else{		
		timer= setTimeout("checkStatus()",200);  
	}
}

function DoUpload(){
	var sSupport="(.ecw .flv)";
	var ret=ShowDialog(Comp_ChooseFile,400,100,true);
	var sExt="";
	if(ret){
		sExt=""+ret;
		sExt=sExt.toLowerCase();
		i=sExt.lastIndexOf(".");
		if(i>0)
			sExt=sExt.substring(i,sExt.length);
		if(sSupport.indexOf(sExt)>=0){
			var iDate=new Date();
			var localFile=ret;
			var i=localFile.lastIndexOf("\\");
			if(i<0){
					i=localFile.lastIndexOf("/");
			}
			if(i>0){
				localFile=localFile.substring(i+1,localFile.length);
			}
					
			m_filename.value=localFile;
			if(m_id.value==0)
				m_filepath.value=m_filepath.value+"/"+iDate.getTime()+".un";
			
					
			qwput.PutRename(ret, m_filepath.value);
			divProcessing.style.display="block";			
			checkStatus();
		}else{
			alert("您只能输入"+sSupport+"格式的文件!");
		}
	}
}

function DoUploadS(){
	
	var ret=ShowDialog(Comp_UploadFile+"?id="+m_id.value+"&cosid="+m_cosid.value,500,200,true);
	var arr=ret.split(TAG_STR);	
	if(arr&&arr.length>=2){
		m_filename.value=arr[0];
		m_filepath.value=arr[1];
		finishedsend(0);
	}	
}

function DoUpload2S(){	
	var ret=ShowDialog(Comp_UploadFile2+"?id="+m_id.value+"&cosid="+m_cosid.value,500,200,true);
	var arr=ret.split(TAG_STR);	
	if(arr&&arr.length>=2){
		m_filename.value=arr[0];
		m_filepath.value=arr[1];
		finishedsend(0);
	}	
}

function DoUpload2(){
	var sSupport="(.doc .ppt .xls .txt .rar .zip .jpg)";
	var ret=ShowDialog(Comp_ChooseFile,400,100,true);
	var sExt="";
	if(ret){
		sExt=""+ret;
		sExt=sExt.toLowerCase();
		i=sExt.lastIndexOf(".");
		if(i>0)
			sExt=sExt.substring(i+1,sExt.length);
		if(sSupport.indexOf(sExt)>=0){
			var iDate=new Date();
			var localFile=ret;
			var i=localFile.lastIndexOf("\\");
			if(i<0){
					i=localFile.lastIndexOf("/");
			}
			if(i>0){
				localFile=localFile.substring(i+1,localFile.length);
			}
					
			m_filename.value=localFile;
			if(m_id.value==0)
				m_filepath.value=m_filepath.value+"/"+iDate.getTime()+".un";
			
					
			qwput.PutRename(ret, m_filepath.value);
			divProcessing.style.display="block";			
			checkStatus();
		}else{
			alert("您只能输入"+sSupport+"格式的文件!");
		}
	}
}

function finishedsend(res)
{

	 if (res==0){
   	  //上载完成
   		showfileinfospan.innerHTML="&nbsp;&nbsp;<font color=black>已经上传文件</font>&nbsp;<font color=red>"+m_filename.value+"</font> <a href=\"javascript:DoDelete()\"><font color=blue>[删除]</font></a>";
   	              
   	 } else {
	   	if (res==1){
		   alert("指定的文件不存在");
	   	} else if (res==2){
		   alert("文件大小不能为零");
	   	} else if (res==3){
		   alert("文件大小超过设定值，上传文件太大，特殊需要请联系客服。");
	   	} else if (res==4){
	       alert("文件的类型不符合要求");
	   	} else if (res==5){
	       alert("连接服务器失败，请检查安全设置，或稍后再试！");
	   	} else if (res==6){
	       alert("文件上传失败，请稍后再试！");
	   	}
	}
  
}


function SaveCosFile(){
	var str="save";
		
	str=str	+TAG_STR+m_cosid.value
			+TAG_STR+m_id.value
			+TAG_STR+m_filename.value
			+TAG_STR+m_filepath.value;
			
			
	var obj=document.all.m_danwei;	
	
	if(m_filename.value==""){
		alert("您没有上传文件！");
		return;
	}
	
	if(!checkFloat(m_money.value)){
		alert("价格格式不正确！");
		return;
	}		
	
	if(obj){
		if(obj[0].checked==true){
			str=str+TAG_STR+(-m_money.value);
		}else{
			if(!checkNum(m_money.value)){
				alert("积分必须为整数!");
				return;
			}
			str=str+TAG_STR+(m_money.value*10);
		}	
	}else{
		str=str+TAG_STR+0;
	}
	
	
	if(!checkNum(m_time.value)){
		alert("课节时长必须为数字！");
		return;
	}	
	str=str+TAG_STR+m_time.value;
	
	if(m_name.value==""){
		alert("请输入课节名称！");
		return;
	}
	str=str+TAG_STR+m_name.value;
	
	str=str+TAG_STR+m_flag3.options[m_flag3.selectedIndex].value;
	//alert(str);
	getHttpPost(Comp_AdminCos,str,FinishSaveCosFile);	
}

function SaveCosAdd(){
	var str="save";
		
	str=str	+TAG_STR+m_cosid.value
			+TAG_STR+m_id.value
			+TAG_STR+m_filename.value
			+TAG_STR+m_filepath.value;
			
			
	var obj=document.all.m_danwei;	
	
	if(m_filename.value==""){
		alert("您没有上传文件！");
		return;
	}
	
	if(!checkFloat(m_money.value)){
		alert("价格格式不正确！");
		return;
	}		
	
	if(obj){
		if(obj[0].checked==true){
			str=str+TAG_STR+(-m_money.value);
		}else{
			if(!checkNum(m_money.value)){
				alert("积分必须为整数!");
				return;
			}
			str=str+TAG_STR+(m_money.value*10);
		}	
	}
	
	if(!checkNum(m_time.value)){
		alert("课节时长必须为数字！");
		return;
	}	
	str=str+TAG_STR+m_time.value;
	
	if(m_name.value==""){
		alert("请输入资源名称！");
		return;
	}
	str=str+TAG_STR+m_name.value;	
	str=str+TAG_STR+m_flag3.options[m_flag3.selectedIndex].value;
	
	getHttpPost(Comp_AdminAddition,str,FinishSaveCosAdd);	
}


function FinishSaveCosFile(e,str){

	if(e=="<ok>"){
		alert("保存成功！");
		arr=str.split(TAG_STR);	
		if(arr.length>1){			
			AddPage(Comp_AdminCos+"?cosid="+arr[1],xue_showwindow);
		}
	}
}

function FinishSaveCosAdd(e,str){
	if(e=="<ok>"){
		alert("保存成功！");
		arr=str.split(TAG_STR);
		if(arr.length>1){			
			AddPage(Comp_AdminAddition+"?cosid="+arr[1],xue_showwindow);
		}
	}
}

function DelCosFile(cosid,fileid){
	if (confirm("确定要删除此资源")){
		var str="del";			
		str=str	+TAG_STR+cosid +TAG_STR+fileid;
		getHttpPost(Comp_AdminCos,str,FinishSaveCosFile);
	}
			
}

function DelCosAdd(cosid,fileid){
	if (confirm("确定要删除此资源")){
		var str="del";			
		str=str	+TAG_STR+cosid +TAG_STR+fileid;
		getHttpPost(Comp_AdminCos,str,FinishSaveCosAdd);
	}
			
}

function EditCosFile(cosid,fileid){
	var str="edit";
	str=str +TAG_STR+cosid+TAG_STR+fileid;	
	getHttpPost(Comp_AdminCos,str,FinishEditCosFile); 
}

function EditCosAdd(cosid,fileid){
	var str="edit";
	str=str +TAG_STR+cosid+TAG_STR+fileid;	
	getHttpPost(Comp_AdminAddition,str,FinishEditCosAdd); 
}

function FinishEditCosFile(e){
	var ret=e.split(TAG_STR);
	if(ret.length>=7){
		m_cosid.value=ret[0];//cosid
		m_id.value=ret[1];//file id
		m_filename.value=ret[2];//file name
		m_filepath.value=ret[3];//file path
		iPrice=parseInt(ret[4]);//price
		var obj=document.all.m_danwei;
		if(obj){
			if(iPrice>0){
				obj[1].checked=true;
				m_money.value=iPrice/10.0;
			}else{
				obj[0].checked=true;
				m_money.value=-iPrice;
			}
		}
		
		m_time.value=ret[5];//time
		m_name.value=ret[6];//name
		
		var iType=parseInt(ret[7]);
		if(iType==0){
			m_flag3.selectedIndex=0;			
		}else{
			m_flag3.selectedIndex=1;
		}		
		
		showfileinfospan.innerHTML="&nbsp;&nbsp;<font color=black>已经上传文件</font>&nbsp;<font color=red>"+m_filename.value+"</font>";
	}
}


function FinishEditCosAdd(e){
	var ret=e.split(TAG_STR);
	if(ret.length>=7){
		m_cosid.value=ret[0];//cosid
		m_id.value=ret[1];//file id
		m_filename.value=ret[2];//file name
		m_filepath.value=ret[3];//file path
		iPrice=parseInt(ret[4]);//price
		var obj=document.all.m_danwei;
		if(iPrice>0){
			obj[1].checked=true;
			m_money.value=iPrice/10.0;
		}else{
			obj[0].checked=true;
			m_money.value=-iPrice;
		}
		
		m_time.value=ret[5];//time
		m_name.value=ret[6];//name
		
		var iType=parseInt(ret[7]);
		if(iType==0){
			m_flag3.selectedIndex=0;			
		}else{
			m_flag3.selectedIndex=1;
		}
		
		showfileinfospan.innerHTML="&nbsp;&nbsp;<font color=black>已经上传文件</font>&nbsp;<font color=red>"+m_filename.value+"</font>";
	}
}

function EditCosInfo(id){
	AddPage(Comp_EditCos+"?id="+id,xue_showwindow);
}


function UpdateAddtion(id){	
	AddPage(Comp_AdminAddition+"?cosid="+id,xue_showwindow);
}

function AddNewDoc(){	
	AddPage(Comp_NewWenJi,xue_showwindow);
}

function SaveDoc(){
	var str="save";
		
	str=str	+TAG_STR+m_id.value;
	
	if(m_titile.value==""){
		alert("请输入文章标题！");
		return;
	}
	str=str+TAG_STR+m_titile.value;
	
	sContent=eWebEditor1.getHTML();
	if(sContent.length<10){
		alert("文章内容必须包含10个字符！");
		return;
	}
	
	str=str+TAG_STR+sContent;
	
	getHttpPost(Comp_WenJi,str,FinishSaveDoc);	
}

function FinishSaveDoc(e){
	if(e=="<ok>")
		AddPage(Comp_WenJi,xue_showwindow);
}

function EditTchDoc(id){
	AddPage(Comp_NewWenJi+"?id="+id,xue_showwindow,FinishGetDoc);
}

function FinishGetDoc(str){
	var sstag="<99xue_content>";
	var setag="</99xue_content>";
	i=str.indexOf(sstag);
	j=str.indexOf(setag);
	if(i>0&&j>i+sstag.length){
		content1.value=str.substring(i+sstag.length,j);
		//alert(content1.value);
	}
	//eWebEditor1.location="../webeditor/ewebeditor.htm?id=content1&style=coolblue&extcss=../images/myccs.css"
}

function DelTchDoc(id){
	if (confirm("您确定要删除选择的文章!")){
		var str="del";		
		str=str	+TAG_STR+id;			
		getHttpPost(Comp_WenJi,str,FinishSaveDoc);	
	}
}

function goKeTang(userid,tempid,noUserNew){
	if(noUserNew)
		window.location="../t"+tempid+"/"+userid+".show";
	else
		window.open("../t"+tempid+"/"+userid+".show");
}

function viewQNA(id){
	window.open("../discussion.htm?id="+id);
}

function ShowProvince(){
	var ret=ShowDialog(Comp_ShowCity,400,100,true);
//	alert(ret);
	if(ret){
		i=ret.indexOf(TAG_STR);
		if(i>0){
			document.all.showCity.value=ret.substring(0,i);
			document.all.province.value=ret.substring(i+TAG_STR.length,ret.length);
		}
	}
}


function DoSaveXinXi(){
	
	if(username.value=="")
	{
	    alert("请输入用户名!");
			username.focus();
	   	return;
	}
	
	if(email.value=="")
	{
	  	alert("请输入电子邮件!");
			email.focus();
	    return;
	}   
	
	var obj=document.all.sex;
	var sexValue=0;
	for(i=0;i<obj.length;i++){
			if(obj[i].checked){
				sexValue=obj[i].value;
				break;
			}
			
	}
	
	if(province.value<0){
		alert("请选择您所在的城市！");
		return;
	}
	
	if(!checkDate(birth.value)){
		alert("生日的格式必须类似1988-08-08形式!");
		birth.focus();
		return;
	}
	
	var str=username.value
		+"<tag>"+email.value
		+"<tag>"+sexValue
		+"<tag>"+province.value
		+"<tag>"+birth.value
		+"<tag>"+userpic.value;
	 	
  	getHttpPost(Comp_XinXi,str,FinishSaveXinXi);	
}


function FinishSaveXinXi(e){
	if(e=="<ok>")
		alert("保存成功!");
	
}


function ChangePassWord(){
	
	if(password0.value=="")
	{
	    alert("请输入原密码!");
			password0.focus();
	   	return;
	}
	
	if(password1.value!=password2.value||password1.value=="")
	{
	    alert("两次输入密码不一致!");
			password1.focus();
	   	return;
	}
	
	
	
	var str=password0.value
		+"<tag>"+password1.value;
	 	
  	getHttpPost(Comp_PassWord,str,FinishPassWord);	
}


function FinishPassWord(e){
	if(e=="<ok>")
		alert("修改成功!");
	
}

function delFreind(id){
	GetPage("../member/haoyou.html?fun=del&id="+id,FinishDelFreind);
}

function FinishDelFreind(str){
	xue_showwindow.innerHTML=str;
}


function DoSaveCount(){
	var str=mybank.options[mybank.selectedIndex].value;		
	str+=TAG_STR+account.value;
	str+=TAG_STR+username.value;
	
		   		
   	getHttpPost(Comp_CountSetting,str,FinishSaveAccount);
}


function FinishSaveAccount(e){
	if(e=="<ok>")
		alert("修改成功!");
}


function BuyScore(maxscore){
	var iScore=score.value;
	
	if(checkNum(iScore)&&iScore*2<=maxscore&&maxscore>0)		   		
   		getHttpPost(Comp_BuyScore,2*iScore,FinishBuyScore);
   	else
   		alert("您最多只能购买"+maxscore+"个积分");	
}


function FinishBuyScore(e){
	if(e=="<ok>"){
		alert("购买成功!");
		doShowPage(Comp_BuyScore);
		AddPage(Comp_Member,xue_member);
	}	
}

var lastStr="";
function doShowPage2(sUrl,str){
	lastStr=str;
	GetPage(sUrl,finishDoShowPage2);
}

function finishDoShowPage2(str){
	xue_showwindow.innerHTML=str+lastStr;
}

function TongJiCos(cosid){
	var str="<table width=\"100%\" border=0><tr><td height=\"20\" align=\"center\"><input type=\"button\" name=\"Submit\" value=\" 返 回 \" onclick=\"GoBackCos()\"></td></tr>";
	doShowPage2(Comp_SellList+"?cos="+cosid,str);
}

function showUser(id){
	window.open("../showuser.htm?id="+id);
}

function uploadImg(){
	ret=showModalDialog("putpic.jsp", window, "dialogWidth:400px;dialogHeight:200px;help:no;scroll:no;status:no");
	//alert(ret);
	if(ret){
		userpic.value=ret;
		obj=document.getElementById("userimg");		
		obj.src="../../"+userpic.value+"?"+new Date;
		
	}
}

function CongZhi(userid,orderid,money){
	try{
		if(checkNum(xuebi.value)&&money>0){
			var str=orderid+"<tag>"+userid+"<tag>"+money;
			getHttpPost(Comp_ChongZhi,str,finishCongZhi);
			window.open("../../chinabank/Send.jsp?v_oid="+orderid+"&v_amount="+money+"&remark1="+userid);
			}
		else
			alert("请输入一个整数!");	
	}catch(ex){		
		
	}finally{
	}
	
}

function finishCongZhi(e){
	doShowPage(Comp_ChongZhi);
}


/////////////////////////////////////////////////////////////
//家教函数
////////////////////////////////////////////////////////////

function SaveSTeach(){
	if(m_name.value==""){
		alert("请输入姓名！");
		return ;
	}
	
	if(m_school.value==""){
		alert("请输入所在学校！");
		return ;
	}
	
	if(province.value<0){
		alert("请选择城市！");
		return;
	}
	
	if(m_address.value==""){
		alert("请输入家庭住址！");
		return ;
	}
	
	if(m_fenlei.value<0){
		alert("请选择分类！");
		return;
	}
	
	var iteachtype=-1;
	var obj=document.all.m_teachtype;
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			iteachtype=obj[i].value;
			break;
		}
	}
	
	if(iteachtype==-1){
		alert("请选择辅导方式！");
		return;
	}
	
	var iFlag1=-1;
	obj=document.all.m_iflag1;
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			iFlag1=obj[i].value;
			break;
		}
	}
	
	if(iFlag1==-1){
		alert("请选择资格要求！");
		return;
	}
	
	if(m_money.value==""){
		alert("请选择薪酬标准！");
		return;
	}
	
	var str="save";
	str+="<tag>"+m_id.value;
	str+="<tag>"+m_name.value;
	str+="<tag>"+m_school.value;
	str+="<tag>"+province.value;
	str+="<tag>"+m_level.options[m_level.selectedIndex].value;
	str+="<tag>"+m_sflag1.value;
	str+="<tag>"+m_address.value;
	str+="<tag>"+m_fenlei.value;
	str+="<tag>"+iteachtype;
	str+="<tag>"+iFlag1;
	str+="<tag>"+m_money.value;
	str+="<tag>"+m_day.options[m_day.selectedIndex].value;
	if(day1_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day2_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day3_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day4_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day5_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day6_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day7_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
				
				
	if(day1_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day2_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day3_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day4_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day5_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day6_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day7_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day1_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day2_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day3_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day4_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day5_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day6_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day7_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
				
	str+="<tag>"+m_info.value+"<tag>";		
	
	getHttpPost(Comp_AskTch,str,FinishSaveSTeach);					
}


function FinishSaveSTeach(str){
	if(str=="<ok>"){
		alert("添加成功！");
		ShowSList();
	}else{
		alert(str);
	}
}

function ShowSList(){
	doShowPage(Comp_AskTchList);
}

function editAskTch(id){
	doShowPage(Comp_AskTch+"?id="+id);
}

function delAskTch(id){
	if (confirm("确定要删除此信息")){
		var str="del<tag>"+id
		getHttpPost(Comp_AskTch,str,FinishDelSTeach);
	}
}

function FinishDelSTeach(str){
		if(str=="<ok>"){			
			ShowSList();
		}else{
			alert(str);
		}
}


function SaveBeTeach(){
	if(m_name.value==""){
		alert("请输入教师姓名！");
		return ;
	}
	
	if(m_school.value==""){
		alert("请输入所在学校！");
		return ;
	}
	
	if(province.value<0){
		alert("请选择城市！");
		return;
	}
	
	if(m_address.value==""){
		alert("请输入家庭住址！");
		return ;
	}
	
	if(m_fenlei.value<0){
		alert("请选择辅导学科！");
		return;
	}
	
	var iteachtype=-1;
	var obj=document.all.m_teachtype;
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			iteachtype=obj[i].value;
			break;
		}
	}
	
	if(iteachtype==-1){
		alert("请选择辅导方式！");
		return;
	}
	
	var iFlag1=0;
	
	
	if(m_money.value==""){
		alert("请选择薪酬标准！");
		return;
	}
	
	var str="save";
	str+="<tag>"+m_id.value;
	str+="<tag>"+m_name.value;
	str+="<tag>"+m_school.value;
	str+="<tag>"+province.value;
	str+="<tag>"+m_level.options[m_level.selectedIndex].value;
	str+="<tag>"+m_sflag1.value;
	str+="<tag>"+m_address.value;
	str+="<tag>"+m_fenlei.value;
	str+="<tag>"+iteachtype;
	str+="<tag>"+iFlag1;
	str+="<tag>"+m_money.value;
	str+="<tag>"+m_day.options[m_day.selectedIndex].value;
	if(day1_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day2_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day3_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day4_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day5_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day6_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day7_1.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
				
				
	if(day1_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day2_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day3_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day4_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day5_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day6_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day7_2.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day1_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day2_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";
		
	if(day3_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day4_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day5_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
		
	if(day6_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
	
	if(day7_3.checked)
		str+="<tag>1";
	else
		str+="<tag>0";	
				
	str+="<tag>"+m_info.value+"<tag>";		
	
	getHttpPost(Comp_BeTch,str,FinishSaveBeTeach);					
}

function FinishSaveBeTeach(str){
	if(str=="<ok>"){
		alert("添加成功！");
		ShowBeList();
	}else{
		alert(str);
	}
}


function ShowBeList(){
	doShowPage(Comp_BeTchList);
}

function editBeTch(id){
	doShowPage(Comp_BeTch+"?id="+id);
}

function delBeTch(id){
	if (confirm("确定要删除此信息")){
		var str="del<tag>"+id
		getHttpPost(Comp_BeTch,str,FinishDelBeTeach);
	}
}

function FinishDelBeTeach(str){
		if(str=="<ok>"){			
			ShowBeList();
		}else{
			alert(str);
		}
}

var timer=null;

function checkUser(){
	
	try{
		AddPage(Comp_Login,xue_login);
		if(timer)
			clearTimeout(timer);
	}catch(e){
		
	}
	
}
function finishLoadItem(str)
{
	if(timer)
		clearTimeout(timer);
	timer= setTimeout("checkUser()",200); 
	
}

function ShowSApplyList(){
	doShowPage(Comp_AskTchListYY);
}

function passAskTchYY(id){
	var str="pass<tag>"+id
	getHttpPost(Comp_AskTchListYY,str,FinishPassAskYY);
}

function FinishPassAskYY(str){
	if(str=="<ok>"){			
			ShowSApplyList();
		}else{
			alert(str);
		}
}

function deleteAskTchYY(id){
	var str="del<tag>"+id
	getHttpPost(Comp_AskTchListYY,str,FinishPassAskYY);
}


function ShowBeApplyList(){
	doShowPage(Comp_BeTchListYY);
}

function passBeTchYY(id){
	var str="pass<tag>"+id
	getHttpPost(Comp_BeTchListYY,str,FinishPassBeYY);
}

function FinishPassBeYY(str){
	if(str=="<ok>"){			
			ShowBeApplyList();
		}else{
			alert(str);
		}
}

function deleteBeTchYY(id){
	var str="del<tag>"+id
	getHttpPost(Comp_BeTchListYY,str,FinishPassBeYY);
}

function deleteYYTch(id){
	var str="del<tag>"+id
	getHttpPost(Comp_BeTchListYY,str,FinishDelYYTch);
}

function FinishDelYYTch(str){
	if(str=="<ok>"){			
			doShowPage(Comp_MyYYTch);
		}else{
			alert(str);
		}
}

function deleteYYStu(id){
	var str="del<tag>"+id
	getHttpPost(Comp_AskTchListYY,str,FinishDelYYStu);
}

function FinishDelYYStu(str){
	if(str=="<ok>"){			
			doShowPage(Comp_MyYYStu);
		}else{
			alert(str);
		}
}

function replyMessage(id){
	window.open("../sendmessage.jsp?id="+id);
}

function delMessage(id){
	var ret=ShowDialog("../delmessage.jsp?id="+id,300,100,true);
	if(ret=="ok"){
		doShowPage(Comp_Message);
	}
}

function viewMessage(id){
	window.open("../showmessage.jsp?id="+id);
}

function ViewCosAdd(cos,id){
	window.open("../showcosfile.jsp?id="+id);
}

function ViewCosFile(cos,id){
	window.open("../showcosfile.jsp?id="+id);
}