// For Debugging
// printCookie();

function newXMLHttpRequest() 
{
  var xmlReq = false;

  if (window.XMLHttpRequest) 
  {
    xmlReq = new XMLHttpRequest();
  } 
  else if (window.ActiveXObject) 
  {
    try {
      xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e1) {
        alert("Unable to create an XMLHttpRequest with ActiveX");
      }
    }
  }
  return xmlReq;
}

function getReadyStateHandler(req, responseHandler, sequence) 
{
  return function () 
  {
    if (req.readyState == 4) 
    {
      if (req.status == 200) 
      {
        responseHandler(req, sequence);
      } 
      else 
      {
				alert("There was a problem retrieving the data:\n" + req.statusText);
      }
    }
  }
}

function loadData(url, processResponse, sequence)
{
  var req = newXMLHttpRequest();

  req.onreadystatechange = getReadyStateHandler(req, processResponse, sequence);

	req.open("GET", url, true);
  req.send();
}


//*****************************************************************************
function includeCommonVars()
{
	var href = window.location.href;
	var Root = href.substring(0, href.toLowerCase().indexOf("runtime"));
	document.write('<script language="JavaScript" src="' + Root + 'Runtime/CommonVars.js"></script>')
}

//*****************************************************************************
function printCookie()
{
  var str = ""
	str += "defaultCharset = " + document.defaultCharset + "\n"
	str += "charset = " + document.charset + "\n"
	str += "================================\n"
  var aCookie = document.cookie.split("; ");
  var length = aCookie.length;
  var size = document.cookie.length;
	str += "Number of cookies = " + length + "\n"
	str += "Size of cookies = " + size + " bytes\n"
	str += "******************************\n"
  for (var i = 0; i < length; i++)
		str += (i + 1) + ". "+ unescape(aCookie[i]) + "\n"
		//str += (i + 1) + ". "+ aCookie[i] + "\n"
  alert(str)
}

//*****************************************************************************
function detect()
{
	var ua = window.navigator.userAgent;
	var an = window.navigator.appName;

  var bMSIE = (ua.indexOf("MSIE") >= 1);
	var bNetscape = (an == "Netscape");

	if (bMSIE)
	{
		bControl = true

		bWin95 = (ua.indexOf("Windows 95") >= 1);
		bWin98 = (ua.indexOf("Windows 98") >= 1);
		bWinNT = (ua.indexOf("Windows NT") >= 1);
		bWin2K = (ua.indexOf("Windows NT 5.0") >= 1);
		bWinXP = (ua.indexOf("Windows NT 5.1") >= 1);
  }
	else if (bNetscape)
	{
		bControl = false

		bWin95 = (ua.indexOf("Win95") >= 1);
		bWin98 = (ua.indexOf("Win98") >= 1);
		bWinNT = (ua.indexOf("WinNT") >= 1);
  }
}

//*****************************************************************************
function getCss()
{
	var a = arguments;
	for (i = 0; i < a.length; i++)
	{ 
		if (a[i].toLowerCase().indexOf("print") > -1)
			var smedia = 'MEDIA="print"'
		else
			var smedia=""   
		w('<link rel="stylesheet" href=' + resPath + a[i] + '.css type="text/css" ' + smedia + '>')
		//w('<link rel="stylesheet" href=' + Root + 'Runtime/Context/styles/' + distributor + '/' + a[i] + '.css type="text/css" ' + smedia + '>')
	}

	var lang, support;
		
	if (GetCookie("Student") != null && getCompositeCookie("Student", "SID") != "-1")
	{
		support = getCompositeCookie("Student", "LangSupLevel");
		lang = language;
	}
	else
	{
		support = getCompositeCookie("Community", "InstLangSupLevel");
		lang = instLang;
	}
	
	if ((lang == "heb" || lang == "ara") && support == 3)
	{
	
		w("<style>")
		w("#navTable{direction:rtl;}")
		w("table.homeBarButtonT{direction:ltr;}")
		w("body.hebBody{direction:rtl;text-align:right}")
		w("table.homeBarButtonTH{direction:ltr;}")	
		w("table.homeBarButtonI{direction:ltr;}")
		w("table.homeBarButtonIH{direction:ltr;}")
		w("#tbl_DHPMainArea{direction:rtl;}")
		w("#downloads{direction:rtl;text-align:right}")
		w(".downloadsTitles{direction:ltr;text-align:right;}")
		w(".downloadBtn{text-align:center}")
		w("#txteduobj{text-align:right;padding-right:12}")
		w("#homeWelcomeMessage{direction:rtl;text-align:right;padding-right:8;padding-bottom:20;padding-top:10;font-weight:bold}")
		w("#myPageWelcomeMessage{direction:rtl;text-align:right;padding-right:45;padding-left:40;}")
		w("#InstructionsCellH{direction:rtl;text-align:right;}")
		w(".midScreenTexts{text-align:right;direction:rtl;}")
		w(".homeBarButtonT,.homeBarButtonTH,.homeBarButtonI,.homeBarButtonILast,.homeBarButtonIH,.HomeBarsCources,.MfButton,.homeBarButtonILastH{direction:rtl;}")	
		w(".PopupTitle{direction:rtl;}")
		w(".dirRTL{direction:rtl}")
		w(".dirLTR{direction:ltr}")
		w(".hebDir{direction:rtl;text-align:right;}")
		w(".TestFB{direction:rtl;}")
		w(".hebBtn{direction:rtl;text-align:left;}")
		w(".forumList{direction:ltr;}")
		w(".magazineGlossLinks{direction:rtl;padding-right:5;}")
		w("</style>")
	}
}

//*****************************************************************************
function MM_swapImgRestore()
{ //v3.0
  var i,x,a=document.MM_sr;
  for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
		x.src = x.oSrc;
}

//*****************************************************************************
function MM_preloadImages()
{ //v3.0
	var d = document;
	if (d.images)
	{
		if (!d.MM_p)
			d.MM_p = new Array();
			
	  var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
	  for (i = 0; i < a.length; i++)
			if (a[i].indexOf("#") != 0)
			{
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			}
	}
}

//*****************************************************************************
function MM_findObj(n, d)
{ //v4.0
	var p, i, x;
	if (!d)
		d = document;
	if ((p = n.indexOf("?")) > 0 && parent.frames.length)
	{
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0,p);
	}
  if (!(x = d[n]) && d.all)
		x = d.all[n];
	for (i = 0; !x && i < d.forms.length; i++)
		x = d.forms[i][n];
  for (i = 0; !x && d.layers && i < d.layers.length; i++)
		x = MM_findObj(n, d.layers[i].document);
  if (!x && document.getElementById)
		x = document.getElementById(n);
	return x;
}

