
// 7-24-03 v_eula = "../lms/eula.htm"
v_eula = cc_cLMSLocation + 'eula.htm';
v_aCookie = new Array('gogetthecookie');
cc_cLMSChrome = 0;

function m_StartThisCourse(){//called by eula
 m_Launch();
}

function m_StartCourse(){
m_SaveToCookie('eula', '1');
 if (v_oClientInfo.persistentCookie == 1 || v_oClientInfo.sessionCookie == 1){
	if (m_ReadFromCookie('eula') == 1) m_Launch();
// 8-12-03	else document.getElementById('b').src = v_eula;
	//else m_ShowEULA();
	m_Launch();
 }
 else{
	alert('Cookies need to be enabled to continue.');
 }


}

function m_ShowEULA(){
 document.getElementById('b').src = v_eula;
 document.getElementById('b').style.display = 'block';
}

function m_Launch(){
 var l_cParams = "cc_cCourseRoot=" + escape(cc_cCourseRoot) + "&"
	+ "cc_cDataPath=" + escape(cc_cDataPath) + "&"
	+ "cc_cStructureFile=" + escape(cc_cStructureFile);
	if (typeof(cc_cAutoLaunch) != 'undefined') l_cParams += "&" + "cc_cAutoLaunch=" + cc_cAutoLaunch;
	else l_cParams += "&" + "cc_cAutoLaunch=0";
	if (typeof(cc_cAutoZoom) != 'undefined') l_cParams += "&" + "cc_cAutoZoom=" + cc_cAutoZoom;
	else l_cParams += "&" + "cc_cAutoZoom=0";
	if (typeof(cc_cLMSChrome) != 'undefined') l_cParams += "&" + "cc_cLMSChrome=" + cc_cLMSChrome;
	else l_cParams += "&" + "cc_cLMSChrome=1";
	if (typeof(cc_cLinkFree) != 'undefined') l_cParams += "&" + "cc_cLinkFree=" + cc_cLinkFree;
	else l_cParams += "&" + "cc_cLinkFree=0";
	if (typeof(cc_cXMLPlayerLocation) != 'undefined') l_cParams += "&" + "cc_cXMLPlayerLocation=" + cc_cXMLPlayerLocation;
	else l_cParams += "&" + "cc_cXMLPlayerLocation=../xmlplayer/";

if (typeof(isHTA) == 'undefined') isHTA = '0';
if (isHTA == '1'){

	
/* 7-28-03
	fso = new ActiveXObject("Scripting.FileSystemObject");
	var rtn1;
	var WshShell;
	WshShell = new ActiveXObject("WScript.Shell");
	bVer = '';
	browserVer = navigator.appVersion;
*/
	v_src= cc_cLMSPlayer + "?" + l_cParams
	document.getElementById('b').style.display = 'block';
	v_iframesrc = document.getElementById('b').document.location.href;
	
	//if(v_iframesrc.indexOf('Program%20Files') >= 0)document.getElementById('b').document.location.href = v_src;
	//else document.getElementById('b').src = v_src;

	document.getElementById('b').src = v_src;

	
	
 }
 else{
	v_winwidth = screen.availWidth - 8;
	v_winheight = screen.availHeight - 28;

	if (cc_cLMSPlayer.slice(0,2) == './') v_src= cc_cLMSPlayer.slice(2) + "?" + l_cParams;
	else  v_src= cc_cLMSPlayer + "?" + l_cParams;
		
	window.open(v_src,'ralms','toolbars=0,top=0, resizable=yes, width='+v_winwidth+', height='+v_winheight+', left=0, status=0');
	window.blur();

	v_src= cc_cLMSPlayer + "?" + l_cParams
	document.getElementById('b').src = cc_cLMSLocation + "startup_lms.htm";
	document.getElementById('b').style.display = 'block';
 }
}


function m_ReadFromCookie(p_cCrumb){
 var l_nCrumbId, l_cCrumbValue;

 if (v_aCookie[0] == 'gogetthecookie') m_GetCookie();
 l_nCrumbId = v_aCookie.find(p_cCrumb);

 if(l_nCrumbId == -1) l_cCrumbValue = 0;
 else l_cCrumbValue = v_aCookie[l_nCrumbId + 1];

 return l_cCrumbValue;
}

