var php_pre = "http://localhost:8080/";
//var php_pre = "/js/";
//登陆，验证
function validate() {
	
	document.getElementById('button22').disabled = true;
	var username= getValue(document.form1.username.value);
	var password= getValue(document.form1.password.value);
	document.form1.username.value = username;
	document.form1.password.value = password;


	if(username== null || username=="") {
		document.getElementById('button22').disabled = false;
	   alert("用户名不能为空!");
	   return false;
	}

	if(password==null || password=="") {
		document.getElementById('button22').disabled = false;
	   alert("密码不能为空!");
	   return false;
	}
	//分配ip
	var coverCode = username.substring(0,2);
	var url = "";//内网ip
	var url_jsp = "";//外网ip
	for(var i=0;i<serverList.length;i++) {
	  var object = serverList[i];	  
	  if(coverCode.toUpperCase()==object.code.toUpperCase()) {
		  url = object.url;//内网ip
		  url_jsp = object.url_jsp;//外网ip		 
		  break;
	   }
	   if(i==serverList.length-1){
		url=defaultUrl;//内网ip
		url_jsp=defaultUrl_jsp;//外网ip
	  }
	}	
			
	
	Define('URLGET_PROXY', php_pre+'logon_jsproxy.php');
	var urlget = Class.get('modello.ajax.Urllib').urlget;

	var ajax_url = "http://"+url+"/InitStudy/servlet/com.init.web.LogonServlet?username="+username+"&password="+escape(password);
	//alert("URL地址:"+ajax_url);
	var response = urlget(ajax_url,null,callback);
}
function callback(response){
	//alert(response.getText());
	//分配ip
	var username= document.form1.username.value;
	var coverCode = username.substring(0,2);
	var url = "";//内网ip
	var url_jsp = "";//外网ip
	for(var i=0;i<serverList.length;i++) {
	  var object = serverList[i];	  
	  if(coverCode.toUpperCase()==object.code.toUpperCase()) {
		  url = object.url;//内网ip
		  url_jsp = object.url_jsp;//外网ip	 
		  break;
	   }
	   if(i==serverList.length-1){
		url=defaultUrl;//内网ip
		url_jsp=defaultUrl_jsp;//外网ip
	  }
	}		
//alert(response.getText());
	var myresult = response.getXML();
	if(myresult!=null){
		var is_user_id = myresult.getElementsByTagName("is_user_id")[0].firstChild.data;
		var is_password = myresult.getElementsByTagName("is_password")[0].firstChild.data;
		var is_time_out = myresult.getElementsByTagName("is_time_out")[0].firstChild.data;
		
		if(is_user_id==1 && is_password==1 && is_time_out==1){
			//登陆成功
			document.form1.action="http://"+url_jsp+"/InitStudy/chinese/logon.jsp";
			//alert(form1.action);
			document.form1.submit();
		}
		else{//登陆失败
			if(is_user_id==0){
				document.getElementById('button22').disabled = false;
				//document.form1.username.value = "没有这个帐号！";
				document.form1.username.value = "";
				document.form1.password.value = "";
				alert("没有这个帐号！");
				return false;
			}
			else if(is_password==0){
				document.getElementById('button22').disabled = false;
				//document.form1.username.value = "密码错误！";
				document.form1.password.value = ""
				alert("密码错误！");
				return false;
			}
			else if(is_time_out==0){
				document.getElementById('button22').disabled = false;
				//document.form1.username.value = "帐号过期！";
				alert("帐号过期！");
				return false;
			}
		}
   		
	}
	else{
		//系统出现问题，请您稍后再试
		alert("请重新登陆！");
	}
}
//回车，自动提交
function auto_tj(){ 
	if(event.keyCode==13){
		if(!document.getElementById('button22').disabled){
			validate();
		}
	}
}