//*****************************************************************************
function MM_swapImage()
{ //v3.0
	var i, j = 0, x , a = MM_swapImage.arguments;
	document.MM_sr = new Array;
	for (i = 0; i < a.length - 2; i += 3)
		if ((x = MM_findObj(a[i])) != null)
		{
			document.MM_sr[j++] = x;
			if (!x.oSrc)
				x.oSrc = x.src;
			x.src = a[i + 2];
		}
}

//*****************************************************************************
function SavePage(url, appletName, itemId, appletMode)
{
	var mark;
	var locUrl = url;
  
  url = url.replace("?", "*") 
  do
  {
		url = url.replace("&", "^")
  }
  while (url.indexOf("&") > -1)
	if (url != "#")
	{
		if (appletMode == "Test")
		{
			if (skill == "Listening" || skill == "Grammar")
				var janre = "&janre=" + obj.Subject
			else
				var janre = ""

			var x = (800 - 320) / 2
			var y = (600 - 310) / 2
			var source = escape('MsgPage.asp?saveState=no' + janre + '&url=' + url + '&FromTMS=' + FromTMS);
			var URL = Root + 'Runtime/Window.asp?Mode=Alert&Width=300&Height=220&Title=cxtCo00TtTest&Feature=cxtCo00TtTest&Source=' + source;
			//window.open(URL,'Message','width=310,height=275,left='+x+',top='+y+',resizable=no,scrollbars=no')
			var features = "dialogWidth: 320px; dialogHeight: 310px; dialogLeft: " + x + "px; dialogTop: " + y + "px; scroll: no; status: no; edge: Sunken; help: no;";
			window.showModalDialog(URL, self, features);
		}
		else if (appletMode == "TestCheck" || appletMode == "seeUserAnswer")
		{ 
			setCompositeCookie("Test", "Marks", "");
			setCompositeCookie("Test", "FinalMark", 0);
			setCompositeCookie("Test", "testsVisited", "")
			setCompositeCookie("Test", "testMode", "")
			if (!FromTMS)
			{
				startTime = getCompositeCookie("Test", "StartTime");  
				if (startTime != null && startTime != "0")
				{
					var compId = getCompositeCookie("Component", "Id");
					stopTime = new Date()
					stopTime = Math.floor(stopTime.getTime() / 1000);
					startTime = eval(startTime)  
					diff = stopTime - startTime;
					saveTestTime(compId, diff)
					setCompositeCookie("Test", "StartTime", 0);
				}
			}
			setCompositeCookie("Unit", "ItemType", getCompositeCookie("Component", "ItemType"));
			document.location = locUrl  
		}
		else
		{
			if (!FromTMS)
			{
				stopTime = new Date()
				diff = Math.floor((stopTime - startTime) / 1000);
				mark = getMark(appletName);             
				saveMark(obj.Id, mark, diff, 1);
				if (skill == "Speaking" && (obj.SubComponent == "Practice" || obj.SubComponent == "Practice 2"))
					updateProgress(1);
				else if (mark > 0)
					updateProgress(1);
			}			
			setCompositeCookie("Unit", "ItemType", getCompositeCookie("Component", "ItemType"));
			document.location = locUrl
		}
	}
}

//*****************************************************************************
function saveCCData(url, lastSubCompId)
{
	var locUrl = url;
  
  url = url.replace("?", "*") 
  do {
		url = url.replace("&", "^")
  }
  while (url.indexOf("&") > -1)
	if (url != "#")
	{
		if (!FromTMS)
		{
			stopTime = new Date()
			stopTime = Math.floor(stopTime.getTime() / 1000);
			diff = stopTime - startTime;
			var subCompId = getCompositeCookie("Component", "ItemId");
			if (arguments.length == 1)
				var lastItemId = subCompId;
			else	
				var lastItemId = lastSubCompId;
			setCompositeCookie("Component", "lastItemId", lastItemId);
			saveMark(lastItemId, 1, diff, 2);
			updateProgress(2);
		}			
		document.location = locUrl;
	}
}

//*****************************************************************************
function updateProgress(progress)
{
	var compId = getCompositeCookie("Component", "Id");
	var oldProgress = getCompositeCookie("Unit", "Progress");
	if (oldProgress != null)
	{
		var ind = oldProgress.indexOf(compId + ":") + compId.length + 1;
		var compType = oldProgress.substring(ind, ind + 1);
		ind = ind + 2;
		if (compType == "1")
		{
			var itemType = getCompositeCookie("Unit", "ItemType");
			if (itemType.indexOf("Practice 2") != -1 || itemType.indexOf("Test") != -1)
				ind = ind + 2;
			else if (itemType.indexOf("Practice") != -1)
				ind = ind + 1;
		}	
		var newProgress = oldProgress.substring(0, ind) + progress + oldProgress.substring(ind + 1, oldProgress.length);

		setCompositeCookie("Unit", "Progress", newProgress)
	}
}

//*****************************************************************************
function saveMark(id, mark, time, compType)
{
	var tmpArr, tmpArr1, tmpArr2, tmpArr3, newMarks, newTime, newMark;
	
  var oldMarks = getCompositeCookie("Component", "markArr");
  if (oldMarks != null && oldMarks != "")
  {
		if (oldMarks.indexOf(id + ":") > -1)
    {
			tmpArr = oldMarks.split(id + ":");
			tmpArr1 = tmpArr[1].split(",");   
			tmpArr2 = tmpArr1[0].split("|");
			if (tmpArr2[1] >= mark)
				newMark = tmpArr2[1];
			else	
				newMark = mark;
			newTime = time + eval(tmpArr2[2]);   
			tmpArr3 = oldMarks.split(id + ":" + tmpArr1[0]);
			newMarks = tmpArr3[0] + id + ":" + tmpArr2[0] + "|" + newMark + "|" + newTime + tmpArr3[1];
    }
    else 
			newMarks = oldMarks + "," + id + ":" + compType + "|" + mark + "|" + time;
  }   
  else
		newMarks = id + ":" + compType + "|" + mark + "|" + time;

	setCompositeCookie("Component", "markArr", newMarks);
	
	if (mark > 0 && compType == 1)
		setPracticeVisited(id);
}

//*****************************************************************************
function saveTestTime(id, time)
{
	var tmpArr, tmpArr1, tmpArr2, newTimes;
  var oldTimes = getCompositeCookie("Test", "Times")
  if (oldTimes != null && oldTimes != "")
  {
		if (oldTimes.indexOf(id + ":") > -1)
    {
			tmpArr = oldTimes.split(id + ":")
			tmpArr1 = tmpArr[1].split(",")   
			newTime = time + eval(tmpArr1[0])   
			tmpArr2 = oldTimes.split(id + ":" + tmpArr1[0])
			newTimes = tmpArr2[0] + id + ":" + newTime + tmpArr2[1]   
    }
    else 
			newTimes = oldTimes + "," + id + ":" + time    
  }   
  else
		newTimes = id + ":" + time  

	setCompositeCookie("Test", "Times", newTimes)
}