function m_SaveToCookie(p_cCrumb, p_cCrumbValue){
 var l_dToday = new Date();
 var l_dThisYear = l_dToday.getFullYear()
 var l_dExpireDate = new Date(l_dThisYear + 10, 11, 31);
 document.cookie = p_cCrumb + '=0;expires=Fri, 31 Dec 1999 23:59:59 GMT';
 if (v_oClientInfo.browser == 'e') document.cookie = p_cCrumb + '=' + p_cCrumbValue + ';expires=' + l_dExpireDate.toGMTString() + ';path=/';
 else document.cookie = p_cCrumb + '=' + p_cCrumbValue + ';expires=' + l_dExpireDate.toGMTString() + ';path=/';
}

function m_GetCookie(){
 var l_aCookie = document.cookie.split('; ');

 v_aCookie = new Array();
 if(l_aCookie != null && l_aCookie != ''){
	for (i = 0; i<l_aCookie.length; i++) {
		var l_aCrumb = l_aCookie[i].split('=');
		v_aCookie[v_aCookie.length] = l_aCrumb[0];
		v_aCookie[v_aCookie.length] = l_aCrumb[1];
	}
 }
}

/* 7-28-03
function m_CreateFolder(p_cFolder){
 var l_lLoop, l_cPathLen, l_nDelimiter1, l_nDelimiter2, l_cPath

 if (!fso.FolderExists(p_cFolder)){
	l_cPathLen = p_cFolder.length;
	l_nDelimiter1 = p_cFolder.indexOf('\\');
	l_nDelimiter2 = p_cFolder.indexOf('\\', l_nDelimiter1+1);
	l_cPath = p_cFolder.substring(0, l_nDelimiter1 + 1);
	l_lLoop = 0;

	while (l_lLoop == 0){
		l_cPath = l_cPath + p_cFolder.substring(l_nDelimiter1 + 1, l_nDelimiter2 + 1);

		if (!fso.FolderExists(l_cPath)){
			fso.CreateFolder(l_cPath);
		}

		l_nDelimiter1 = l_nDelimiter2;
		l_nDelimiter2 = p_cFolder.indexOf('\\', l_nDelimiter1 + 1);

		if (l_nDelimiter2 == -1) l_lLoop = 1;

	}
 }
}

function m_SaveToFile(p_cFolder, p_cFile, p_cContents){
 var l_oFso, l_cFolderFile, l_cTextStream;
 l_oFso = new ActiveXObject("Scripting.FileSystemObject"); 

 if (typeof(l_oFso) == 'undefined'){
	return
 }
 else{
	l_cFolderFile = p_cFile +'.txt'

	var l_WshShell = new ActiveXObject("WScript.Shell");;

	l_cFolderPath = 'c:\\tra\\' + p_cFolder +'\\';
	m_CreateFolder(l_cFolderPath);
	l_cTextStream = l_oFso.CreateTextFile(l_cFolderPath + l_cFolderFile, true, false);
	l_cTextStream.Write(p_cContents);
	l_cTextStream.Close();
 }
}
*/

function m_resize(){
 if (br == 'e'){
	var l_width = parent.document.body.clientWidth;
	var l_height = parent.document.body.clientHeight;
 }
 else{
	var l_width = window.innerWidth;
	var l_height = window.innerHeight;
 }

 document.getElementById('b').style.width = l_width;
 document.getElementById('b').style.height = l_height;
}

if(m_CheckRequirements(1)){
/* 7-28-03
	if (isHTA == 1){
		m_SaveToFile('path','courseroot',escape(cc_cCourseRoot));
		m_SaveToFile('path','datapath',escape(cc_cDataPath));
		m_SaveToFile('path','structure',escape(cc_cStructureFile));
	}
*/
m_SaveToCookie('eula', '1');
//	if (m_ReadFromCookie('eula') == 1) m_StartCourse();
//	if (m_ReadFromCookie('eula') != 1)document.getElementById('b').src = v_eula;
	if (m_ReadFromCookie('eula') != 1) m_ShowEULA();
	m_StartCourse();
	m_resize();
}