function auto_regster(imediately){ 
	if(event.keyCode==13){
		if(document.getElementById('div_99').style.display==""){
			isExistEmail(imediately);
		}
	}
}
//用户注册
function register(imediately) {

	var email= document.getElementById("email").value;
	
	//注册用户，用187服务器
	var url=defaultUrl;//内网ip
	//var url_jsp=defaultUrl_jsp;//外网ip
	
	Define('URLGET_PROXY', php_pre+'jsproxy.php');
	var urlget = Class.get('modello.ajax.Urllib').urlget;
	
	var ajax_url = "http://"+url+"/InitStudy/servlet/com.init.free.service.UserRegisterServlet?email="+email+"&imediately="+imediately;
	//alert("URL地址:"+ajax_url);
	var response = urlget(ajax_url,null,call_register);
}
function isExistEmail(imediately){
	//document.getElementById('button99').disabled = true;
	document.getElementById('div_99').style.display="none";
	document.getElementById('div_100').style.display="";
	var email= getValue(document.getElementById("email").value);
	document.getElementById("email").value = email;
	
	if(email=="") {
	   //alert("邮箱不能为空！");
	   document.getElementById("zq").style.display="none";
	   document.getElementById("cw").style.display="";
	   document.getElementById("cw").innerHTML="邮箱不能为空！";
	   document.getElementById("email").focus();
	   //document.getElementById('button99').disabled = false;
	   document.getElementById('div_99').style.display="";
		document.getElementById('div_100').style.display="none";
	   return false;
	}
	else if(checkEmail(email)){
		//alert("邮箱地址非法！");
		document.getElementById("zq").style.display="none";
	    document.getElementById("cw").style.display="";
	    document.getElementById("cw").innerHTML="邮箱地址非法！";
		document.getElementById("email").focus();
		//document.getElementById('button99').disabled = false;
		document.getElementById('div_99').style.display="";
		document.getElementById('div_100').style.display="none";
		return false;
	}
	
	//注册用户，用187服务器
	var url=defaultUrl;//内网ip
	//var url_jsp=defaultUrl_jsp;//外网ip
	
	Define('URLGET_PROXY', php_pre+'logon_jsproxy.php');
	var urlget = Class.get('modello.ajax.Urllib').urlget;
	
	var ajax_url = "http://"+url+"/InitStudy/servlet/com.init.free.service.IsExistEmailServlet?email="+email+"&imediately="+imediately;
	var response = urlget(ajax_url,null,call_isExistEmail);
}
function call_isExistEmail(response){
	//alert(response.getText());
	var myresult = response.getXML();
	if(myresult!=null){
		var isExistEmail = myresult.getElementsByTagName("isExistEmail")[0].firstChild.data;
		var imediately = myresult.getElementsByTagName("imediately")[0].firstChild.data;
		//alert(isExistEmail);
		if(isExistEmail==1){//存在，不能注册
			//document.getElementById("zq").innerHTML="已存在该邮箱，请您使用其它邮箱注册！";
			document.getElementById("zq").style.display="none";
			document.getElementById("cw").style.display="";
			document.getElementById("cw").innerHTML="该邮箱已使用！不可再注册。";
			//document.getElementById('button99').disabled = false;
			document.getElementById('div_99').style.display="";
			document.getElementById('div_100').style.display="none";
			return false;
		}
		else{//不存在该email
			register(imediately);
		}
   		
	}
	else{
		//系统出现问题，请您稍后再试
		//document.getElementById('button99').disabled = false;
		document.getElementById('div_99').style.display="";
		document.getElementById('div_100').style.display="none";
		alert("注册失败！请重新注册！");
	}
}