//*****************************************************************************
function setPracticeVisited(id)
{
	var visStr = getCompositeCookie("Unit", "VisitedItems")
  if (visStr != null)
  {      
		if (visStr.indexOf(id + "") == -1)
		{
			visStr += "," + id 
			setCompositeCookie("Unit", "VisitedItems", visStr)
		}
	}		
  else
		setCompositeCookie("Unit", "VisitedItems", id)
}

//*****************************************************************************
function getPracticeVisited(id)
{
	var visStr = getCompositeCookie("Unit", "VisitedItems")
	//var practVisitedStr = getCompositeCookie("Component", "markArr")
  if (visStr != null)      
		if (visStr.indexOf(id + "") > -1)
			return true;
    else
			return false;
  else
		return false;       
}

//*****************************************************************************
function updateTestsVisited(num)
{
  var testsVisitedStr = getCompositeCookie("Test", "testsVisited")
  if (testsVisitedStr != null)    
  {  
		if (testsVisitedStr.indexOf("[" + num + "]") == -1)
    { 
      newStr = testsVisitedStr + "[" + num + "]"
      setCompositeCookie("Test", "testsVisited", newStr)    
    }
  }
  else        
  {
		newStr = "[" + num + "]"
    setCompositeCookie("Test", "testsVisited", newStr)    
  }  
}

//*****************************************************************************
function getTestVisited(num)
{
  var testsVisitedStr = getCompositeCookie("Test", "testsVisited")
  if (testsVisitedStr != null)      
    if (testsVisitedStr.indexOf("[" + num + "]") > -1)
      return true;
    else
      return false;
  else
      return false;       
}

//*****************************************************************************
function OpenMsgWindow(url, appletName)
{
  if (compleatTest)
  {
		if (document.applets[appletName] != null)
		{
			document.applets[appletName].saveUserState();
			var marks = document.applets[appletName].getTestMarks();
			var finalMark = document.applets[appletName].getFinalMark();
			setCompositeCookie("Test", "Marks", marks);
			setCompositeCookie("Test", "FinalMark", finalMark);
		}
		document.location = url;
	}
  else
	{
		url = url.replace("?", "*") 
		do
		{
			url = url.replace("&","^")
		}
		while (url.indexOf("&") > -1)   
		if (skill == "Listening" || skill == "Grammar")
			var janre = "&janre=" + obj.Subject
		else
			var janre = ""	

		var x = (800 - 320) / 2;
		var y = (600 - 310) / 2;

		var source = escape('MsgPage.asp?url=' + url + janre + '&FromTMS=' + FromTMS);
		var URL = Root + 'Runtime/Window.asp?Mode=Alert&Width=300&Height=220&Title=cxtCo00TtTest&Feature=cxtCo00TtTest&Source=' + source;
		//window.open(URL,'Message','width=310,height=275,left='+x+',top='+y+',resizable=no,scrollbars=no')
		var features = "dialogWidth: 320px; dialogHeight: 310px; dialogLeft: " + x + "px; dialogTop: " + y + "px; scroll: no; status: no; edge: Sunken; help: no;";
		window.showModalDialog(URL, self, features);
	}
}

//*****************************************************************************
function getSubCompArr()
{
	var sSubComp = getCompositeCookie("Component", "Items")
	var arr1 = sSubComp.split("%")
  for (var i = 0; i < arr1.length; i++)
  {
		var arr2 = arr1[i].split(",");
		subCompNameArr[i] = arr2[0];
		subCompIdArr[i] = eval(arr2[1]);
  } 
}

//*****************************************************************************
function getQueryString(param)
{
	var sURL = document.URL.toString();
	//var sUrl = document.location.href.toString();
	if (sURL.indexOf(param + "=") != -1)
	{
		var aQuery = sURL.split("?");
	  aQuery = aQuery[1].split("&");
	  for (var i = 0; i < aQuery.length; i++)
	  {
	    // a name/value pair (a crumb) is separated by an equal sign
	    var aCrumb = aQuery[i].split("=");
	    if (param == aCrumb[0]) 
	      return unescape(aCrumb[1]);
	  }
	}
	else
	  return null;
}

//*****************************************************************************
function getSubComp(id, compType)
{
	var url = "Template.asp?unitData=" + getCompositeCookie("Unit", "UnitId") + "&FromTMS=" + FromTMS + "&SID=" + getCompositeCookie("Student", "SID"); 
	setCompositeCookie("Component", "ItemId", id);
	setCompositeCookie("Component", "ItemType", compType);
	if (compType == "Test");
		setCompositeCookie("Test", "Stage", "Intro");

	SavePage(url, appName, obj.Id, appletMode);
}

//*****************************************************************************
function getCustSubComp(id)
{
	var lastSubCompId = getCompositeCookie("Component", "ItemId");
	setCompositeCookie("Component", "ItemId", id);
	var url = "CustomTemplate.asp?unitData=" + getCompositeCookie("Unit", "UnitId") + "&FromTMS=" + FromTMS + "&SID=" + getCompositeCookie("Student", "SID")

	saveCCData(url, lastSubCompId);
}

//*****************************************************************************
function restoreTestVars()
{
	setCompositeCookie("Component", "ItemId", obj.SequenceArr[obj.Sequence - 1]);
	setCompositeCookie("Component", "ItemType", "Test");
}

//*****************************************************************************
function getMediaPath()
{
	var ret = ""
	var path = document.location.href
	num = path.lastIndexOf("/")
	if (skill == "Listening" && obj.SubComponent == "Explore")
	{
	    wave = obj.Code + ".wav"
	    folder = obj.Code.substr(0,obj.Code.length-1)
	}
	if (skill == "Grammar")
	{
		folder = obj.Code.substr(0,obj.Code.length-1)
		wave = folder + "101.mp3"
	}
	else if(skill == "Speaking" && obj.SubComponent == "Practice")
		return ret
	else if(obj.SubComponent=="Explore")
	{
		wave = obj.Code + "01.mp3"
	  folder = obj.Code.substr(0,obj.Code.length-1)
	}
	else    
	{
		folder = obj.Code.substr(0,obj.Code.length-4)
	  wave = folder + "e01.mp3"
	}   
	    
	if (skill == "Listening" && TVMode =="Video")
		wave = folder + "e.mpg"

	return (path.substr(0,num) + "/Media/" + skill + "/" + folder + "/" + wave)
}

