
function addCollAjax(id,uid){
	if(uid<=0){
		alert("您没有登录，不能收藏此课件");	
		return false;
	}
	if(id<=0){
		alert("收藏课件出现错误！请确认您的操作，谢谢");	
	}
	var pars = "action=addcoll&id="+id+"&uid="+uid;
	var myAjax = new Ajax.Request("eduhelp_addcoll.php",{method:'get',parameters: pars, onSuccess: add_Coll_ok, onFailure: ajax_failure});
}



function add_Coll_ok(o){
	var res = trim(o.responseText);
	//alert(res);
	switch(res){
		case "1":
			if(confirm("收藏课件成功，点击\"确定\"转到\"我的课件收藏夹\"页面")){
				self.location="collection.php";
			}
			//alert("收藏课件成功，点击\"确定\"转到\"我的课件收藏夹\"页面");
			//self.location="collection.php";
		break;
		case "2":
			alert("您已经收藏此课件");
		break;
		default:
			alert("收藏课件出现错误！请确认您的操作，谢谢");
	}
}

function planAdd(uid,ids){
	if(uid<=0){
		alert("您没有登录，不能添加此课件到课程表");	
		return false;
	}else{
		var position = Position.cumulativeOffset($("imgaddplan"));
		var str = "<form name=\"addplanform\" id=\"addplanform\" method=\"post\">请选择时间段:<select name=\"time123\" id=\"time123\"><option value=\"1\" selected>上午</option><option value=\"2\">下午</option><option value=\"3\">晚上</option></select><input name=\"idsvalue\" type=\"hidden\" id=\"idsvalue\" value=\""+ids+"\" /><br>请选择日期:<input type=\"text\" name=\"stutime\" class=\"inputLogin\" onfocus=\"c.showMoreDay = false;c.show(this);\"/><br /><input name=\"add\" type=\"button\" class=\"inputadd\" value=\" 添加 \" onclick=\"planAddOP()\" />&nbsp;&nbsp;<input type=\"button\" class=\"inputadd\" value=\" 关闭窗口 \" onclick='hide_message();' /></form>";
		show_message(str, "ok", position[0]-150, position[1]+30);
	}
}

function planAddOP(){
	var idsvalue = addplanform.idsvalue.value;
	var stutime = addplanform.stutime.value;
	var t123 = addplanform.time123.options[addplanform.time123.selectedIndex].value;
	var pars = "action=addplanform&aid="+idsvalue+"&uid="+userid+"&stutime="+stutime+"&time123="+t123;
	var myAjax = new Ajax.Request("ajaxplanform.php",{method:'get',parameters: pars, onSuccess: add_PlanForm_ok, onFailure: ajax_failure});

}
function add_PlanForm_ok(o){
	var res = trim(o.responseText);
	//alert(res);
	if(res=="1"){
		if(confirm("添加课件到计划表成功，点击\"确定\"转到\"课件学习计划安排\"页面。点击\"取消\"继续添加课件。")){
			//alert("添加课件到计划表成功，点击\"确定\"转到\"课件学习计划安排\"页面");
			self.location="planstu.php";
		} else {
			hide_message();
			if(typeof(document.all["ids"])!=undefined){
				if(document.all["ids"].length>0){
					for(var i=0; i<document.all["ids"].length; i++)	{
						document.all["ids"][i].checked = false;
					}
				} else {
					document.all["ids"].checked = false;
				}
			}
		}
	} else {
		alert("添加课件到计划表出现错误！请确认您的操作，谢谢");
	}
}
