// JScript File

window.setTimeoutEx = function(fRef, mDelay) {
//debugger
    if(typeof fRef == 'function')
    {
        var argu = Array.prototype.slice.call(arguments,2);
        var f = (function(){ fRef.apply(null, argu); });
        return window.setTimeout(f, mDelay);
    }
        return window.setTimeout(fRef,mDelay);
    }
    
    
window.setIntervalEx = function(fRef, mDelay) {
    if(typeof fRef == 'function')
    {
        var argu = Array.prototype.slice.call(arguments,2);
        var f = (function(){ fRef.apply(null, argu); });
        return  window.setInterval(f, mDelay);
    }
        return  window.setInterval(fRef,mDelay);
    }    
	
var m_curLesson = null;
var strCache = null;
var m_oStudyMode1=null;
var objCache = null;



function OnLessonDownloaded(result)
{
   //debugger
    m_curLesson = result;
   
   document.all("panel0").style.display="none";
   document.all("panel1").style.display="";
		       
   m_oStudyMode1 = new StudyMode1("panel1",m_curLesson);
   m_oStudyMode1.Init();
   
}


function PageMethodsState(callBackFunc)
{
 
   this.TimeId = null;
   
   this.CallBackFunc = callBackFunc;
   
   //public
   this.Check = function()
   {
        this.TimeId = window.setTimeoutEx(this.CheckBody,10,this);
            
   }
   
   //private 
   this.CheckBody = function(webData)
   {
     
     if ( typeof(PageMethods) == "undefined" )
     {
        window.clearTimeout(webData.TimeId);
        webData.TimeId = window.setTimeoutEx(webData.CheckBody,10);
        return;
     }  
     
     webData.CallBackFunc();
   }
  
     
}


function OnMeaningDownloaded(result)
{
   //debugger;
    if(m_oStudyMode1!=null)
	{
	 	m_oStudyMode1.DisPlayMeaning(result);
	}

   
}


function OnLoadMeaning(id)
{
     PageMethods.DownloadMeaning(id,OnMeaningDownloaded);
}


function OnLoadWordByType(type)
{
     PageMethods.DownloadWordByType(type,OnWordDownloaded);
}

function OnLoadWordByTypeAndText(type,text)
{
     PageMethods.DownloadWordByTypeAndText(type,text,OnWordDownloaded);
}

function OnWordDownloaded(result)
{
 
    if(m_oStudyMode1!=null)
	{
	 	m_oStudyMode1.DisPlayWordByType(result);
	}

   
}




function OnPageMethodReady()
{
    //debugger;
    //alert(document.all("panel0"));
    PageMethods.DownloadLesson(OnLessonDownloaded);
}

function LoadData()
{
    document.all("panel0").style.display="";
    document.all("panel1").style.display="none";
    
    pms.Check(OnPageMethodReady);
    

}
var pms =null;
document.body.onload = function()
{
    //debugger;
    
    pms = new PageMethodsState(OnPageMethodReady);  
   
    document.all("panel0").style.display="";
    LoadData();
   
} 


function selectWord()
{
//debugger
 
  var wordlist=document.getElementById("WordList");
  for(var i=0;i<wordlist.children.length;i++)
  {
  	 wordlist.children[i].className="Word_item";
  }
  event.srcElement.className="Word_item_click";
  
	
}