//*****************************************************************************
function openText(val)
{  
	if (document.applets[appName] != null)
	{
		if (document.applets[appName].isActive())
		{
			switch(val)
		  {
				case "seeText":
					document.applets[appName].seeText();
			    break;
				case "seeExplanation":
					document.applets[appName].seeExplanation();
			    break;
			}
		}
	}        
}

//*****************************************************************************
function openMediaWindow()
{
	var source = "seeMedia.asp?unitData=" + getCompositeCookie("Unit", "UnitId");
	switch (obj.Subject)
  {
		case "TV":
				window.open(Root + 'Runtime/Window.asp?Width=250&Height=250&Title=cxtCoTrTtWatchTV&Feature=cxtCoTrTtWatchTV&Source=' + source,'SeeMedia','width=240,height=305,left=200,top=200,resizable=no,scrollbars=no')
        break; 
		case "Radio":
				window.open(Root + 'Runtime/Window.asp?Width=250&Height=200&Title=cxtCoTrTtListenRadio&Feature=cxtCoTrTtListenRadio&Source=' + source,'SeeMedia','width=230,height=255,left=200,top=200,resizable=no,scrollbars=no')
        break;
		case "Voice Mail":
				window.open(Root + 'Runtime/Window.asp?Width=250&Height=200&Title=cxtCoTrTtListenVoiceMail&Feature=cxtCoTrTtListenVoiceMail&Source=' + source,'SeeMedia','width=230,height=255,left=200,top=200,resizable=no,scrollbars=no')
        break;
  }   
}

//*****************************************************************************
function changeTVMode(mode, state)
{
	setCompositeCookie("Media", "TVMode", mode)		
	if (state == 0)	 // EDO
	{
		document.location = "Template.asp?unitData=" + getCompositeCookie("Unit", "UnitId") + "&FromTMS=" + FromTMS + "&SID=" + getCompositeCookie("Student", "SID")
	}
	else if (state == 1)	// PLT
	{
		document.location.reload();
	}
}

//*****************************************************************************
function changeTVModeCB(objSelect, state)
{
	var curState = 0;
	if (arguments.length == 2)
	{
		if (state != "")
			curState = state;
	}
	var mode = objSelect[objSelect.selectedIndex].value;
	changeTVMode(mode, curState);
}

//*****************************************************************************
function GetCookie(sName)
{
  // Cookies are separated by semicolons and space
  var aCookie = document.cookie.split("; ");
  for (var i = 0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if ((sName == aCrumb[0]) && (aCrumb[1] != null)) 
    {
			var ret = unescape(aCrumb[1]);
      do {
        ret = ret.replace("+", " ");
      } while (ret.indexOf("+") > -1)
      return ret; 
    }
  }
  return null;
}	

//*****************************************************************************
function getCompositeCookie(sCName, sIName)
{
  var cookieStr = GetCookie(sCName);
	if (cookieStr != null)
  {
		var aCookie = cookieStr.split("^");
		for (var i = 0; i < aCookie.length; i++)
		{
			var aCrumb = aCookie[i].split("*");
			if ((sIName == aCrumb[0]) && (aCrumb[1] != null)) 
			{
				var ret = aCrumb[1];
				do {
					ret = ret.replace("+", " ");
        } while (ret.indexOf("+") > -1)
				return ret; 
      }
		}
		return null; 
  }
	else
		return null; 
}

//*****************************************************************************
function setCompositeCookie(sCName, sIName, sIVal)
{
	var newCookie;
	
  var oldCookie = GetCookie(sCName);
	if (oldCookie != null)
  {
		var SInd = 0, EInd = 0;
		EInd = oldCookie.indexOf("^" + sIName + "*");
		if (EInd != -1)
		{
			EInd += sIName.length + 2;
			newCookie = oldCookie.substring(SInd, EInd) + sIVal;
			SInd = EInd;
			EInd = oldCookie.indexOf("^", SInd);
			if (EInd != -1)
				newCookie += oldCookie.substring(EInd);
		}
		else
		{
			newCookie = oldCookie + "^" + sIName + "*" + sIVal;
		}
  }
  else
		newCookie = "^" + sIName + "*" + sIVal; 

	document.cookie = sCName + "=" + escape(newCookie) + "; path=/";
}

//*****************************************************************************
function DelCookie(sName)	//Deletes permanent cookie
{
  document.cookie = sName + "=" + "" + "; expires=Fri, 31 Dec 1989 23:59:59 GMT;";	
}

//*****************************************************************************
function OnDicClick(userLanguage)
{
	var wd_Word, myStr, wd_Language, myWin, wd_temp
	var iIndex = 0
	wd_Word = document.DicForm.WDQString.value
	wd_Language = userLanguage // document.DicForm.selectLanguage.selectedIndex + 1
	if (wd_Word != "")
	{
		wd_Word = escape(wd_Word);
		if	(myWin != null)
			myStr = Root + "Runtime/Dictionary/WDFrames.asp?wd_Word=" + wd_Word +"&wd_Language=" + wd_Language + "&wd_History=" + 1
		else
			myStr = Root + "Runtime/Dictionary/WDFrames.asp?wd_Word=" + wd_Word +"&wd_Language=" + wd_Language + "&wd_History=" + 0
			
		myWin = window.open(myStr, "Dictionary", 'width=212,height=312,left=200,top=200')
	}
}

//*****************************************************************************
function MM_openBrWindow(theURL, winName, features)
{ 
  window.open(theURL, winName, features);
}

//*****************************************************************************
function getHelp(sHelpName)
{
  var a = arguments;
	var sHelp = a.length > 0 ? a[0] : helpFile;
	if (sHelp != "")
	{
	  var URL = Root + "Runtime/Help.asp?name=" + sHelp
		var x = (800 - 550) / 2
		var y = (600 - 460) / 2
    window.open(URL, 'Help', 'width=550,height=455,left='+x+',top='+y+',resizable=no,scrollbars=no')
	}
}

//*****************************************************************************
function downloads()
{
	var URL = Root + "Runtime/Window.asp?Mode=download&Width=490&Height=420&Title=cxtCoOwStDownloads&Feature=cxtCoOwStDownloads&Source=" + Root + "Runtime/Detect.htm"
	var x = (800 - 550) / 2
	var y = (600 - 460) / 2
	window.open(URL, 'Detect', 'width=500,height=475,left='+x+',top='+y+',resizable=no,scrollbars=no')
}

