// printCookie();

function getWMPVer()
{
	var ver = 6.4, WMPVer;

	WMPVer = getCompositeCookie("Media", "MPV");
	if (WMPVer != null)
	{
		WMPVer = parseFloat(WMPVer);
		if (!isNaN(WMPVer))
			ver = WMPVer;
	}
	else
	{
		try {
			var objMP7 = new ActiveXObject("WMPlayer.OCX");
			WMPVer = objMP7.versionInfo;
			WMPVer = parseFloat(WMPVer);
			if (!isNaN(WMPVer))
				ver = WMPVer;
			objMP7 = null;
		}
		catch(e) {}
	}
  return ver;
}

function buildMediaPlayer(id, width, height, autoStart, showStatusBar)
{
	var GUID6 = "22d6f312-b0f6-11d0-94ab-0080c74c7e95";
	var GUID7 = "6BF52A52-394A-11D3-B153-00C04F79FAA6";
	var style = "block";

	if (width == 0 && height == 0)
		style = "none";

	if (getWMPVer() >= 7.0)
	{
		w('<OBJECT id="'+id+'" codeBase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" classid="CLSID:'+GUID7+'" width="'+width+'" height="'+height+'" type="application/x-oleobject">')
			w('<PARAM NAME="AutoStart" VALUE="' + autoStart + '">')
			w('<PARAM NAME="uiMode" VALUE="none">')
			w('<PARAM NAME="enableContextMenu" VALUE="false">')
		w('</OBJECT>')
	}
	else	
	{
		w('<div style="display:'+style+'"><OBJECT id="'+id+'" codeBase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" classid="CLSID:'+GUID6+'" width="'+width+'" height="'+height+'" type="application/x-oleobject">')
			w('<PARAM NAME="AutoStart" VALUE="' + autoStart + '">')
			w('<PARAM NAME="AutoRewind" VALUE="0">')
 			w('<PARAM NAME="DisplaySize" VALUE="4">')  
			w('<PARAM NAME="ShowTracker" VALUE="0">')
			w('<PARAM NAME="ShowControls" VALUE="0">')
			w('<PARAM NAME="ShowStatusBar" VALUE="' + showStatusBar + '">') 
			w('<PARAM NAME="ClickToPlay" VALUE="0">') 
			w('<PARAM NAME="EnableContextMenu" VALUE="0">') 
		w('</OBJECT></div>')
	}
}

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 processGBVResponse(req)
{
	var resText = req.responseText;
	resText = resText.substr(resText.indexOf("[data]") + 6);
	setCompositeCookie("Student", "GBVer", resText);
	if (resText == 0)	
		setCompositeCookie("Student", "GB", 0);
}
	
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 d = document;
  var str = "";
	str += "defaultCharset = " + d.defaultCharset + "\n"
	str += "charset = " + d.charset + "\n"
	str += "================================\n"
  var aCookie = d.cookie.split("; ");
  var length = aCookie.length;
  var size = d.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";
  alert(str);
}

function detect()
{
	var ua = window.navigator.userAgent;
  var bMSIE = (ua.indexOf("MSIE") != -1);
	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);
		if (bWinXP)
			bWinXPSP2 = (ua.indexOf("SV1") != -1);
		bWinVS = (ua.indexOf("Windows NT 6.0") != -1);
  }
}

