var glossaryWindow = null;
var GraphCalcWindow = null
var AlgebraTilesWindow = null
var ScCalcWindow = null
var IntgChipsWindow = null
var SeqStatCalcWindow = null
var FuncBarsWindow = null
var JournalWindow = null
var DecFracSqWindow = null
var ChapCMWindow = null;
var IndexWindow = null;
var HelpWindow = null;
var plannerWindow = null;
var calculatorWindow = null;
var JournalAssessWindow = null;
var JournalOAWindow = null;
var NotepadWindow = null;


function openGlossaryTerm(sz_term)
{
	var URL = "manipulatives/Glossary/Glossary.html?sz_term="+sz_term;

	var theHeight = InternetExplorer ? (screen.availHeight)*0.8 : (((screen.height)-taskBarHeight))*0.8;
	var theWidth = InternetExplorer ? (screen.availWidth)*0.8 : (screen.width)*0.8;
	var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
	glossaryWindow=window.open(URL, "glossaryWin", windowProperties);
	glossaryWindow.focus();
	
}


function openPDF( theURL ) {

	//alert( "theURL " + theURL )

	var theHeight = InternetExplorer ? screen.availHeight : (screen.height)-taskBarHeight;
	var theWidth = InternetExplorer ? screen.availWidth : screen.width;
	var windowProperties = "top=0,left=0,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;

	pdfWin=window.open(theURL, "pdfWin", windowProperties);
	if (MacPlatform && InternetExplorer)
		pdfWin.resizeTo(theWidth, theHeight);
	pdfWin.focus();

}


function launchGraphCalc( ) {
	var URL = "manipulatives/GraphCalc/graphCalc.html";

	if (GraphCalcWindow == null || GraphCalcWindow.closed)
	{
		var theHeight = InternetExplorer ? (screen.availHeight)*0.8 : (((screen.height)-taskBarHeight))*0.8;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.8 : (screen.width)*0.8;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		GraphCalcWindow=window.open(URL, "GraphCalcWin", windowProperties);
		GraphCalcWindow.focus();
	}
	else
		GraphCalcWindow.focus();

}

function launchAlgebraTiles( ) {
	var URL = "manipulatives/Algebra_Tiles/Algebra_Tiles.html";

	if (AlgebraTilesWindow == null || AlgebraTilesWindow.closed)
	{
		var theHeight = InternetExplorer ? (screen.availHeight)*0.7 : (((screen.height)-taskBarHeight))*0.7;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.75 : (screen.width)*0.75;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		AlgebraTilesWindow=window.open(URL, "AlgebraTilesWin", windowProperties);
		AlgebraTilesWindow.focus();
	}
	else
		AlgebraTilesWindow.focus();

}

function launchScCalc( ) {
	var URL = "manipulatives/Sci_Calculator/Sci_Calculator.html";

	if (ScCalcWindow == null || ScCalcWindow.closed)
	{
		var theHeight = InternetExplorer ? (screen.availHeight)*0.52 : (((screen.height)-taskBarHeight))*0.52;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.43 : (screen.width)*0.43;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		ScCalcWindow=window.open(URL, "ScCalcWin", windowProperties);
		ScCalcWindow.focus();
	}
	else
		ScCalcWindow.focus();

}

function launchIntgChips( ) {
	var URL = "manipulatives/Integer_Chips/Integer_Chips.html";

	if (IntgChipsWindow == null || IntgChipsWindow.closed)
	{
		var theHeight = InternetExplorer ? (screen.availHeight)*0.40 : (((screen.height)-taskBarHeight))*0.40;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.55 : (screen.width)*0.55;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		IntgChipsWindow=window.open(URL, "IntgChipsWin", windowProperties);
		IntgChipsWindow.focus();
	}
	else
		IntgChipsWindow.focus();

}

function launchSeqStatCalc( ) {
	var URL = "manipulatives/Stat_Calculator/Stat_Calculator.html";

	if (SeqStatCalcWindow == null || SeqStatCalcWindow.closed)
	{

		var theHeight = InternetExplorer ? (screen.availHeight)*0.7 : (((screen.height)-taskBarHeight))*0.7;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.7 : (screen.width)*0.7;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		SeqStatCalcWindow=window.open(URL, "SeqStatCalcWin", windowProperties);
		SeqStatCalcWindow.focus();
	}
	else
		SeqStatCalcWindow.focus();

}

function launchFuncBars( ) {
	var URL = "manipulatives/Func_Bars/Func_Bars.html";

	if (FuncBarsWindow == null || FuncBarsWindow.closed)
	{

		var theHeight = InternetExplorer ? (screen.availHeight)*0.6 : (((screen.height)-taskBarHeight))*0.6;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.7 : (screen.width)*0.7;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		FuncBarsWindow=window.open(URL, "FuncBarsWin", windowProperties);
		FuncBarsWindow.focus();
	}
	else
		FuncBarsWindow.focus();

}