//*****************************************************************************
function register()
{
	var URL = Root + "Runtime/Window.asp?Mode=Registration&Width=450&Height=425&Title=cxtCgOw00TtEDOnline&Feature=cxtCgOw00TtRegistration&Source=" + Root + "Runtime/Register.asp";
	//var x = (800 - 510) / 2
	//var y = (600 - 455) / 2

	window.open(URL, 'Registration', 'width=460,height=480,left=100,top=100,resizable=no,scrollbars=no')
	//window.open(URL, 'Registration', 'width=560,height=555,left='+x+',top='+y+',resizable=no,scrollbars=no')
}

//*****************************************************************************
function LogOut()
{
	var x = (800 - 360) / 2
	var y = (600 - 215) / 2
	var URL = Root + "Runtime/Window.asp?Mode=Alert&Width=340&Height=125&Title=cxt00NbBtLogOut&Feature=cxt00NbBtLogOut&Source=" + Root + "Runtime/LogOut.asp"
	//window.open(URL,'LogOut','width=350,height=180,left='+x+',top='+y+',resizable=no,scrollbars=no')
	var features = "dialogWidth: 360px; dialogHeight: 215px; dialogLeft: " + x + "px; dialogTop: " + y + "px; scroll: no; status: no; edge: Sunken; help: no;"
	var ret = window.showModalDialog(URL, "", features);
	if (ret == "Yes")
		endSession();
}

//***************************************************************************
function endSession()
{
	setCompositeCookie("Student", "SID", -1);
	document.location = Root + "Runtime/Home/Home.asp"
}

//*****************************************************************************
function getSupport()
{
	var hasTeacher = getCompositeCookie("Student", "HasTeacher");
	if (hasTeacher != null && hasTeacher != 0)
		document.location = Root + "Runtime/Support/Inbox.asp";
	else
	{
		var URL = Root + "Runtime/Window.asp?Width=390&Height=185&Title=cxt00NbBtSupport&Feature=cxtTsMs00NtContactYourTeacher&Source=" + Root + "Runtime/Support/SendMail.asp"
		var x = (800 - 400) / 2
		var y = (600 - 240) / 2
		//var x = (screen.width - 450) / 2
		//var y = (screen.height - 475) / 2
		window.open(URL,'SendMail','width=400,height=240,left='+x+',top='+y+',resizable=no,scrollbars=no')
	}
}

//*****************************************************************************
function openYouWho()
{
	var wndYW = window.open(Root + "Runtime/FriendsOnline/YHPage.asp", "youwho", 'width=182,height=220,left=200,top=200');
}

//*****************************************************************************
function insertTemplateTxt(strTxt, arSeach, arRepl)
{
	if (strTxt && arSeach)
	{
		for(var i = 0; i < arSeach.length; i++)
		{
			if (strTxt.indexOf(arSeach[i]) != -1)
			{
				strTxt = strTxt.substring(0, strTxt.indexOf(arSeach[i])) + arRepl[i] + strTxt.substring(strTxt.indexOf(arSeach[i]) + arSeach[i].length);
			}
		}
	}
	return strTxt;
}

//*****************************************************************************
function FindIndex(select, text)
{
	var i;
	for (i = 0; i < select.length; i++)
	{
		if (select.options[i].text == text)
			break;
	}
	return i;
}

//*****************************************************************************
function buildPictureContainer(graphicMode, width, height, flashSrc, imgSrc, imgName, containerId)
{
	if (graphicMode == "flash")
	{
		w("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='" + width + "' height='" + height + "' id='" + containerId + "'>")
		w("<param name=movie value='" + Root + "Runtime/Flash/supercontainer.swf?" + flashSrc + "&height=" + height + "&width=" + width + "&path=" + resPath + "flashcss.txt'>")
		w("<param name=quality value=high>")
		w("<param name='SCALE' value='exactfit'>")
		w("<embed src='" + Root + "Runtime/Flash/supercontainer.swf?" + flashSrc + "&height=" + height + "&width=" + width + "&path=" + resPath + "flashcss.txt' quality='high' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='" + width + "' height='" + height + "' scale='exactfit'></embed>")
		w("</object>")
	}
	else if (width != "")
		w("<img width='" + width + "' height='" + height + "' src='" + imgSrc + "' border=0 name='" + imgName + "'>")
	else	
		w("<img src='" + imgSrc + "' border=0 name='" + imgName + "'>")
}

//*****************************************************************************
function RollOverObject(p1, p2, pic, p4, mode, numPic, containerId)
{
	if (mode == "flash")
	  rollover(numPic, containerId)
	else
	  MM_swapImage(p1, p2, pic, p4)
}

//*****************************************************************************
function RollOutObject(mode, numPic, containerId)
{
	if (mode == "flash")
	  rollout(numPic, containerId)
	else
	  MM_swapImgRestore()
}

//*****************************************************************************
function isObjValid(sName)
{
  var Obj = document.getElementById(sName);
  return ((Obj != null) && (Obj.object != null));
}

//*****************************************************************************
function rollover(pic, containerId)
{
	if (!isObjValid(containerId))
		return false;
	
	var cid = eval("window.document." + containerId);
	if (cid.PercentLoaded() == 100)
	{
		cid.SetVariable("_root.activepicture",pic);  
		cid.TCallLabel('/','rollover')
	}
}

//*****************************************************************************
function rollout(pic, containerId)
{
	if (!isObjValid(containerId))
		return false;
		
	var cid = eval("window.document." + containerId);
	if (cid.PercentLoaded() == 100)
	{
		cid.SetVariable("_root.activepicture",pic);  
		cid.TCallLabel('/','rollout')
	}
}

//*****************************************************************************
function PreloadJavaClasses()
{
	if (document.applets["AppletPreloader"] != null)
		document.applets["AppletPreloader"].startPreload()
}

//*****************************************************************************
function getLastLoadClass()
{
	if (document.applets["AppletPreloader"] != null)
	{
		var nextPreload = document.applets["AppletPreloader"].nextInList()
		if (nextPreload == "")
			nextPreload = "all"
		document.cookie = "nextPreload=" + "^" + nextPreload
	}
}

//*****************************************************************************
function getListOfClasses(findStr, fullStr)  
{
	var ret = ""
	var num = fullStr.indexOf(findStr + ",")
	if (num > -1)
		var ret = fullStr.substr(num)
	return ret   
}

//*****************************************************************************
function getTextTR(code, link)
{
	var txt = getTranslate(code)
	txt = txt.replace("<link>", link)
	if (link != "")
		txt = txt.replace("</link>", "</a>")
	else	
		txt = txt.replace("</link>", "")
	return txt
}

//*****************************************************************************
function getSkillTranslate(skill)
{
	switch(skill)
	{
		case "Reading":
			return getTranslate('cxtCo00NtReading')
		case "Listening":  
			return getTranslate('cxtCo00NtListening')
		case "Speaking":
			return getTranslate('cxtCo00NtSpeaking')
		case "Grammar":
			return getTranslate('cxtCo00NtGrammar')
		case "Web Activity":
			return getTranslate('')
		default:
			return skill
	}
}