function getCss()
{
	var a = arguments, home = false, arg;
	for (i = 0; i < a.length; i++)
	{ 
		arg = a[i].toLowerCase();
		if (arg.indexOf("print") > -1)
			var smedia = 'MEDIA="print"'
		else
			var smedia=""   
		w('<link rel="stylesheet" href=' + resPath + a[i] + '.css type="text/css" ' + smedia + '>')
	}
	if (typeof currentPage != "undefined")
	{
		if (currentPage == "Home")
			home = true;
	}	
	else if (parent.currentPage == "Home")
	{
		home = true;
	}	
	if (home)
	{
		toolsCellWidth = "123"
		inputCellWidth = "90"
		sideMargin = "5px"
		bgRoot = "home"
	}
	else
	{
		toolsCellWidth="110"
		inputCellWidth="90"
		sideMargin="4px 0px 4px 0px"
		bgRoot="common"
	}
	// tools styles
	w("<style>")
	w(".toolsTable{width:"+toolsCellWidth+"px;display:inline;margin:"+sideMargin+"}")
	w(".toolsTop{width:"+toolsCellWidth+"px;background-image:url("+Root+"Runtime/context/newLook/"+bgRoot+"/toolsTitleTop.gif)}")
	w(".toolsTitle{width:"+toolsCellWidth+"px;background-image:url("+Root+"Runtime/context/newLook/"+bgRoot+"/toolsTitleBg.gif);color:#000000;line-height:1.4em;text-align:center;color:#000000;padding-bottom:5px;}")
	w(".toolsBody{width:"+toolsCellWidth+"px;background-image:url("+Root+"Runtime/context/newLook/"+bgRoot+"/toolsBg.gif);color:#000000;line-height:1.4em;text-align:center;}")
	w(".toolsBottom{height:4px;width:"+toolsCellWidth+"px;background-image:url("+Root+"Runtime/context/newLook/"+bgRoot+"/toolsBottom.gif);}")
	w(".toolsInput{width:"+inputCellWidth+"px;color:#000000;}")
	w(".toolsGo{color:#ffffff}")
	w(".loginForgot{color:#000000;}")
	w(".layout0thin0line{background-color:#ffffff}")
	w("td.layout0thin0line table {display:none}")
	w(".ept0bg0highlight {padding:0px;background-image:url("+Root+"Runtime/context/newLook/common/eptBg.gif)}")
	w(".ept0links{padding:0px;}")
	w(".eptOut{font-weight:normal;}")
	w(".loginLeftBg{border:0px solid;background:transparent;}")
	w(".DictionayTitle{LETTER-SPACING: 0px;}")
	w("</style>")

	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("#plannerFrame{width:230;float:right;}")
		w("</style>")
	}else{
		w("<style>")
		w("#plannerFrame{width:230;float:left;}")
		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 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;
			var features = "dialogWidth: 320px; dialogHeight: 310px; 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")
				{
					switch(obj.SubComponent)
					{
						case "Practice":
							if (mark > 0)
								updateProgress(1);
							break;    
						default:
							updateProgress(1);
						break;    
					}
				}
				else if (mark > 0)
					updateProgress(1);
			}			
			setCompositeCookie("Unit", "ItemType", getCompositeCookie("Component", "ItemType"));
			document.location = locUrl
		}
	}
}

function saveCCData(url, itemId)
{
	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;
			if (arguments.length == 1)
				var lastItemId = getCompositeCookie("Component", "ItemId");
			else	
				var lastItemId = itemId;
			setCompositeCookie("Component", "lastItemId", lastItemId);
			saveMark(lastItemId, 1, diff, 2);
			updateProgress(1);
		}			
		document.location = locUrl;
	}
}

function updateProgress(progress)
{
	var compId = getCompositeCookie("Component", "Id");
	var subCompId = getCompositeCookie("Component", "SCId");
	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 ind1 = oldProgress.indexOf("|", ind);
			if (ind1 != -1)
				var subComps = oldProgress.substring(ind, ind1);
			else	
				var subComps = oldProgress.substr(ind);
			ind1 = subComps.indexOf(subCompId + ".") + subCompId.length + 1;
			ind += ind1;
		}	
		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")
  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)
{
  var d = document;
  if (compleatTest)
  {
		if (d.applets[appletName] != null)
		{
			d.applets[appletName].saveUserState();
			var marks = d.applets[appletName].getTestMarks();
			var finalMark = d.applets[appletName].getFinalMark();
			setCompositeCookie("Test", "Marks", marks);
			setCompositeCookie("Test", "FinalMark", finalMark);
		}
		d.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 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;
		var features = "dialogWidth: 320px; dialogHeight: 310px; scroll: no; status: no; edge: Sunken; help: no;";
		window.showModalDialog(URL, self, features);
	}
}

function getSubCompArr()
{
	var subComp = getCompositeCookie("Component", "Items")
	if (subComp != null && subComp != "")
	{
		var arr1 = subComp.split("%")
		for (var i = 0; i < arr1.length; i++)
		{
			var arr2 = arr1[i].split(",");
			subCompNameArr[i] = arr2[0];
			subCompIdArr[i] = eval(arr2[1]);
			itemIdArr[i] = eval(arr2[2]);
		}
  } 
}

