// QTLectures.js
// Definitions for QT player lectures
// Copyright 2007 nekotech SOFTWARE

var Lectures = {
	"Ch13" : {
		"title" : "Chapter 13 Bankruptcy",
		"segments" : [ 
			"2223321C",	"303D3204",	"391A2C25",	"2219172D",	"393E2C3C",	"152B3204",	"303D2404",	"2A163233",
			"19021B3C",	"183A171B",	"3C161A3F",	"153E031B",	"182B2C18",	"18312440",	"3D2B1A40",	"39312418",
			"3C3D1B25",	"15313E33"
		],
		"endcode" : "391A2C3F34"
	},

	"Ch7" : {
		"title" : "Chapter 7 Bankruptcy",
		"segments" : [ 
			"3C193F18",	"193E1B1B",	"2A230325",	"3C2B2C04",	"3C2B3B3F",	"19023E2D",	"302B1725",	"151A243C",
			"30311718",	"19023F25",	"193D1718",	"153A1B25",	"153A0325",	"18191718"
		],
		"endcode" : "391A2C3F34"
	},

	"Estate1" : {
		"title" : "Estate Planning I",
		"segments" : [ 
			"221A1B33",	"303D1B18",	"01163B25",	"3D3E2C1B",	"3D233B1B",	"221A3F1C",	"182B173F",	"3D2B3E40",
			"39233B25",	"18193204",	"22191704",	"39191B2D",	"19192404",	"1523321C",	"39163E3C",	"152B3E40",
			"3C16173C",	"151A033C",	"301A2425"
		],
		"endcode" : "39162C2D1C"
	},

	"Estate2" : {
		"title" : "Estate Planning II",
		"segments" : [ 
			"39023F25",	"153D173F",	"183E2C3F",	"3C3E1725",	"153A243F",	"2A3E3E1B",	"19163B18",	"30313B1C",
			"013D1B40",	"3C232C3C",	"153D1B40",	"223E1B18",	"1916321C",	"013A1A33",	"19163E40",	"19191725",
			"22163E1B",	"30192418"
		],
		"endcode" : "39162C2D1C"
	},

	"Ethics1" : {
		"title" : "Legal Ethics I",
		"segments" : [ 
			"221A2C2D",	"3D023F33",	"30163E3C",	"3C161718",	"393D3B3C",	"013D1B2D",	"012B033F",	"393A3F3F",
			"15161B1B",	"3C231B1B",	"2A02322D",	"3C3D3F18",	"15023B33",	"18233F1C",	"30313F04",	"22161740",
			"2A3E3225",	"30162440"
		],
		"endcode" : "193A2C3F2E"
	},

	"Ethics2" : {
		"title" : "Legal Ethics II",
		"segments" : [ 
			"2A3D1B04",	"2A3A3B40",	"39193204",	"012B1A18",	"15163E33",	"2A19323F",	"2219243F",	"3D3A0318",
			"3C3A0340",	"2A2B2C25",	"013A1A3C",	"39193B04",	"183E171B",	"39311704",	"3D163B3C",	"3C1A3F1B",
			"193A3E1B",	"393D171C"
		],
		"endcode" : "193A2C3F2E"
	},

	"Ethics3" : {
		"title" : "Elimination of Gender Bias and Substance Abuse",
		"segments" : [ 
			"151A322D",	"3C163E33",	"22313B40",	"2219031B",	"39311A3C",	"013E031C",	"3C3A3E33",	"153E2C33",
			"30232C33",	"223E323F",	"3D312C3F",	"393E3E2D",	"2A16172D",	"30232C1C",	"30232C3C",	"182B1704",
			"183E3B1C",	"01192C1C"
		],
		"endcode" : "193A2C3F2E"
	},

	"FnPlan1" : {
		"title" : "Financial Planning I",
		"segments" : [ 
			"15021B18",	"39191B18",	"3C021733",	"39161B3F",	"3C3A033F", "2A313204",	"2A023E25",	"19312418",
			"301A3F40",	"192B3E04", "393D033F",	"30192418",	"15313F25",	"181A3B18",	"39193B1B", "393E242D",
			"393E243F",	"3D2B1725",	"39020325"
		],
		"endcode" : "193D2C2D1C"
	},

	"FnPlan2" : {
		"title" : "Financial Planning II",
		"segments" : [ 
			"183D2C25",	"39163F40",	"30023218",	"151A1A40",	"19233F04",	"3C2B173C",	"153E3F33",	"19022440",
			"30232C40",	"393E171C",	"2A163E3C",	"152B1A25",	"392B2C3C",	"012B3E18",	"3D233F40",	"2A1A171B",
			"39023E3C",	"013E2418",	"22313F1B"
		],
		"endcode" : "193D2C2D1C"
	},

	"Incorp" : {
		"title" : "Incorporating a Small Business",
		"segments" : [ 
			"1831323C",	"3D3E1740",	"3C3A2404",	"2231031C",	"1916243F",	"152B243F",	"2A1A1A3C",	"3D3E2C40",
			"18193E33",	"3916033C",	"182B1B40",	"39310304",	"303D3225",	"302B2C3F",	"2A3D3B2D",	"3D3A3225",
			"152B0304",	"15021B3C"
		],
		"endcode" : "15162C2D2E"
	},

	"LimLia" : {
		"title" : "Limited Liability Corporations",
		"segments" : [ 
			"19021A25",	"18163E2D",	"30021704",	"22231A25",	"011A242D",	"223D3E1C",	"18193E04",	"39231B3F",
			"1916323C",	"15193F2D",	"2A1A1A18",	"39163F3F",	"30163240",	"18190325",	"222B1A3C",	"22231B40",
			"3C3D031C",	"393E2425",	"183E242D"
		],
		"endcode" : "193A1B3C"
	},

	"Manage" : {
		"title" : "Law Office Management",
		"segments" : [ 
			"191A1704",	"30022C3C",	"153A243F",	"2A233B33",	"3D193B40",	"2A193B33",	"183D2418",	"3D3A1B33",
			"192B3225",	"18191A04",	"181A3E3F",	"15230325",	"303A3F3C",	"3D16323F",	"3D2B3E1B",	"19021A33",
			"152B2C3C",	"3C2B3F3F"
		],
		"endcode" : "19162C3F1C"
	},

	"NAFTA" : {
		"title" : "North American Free Trade Agreement",
		"segments" : [ 
			"2A313E18",	"223A0340",	"15023B33",	"223A1A2D",	"183E1B1B",	"223A1B33",	"011A3F04",	"391A0340",
			"01162C3C",	"221A3F1B",	"393A3240",	"22233B33",	"19021A1B",	"302B3B3F"
		],
		"endcode" : "1902171C"
	},

	"NonPro" : {
		"title" : "Nonprofit Corporations",
		"segments" : [ 
			"3C1A3204",	"223D3204",	"22163E04",	"01161A3F",	"2A1A321C", "22163B25",	"152B3F04",	"15231B04",
			"3D3A3B3C",	"2A023204", "15192433",	"3D023E1B",	"30232425",	"01231B40",	"012B3B3C",	"2A233E3C",
			"3C163F3F",	"183A3B1C"
		],
		"endcode" : "2A2B3E2D2E2F"
	},

	"Partnr" : {
		"title" : "Partnerships",
		"segments" : [ 
			"19193E1B",	"222B3B3C",	"013A3F1B",	"18230304",	"15023B1C",	"1519321B",	"30022440",	"392B3E3F",
			"3C313F3C",	"192B242D",	"013D2404",	"3D193F18",	"012B3E25",	"3C161725",	"153A2440",	"1923321B",
			"3C3D1B3C",	"013E3B1C"
		],
		"endcode" : "2A2B1A181D"
	},

	"PowerA" : {
		"title" : "Power of Attorney",
		"segments" : [ 
			"3C16171B",	"3D312C1C",	"3D3A1A33",	"19311A25",	"222B321C",	"392B032D",	"182B1725",	"391A1A33",
			"182B3E25",	"182B2425"
		],
		"endcode" : "2A2B1A2D2E2F"
	},

	"SmallC" : {
		"title" : "Small Claims Court",
		"segments" : [ 
			"221A031B",	"3C023F40",	"3C3E3240",	"3D1A0340",	"2A233F25",	"30312C33",	"3931321C",	"0116243C",
			"19161A1B",	"013E172D",	"391A243F"
		],
		"endcode" : "2A2B242D401A"
	}
};