function call_register(response){
	//alert(response.getText());
	var myresult = response.getXML();
	//注册用户，用187服务器
	var url=defaultUrl;//内网ip
	var url_jsp=defaultUrl_jsp;//外网ip
	//alert(url);
	if(myresult!=null){
		var is_success = myresult.getElementsByTagName("is_success")[0].firstChild.data;
		var email = myresult.getElementsByTagName("email")[0].firstChild.data;
		var user_id = myresult.getElementsByTagName("user_id")[0].firstChild.data;
		var password = myresult.getElementsByTagName("password")[0].firstChild.data;
		var imediately = myresult.getElementsByTagName("imediately")[0].firstChild.data;
		
		if(is_success==0){//注册失败		
			//document.getElementById('button99').disabled = false;
			document.getElementById('div_99').style.display="";
			document.getElementById('div_100').style.display="none";
			alert("注册失败！请重新注册！");
		}
		else{//注册成功，重写页面;下列代码拷贝自ljty02.html；
			//alert("注册成功");//curriculum_ty.jsp
			if(imediately=='1'){//首页，点击立即体验进入
				document.getElementById("suc").innerHTML="<div class=\"ljty_title\">注册帐号 >> 填写邮箱地址 &gt;&gt; <span class=\"c_bule\">注册成功<\/span><\/div><div class=\"ljty_text\"><table width=\"100%\" border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"4\"><tr><td width=\"49%\" height=\"28\"><div id=\"zq\">注册成功<\/div><\/td><td width=\"51%\"><\/td><\/tr> <tr><td height=\"57\" colspan=\"2\" style=\"font-size:14px; line-height:24px;\">您的帐号：<span class=\"c_red\">"+user_id+"<\/span>&nbsp;&nbsp;密码：<span class=\"c_red\">"+password+"<\/span><br \/>系统已将您的帐号和密码发送到您的电子邮箱 <span class=\"c_red\">"+email+"<\/span> 中<br \/><\/td><\/tr><tr><td colspan=\"2\">&nbsp;<\/td><\/tr><tr><td height=\"76\" colspan=\"2\" valign=\"top\"><table width=\"230\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"115\"><\/td><td width=\"227\"><input type=\"button\" name=\"button66\" onclick=\"tj3();\" class=\"an_bg_1\"  value=\"开始体验\"><\/td><\/tr><\/table><\/td><\/tr><\/table><\/div>                             <form name=\"form1\" action=\"http:\/\/"+url_jsp+"\/InitStudy\/chinese\/logon.jsp\" target=\"_parent\"><input type=\"hidden\" name=\"username\" value=\""+user_id+"\"><input type=\"hidden\" name=\"password\" value=\""+password+"\"><input type=\"hidden\" name=\"dispatch_type\" value=\"\"><input type=\"hidden\" name=\"justNowRegister\" value=\"1\"> <\/form>";
			}
			else{//首页，点击8秒注册进入
				document.getElementById("suc").innerHTML="<div class=\"ljty_title\">注册帐号 >> 填写邮箱地址 &gt;&gt; <span class=\"c_bule\">注册成功<\/span><\/div><div class=\"ljty_text\"><table width=\"100%\" border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"4\"><tr><td width=\"49%\" height=\"28\"><div id=\"zq\">注册成功<\/div><\/td><td width=\"51%\"><\/td><\/tr> <tr><td height=\"57\" colspan=\"2\" style=\"font-size:14px; line-height:24px;\">您的帐号：<span class=\"c_red\">"+user_id+"<\/span>&nbsp;&nbsp;密码：<span class=\"c_red\">"+password+"<\/span><br \/>系统已将您的帐号和密码发送到您的电子邮箱 <span class=\"c_red\">"+email+"<\/span> 中<br \/><\/td><\/tr><tr><td colspan=\"2\">&nbsp;<\/td><\/tr><tr><td height=\"76\" colspan=\"2\" valign=\"top\"><table width=\"230\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"115\"><input <input name=\"button77\" type=\"button\" onclick=\"tj2();\" class=\"an_bg_1\"  value=\"学习卡激活\"><\/td><td width=\"227\"><input name=\"button88\" type=\"button\" onclick=\"tj();\" class=\"an_bg_1\" value=\"开始体验\"><\/td><\/tr><\/table><\/td><\/tr><\/table><\/div>                             <form name=\"form1\" action=\"http:\/\/"+url_jsp+"\/InitStudy\/chinese\/logon.jsp\" target=\"_parent\"><input type=\"hidden\" name=\"username\" value=\""+user_id+"\"><input type=\"hidden\" name=\"password\" value=\""+password+"\"><input type=\"hidden\" name=\"dispatch_type\" value=\"1\"><input type=\"hidden\" name=\"justNowRegister\" value=\"1\"> <\/form>";
			}
		}
   		
	}
	else{
		//系统出现问题，请您稍后再试
		//document.getElementById('button99').disabled = false;
		document.getElementById('div_99').style.display="";
		document.getElementById('div_100').style.display="none";
		alert("注册失败！请重新注册！");
	}
}
function tj(){
	document.getElementById('button77').disabled = true;
	document.getElementById('button88').disabled = true;
	document.form1.dispatch_type.value="3";
	document.form1.submit();
}
function tj2(){
	document.getElementById('button77').disabled = true;
	document.getElementById('button88').disabled = true;
	document.form1.dispatch_type.value="2";
	document.form1.submit();
}
function tj3(){
	document.getElementById('button66').disabled = true;
	document.form1.dispatch_type.value="3";
	document.form1.submit();
}
//检查邮件
function checkEmail(str) {
  if (!(str == "")) {
    var atIndex = str.indexOf('@');
    var dotIndex = str.indexOf('.', atIndex);
    var flag = false;
    theSub = str.substring(0, dotIndex + 1);
    if ((atIndex < 1) || (atIndex != str.lastIndexOf('@')) ||
        (dotIndex < atIndex + 2) || (str.length <= theSub.length)) {
        flag = true;
    } else {
        flag = false;
    }
    return flag;
  }
}

