//信息操作部分开始，严禁修改

var expDays = 365*2;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

//设置cookies
function SetCookie (name, value) {
       var argv = SetCookie.arguments;
       var argc = SetCookie.arguments.length;
       var expires = (argc > 2) ? argv[2] : null;
       var path = (argc > 3) ? argv[3] : null;
       var domain = (argc > 4) ? argv[4] : null;
       var secure = (argc > 5) ? argv[5] : false;
       document.cookie = name + "=" + escape (value) + 
         ((expires == null) ? "" : ("; expires=" + expires.toGMTString()))
          + ((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : 
          ("; domain=" + domain)) +((secure == true) ? "; secure" : "");

}

//以下读取指定cookies信息
//获得名字
function GetCookie (name) {
     var arg = name + "=";
     var alen = arg.length;
     var clen = document.cookie.length; 
     var i = 0;
     while (i < clen) {
          var j = i + alen;
          if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
          i = document.cookie.indexOf(" ", i) + 1;
          if (i == 0) break;
          } 
    return null;
}

//获得值
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));

}
//cookie读取结束

//删除cookie信息
function DeleteCookie (name) {
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
//信息操作部分结束


//课程用户信息开始
//Lesson_Name 是课程名，不同的课程应取不同的名字
var Lesson_Name="tnx"
var cj_LearnInfo;

//保存学习环境
function cj_GetInfo(){
         var cj_SaveIt=cj_GetSaveFlag();
//                                alert(cj_SaveIt);
         var cj_Capter,cj_Page,cj_Adress,cj_Infos,cj_InfoName;
         if(cj_SaveIt==0)
           return;
         else{
           cj_Capter=document.location.href;
           cj_Page=parent.inserts.document.location.href;
           cj_Adress=document.form1.textAdree.value;
           cj_Infos=cj_Capter+"%"+cj_Page+"%"+cj_Adress;
           cj_InfoName=Lesson_Name+"_history";
//	                           alert(cj_InfoName);
           SetCookie(cj_InfoName,cj_Infos,exp,"/",null,false);
//                                  cj_Infos=GetCookie(cj_InfoName);
//                                  alert(cj_Infos);         
           }
        }
        

//退出学习时是否要保存学习环境
function cj_GetSaveFlag(){
	var cj_Flag;
	var cj_InfoName;
	cj_InfoName=Lesson_Name+"_SaveFlag";
	cj_Flag=GetCookie(cj_InfoName);
	return(cj_Flag);
	}
//获取学习历史	
function cj_GetHistory(){
	var cj_InfoName;
	cj_InfoName=Lesson_Name+"_history";
	cj_LearnInfo=GetCookie(cj_InfoName);
//              	alert(cj_LearnInfo);
	}
	
//判断是否已经存在学习任务，并显示相关信息
function cj_LastLearn(){
	var cj_LearnInfos;
	var cj_InfoName;
	var cj_Option;
	cj_Option=cj_GetSaveFlag();
//	if(cj_Option==null){      //初始选项：继续学习，取消本行注释，可记录上一次学习选项。
	        cj_Option=1;
	        cj_InfoName=Lesson_Name+"_SaveFlag";
	        SetCookie(cj_InfoName,cj_Option,exp);
//	        }
	cj_InfoName=Lesson_Name+"_history";
//	                           alert(cj_InfoName);
	cj_LearnInfo=GetCookie(cj_InfoName);
//                             	alert(cj_LearnInfo);
	if(cj_LearnInfo==null){ //如果任务不存在
	        cj_LearnInfos="";
	        address.innerText="没有您以前的学习记录";
	        }
	else{   //如果存在
	        cj_LearnInfos=cj_LearnInfo.split("%");
	        address.innerText=cj_LearnInfos[2];
	        }
	}
	
//保存用户继续学习、重新学习、自由浏览的选项
function cj_SaveOption(n){
	var cj_Option=n;
	var cj_InfoName;
	if(cj_Option=="0") express.innerHTML="打开课程的主界面，自由浏览、学习课程内容。<br>学习结束不记录本次学习浏览位置。";
	if(cj_Option=="1") express.innerHTML="从上一次学习结束的地方开始，继续学习下面的内容。<br>学习结束时，记下本次学习的位置，以便下一次继续学习。";
	if(cj_Option=="2") express.innerHTML="打开课程的主界面，开始一次新的学习任务。<br>学习结束，记下本次学习的内容，以便下一次继续学习。<br><font color=red>注意：</font>以前的学习历史记录将被覆盖！";
	cj_InfoName=Lesson_Name+"_SaveFlag";
	SetCookie(cj_InfoName,cj_Option,exp);
        }

//初始化学习环境——章，进入主页面前调用
function cj_InCapter(){
	var cj_Option;
	var cj_LearnInfos;
	var cj_FullScreen,cj_UseLeft,cj_UseTop;
	var cj_InfoName=Lesson_Name+"_PageFlag";
	SetCookie(cj_InfoName,'1',exp,"/",null,false);       ////监视页面跳转来源
	cj_Option=cj_GetSaveFlag();
	if (screen.width==800){
		cj_FullScreen=1;
		cj_UseLeft=0;
		cj_UseTop=0;
        	}
        else{
		cj_FullScreen=0;
		cj_UseLeft=112;
		cj_UseTop=84;
		}
	if((cj_Option=="1")&&(cj_LearnInfo!=null)){
		cj_LearnInfos=cj_LearnInfo.split("%");
		window.open(cj_LearnInfos[0],'zk017b','screenX=0,screenY=0,directories=0,fullscreen='+cj_FullScreen+',left='+cj_UseLeft+',top='+cj_UseTop+',width=800,height=600,location=0,menubar=0,scrollbars=0,status=0,toolbar=0')
		}
	else
	        window.open('main.htm','zk017b','screenX=0,screenY=0,directories=0,fullscreen='+cj_FullScreen+',left='+cj_UseLeft+',top='+cj_UseTop+',width=800,height=600,location=0,menubar=0,scrollbars=0,status=0,toolbar=0')
	window.close()}
	
//初始化学习环境——地址和页，各章的main页面的onlaod事件中调用
function cj_InPage(){
	var cj_LearnInfos;
	var cj_Option=cj_GetSaveFlag();	
	var cj_InfoName=Lesson_Name+"_PageFlag";
	var cj_PageFlag=GetCookie(cj_InfoName);
//	                           alert(cj_PageFlag);
	cj_Infos=0;
        SetCookie(cj_InfoName,cj_Infos,exp,"/",null,false);         //监视页面跳转来源
	MFXinitMenu();           //菜单的初始化	
//	if(cj_PageFlag=='0')
//	      return;
	cj_GetHistory();
//                            	alert(cj_Option);
//                      	alert(cj_LearnInfo);
	if((cj_Option!='1')||(cj_LearnInfo==null)||(cj_PageFlag=='0'))
	     return;
	else{
//	                        alert("页面跳转？");
	     cj_LearnInfos=cj_LearnInfo.split("%");
	     cj_address(cj_LearnInfos[2]);       //cj_address在jsN.js中定义
	     parent.inserts.document.location.href=cj_LearnInfos[1];
	     }
	}


//测试参考