function LectureFromCode(code) {
	return Lectures[code];
}

function SegmentIndex(lectureCode, code) {
	var lecture = Lectures[lectureCode];
	var encoded = Encode(code);
	var segmentCount = lecture.segments.length;
	
	for (var i = 0; i < segmentCount; ++i) {
		if (lecture.segments[i] == encoded)
			return i;
	}
	
	return -1;
}

function NextSegmentIndex(lectureCode, index) {
	var lecture = Lectures[lectureCode];
	if (index < (lecture.segments.length - 1))
		return index + 1;
		
	return -1;
}

function IsValidSegmentCode(lectureCode, segmentCode) {
	return SegmentIndex(lectureCode, segmentCode) != -1 ? true : false;
}

function SetCurrentLectureMenuCode(onMenuChangeHandler) {
	var lectureMenu = document.getElementById("LectureMenu");
	var lectureCode = lectureMenu.options[lectureMenu.selectedIndex].value;
	setTimeout(onMenuChangeHandler + '("' + lectureCode + '");', 0);
}

function BuildLectureMenu(onMenuChangeHandlerStr) {
	var changeCB = "SetCurrentLectureMenuCode('" + onMenuChangeHandlerStr + "');";
	var menu = '<select id="LectureMenu" onchange="' + changeCB + '">';
	var keys = Lectures.allKeys();
	
	for (var i = 0; i < keys.length; ++i) {
		var key = keys[i];
		menu += "<option value='" + key + "'>" + Lectures[key].title + "<" + "/option>";
	}
	
	setTimeout(onMenuChangeHandlerStr + '("' + keys[0] + '");', 0);
	menu += "<" + "/select>";
	
	return menu;
}