//生成随机码
function randomNum1(){
	var random_num = "";
	var numArray = new Array(4);
	for(var i=0;i<numArray.length;i++){
		numArray[i] = Math.round(Math.random()*9);
	}
	for(var j=0;j<numArray.length;j++){
		random_num+=numArray[j];
	}
	return random_num; 
}
function showNum(){
	document.getElementById("Code").innerHTML=randomNum1(); 
}
//处理字符串
function getValue(str){
	if ((str == null) || (str.replace(/(^\s*)|(\s*$)/g, "")=="")) {
	    return "";
	} else {
	    return str.replace(/(^\s*)|(\s*$)/g, "");
	}
}
//8秒注册引用
function sAlert(str){
	sAlert_all(str,560,360);
}

function sAlert_all(str, width, heigh){
	sAlert_all_2(str, width, heigh, 45, 36);
}

function sAlert_all_2(str, width, heigh, leftRate, topRate){
	var msgw,msgh,bordercolor;
	msgw=width;//提示窗口的宽度
	msgh=heigh;//提示窗口的高度
	titleheight=18 //提示窗口标题高度
	bordercolor="#336699";//提示窗口的边框颜色
	titlecolor="#99CCFF";//提示窗口的标题颜色
	var sWidth,sHeight;
	sWidth=document.body.offsetWidth;
	sHeight=screen.height;
	var bgObj=document.createElement("div");
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#777";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=15";
	bgObj.style.opacity="0.1";
	bgObj.style.left="0";
	bgObj.style.width=sWidth + "px";
	bgObj.style.height=sHeight + "px";
	bgObj.style.zIndex = "10000";
	document.body.appendChild(bgObj);
	var msgObj=document.createElement("div")
	msgObj.setAttribute("id","msgDiv");
	msgObj.setAttribute("align","center");
	msgObj.style.background="white";
	msgObj.style.border="1px solid " + bordercolor;
	msgObj.style.position = "absolute";
	msgObj.style.left = leftRate+"%";
	msgObj.style.top = topRate+"%";
	msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
	msgObj.style.marginLeft = "-225px" ;
	msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
	msgObj.style.width = msgw + "px";
	msgObj.style.height =msgh + "px";
	msgObj.style.textAlign = "center";
	msgObj.style.overflow = "hidden";
	msgObj.style.lineHeight ="22px";
	msgObj.style.zIndex = "10001";
	var title=document.createElement("h4");
	title.setAttribute("id","msgTitle");
	title.setAttribute("align","right");
	title.style.margin="0";
	title.style.padding="3px";
	title.style.background=bordercolor;
	title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
	title.style.opacity="0.75";
	title.style.border="1px solid " + bordercolor;
	title.style.height="18px";
	title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
	title.style.color="white";
	title.style.cursor="pointer";
	title.innerHTML="关闭";
	title.onclick=function(){
		document.body.removeChild(bgObj);
		document.getElementById("msgDiv").removeChild(title);
		document.body.removeChild(msgObj);
	}
	document.body.appendChild(msgObj);
	document.getElementById("msgDiv").appendChild(title);
	var txt=document.createElement("p");
	txt.style.margin="1em 0"
	txt.setAttribute("id","msgTxt");
	txt.innerHTML=str;
	document.getElementById("msgDiv").appendChild(txt);
}