function getSubComp(itemId, itemType, subCompId)
{
	var url = "Template.asp?unitData=" + getCompositeCookie("Unit", "UnitId") + "&FromTMS=" + FromTMS + "&SID=" + getCompositeCookie("Student", "SID"); 
	setCompositeCookie("Component", "ItemId", itemId);
	setCompositeCookie("Component", "ItemType", itemType);
	if (itemType == "Test");
		setCompositeCookie("Test", "Stage", "Intro");
	SavePage(url, appName, obj.Id, appletMode);
	setCompositeCookie("Component", "SCId", subCompId);
}

function getCustSubComp(itemId)
{
	var lastItemId = getCompositeCookie("Component", "ItemId");
	setCompositeCookie("Component", "ItemId", itemId);
	var url = "CustomTemplate.asp?unitData=" + getCompositeCookie("Unit", "UnitId") + "&FromTMS=" + FromTMS + "&SID=" + getCompositeCookie("Student", "SID")

	saveCCData(url, lastItemId);
}

function getQueryString(param)
{
	var sURL = document.URL.toString();
	if (sURL.indexOf(param + "=") != -1)
	{
		var aQuery = sURL.split("?");
	  aQuery = aQuery[1].split("&");
	  for (var i = 0; i < aQuery.length; i++)
	  {
	    var aCrumb = aQuery[i].split("=");
	    if (param == aCrumb[0]) 
	      return unescape(aCrumb[1]);
	  }
	}
	else
	  return null;
}

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")
	{
		if (getWMPVer() >= 7.0)
			wave = folder + "e.wmv"
		else
			wave = folder + "e.mpg"
	}
	return (path.substr(0,num) + "/Media/" + skill + "/" + folder + "/" + wave)
}