//*****************************************************************************
function getEPTTranslate(val)
{
	switch(val)
	{
		case "Explore":
			return getTranslate('cxtCo00TtExplore')
		case "Practice":  
			return getTranslate('cxtCo00TtPractice')
		case "Test":
			return getTranslate('cxtCo00TtTest')
		default:
			return val
	}
}

//*****************************************************************************
	function includeTranslationJS()
	{
		var lang = getContextLanguage();
		w('<script language="JavaScript" src="' + Root + 'Runtime/Localization/Context/' + lang + '.js"></script>');
	}

//*****************************************************************************
	function getContextLanguage()
	{
		var lang, support;
		
		if (GetCookie("Student") != null && getCompositeCookie("Student", "SID") != "-1")
		{
			support = getCompositeCookie("Student", "LangSupLevel");
			if (support == 0 || support == 1)
				lang = "eng";
			else	
				lang = language;
		}
		else if (GetCookie("Community") != null)
		{
			support = getCompositeCookie("Community", "InstLangSupLevel");
			if (support == 0 || support == 1)
				lang = "eng";
			else	
				lang = instLang;
		}
		else	// PLT
			lang = "eng";
			
		return lang;
	}

//*****************************************************************************
	function getContentLanguage()
	{
		var lang, support;
		
		if (GetCookie("Student") != null && getCompositeCookie("Student", "SID") != "-1")
		{
			support = getCompositeCookie("Student", "LangSupLevel");
			if (support == 0)
				lang = "eng";
			else	
				lang = language;
		}
		else
			lang = "eng";

		return lang;
	}

//*****************************************************************************
	function checkInstallation(feature)
	{
		var isInstalled = getCompositeCookie("Media", feature)
		if (isInstalled == "1")
			return

		var x = (800 - 450) / 2
		var y = (600 - 255) / 2
		var win = window.open(Root + 'Runtime/Window.asp?Mode=download&Width=440&Height=200&Title=cxtCoOwStDownloads&Feature=cxtCoOwStDownloads&Source=' + Root + 'Runtime/InstallOne.asp?feature='+feature,'InstallOne','width=450,height=255,left='+x+',top='+y+',resizable=no,scrollbars=no')
	}
	
//*****************************************************************************
	function IsSRInstalled()
	{
	  var SRPresent = getCompositeCookie("Media", "SR");
	  if (SRPresent != 1)
	  { // still , may be flag not updated , check out again status of SR
			try
	    {
				var srObj = new ActiveXObject("MTWTools.SafeSRS");
	      if ((srObj != null) && (srObj.isSRAvailable))
					SRPresent = 1;
	      else
					SRPresent = 0;
	      srObj = null;    
	    }
	    catch (Expt) { SRPresent = 0; }    
	      
	    if (SRPresent == 1)
				setCompositeCookie("Media", "SR", 1);
	  }
	  return SRPresent;
	}

//*****************************************************************************
	function getPageOf(code, currentPage, totalPages)
	{
		var txt = getTranslate(code)
		txt = txt.replace("<cur>", currentPage)
		txt = txt.replace("<total>", totalPages)
		return txt
	}

//*****************************************************************************
	function changeBtnStyle(btnName, NStyle, HStyle, enter)
	{
		if (enter == 1)
		{
			if (eval("document.all." + btnName).className == NStyle)
			{
				eval("document.all." + btnName).className = HStyle
			}
		}
		else
		{
			eval("document.all." + btnName).className = NStyle
		}
	}

//*****************************************************************************
	function checkSoundCompression()
	{
		var isInstalled = getCompositeCookie("Media", "SComp");
		if (isInstalled == 1)
			return;
		else
		{
			if (bWin95 || bWin98)
				alert(getTranslate("cxt0000PmNtSoundComponent9895"))
			else if (bWinNT || bWin2K || bWinXP)
				alert(getTranslate("cxt0000PmNtSoundComponent2000"))
		}	
	}

//*****************************************************************************
	function loginAlert()
	{
		alert(getTranslate("cxtCoLgNtPleaseLogin"))
	}

//*****************************************************************************
	function putAlert(code)
	{
		alert(getTranslate(code));
	}
	
//*****************************************************************************
	function openLoginWindow(feature, source)
	{
		var Source = escape(Root + "Runtime/LogIn.asp?Feature=" + feature + "&Source=" + source);
		var URL = Root + "Runtime/Window.asp?Width=300&Height=250&Title=cxtHoMnBtLogin&Feature=cxtHoMnBtLogin&Source=" + Source;
		window.open(URL,'LogIn','width=310,height=305,left=100,top=100,resizable=no,scrollbars=no')
	}

//************************* Practice Manager **********************************
//*****************************************************************************
function getNextPractice(num)
{
	if (practiceLoaded)
	{
		practiceLoaded = false;

		if (num == 0 || num == obj.Sequence || num > obj.TotalSequence)
		  return;
		else
		{
			document.body.style.cursor = "wait";
			if (!FromTMS)
			{
				var mark = getMark(appName);             
				stopTime = new Date()
				diff = Math.floor((stopTime - startTime) / 1000);
				saveMark(obj.Id, mark, diff, 1);
				if (mark > 0)
					updateProgress(1);
				startTime = new Date()
			}
			setCompositeCookie("Component", "ItemId", obj.SequenceArr[num - 1]);
			obj = getItem(obj.SequenceArr[num - 1]);
			helpFile = getHelpFileName(InteractionArr[num - 1]);
			if (document.applets[appName] != null)
			{
				document.applets[appName].getPractice(num - 1);
			}
			if (skill == "Reading" && SeqImages)
			{
				/*
				if (obj.ItemType == "Sequence Image")
					document.all.PTable.outerHTML = '<table id="PTable" width="370" border="0" cellspacing="0" cellpadding="0" height="20">'
				else
					document.all.PTable.outerHTML = '<table id="PTable" width="332" border="0" cellspacing="0" cellpadding="0" height="20">'
				*/	
			}
			buildPager("Practice", "yes")
			buildBackNextBtn("", "yes");
		}
  }
}

//*****************************************************************************
function endLoading()
{
	practiceLoaded = true;
	document.body.style.cursor = "default";
}

