var Showwordnum = -1;
var stroutary = new Array(); //生字系统﻿
var stralloutary = new Array(); //保存
var strnewwordidary = new Array(); //生字id数组
var stroutnoteary = new Array(); //备注数组
var stroutsysnewwords = new Array();//生词数组
/********************************************************************
 功能： 设置拼音显示与隐藏 
 类型： 接口函数
 参数：	
 创建人: zxw
********************************************************************/	
function Showpinyin(){
	//隐藏拼音
	if(document.getElementById('new_pinyin').checked == false){
		document.getElementById("IDpinyin").style.visibility = "hidden";		
	}else{
		document.getElementById("IDpinyin").style.visibility = "visible";	
	}
}
/********************************************************************
 功能： 设置生词显示与隐藏 
 类型： 接口函数
 参数：    
 创建人: zxw
********************************************************************/    
function Showchinese(){
    //隐藏拼音
    if(document.getElementById('new_chinese').checked == false){
        document.getElementById("IDchinese").style.visibility = "hidden";        
    }else{
        document.getElementById("IDchinese").style.visibility = "visible";    
    }
}
/********************************************************************
 功能： 设置翻译显示与隐藏 
 类型： 接口函数
 参数：    
 创建人: zxw
********************************************************************/    
function Showtanslation(){
    //隐藏拼音
    if(document.getElementById('new_translation').checked == false){
        document.getElementById("IDenglish").style.visibility = "hidden";        
    }else{
        document.getElementById("IDenglish").style.visibility = "visible";    
    }
}
/********************************************************************
 功能： 设置flash显示与隐藏 
 类型： 接口函数
 参数：    
 创建人: zxw
********************************************************************/    
function Showstroke(){
    //隐藏拼音
    if(document.getElementById('new_stroke').checked == false){
        document.getElementById("flashchar").style.visibility = "hidden";
        document.getElementById("UCwrite").style.visibility = "hidden";
                
    }else{
        document.getElementById("flashchar").style.visibility = "visible";
        document.getElementById("UCwrite").style.visibility = "visible";    
    }
}
/********************************************************************
 功能： 下一个词 
 类型： 接口函数
 参数：    
 创建人: zxw
********************************************************************/ 
function Nextword(){
   var newwordall = stroutary.length;
       Showwordnum = Showwordnum + 1;
       document.getElementById("IDactualPage").innerHTML = stroutary[Showwordnum];
       if (Showwordnum == 0)
           document.getElementById("IDprevCard").innerHTML = '';
       if (Showwordnum == newwordall-2)
           document.getElementById("IDnextCard").innerHTML = '';
       document.getElementById("wordid").value = strnewwordidary[Showwordnum];

       if (stroutnoteary[Showwordnum] == "" || stroutnoteary[Showwordnum] == null)
       	document.getElementById("comment").value = "You can type your notes here and they will be saved along with the character/words for you to review later.";
       else
       	document.getElementById("comment").value = stroutnoteary[Showwordnum];
       document.getElementById("megid").innerHTML = "";
       
       Changeword();
       
       Showvocstens(sys_lessonid,stroutsysnewwords[Showwordnum]);
       
       Showpinyin();
       Showchinese();
       Showtanslation();
       Showstroke();
}
/********************************************************************
 功能： 上一个词 
 类型： 接口函数
 参数：    
 创建人: zxw
********************************************************************/    
function Preword(){
   Showwordnum = Showwordnum - 1;
   document.getElementById("IDactualPage").innerHTML = stroutary[Showwordnum];
   if (Showwordnum == 0)
       document.getElementById("IDprevCard").innerHTML = '';
   document.getElementById("wordid").value = strnewwordidary[Showwordnum];
   if (stroutnoteary[Showwordnum] == "" || stroutnoteary[Showwordnum] == null)
       	document.getElementById("comment").value = "You can type your notes here and they will be saved along with the character/words for you to review later.";
   else
       	document.getElementById("comment").value = stroutnoteary[Showwordnum];
   document.getElementById("megid").innerHTML = ""; 
   
   Changeword();
   Showvocstens(sys_lessonid,stroutsysnewwords[Showwordnum]);
   Showpinyin();
   Showchinese();
   Showtanslation();
   Showstroke();
}
/********************************************************************
 功能： 实现翻页功能的操作
 类型： 接口函数
 参数：    
 创建人: zxw
********************************************************************/  
//小于等于10页好全部显示
var tpagenum = 8;
//前边显示
var tprepagenum = 5;
function Changeword(){
    var conbutton = "";
    conbutton = '<label>Pinyin</label><input type="checkbox" name="new_pinyin" id="new_pinyin" value="1" onClick="javascript:Showpinyin();"/>';
    conbutton += '<label>&nbsp;Chinese</label><input type="checkbox" name="new_chinese" id="new_chinese" value="1" checked="checked" onClick="javascript:Showchinese();"/>';
    conbutton += '<label>&nbsp;Trans</label><input type="checkbox" name="new_translation" id="new_translation" value="1" onClick="javascript:Showtanslation();"/>';
    conbutton += '<label>&nbsp;Stroke Order</label><input type="checkbox" name="new_stroke" id="new_stroke" value="1" checked="checked" onClick="javascript:Showstroke();"/>';
    document.getElementById("IDfloatL").innerHTML = conbutton;
  
    var conpage = "";
    var newwordnum = stroutary.length - 1;
    var truepage = 0;
    var bigpage =  newwordnum - 2;
    
    if (Showwordnum+1 == 1)
        conpage = '<span class="AtStart">« Prev</span>';
    else
        conpage = '<a class="Next" onClick="Preword()" STYLE="cursor:pointer;">« Prev</a>'; 
        
    //小于等于10个单词全部页码全部显示
    if(newwordnum <= tpagenum){
        for(var numone=0; numone<newwordnum;numone++){
             truepage = numone + 1;
             if (Showwordnum == numone)
                conpage += '<span class="this-page">'+truepage+'</span>';
             else
                conpage += '<a onClick="getPage('+numone+')" STYLE="cursor:pointer;">'+truepage+'</a>';
        }
    }else{
        if (tprepagenum > Showwordnum+2){
            for(var numone=0; numone<tprepagenum;numone++){
                 truepage = numone + 1;
                 if (Showwordnum == numone)
                    conpage += '<span class="this-page">'+truepage+'</span>';
                 else
                    conpage += '<a onClick="getPage('+numone+')" STYLE="cursor:pointer;">'+truepage+'</a>';
            }
            conpage +='....';
            for(bigpage; bigpage<newwordnum;bigpage++){
                 truepage = bigpage + 1;
                 if (Showwordnum == bigpage)
                    conpage += '<span class="this-page">'+truepage+'</span>';
                 else
                    conpage += '<a onClick="getPage('+bigpage+')" STYLE="cursor:pointer;">'+truepage+'</a>';
            }
        }else{
            if (Showwordnum+3 >= newwordnum){
                for(var numone=0; numone<2;numone++){
                     truepage = numone + 1;
                     if (Showwordnum == numone)
                        conpage += '<span class="this-page">'+truepage+'</span>';
                     else
                        conpage += '<a onClick="getPage('+numone+')" STYLE="cursor:pointer;">'+truepage+'</a>';
                }
                conpage +='....';
                for(var numone=Showwordnum-2; numone<newwordnum;numone++){
                     truepage = numone + 1;
                     if (Showwordnum == numone)
                        conpage += '<span class="this-page">'+truepage+'</span>';
                     else
                        conpage += '<a onClick="getPage('+numone+')" STYLE="cursor:pointer;">'+truepage+'</a>';
                }
            }else{
                for(var numone=Showwordnum-2; numone<Showwordnum+3;numone++){
                     truepage = numone + 1;
                     if (Showwordnum == numone)
                        conpage += '<span class="this-page">'+truepage+'</span>';
                     else
                        conpage += '<a onClick="getPage('+numone+')" STYLE="cursor:pointer;">'+truepage+'</a>';
                }
                conpage +='....';
                for(bigpage; bigpage<newwordnum;bigpage++){
                     truepage = bigpage + 1;
                     if (Showwordnum == bigpage)
                        conpage += '<span class="this-page">'+truepage+'</span>';
                     else
                        conpage += '<a onClick="getPage('+bigpage+')" STYLE="cursor:pointer;">'+truepage+'</a>';
                }
            }
        }
    }
          
    if (Showwordnum+1 == newwordnum)
        conpage += '<span class="AtStart">Next »</span>';
    else
        conpage += '<a class="Next" onClick="Nextword()" STYLE="cursor:pointer;">Next »</a>';
        
   document.getElementById("IDPaginator").innerHTML = conpage;     
}
/********************************************************************
 功能： 实现翻页功能的操作
 类型： 接口函数
 参数：    
 创建人: zxw
********************************************************************/
function getPage(nowpage){
   Showwordnum = nowpage - 1;
   Nextword();
}
/********************************************************************
 功能： 生字全选
 类型： 接口函数
 参数：    
 创建人: zxw
********************************************************************/
function Selectcheck(){
    var selcheck = document.getElementsByName("selnew_words");
    for(var i=0;i<selcheck.length;i++)
            selcheck[i].checked = true;
    
    stroutary = stralloutary;
    Showwordnum = -1;
    Nextword();  
}

function SelectNotcheck(){
    var selcheck = document.getElementsByName("selnew_words");
    for(var i=0;i<selcheck.length;i++)
            selcheck[i].checked = false;

    stroutary = null;
    document.getElementById("IDactualPage").innerHTML = "";
    document.getElementById("IDfloatL").innerHTML = "";
    document.getElementById("IDPaginator").innerHTML = "";
}

function Selectonecheck(){
    var arynum = 0;
    stroutary = new Array(); 
    var selcheck = document.getElementsByName("selnew_words");
    for(var i=0;i<selcheck.length;i++){
        if(selcheck[i].checked == true){
           stroutary[arynum] = stralloutary[selcheck[i].value-1];
           arynum = arynum + 1; 
        }
    }
    stroutary[arynum] = " ";
    Showwordnum = -1;
    Nextword();
}