function openText(val)
{  
  var d = document;
	if (d.applets[appName] != null)
	{
		if (d.applets[appName].isActive())
		{
			switch(val)
		  {
				case "seeText":
					d.applets[appName].seeText();
			    break;
				case "seeExplanation":
					d.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)
{
  var d = document;
	setCompositeCookie("Media", "TVMode", mode)		
	if (state == 0)	 // EDO
	{
		d.location = "Template.asp?unitData=" + getCompositeCookie("Unit", "UnitId") + "&FromTMS=" + FromTMS + "&SID=" + getCompositeCookie("Student", "SID")
	}
	else if (state == 1)	// PLT
	{
		d.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)
{
  var aCookie = document.cookie.split("; ");
  for (var i = 0; i < aCookie.length; i++)
  {
    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)
{
  document.cookie = sName + "=" + "" + "; expires=Fri, 31 Dec 1989 23:59:59 GMT;";	
}

function OnDicClick(userLanguage)
{
	var wd_Word, wd_Language, URL, myWin

	wd_Word = document.DicForm.WDQString.value
	if (wd_Word != "")
	{
		wd_Word = escape(wd_Word);
		wd_Language = userLanguage
		if	(myWin != null)
			URL = Root + "Runtime/Dictionary/WDFrames.asp?wd_Word=" + wd_Word + "&wd_Language=" + wd_Language + "&wd_History=1";
		else
			URL = Root + "Runtime/Dictionary/WDFrames.asp?wd_Word=" + wd_Word + "&wd_Language=" + wd_Language + "&wd_History=0";
			
		myWin = window.open(URL, "Dictionary", "width=242,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";
	window.open(URL, 'Registration', 'width=460,height=480,left=100,top=100,resizable=no,scrollbars=no')
}

function LogOut()
{
	var height;
	if (bWinXP)
		height = 210;
	else	
		height = 190;
	
	var URL = Root + "Runtime/Window.asp?Mode=Alert&Width=270&Height=100&Title=cxt00NbBtLogOut&Feature=cxt00NbBtLogOut&Source=" + Root + "Runtime/LogOut.asp"
	var features = "dialogWidth: 300px; dialogHeight: " + height + "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
		window.open(URL,'SendMail','width=400,height=240,left='+x+',top='+y+',resizable=no,scrollbars=no')
	}
}

function openYouWho()
{
	window.open(Root + "Runtime/FriendsOnline/YHPage.asp", "YouWho", 'width=250,height=220,left=200,top=200');
}

function openGrammarBook()
{
	var gbVer = getCompositeCookie("Student", "GBVer"); 
	if (gbVer == null)
	{
		setTimeout("openGrammarBook()", 100)
		return;
	}
	if (gbVer == 0)
	{
		setCompositeCookie("Student", "GB", 0);
		alert(getTranslate("cxt24100GbPmNtNotAuthorized"))
		return;
	} 	
	var x = (screen.width - 755) / 2;
	var y = (screen.height - 545 - 50) / 2;
	var URL = Root + "Runtime/GrammarBook/GrammarBook.asp";
	window.open(URL,'GrammarBook','width=755,height=545,left='+x+',top='+y+',resizable=no,scrollbars=no')
}

function openAppletDialog(message, title, buttons)
{
	var height;
	if (bWinXP)
		height = 230;
	else	
		height = 210;

	message = message.replace("?", "&#63;")
	var source = escape(Root + "Runtime/appletDialog.asp?message=" + message + "&buttons=" + buttons);
	var URL = Root + "Runtime/Window.asp?Mode=Alert&Width=270&Height=120&Title=" + title + "&Feature=" + title + "&Source=" + source;
	var features = "dialogWidth: 300px; dialogHeight: " + height + "px; scroll: no; status: no; edge: Sunken; help: no;"
	var ret = window.showModalDialog(URL, "", features);
	if (ret == "Yes")
		return true;
	else	
		return false;
}

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 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 "Vocabulary":
			return getTranslate("cxt241000000NtVocabulary");
		case "Alphabet":
			return getTranslate("cxt24100Co00NtAlphabet");
		case "Writing":
			return getTranslate("cxt24100Co00NtWriting");
		default:
			return skill;
	}
}

function getEPTTranslate(val)
{
	switch(val)
	{
		case "Prepare":  
			return getTranslate("cxt24100Co00TtPrepare");
		case "Explore":
			return getTranslate("cxtCo00TtExplore");
		case "Practice":  
			return getTranslate("cxtCo00TtPractice");
		case "Practice 1":  
			return getTranslate("cxt24100Co00TtPractice1");
		case "Practice 2":  
			return getTranslate("cxt24100Co00TtPractice2");
		case "Test":
			return getTranslate("cxtCo00TtTest");
		case "Interact 1":
			return getTranslate("cxt24100Co00TtInteract1");
		case "Interact 2":
			return getTranslate("cxt24100Co00TtInteract2");
		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 source = escape(Root + "Runtime/InstallOne.asp?feature=" + feature);
	var URL = Root + "Runtime/Window.asp?Mode=download&Width=440&Height=200&Title=cxtCoOwStDownloads&Feature=cxtCoOwStDownloads&Source=" + source;

	window.open(URL,'InstallOne','width=450,height=255,left='+x+',top='+y+',resizable=no,scrollbars=no')
}
	
function IsSRInstalled()
{
  var SRPresent = getCompositeCookie("Media", "SR");
  if (SRPresent != 1)
  {
		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=200,top=200,resizable=no,scrollbars=no')
}

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");
		}
  }
}

function restorePagerIndex(ind)
{
	obj = getItem(obj.SequenceArr[ind]);
	setCompositeCookie("Component", "ItemId", obj.SequenceArr[ind]);
	helpFile = getHelpFileName(InteractionArr[ind]);

	endLoading();
}

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")
			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");
			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 = 0;
	if (appletName == "")
	{
		mark = 1;
		if (obj.SubComponent != "Test")
			setCompositeCookie("Component", "lastItemId", obj.Id);
	}
	else
	{
		var appletObj = document.applets[appletName];
		try
		{
			if (appletObj != null && appletObj.isActive())
			{
				mark = document.applets[appletName].calculateMark();
			  if (mark > 0 && obj.SubComponent != "Test")
			  {
					setCompositeCookie("Component", "lastItemId", obj.Id);
				}
			}
		}
		catch (e){}		
	}
	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":
				case "Writing":
					strApplN = "ExploreRLV"
					helpFile = "ReadingExploreH"
					break;
				case "Grammar":
					strApplN = "ExploreG"
					helpFile = "GrammarExploreH"
					break;
				case "Speaking":
					if (obj.Subject == "Video")
						strApplN = "ExploreLLM"
					else	
						strApplN = "ExploreSLV"
					helpFile = "SpeakingExploreH"
					break;	        
			}
			break;    
		case "Practice 1":
		case "Practice 2":
			strApplN = "PracticeSpk";
			var lasrLetter = obj.Code.substr(obj.Code.length - 1, 1);
			if (lasrLetter.toLowerCase() == "m")
				helpFile = "SpeakingPractice2H";
			else
				helpFile = "SpeakingPractice1H";
			break;    
		case "Interact 1":
		case "Interact 2":
			strApplN = "PracticeVSO";
			var lasrLetter = obj.Code.substr(obj.Code.length - 1, 1);
			if (lasrLetter.toLowerCase() == "w")
				helpFile = "SpeakingPractice2H";
			else
				helpFile = "SpeakingPractice1H";
			break;    
		case "Practice":
		case "Test":
			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 hc = skill.substr(0,1) + obj.SubComponent.substr(0,1);
	var name;

	switch(Interaction)
	{
		case "Classification":
		  name = hc +  "ClassificationH"
		  break;    
		case "Fill in The Blanks Segment":
		  name = hc +  "FITBSegH"
		  break;  
		case "Fill In The Blanks Whole":
		  name = hc +  "FITBWholeH"  
		  break;  
		case "Sequence Image":
		  name = hc +  "sequencingIH"      
		  break;  
		case "Sequence Sentence":
		  name = hc +  "sequencingSH"	         
		  break;  
		case "Cloze":
		  name = hc +  "ClozeH"
		  break;  
		case "Cloze Whole":
		  name = hc +  "ClozeWholeH"
		  break;  
		case "Cloze Whole (bmp)":
		  name = hc +  "ClozeWholeH"
		  break;  
		case "Mark The True":
		  name = hc +  "MTTH"
		  break;  
		case "Matching":
		  name = hc +  "matchingH"
		  break;  
		case "Multiple Choice Question Segments":
		  name = hc +  "mcqsegH"
		  break;  
		case "Multiple Choice Question Whole":
		  name = hc +  "mcqwholeH"
		  break;      
		case "Cloze Segments":
		  name = hc +  "ClozeSegH"
		  break;  
		case "Open Ended Segments":
		  name = hc +  "OpenEndedH"
		  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;  
			case "Match Text To Picture":
			  name = "PracticeTextToPicture"         
			  break;  
			case "Matching Game":
			  name = "PracticeMatchingGame" 
			  break;  
			case "Cloze":
			  name = "PracticeCloze"         
			  break;  
			case "Multiple Choice Question":
			  name = "PracticeMultipleChoiceQuestion" 
			  break;  
			case "Open Ended":
			  name = "PracticeOpenEnded"         
			  break;  
			case "Free Writing":
			  name = "PracticeFreeWriting"         
			  break;  
		}
		path += "Programmers/" + name + "/" + name + ".zip,";
	}
	return path;
}