//**********************************************************************
// Journal Functions
//
function launchNotepad() { //mode1 - called by desktop & tools drop down
	var URL = "manipulatives/Journal/Notepad.html";

	if (NotepadWindow == null || NotepadWindow.closed)
	{

		var theHeight = InternetExplorer ? (screen.availHeight)*0.7 : (((screen.height)-taskBarHeight))*0.7;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.55 : (screen.width)*0.55;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		NotepadWindow=window.open(URL, "NotepadWin", windowProperties);
		NotepadWindow.focus();
	}
	else
		NotepadWindow.focus();

}

function launchJournal() { //mode2 - called by journal buttons (open access)
	var URL = "manipulatives/Journal/JournalOA.html";

	if (JournalOAWindow == null || JournalOAWindow.closed)
	{

		var theHeight = InternetExplorer ? (screen.availHeight)*0.7 : (((screen.height)-taskBarHeight))*0.7;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.55 : (screen.width)*0.55;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		JournalOAWindow=window.open(URL, "JournalOAWin", windowProperties);
		JournalOAWindow.focus();
	}
	else
		JournalOAWindow.focus();

}

function launchJournalAssess(in_mode,in_sectionName,in_label) { //mode3 - called by journal buttons in assessment
	
	var URL = "manipulatives/Journal/JournalAssess.html?mode="+in_mode+"&sectionName="+in_sectionName+"&label="+in_label;
	
	if (JournalAssessWindow == null || JournalAssessWindow.closed)
	{

		var theHeight = InternetExplorer ? (screen.availHeight)*0.7 : (((screen.height)-taskBarHeight))*0.7;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.55 : (screen.width)*0.55;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		JournalAssessWindow=window.open(URL, "JournalAssessWin", windowProperties);
		JournalAssessWindow.focus();
	}
	else
		JournalAssessWindow.focus();
}

//***********************************************************

function launchDecFracSq( ) {
	var URL = "manipulatives/Decimal_Fractions/Decimal_Fractions.html";

	if (DecFracSqWindow == null || DecFracSqWindow.closed)
	{

		var theHeight = InternetExplorer ? (screen.availHeight)*0.75 : (((screen.height)-taskBarHeight))*0.75;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.75 : (screen.width)*0.75;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		DecFracSqWindow=window.open(URL, "DecFracSqWin", windowProperties);
		DecFracSqWindow.focus();
	}
	else
		DecFracSqWindow.focus();

}

function launchIndex( ) {
	if( course.length > 1 ) {
		myCourse = course.substring( 1 );
	} else {
		myCourse = course
	}
	var URL = "Index.html?course=" + myCourse;



	if (IndexWindow == null || IndexWindow.closed)
	{
		var theHeight = InternetExplorer ? (screen.availHeight)*0.8 : (((screen.height)-taskBarHeight))*0.8;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.8 : (screen.width)*0.8;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		IndexWindow=window.open(URL, "IndexWindow", windowProperties);
		IndexWindow.focus();
	}
	else
		IndexWindow.focus();

}

function launchHelp( ) {
	var URL = "manipulatives/Help/Help.html";

	if (IndexWindow == null || IndexWindow.closed)
	{

		var theHeight = InternetExplorer ? (screen.availHeight)*0.8 : (((screen.height)-taskBarHeight))*0.8;
		var theWidth = InternetExplorer ? (screen.availWidth)*0.8 : (screen.width)*0.8;

		var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=no,height="+theHeight+",width="+theWidth;
		HelpWindow=window.open(URL, "HelpWindow", windowProperties);
		HelpWindow.focus();
	}
	else
		HelpWindow.focus();

}

function goDesk( ) {
	if( course.length == 2 ) {
		if( actCourse == 4 ) {
			course = 4
		} else {
			course = course.substr( 1 );
		}
	}
	self.location.href = "desktop.html?edition="+edition+"&course="+course+"&state="+state+"&calc="+calc;
}

function launchSGRexample( path ) {	
	
	var URL = "assess/SGRexample.html?path=../"+path;
	
	var theHeight = InternetExplorer ? (screen.availHeight)*0.6 : (((screen.height)-taskBarHeight))*0.6;
	var theWidth = InternetExplorer ? (screen.availWidth)*0.56 : (screen.width)*0.56;	
	
	var windowProperties = "top=0,left=0,toolbar=no,status=no,resizable=no,scrollbars=yes,height="+theHeight+",width="+theWidth;
	ExampleWindow = window.open(URL, "ExampleWindow", windowProperties);
	ExampleWindow.focus();
}