function sAlert_Hide(str, width, heigh,obj){
	var msgw,msgh,bordercolor;
	msgw=width;//提示窗口的宽度
	msgh=heigh;//提示窗口的高度
	titleheight=18 //提示窗口标题高度
	bordercolor="#336699";//提示窗口的边框颜色
	titlecolor="#99CCFF";//提示窗口的标题颜色
	var sWidth,sHeight;
	sWidth=document.body.offsetWidth;
	sHeight=screen.height;
	var bgObj=document.createElement("div");
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#777";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=15";
	bgObj.style.opacity="0.1";
	bgObj.style.left="0";
	bgObj.style.width=sWidth + "px";
	bgObj.style.height=sHeight + "px";
	bgObj.style.zIndex = "10000";
	document.body.appendChild(bgObj);
	var msgObj=document.createElement("div")
	msgObj.setAttribute("id","msgDiv");
	msgObj.setAttribute("align","center");
	msgObj.style.background="white";
	msgObj.style.border="1px solid " + bordercolor;
	msgObj.style.position = "absolute";
	msgObj.style.left = "45%";
	msgObj.style.top = "36%";
	msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
	msgObj.style.marginLeft = "-225px" ;
	msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
	msgObj.style.width = msgw + "px";
	msgObj.style.height =msgh + "px";
	msgObj.style.textAlign = "center";
	msgObj.style.lineHeight ="22px";
	msgObj.style.zIndex = "10001";
	var title=document.createElement("h4");
	title.setAttribute("id","msgTitle");
	title.setAttribute("align","right");
	title.style.margin="0";
	title.style.padding="3px";
	title.style.background=bordercolor;
	title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
	title.style.opacity="0.75";
	title.style.border="1px solid " + bordercolor;
	title.style.height="18px";
	title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
	title.style.color="white";
	title.style.cursor="pointer";
	title.innerHTML="关闭";
	title.onclick=function(){
		document.body.removeChild(bgObj);
		document.getElementById("msgDiv").removeChild(title);
		document.body.removeChild(msgObj);
		obj.style.display="block";
	}
	document.body.appendChild(msgObj);
	document.getElementById("msgDiv").appendChild(title);
	var txt=document.createElement("p");
	txt.style.margin="1em 0"
	txt.setAttribute("id","msgTxt");
	txt.innerHTML=str;
	document.getElementById("msgDiv").appendChild(txt);
}
/*
yangfan add
为页面弹出说明准备
*/
function sAlert_window(str){
  var msgw,msgh,bordercolor;
msgw=560;//提示窗口的宽度
msgh=396;//提示窗口的高度
titleheight=18 //提示窗口标题高度
bordercolor="#336699";//提示窗口的边框颜色
titlecolor="#99CCFF";//提示窗口的标题颜色
var sWidth,sHeight;
sWidth=document.body.offsetWidth;
sHeight=screen.height;
var bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.style.background="#777";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=15";
bgObj.style.opacity="0.1";
bgObj.style.left="0";
bgObj.style.width=sWidth + "px";
bgObj.style.height=sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);
var msgObj=document.createElement("div")
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "27%";
msgObj.style.top = "36%";
msgObj.style.marginleft = "-225px"; 
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = msgw + "px";
msgObj.style.height =msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.overflow = "hidden";
msgObj.style.lineHeight ="22px";
msgObj.style.zIndex = "10001";
var title=document.createElement("h4");
title.setAttribute("id","msgTitle");
title.setAttribute("align","right");
title.style.margin="0";
title.style.padding="3px";
title.style.background=bordercolor;
title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
title.style.opacity="0.75";
title.style.border="1px solid " + bordercolor;
title.style.height="18px";
title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
title.style.color="white";
title.style.cursor="pointer";
title.innerHTML="关闭";
title.onclick=function(){
document.body.removeChild(bgObj);
document.getElementById("msgDiv").removeChild(title);
document.body.removeChild(msgObj);
}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(title);
var txt=document.createElement("p");
txt.style.margin="1em 0"
txt.setAttribute("id","msgTxt");
txt.innerHTML=str;
document.getElementById("msgDiv").appendChild(txt);
}
//免费体验课程列表
//小学
function selectProgram1(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=XiaoXue&sort_count=11';
	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}