function buildExplApplet(id, width, height)
{
	w('<APPLET id="' + id + '" name="TextImg" code="edweb/tools/TextImg.class"') 
		w('width="'+width+'" height="'+height+'"')
		w('archive="Programmers/CommonClasses/BaseClasses.zip,Programmers/Tools/TextImg.zip,Programmers/CommonClasses/UCommonClasses.zip" mayscript>')
	w('</APPLET>')
}

// 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)
{
	var MP = window.document.MediaPlayer;
	MP.SetVariable("_root.fromFrame",parseInt(from_tm*12));  
	MP.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)
{
	return; // 01.07.
	var MP = window.document.MediaPlayer;
	if (MP.PercentLoaded() > 0)
	{
		var splitString = strIni.split(";");
		var filetmp = splitString[0].split("=");
		var fileName = filetmp[1];
		var slidetmp = splitString[1].split("=");
		var slides = slidetmp[1];

		MP.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));
		   	
	   	MP.SetVariable(thisVar,currSlide);  
		}
		var segtmp = splitString[3].split("=");
		var segNumber = segtmp[1];
			
		MP.SetVariable("segNumber",segNumber);  
			
		var SegArray = splitString[4].split("&");
		for (var i = 0; i < segNumber; i++) 
		{
			var currSegTmp = SegArray[i].split("=");
			var currSeg = currSegTmp[1];
			MP.SetVariable("seg",currSeg);  
	   	MP.TCallLabel('/','initSegArr');
		}
	}
}

function setFile(fileName)
{
	var MP = window.document.MediaPlayer;
	var paths = fileName.split("/");
	var filetmp = paths[paths.length-1].split(".");
	var fileName = filetmp[0];
	var directory = paths[paths.length-2]; 
	MP.SetVariable("_root.directory",directory);  
	MP.SetVariable("_root.FileName",fileName);  	
}

function glSetAutoStart(bAutoStart){
	bglAutoStart = bAutoStart;
}