//*****************************************************************************
function getNextTest(num, mode)
{
	if (practiceLoaded)
	{
		practiceLoaded = false;

		if (num == 0 || num == obj.Sequence || num > obj.TotalSequence)
		  return;
		else
		{
			document.body.style.cursor = "wait";
			if (mode != testMode)
			{
				setCompositeCookie("Test", "testMode", mode)
			}    
			setCompositeCookie("Component", "ItemId", obj.SequenceArr[num - 1]);
			obj = getItem(obj.SequenceArr[num - 1]);
			obj.SequenceArr = testRandomSet;
			obj.Sequence = num;
			var url = "TestFeedback.asp?sequence=" + obj.Sequence + "&ItemId=" + obj.Id + "&TotalSequence=" + obj.TotalSequence + "&FromTMS=" + FromTMS
			document.all.SubmitTest.innerHTML = '<a href="javascript:OpenMsgWindow(&quot;' + url + '&quot;, &quot;' + appName + '&quot;)" class="StartTestText">' + getTranslate("cxtCoTeBtSubmitTest") + ' &gt;&gt;</a>'

			helpFile = getHelpFileName(InteractionArr[num - 1]);
			buildPager(mode, "yes")
			buildBackNextBtn(mode, "yes");

			if (document.applets[appName] != null)
			{
				document.applets[appName].setItemVisited(visitedCurrentItem);
				document.applets[appName].getPractice(num - 1);
			}
		}
	}
}

//*****************************************************************************
function getTestAnswer(num)
{
	setCompositeCookie("Component", "ItemId", testRandomSet[num - 1])
	setCompositeCookie("Test", "Sequence", num);
	document.location = "TestCheckAnswers.asp?Sequence=" + num + "&TotalSequence=" + obj.TotalSequence + "&ItemId=" + testRandomSet[num-1] + "&FromTMS=" + FromTMS
}

//*****************************************************************************
function getNextTestAnswer(num, mode)
{
	if (practiceLoaded)
	{
		practiceLoaded = false;

		if (num == 0 || num == obj.Sequence || num > obj.TotalSequence)
		  return;
		else
		{
			setCompositeCookie("Component", "ItemId", obj.SequenceArr[num - 1]);
			obj = getItem(obj.SequenceArr[num - 1]);
			obj.SequenceArr = testRandomSet;
			obj.Sequence = num;
			helpFile = getHelpFileName(InteractionArr[num - 1]);
			if (document.applets[appName] != null)
				document.applets[appName].getPractice(num - 1);
			buildPager(mode, "yes");
			buildBackNextBtn(mode, "yes");
			appletMode = "seeUserAnswer"
			currentMode = "seeUserAnswer";
			UpdateMenuView("Your", "Correct");      
			updateResultTable(num, obj.TotalSequence);
		}
	}
}
		
//*****************************************************************************
function updateResultTable(num, numPractices)
{
	var marks = getCompositeCookie("Test", "Marks");
	var marksArr = marks.split("|");
	var styleButton = "TestQuestionButton";
	var testMark, pic, url, strHref, strHrefImg;
	
	for (i = 1; i <= numPractices; i++)
	{
	  testMark = marksArr[i - 1];                 
		if (testMark == 0)
			pic = "Context/test/feadback/WrongAnswer3.gif";
		else if (testMark > 0 && testMark < 100)
			pic = "Context/test/feadback/halfAnswer3.gif";
		else
			pic = "Context/test/feadback/RightAnswer3.gif";

		url = "javaScript:getNextTestAnswer(" + i + ", &quot;TestCheck&quot;)"
		if (i == num)
		{
		 	strHref = "<span class='TestPageActive'>" + i + "</span>";
		 	strHrefImg = "<img src='" + pic + "' width='11' height='11'>";  		 		  
 		}		 	
 		else
 		{
		  strHref = "<a class='TestPage' href='" + url + "'>" + i + "</a>";
		  strHrefImg = "<a href='" + url + "'><img src='" + pic + "' width='11' height='11' border='0'></a>";
 		}
		document.all["Ref" + i].innerHTML = strHref;
		document.all["imgRef" + i].innerHTML = strHrefImg;
	}
}

//*****************************************************************************
function getMark(appletName)
{
	var mark;
	if (appletName == "")
	{
		mark = 1; // for explore: always compleate
		if (obj.SubComponent != "Test")
			setCompositeCookie("Component", "lastItemId", obj.Id);
	}
	else if (document.applets[appletName] != null)
	{
		if (document.applets[appletName].isActive())
		{  
			mark = document.applets[appletName].calculateMark();
      if (mark > 0 && obj.SubComponent != "Test")
      {
				setCompositeCookie("Component", "lastItemId", obj.Id);
			}
		}     
		else
			mark = 0;
	}		
	else
		mark = 0;

	return mark;
}

//*****************************************************************************
function getAppletName()
{
	var helpCode = skill.substr(0,1) + obj.SubComponent.substr(0,1);
	switch(obj.SubComponent)
	{
		case "Explore":
		  switch(skill)
		  { 
		    case "Listening":
		      strApplN = "ExploreLLM"
		      helpFile = "ListeningExploreH"
		      break;
		    case "Reading":
		      strApplN = "ExploreRLV"
		      helpFile = "ReadingExploreH"
		      break;
		    case "Grammar":
	 	      strApplN = "ExploreG"
	 	      helpFile = "GrammarExploreH"
		      break;
		    case "Speaking":
					strApplN = "ExploreSLV"
		      //strApplN = "ExploreSVM"
		      helpFile = "SpeakingExploreH"
		      break;	        
		  }
		  break;    
		case "Practice":
		case "Practice 2":
		case "Test":
			if (skill == "Speaking" && obj.SubComponent != "Test")
			{
				strApplN = "PracticeSpk";
				var lasrLetter = obj.Code.substr(obj.Code.length - 1, 1);
				if (lasrLetter.toLowerCase() == "m")
					helpFile = "SpeakingPractice2H";
				else
					helpFile = "SpeakingPractice1H";
			}
			else
			{
				appCode = "PracticeManager";
				appName = "PracticeManager";
				strApplN = "PracticeManager";
				if (obj.SubComponent == "Test" && testMode != "Test")
					helpFile = helpCode + "openH";
				else
					helpFile = getHelpFileName(obj.ItemType);
			}
		  break;    
	}
}