//初中
function selectProgram2(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=ChuZhong&sort_count=8';
	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}
//高中
function selectProgram3(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=GaoZhong&sort_count=7';
	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}
//大学
function selectProgram4(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=DaXue&sort_count=10';
	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}
//出国
function selectProgram5(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=ChuGuo&sort_count=7';
	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}
//成人
function selectProgram6(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=ChengRen&sort_count=12';	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}
//其它
function selectProgram7(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=QiTa&sort_count=1';
	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}
//常用英语
function selectProgram8(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=ChangYong&sort_count=12';	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}
//行业英语
function selectProgram9(path){
	//调用Servlet
	var url = path+'/servlet/com.init.free.service.SelectProgramServlet';
	var pars = 'sort=HangYe&sort_count=3';	
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse,onFailure: reportError});	
}

function showResponse(resp){
	var data = resp.responseXML;
	var reasons = data.getElementsByTagName("reason");
	if(reasons==null||reasons.length==0){
		$(bodyContent).innerHTML = resp.responseText;
	}else{
		var reason = reasons[0].firstChild.data;
		if(reason=='session_out'){
			var url = data.getElementsByTagName("url")[0].firstChild.data;
  		window.location.href=url;
  		return;
		}else{
			alert("系统出现问题，请您稍后再试!");
		}
	}
}
function reportError(resp){
	alert("系统出现问题，请您稍后再试!");
}
//添加体验课程
function insertUserProgram(path,isAllAdd){
		
	var program = "";
	var noChecked = 0;

	if(form1.program!=null){
    	if(form1.program.length!=null){
    		if(form1.program.length>0){
    			for(var i=0;i<form1.program.length;i++){
    				if(form1.program[i].checked){
						noChecked = 1;
						program = form1.program[i].value;
						form1.action=path+'/servlet/com.init.free.service.InsertUserProgramServlet';
    					form1.submit();
    			    }	
    			}
    		}
    	}else{
    		if(form1.program.checked){
				noChecked = 1;
				program = form1.program.value;
				form1.action=path+'/servlet/com.init.free.service.InsertUserProgramServlet';
    			form1.submit();	
    		}
    	}
    }	
    else{
		alert("本体验课程都已加入您的体验学习列表或已购买！请购买或查看其它课程！");
		return false;
	}
	//isAllAdd:true 标识 体验课程user_program表中已都有了
	if(isAllAdd=='true'){
		alert("本组课程已加入您的课程列表，请添加其它组课程！");
		return false;
	}

	if(noChecked==0){
		alert("请选择一门课程，才能进行体验！");
		return false;
	}	
}
