//  Controller baseline established 10/9/2007

var inputType        = (userType == "Internal") ? "checkbox"            : "hidden";
var debugTxt         = (userType == "Internal") ? "Debug Mode"          : "";
var debugBehaviorTxt = (userType == "Internal") ? "Debug Behavior"      : "";
var reviewerTxt      = (userType == "Internal") ? "Reviewer Mode"       : "";
var editShowTextTxt  = (userType == "Internal") ? "Edit Show Text Mode" : "";
var rma508Txt        = (userType == "Internal") ? "RMA Mode"            : "";
//var pathToRoot       = "../";
var pathToRoot       = "";
var wndw;

function launchCurrent() {
	var tgtURL = dfltModulePath + "module.htm" + getModeParamString();
	launchURL(tgtURL);
}


function launchNew() {
	startRefreshMovie();

	clearCookieData();

	//  Open the module in the refresh window.
	setTimeout("redirectRefreshWindow();", 3000);
}



function launchBrowserTest() {
	launchURL(pathToRoot + "common/cw/htm/browsertest.htm");
}

function launchURL(url) {
	var wndwFeatures = "width=" + flashwidth + ",height=" + flashheight + ",resizable=0,status=0,scrollbars=0";
	wndw = window.open(url, 'content', wndwFeatures);
	wndw.focus();
}

function redirectRefreshWindow() {
	wndw.location.href = dfltModulePath + "module.htm" + getModeParamString();
	wndw.focus();
}


function clearCookieData() {
	var cookieName  = getParameterCookieName();
	var cookieValue = readCookie(cookieName);

	deleteCookie(cookieName, cookiePath);
}

function startRefreshMovie() {
	var refreshURL = pathToRoot + "common/controller/htm/refresh.htm?thisAU=" + thisAU + "&flashwidth=" + flashwidth + "&flashheight=" + flashheight;
	launchURL(refreshURL);
}


function getModeParamString() {
	var paramStr = getURLParamsString();

	var frm = document.forms[0];
	if (frm.debugMode.checked) {
		paramStr +="debugMode=1&";
	}
	if (frm.debugBehavior.checked) {
		paramStr +="debugBehavior=1&";
	}
	if (frm.reviewerMode.checked) {
		paramStr +="reviewerMode=1&";
	}
	if (frm.showTextEditMode.checked) {
		paramStr +="showTextEditMode=1&";
	}
	if (frm.accessibilityMode.checked) {
		paramStr +="accessibilityMode=1&";
		paramStr +="debug508=1&";
	}
	return (paramStr == "") ? "" : "?" + paramStr;
}

//  This function is used to ensured that all parameters passed into
//  this page are relayed to module.htm.
function getURLParamsString() {
	var paramStr = "";
	for (var paramName in urlParams) {
		paramStr = paramStr + paramName + "=" + urlParams[paramName] + "&";
	}
	return paramStr;
}

function writeLaunchPage() {

	document.write('<HTML>');
	document.write('<HEAD>');
	document.write('  <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>');
	document.write('  <STYLE type="text/css">');
	document.write('    td {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000}');
	document.write('  </STYLE>');
	document.write('  <TITLE>' + title + '</TITLE>');
	document.write('</HEAD>');
	document.write('<BODY bgcolor="#cccccc" text="#000000">');
	document.write('    <NOSCRIPT>');
	document.write('        Your browser does not support JavaScript. JavaScript is required to view this course.');
	document.write('    </NOSCRIPT>');
	document.write('    <TABLE WIDTH="750" BORDER="0" CELLSPACING="1" CELLPADDING="0" ALIGN="center" BGCOLOR="#666666">')
	document.write('      <tr>');
	document.write('        <td bgcolor="#FFFFFF">');
	document.write('          <IMG height=168 src="' + pathToRoot + 'common/cw/images/launchPgImage.jpg" width=750> ');
	document.write('          <br>&nbsp;&nbsp;');
//	document.write('          <TABLE BORDER="0" width = "735" align="center">');
//	document.write('            <tr>');
//	document.write('              <td>You are about to view the alpha lesson for <b>Principles of Automotive Air Conditioning</b>. This alpha lesson consists of a presentation screen that focuses on the air conditioning system\'s compressor and demonstrates graphics, animation, popups, and rollovers as well as 2 checks on learning.  Prior to viewing the compressor screens, students will have had an overall review of the A/C cycle and an introduction to the A/C components in vehicles. This alpha lesson will take approximately 5-10 minutes to complete. To start the alpha lesson, select "Launch New Principles of Automotive Air Conditioning Alpha Lesson". ');
//	document.write('              </td>');
//	document.write('            </tr>');
//	document.write('          </table>');
	//document.write('        </A>');
	document.write('        <BR>&nbsp;&nbsp;');
	document.write('        <br>&nbsp;&nbsp;');
	document.write('        <A href="javascript:launchNew();">');
	document.write('          Launch New <B>' + shortTitle + '</B>');
	document.write('        </A>');
	document.write('        <BR><BR>&nbsp;&nbsp;');
	document.write('        <A href="javascript:launchCurrent();">');
	document.write('          Continue Current <B>' + shortTitle + '</B>');
	document.write('        </A>');
	document.write('        <BR><BR>&nbsp;&nbsp;');
	document.write('        <FORM>');
	document.write('          &nbsp;&nbsp;');
	document.write('          <INPUT type=' + inputType  +' name=debugMode>'         + debugTxt         + '&nbsp;&nbsp;');
	document.write('          <INPUT type=' + inputType  +' name=debugBehavior>'     + debugBehaviorTxt + '&nbsp;&nbsp;');
	document.write('          <INPUT type=' + inputType  +' name=reviewerMode>'      + reviewerTxt      + '&nbsp;&nbsp;');
	document.write('          <INPUT type=' + inputType  +' name=accessibilityMode>' + rma508Txt        + '&nbsp;&nbsp;');
	document.write('          <INPUT type=' + inputType  +' name=showTextEditMode>'  + editShowTextTxt  + '&nbsp;&nbsp;');
	document.write('        </FORM>');
	document.write('      </td>');
	document.write('    </tr>');
	document.write('  </table>');
	document.write('</BODY>');
	document.write('</HTML>');
}