//*****************************************************************************
function getHelpFileName(Interaction)
{
	var helpCode = skill.substr(0,1) + obj.SubComponent.substr(0,1);
	var name;

	switch(Interaction)
	{
		case "Classification":
		  name = helpCode +  "ClassificationH"
		  break;    
		case "Fill in The Blanks Segment":
		  name = helpCode +  "FITBSegH"
		  break;  
		case "Fill In The Blanks Whole":
		  name = helpCode +  "FITBWholeH"  
		  break;  
		case "Sequence Image":
		  name = helpCode +  "sequencingIH"      
		  break;  
		case "Sequence Sentence":
		  name = helpCode +  "sequencingSH"	         
		  break;  
		case "Cloze Whole":
		  name = helpCode +  "ClozeWholeH"
		  break;  
		case "Cloze Whole (bmp)":
		  name = helpCode +  "ClozeWholeH"
		  break;  
		case "Mark The True":
		  name = helpCode +  "MTTH"
		  break;  
		case "Matching":
		  name = helpCode +  "matchingH"
		  break;  
		case "Multiple Choice Question Segments":
		  name = helpCode +  "mcqsegH"
		  break;  
		case "Multiple Choice Question Whole":
		  name = helpCode +  "mcqwholeH"
		  break;      
		case "Cloze Segments":
		  name = helpCode +  "ClozeSegH"
		  break;  
		case "Open Ended Segments":
		  name = helpCode +  ""
		  break;  
	}
	return name;
}

//*****************************************************************************
function buildPracticesPath()
{
	var name, found;
	var path = "";
	var length = InteractionArr.length;
	
	for (i = 0; i < length; i++)
	{
		found = false;
		for (j = 0; j < i; j++)
		{
			if (InteractionArr[i] == InteractionArr[j])
			{
				found = true;
				break;
			}
		}		
		if (found)
			continue;
			
		switch(InteractionArr[i])
		{
			case "Classification":
			  name = "PracticeClassification"     
			  break;    
			case "Fill in The Blanks Segment":
			  name = "PracticeFITBSegments"     
			  break;  
			case "Fill In The Blanks Whole":
			  name = "PracticeFITBWhole"   
			  break;  
			case "Sequence Image":
			  name = "PracticeSeqImages"     
			  break;  
			case "Sequence Sentence":
			  name = "PracticeSeqSentences"       
			  break;  
			case "Cloze Whole":
			  name = "PracticeClozeWhole"         
			  break;  
			case "Cloze Whole (bmp)":
			  name = "PracticeClozeWholeGrammar"         
			  break;  
			case "Mark The True":
			  name = "PracticeMarkTheTrue"      
			  break;  
			case "Matching":
			  name = "PracticeMatching"    
			  break;  
			case "Multiple Choice Question Segments":
			  name = "PracticeMCQSegments" 
			  break;  
			case "Multiple Choice Question Whole":
			  name = "PracticeMCQWhole"   
			  break;      
			case "Cloze Segments":
			  name = "PracticeClozeSegments"         
			  break;  
			case "Open Ended Segments":
			  name = "PracticeOESegments"         
			  break;  
		}
		path += "Programmers/" + name + "/" + name + ".zip,";
	}
	return path;
}

//************************* Practice Manager **********************************

//-----------------------------------------------------------------------------
//---------------------- Flash functions --------------------------------------
//-----------------------------------------------------------------------------
	function MediaPlayer_DoFSCommand(command, args)
	{ 
		var applList = getTrackerObj().getVariable("ListenerObj");
		if (command == "eos")
		{ 
			var mp = document.applets[applList].getPlayerForName("MediaPlayer");
			if (mp != null)
				mp.EndOfStream(0);
		}
		else if (command == "play")
		{
			onBtnValueChanged(applList,"mtrc_play",true);
		}
		else if (command == "stop")
		{
			onBtnValueChanged(applList,"mtrc_play",false);
		}
		else if (command == "TrPos")
		{
			onTrackerValueChanged(applList,"TrackerLite",args,0);
		}
		else if (command == "TrPosDrag")
		{
			onTrackerValueChanged(applList,'TrackerLite',args-1,3);
		}
		else if (command == "btnState")
		{
			alert(args);
		}
	}

//----------------------------------------------------------------------------------------
	function setFSelectedSE(from_tm,to_tm)
	{
		window.document.MediaPlayer.SetVariable("_root.fromFrame",parseInt(from_tm*12));  
		window.document.MediaPlayer.SetVariable("_root.toFrame",parseInt(to_tm*12));  
	}

//----------------------------------------------------------------------------------------
	function playFlash()
	{
		window.document.MediaPlayer.TCallLabel('/','flashPlay');
	}

//----------------------------------------------------------------------------------------
	function stopFlash()
	{
		window.document.MediaPlayer.TCallLabel('/','flashStop');
	}

//----------------------------------------------------------------------------------------
	function setPositionFL(from_tm)
	{
	//	window.document.MediaPlayer.SetVariable("_root.fromFrame",from_tm*12.026);  
	//	window.document.MediaPlayer.TCallLabel('/','setTrPos');
	}

//----------------------------------------------------------------------------------------
	function GetDurationFl()
	{
		var duration = eval(window.document.MediaPlayer.getVariable("soundDuration")/12);
		return duration;
	}

//----------------------------------------------------------------------------------------
	function GetPositionFl()
	{
		var position = eval(window.document.MediaPlayer.getVariable("_root.TrPosition"));
		return position;
	}

//----------------------------------------------------------------------------------------
	function btnState()
	{
		var buttonState = window.document.MediaPlayer.getVariable("buttonState");
		return buttonState;
	}

//----------------------------------------------------------------------------------------
	function initFlash(strIni)
	{
		if (window.document.MediaPlayer.PercentLoaded() > 0)
		{
			var splitString = strIni.split(";");
			var filetmp = splitString[0].split("=");
			var fileName = filetmp[1];
			var slidetmp = splitString[1].split("=");
			var slides = slidetmp[1];

			window.document.MediaPlayer.SetVariable("slides",slides);  
			
			var slidesArray = splitString[2].split("&");
			for (var i = 0; i < slides; i++) 
			{
				var currSlideTmp = slidesArray[i].split("=");
				var currSlide = currSlideTmp[1];
				var thisVar = new String("_root.s" + (i+1));
		   	
		   	window.document.MediaPlayer.SetVariable(thisVar,currSlide);  
			}
			var segtmp = splitString[3].split("=");
			var segNumber = segtmp[1];
			
			window.document.MediaPlayer.SetVariable("segNumber",segNumber);  
			
			var SegArray = splitString[4].split("&");
			for (var i = 0; i < segNumber; i++) 
			{
				var currSegTmp = SegArray[i].split("=");
				var currSeg = currSegTmp[1];
				window.document.MediaPlayer.SetVariable("seg",currSeg);  
		   	window.document.MediaPlayer.TCallLabel('/','initSegArr');
			}
		}
	}

//----------------------------------------------------------------------------------------
	function setFile(fileName)
	{
		var paths = fileName.split("/");
		var filetmp = paths[paths.length-1].split(".");
		var fileName = filetmp[0];
		var directory = paths[paths.length-2]; 
		window.document.MediaPlayer.SetVariable("_root.directory",directory);  
		window.document.MediaPlayer.SetVariable("_root.FileName",fileName);  	
	}