function SetPreviousSegmentMenuCode(onMenuChangeHandler) {
	var menu = document.getElementById("PreviousSegmentMenu");
	var value = menu.options[menu.selectedIndex].value;
	setTimeout(onMenuChangeHandler + '("' + value + '");', 0);
}

function BuildPreviousSegmentMenu(lectureCode, index, onMenuChangeHandlerStr) {
	var changeCB = "SetPreviousSegmentMenuCode('" + onMenuChangeHandlerStr + "');";
	var menu = '<select id="PreviousSegmentMenu" onchange="' + changeCB + '">';
	var lecture = Lectures[lectureCode];
	var selectedIndex = index - 1;

	// In the case of a self-study lecture, include all and 	
	if (index > lecture.segments.length) {
		index = lecture.segments.length;
		selectedIndex = 0;
	}
	
	for (var i = 0; i < index; ++i) {
		var code = Decode(lecture.segments[i]);
		menu += "<option value='" + code + "'";
		
		if (i == selectedIndex)
			menu += " selected ";
		
		menu += "># " + Number(i + 1) + " ";
		
		// Global from QTPlayer.html
		if (gPlayMode == "P")
			menu += "-- (Code: " + code + ")";
			
		menu += "</option>";
	}
	
	if (index)
		setTimeout(onMenuChangeHandlerStr + '("' + Decode(lecture.segments[selectedIndex]) + '");', 0);
		
	menu += "<" + "/select>";
	
	return menu;
}

function FileForLecture(lectureCode, index) {
	var charForIndex = "abcdefghijklmnopqrstuvwxyz";
	
	return lectureCode.toLowerCase() + charForIndex.substr(index, 1) + ".mov";
}


