
var allData = new Array();
//var allCourses = new Array();
var allCoursesSorted = new Array();
var i = 0;
// /flyers/SEM299.pdf,Saturday, Sep 9, 2006,,Las Vegas,NV,,,325,MBZ%20Engine%20Management

//Number 0,Date 1,Day 2 2,City 3,State 4,Canceled 5,Sold Out 6,Cost 7,Title 8
//allCourses[i++]=",,,,,,,,------------------------------------------------";
/*allCourses[i++]="SEM193,3/19/2005,,Reno,NV,Canceled,,285,Introduction to Volvo";
allCourses[i++]="SEM175,1/15/2005,,San Diego,CA,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM176,1/22/2005,,Las Vegas,NV,,Sold Out,280,Mercedes Can & Body Systems";
allCourses[i++]="SEM177,1/29/2005,,Orlando,FL,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM178,1/29/2005,,Newport News,VA,,,285,Introduction to Volvo";
allCourses[i++]="SEM179,2/12/2005,,Chicago,IL,,,280,Mercedes Can & Body Systems";
allCourses[i++]="SEM180,2/13/2005,2/20/2005,Long Beach,CA,,,400,BMW Body Systems";
allCourses[i++]="SEM182,2/19/2005,,Roseville,MN,,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM183,2/19/2005,,Seattle,WA,,Sold Out,285,Introduction to Volvo";
allCourses[i++]="SEM185,2/26/2005,,Portland,OR,,,285,Introduction to Volvo";
allCourses[i++]="SEM186,2/26/2005,,Houston,TX,,,280,Mercedes Climate Control Systems";
allCourses[i++]="SEM187,3/2/2005,3/3/2005,San Rafael,CA,,,280,PWR Computer Control Systems Analysis";
allCourses[i++]="SEM188,3/5/2005,,San Rafael,CA,,Sold Out,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM189,3/5/2005,3/6/2005,Cambridge,MA,,,400,BMW Body Systems";
allCourses[i++]="SEM191,3/12/2005,,Hebron,KY,,,280,PWR Computer Control Systems Analysis";
allCourses[i++]="SEM192,3/13/2005,,Hebron,KY,,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM195,3/19/2005,,Nashville,TN,,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM196,4/6/2005,4/7/2005,Santa Clara,CA,,Sold Out,285,Introduction to Volvo";
allCourses[i++]="SEM197,4/9/2005,,Sacramento,CA,,Sold Out,285,Introduction to Volvo";
allCourses[i++]="SEM198,4/2/2005,,Phoenix,AZ,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM199,4/2/2005,4/3/2005,San Diego,CA,,,400,BMW Body Systems - TWO DAY EVENT";
allCourses[i++]="SEM200,4/6/2005,4/7/2005,Jacksonville,FL,Canceled,,280,PWR Computer Control Systems Analysis";
allCourses[i++]="SEM201,4/9/2005,,Orlando,FL,,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM202,4/16/2005,,Chicago,IL,Canceled,,280,PWR Computer Control Systems Analysis";
allCourses[i++]="SEM203,4/17/2005,,Chicago,IL,Canceled,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM205,4/16/2005,,Minneapolis,MN,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM206,4/23/2005,4/30/2005,Memphis,TN,,,400,BMW Body Systems";
allCourses[i++]="SEM207,4/30/2005,,Norcross,GA,,,285,Introduction to Volvo";
allCourses[i++]="SEM208,5/14/2005,,Denver,CO,,Sold Out,285,Introduction to Volvo";
allCourses[i++]="SEM209,5/15/2005,,Edison,NJ,,Sold Out,285,BMW Engine Management";
allCourses[i++]="SEM210,5/14/2005,,Reston,VA,Canceled,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM211,5/15/2005,,Reston,VA,Canceled,,280,PWR Computer Control Systems Analysis";
allCourses[i++]="SEM212,5/21/2005,,Morrisville,NC,,Sold Out,285,BMW Engine Management";
allCourses[i++]="SEM213,5/14/2005,,Salt Lake City,UT,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM216,6/11/2005,,Long Beach,CA,,Sold Out,285,Introduction to Volvo";
allCourses[i++]="SEM217,6/11/2005,,Norcross,GA,,,280,MBZ Engine Management";
allCourses[i++]="SEM218,6/18/2005,,Falls Church,VA,,,280,MBZ Engine Management";
allCourses[i++]="SEM219,6/18/2005,,Cincinnati,OH,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM220,6/25/2005,,Austin,TX,,,350,BMW Engine Management";
allCourses[i++]="SEM221,6/18/2005,,Santa Clara,CA,,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM221,6/25/2005,,Santa Clara,CA,Canceled,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM222,6/20/2005,6/21/2005,Santa Clara,CA,,,280,PWR Computer Control Systems Analysis";
allCourses[i++]="SEM223,8/13/2005,,Salt Lake,UT,Canceled,,285,Introduction to Volvo";
allCourses[i++]="SEM224,8/27/2005,,Portland,OR,,Sold Out,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM225,9/10/2005,,Fresno,CA,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM226,9/10/2005,9/11/2005,Torrance,CA,,Sold Out,575,BMW E65 & E66";
allCourses[i++]="SEM227,9/10/2005,,San Diego,CA,,,285,Introduction to Volvo";
allCourses[i++]="SEM228,9/14/2005,9/15/2005,Minneapolis,MN,,,285,Introduction to Volvo";
allCourses[i++]="SEM229,9/17/2005,,Plainview,NY,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM230,9/24/2005,9/25/2005,Reston,VA,,Sold Out,450,BMW Engine Management";
allCourses[i++]="SEM231,9/17/2005,9/18/2005,Las Vegas,NV,,,450,BMW Body Systems";
allCourses[i++]="SEM232,9/17/2005,,Dallas,TX,,,280,MBZ Engine Management";
allCourses[i++]="SEM233,9/18/2005,,Houston,TX,,,280,MBZ Engine Management";
allCourses[i++]="SEM234,9/24/2005,,Newport News,VA,Canceled,,280,MBZ Can & Body systems";
allCourses[i++]="SEM235,10/1/2005,,Burlington,MA,,,285,Introduction to Volvo";
allCourses[i++]="SEM236,10/1/2005,,Bothell,WA,,Sold Out,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM237,10/1/2005,10/2/2005,Lakewood,CO,,,450,BMW Engine Management";
allCourses[i++]="SEM238,10/22/2005,,Elk Grove,IL,,Sold Out,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM239,10/22/2005,10/23/2005,Salt Lake City ,UT,Canceled,,450,BMW Engine Management";
allCourses[i++]="SEM241,11/5/2005,,Houston,TX,,,285,Introduction to Volvo";
allCourses[i++]="SEM249,11/5/2005,,Arlington,VA,,,280,MBZ Engine Management";
allCourses[i++]="SEM252,11/5/2005,,San Diego,CA,,,280,PWR Computer Control Systems Analysis";
allCourses[i++]="SEM251,11/5/2005,11/6/2005,Phoenix,AZ,,Sold Out,450,BMW Body Systems";
allCourses[i++]="SEM242,11/6/2005,,Fort Worth,TX,,,285,Introduction to Volvo";
allCourses[i++]="SEM244,11/12/2005,,Newport News,VA,,,275,Volkswagen Common Problems & Driveability";
allCourses[i++]="SEM250,11/12/2005,,Plainview,NY,Canceled,,280,MBZ Engine Management";
allCourses[i++]="SEM245,11/19/2005,,Toronto,ON,,,350,MBZ Engine Management";
allCourses[i++]="SEM246,11/19/2005,,Lakewood,CO,Canceled,,285,Introduction to Volvo";
allCourses[i++]="SEM253,11/19/2005,11/20/2005,Sacramento,CA,,,450,BMW Engine Management";
allCourses[i++]="SEM254,11/19/2005,,Cambridge,MA,Canceled,,280,PWR Driveability Diagnostic Strategies";
allCourses[i++]="SEM256,11/20/2005,,Cambridge,MA,Canceled,,280,PWR Computer Control Systems Analysis";
allCourses[i++]="SEM247,12/3/2005,,Atlanta,GA,,,280,Mercedes Can & Body Systems";
allCourses[i++]="SEM248,12/3/2005,12/4/2005,Santa Clara,CA,,Sold Out,575,BMW E65 & E66";
allCourses[i++]="SEM255,12/3/2005,,North Haven,CT,Canceled,,285,Introduction to Volvo";
allCourses[i++]="SEM255,12/3/2005,,Stamford,CT,,,285,Introduction to Volvo";
allCourses[i++]="SEM260,2/25/2006,,Paramus,NJ,,,325,MBZ Engine Management";
allCourses[i++]="SEM261,2/25/2006,,Irvine,CA,,,285,Introduction to Volvo";
allCourses[i++]="SEM262,3/11/2006,,Pleasanton,CA,,,285,Introduction to Volvo";
allCourses[i++]="SEM263,3/4/2006,,Raleigh,NC,Canceled ,,285,VW Common Problems";
allCourses[i++]="SEM264,3/4/2006,3/5/2006,Orlando,FL,,Sold Out,500,BMW Engine Management II";
allCourses[i++]="SEM265,3/11/2006,,Rockville,MD,,,275,Honda";
allCourses[i++]="SEM266,3/4/2006,,Austin,TX,,,325,MBZ Engine Management";
allCourses[i++]="SEM267,3/11/2006,3/12/2006,FT Lauderdale,FL,,Sold Out,500,BMW Body Systems I";
allCourses[i++]="SEM268,3/18/2006,,Dallas,TX,,,275,Honda";
allCourses[i++]="SEM269,3/25/2006,,Lakewood,CO,,,275,Toyota Driveability";
allCourses[i++]="SEM270,3/25/2006,3/26/2006,Portland,OR,,,500,BMW Engine Management II";
allCourses[i++]="SEM271,3/25/2006,,Burbank,CA,,Sold Out,325,MBZ Engine Management";
allCourses[i++]="SEM275,4/22/2006,4/23/2006,Irvine,TX,,,500,BMW Engine Management II";
allCourses[i++]="SEM276,4/22/2006,,Santa Clara,CA,,,325,MBZ Engine Management";
allCourses[i++]="SEM277,4/29/2006,,Richmond,BC,,,375,MBZ Engine Management";
allCourses[i++]="SEM279,4/29/2006,4/30/2006,Lexington,MA,,,500,BMW Engine Management II";
allCourses[i++]="SEM280,4/30/2006,,Long Beach,CA,,,275,Toyota Driveability";
allCourses[i++]="SEM281,4/30/2006,,Edmonton,CN,,,375,MBZ Engine Management";
allCourses[i++]="SEM282,5/6/2006,,Nashville,TN,,,325,MBZ Engine Management";
allCourses[i++]="SEM283,5/6/2006,5/7/2006,San Rafael,CA,,Sold Out,600,BMW E65 & E66 7 series";
allCourses[i++]="SEM284,5/13/2006,,Orlando,FL,,Sold Out,325,MBZ Engine Management";
allCourses[i++]="SEM285,5/21/2006,,Chicago,IL,Canceled ,,325,MBZ Engine Management";
allCourses[i++]="SEM286,5/20/2006,,Phoenix,AZ,,,275,Toyota Driveability";
allCourses[i++]="SEM287,5/20/2006,,Edison,NJ,,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM272,5/20/2006,5/21/2006,Bothell,WA,,,500,BMW Engine Management II";
allCourses[i++]="SEM288,5/27/2006,5/28/2006,Toronto,CN,,,600,BMW Engine Management II";
allCourses[i++]="SEM289,6/3/2006,6/4/2006,Houston,TX,,,600,BMW E65 & E66 7 series";
allCourses[i++]="SEM290,6/4/2006,,Culver City,CA,,,285,Volkswagen  Common Problems";
allCourses[i++]="SEM291,6/10/2006,,Portland,OR,,,325,MBZ Engine Management";
allCourses[i++]="SEM292,6/10/2006,,Sacramento,CA,,Sold Out,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM293,6/10/2006,6/11/2006,Marietta,GA,,Sold Out,500,BMW Engine Management II";
allCourses[i++]="SEM294,6/17/2006,,Cambridge,MA,Canceled,,325,MBZ Engine Management";
allCourses[i++]="SEM278,6/17/2006,,Newport News,VA,,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM296,6/24/2006,,Miami,FL,,,325,MBZ Engine Management";
allCourses[i++]="SEM297,6/24/2006,6/25/2006,Toledo,OH,Canceled,,500,BMW Engine Management II";
allCourses[i++]="SEM298,6/24/2006,,Golden,CO,,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM299,9/9/2006,,Las Vegas,NV,,,325,MBZ Engine Management";
allCourses[i++]="SEM300,9/9/2006,,Austin,TX,,,275,Toyota Driveability";
allCourses[i++]="SEM301,9/9/2006,,Orlando,FL,,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM302,9/9/2006,,Kirkland,WA,,,600,BMW E65 & E66 7 series";
allCourses[i++]="SEM303,9/16/2006,,Bethesda,MD,,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM304,9/16/2006,,Long Beach,CA,Canceled,,295,Advanced Toyota Hybrid Service Driveability & Common Issues";
allCourses[i++]="SEM305,9/16/2006,,Lakewood ,CO,,,325,MBZ Engine Management";
allCourses[i++]="SEM306,9/16/2006,9/17/2006,Melville,NY,,,500,BMW Engine Management II";
allCourses[i++]="SEM307,9/16/2006,9/17/2006,Pleasanton,CA,,,500,BMW Body Systems II";
allCourses[i++]="SEM308,9/23/2006,,Fresno,CA,,,275,Toyota Driveability";
allCourses[i++]="SEM309,9/23/2006,,Durham,NC,,,325,MBZ Engine Management";
allCourses[i++]="SEM310,9/23/2006,,Vancouver,CN,,,325,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM311,9/23/2006,9/24/2006,San Diego,CA,,,600,BMW E65 & E66 7 series";
allCourses[i++]="SEM312,9/24/2006,,Edmonton,CN,,,325,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM313,9/30/2006,,Minneapolis,MN,,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM314,9/30/2006,10/1/2006,Phoenix,AZ,,,500,BMW Engine Management II";
allCourses[i++]="SEM315,10/7/2006,,Cambridge,MA,,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM316,10/14/2006,,Norcross,GA,,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM317,10/14/2006,10/15/2006,Portland,OR,,,500,BMW Body Systems II";
allCourses[i++]="SEM318,10/21/2006,,San Rafael,CA,,,275,Toyota Driveability";
allCourses[i++]="SEM319,10/21/2006,,Cincinnati,OH,,,325,MBZ Engine Management";
allCourses[i++]="SEM320,10/21/2006,10/22/2006,Rockville,MD,,,600,BMW E65 & E66 7 series";
allCourses[i++]="SEM321,10/28/2006,,Edison,NJ,Canceled,,295,Advanced Toyota Hybrid Service Driveability & Common Issues";
allCourses[i++]="SEM322,10/28/2006,10/29/2006,Chicago,IL,,,600,BMW E65 & E66 7 series";
allCourses[i++]="SEM323,11/4/2006,,Vancouver,CN,,,300,Toyota Driveability";
allCourses[i++]="SEM324,11/4/2006,,Toronto,CN,,,325,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM326,11/4/2006,11/5/2006,Golden,CO,,,500,BMW Body Systems II";
allCourses[i++]="SEM327,11/5/2006,,Edmonton,CN,,,300,Toyota Driveability";
allCourses[i++]="SEM329,11/18/2006,,San Diego,CA,,,325,MBZ Engine Management";
allCourses[i++]="SEM330,11/18/2006,,Houston,TX,Canceled,,285,Advanced Volvo Network & Software Diagnosis";
allCourses[i++]="SEM331,11/18/2006,,Bothell,WA,Canceled,,295,Advanced Toyota Hybrid Service Driveability & Common Issues";
allCourses[i++]="SEM332,11/18/2006,11/19/2006,Raleigh,NC,,,500,BMW Body Systems II";
allCourses[i++]="SEM333,12/2/2006,,Sacramento,CA,,,325,MBZ Transmission";
allCourses[i++]="SEM334,12/2/2006,,Portland,OR,,,275,Toyota Driveability";
allCourses[i++]="SEM335,12/2/2006,12/3/2006,Las Vegas,NV,,,500,BMW Engine Management II";
*/
for (var i=0; i<allCourses.length; i++)
{//alert (allCourses[i]);
	allData[i] = allCourses[i];}


/*for (var z in allData) {
document.write (allData[z] + "<br />");}
*/

for (var i=0; i<allCourses.length - 1; i++)
{
  for (var j=i+1; j<allCourses.length; j++)
  {
   var itema = allCourses[i].split(',');
   var itemb = allCourses[j].split(',');
	if (itema[8] == itemb[8])
	  {allCourses[j] = '';}
  }
}


			
k = 0;
for (var i in allCourses) {

	if (allCourses[i] != ''){
	allCoursesSorted[k] = allCourses[i];
	k++}
}



function sortByCourseTitle(a, b) {
    var x = a.split(',');
    var y = b.split(',');
	  if (x[8]<y[8]) return -1;
	  if (x[8]>y[8]) return 1;
//    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

allCoursesSorted.sort(sortByCourseTitle);
cData="";
function writeallCoursesSelector(){
//	document.writeln ('<SELECT NAME="allCoursess" ONCHANGE="location.href=this.options[this.selectedIndex].value;this.options[0].selected = true">');
	document.writeln ('<SELECT NAME="allCourses" class="normal" ONCHANGE="addOption(document.form1.courseDates,this.options[this.selectedIndex].text)" style="width:260px">');
//	document.writeln ('<SELECT NAME="allCourses" class="small" ONCHANGE="alert(this.options[this.selectedIndex].text)" style="width:200px">');
	document.write ('<OPTION VALUE="" SELECTED>Choose a course -></OPTION>');
	for (var j in allCoursesSorted) {
		var item = allCoursesSorted[j].split(',');
		var courseID = item[0];
		var courseTitle = item[8];
		document.writeln ('<OPTION VALUE="' + courseID + '">' + courseTitle + '</OPTION>');
	}
	document.writeln ('</SELECT NAME>');
}

function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
	}

function removeAllOptions(from) { 
	if (!hasOptions(from)) { return; }
	for (var i=(from.options.length-1); i>=0; i--) { 
		from.options[i] = null; 
		} 
	from.selectedIndex = -1; 
	} 

coursedata = new Array();

function addOption(obj,value) {
	cTitle = value;
//	alert("add this option" + cTitle);
	removeAllOptions(obj);
	obj.options[obj.options.length] = new Option("Choose a location:", "", false);
	var z = 0;
	for (var i=0; i<allData.length; i++){
		
		var item = allData[i].split(',');
		var courseID = item[0];
		var courseTitle = item[8];
		var courseDate = item[1];
		var courseCity = item[3];
		var courseState = item[4];
//		alert("alldata array = " + courseTitle);
		if (courseTitle.match(cTitle))
	  		{
			var text = courseCity + ',' + courseState + ' - ' + courseDate;
			obj.options[obj.options.length] = new Option(text, courseID, false);
			coursedata[z] = (allData[i]); 
			z++;
			}
	}

//alert(coursedata.length);
//for (var z in document.links) {document.write (document.links[z] + "<br />");}

}


function pData(value) {
var	detailsLink = "";
var	cDate = value;
//alert ("data passed = " + cDate);
//alert ("courses = " + coursedata);
var finaltext = "";
//var soldOut = 0;
for (var i=0; i<coursedata.length; i++){
		var item = coursedata[i].split(',');

		var color = item[11];
		var cancelled = item[10];
		var semnum = item[9];
		var courseID = item[0];
		var courseTitle = item[8];
		var courseDate = item[1];
		courseDate = courseDate.replace(/&/g, "and");
		//alert("ccccourseDate = " + courseDate);
		var courseCity = item[3];
		var courseState = item[4];
		var courseCost = item[7];
		var soldOut = item[6];
		var text = courseCity + ',' + courseState + ' - ' + courseDate;
		var displayLoc = courseCity + ", " + courseState;
		//courseTitle = escape(courseTitle);
//		alert(soldOut)
		
		if (courseID == cDate)
	  		{//alert(courseTitle);
			finaltext = courseCity + ',' + courseState + ' - ' + courseDate;
			if(soldOut){courseDate = "- THIS COURSE HAS SOLD OUT -"; displayLoc = "- THIS COURSE HAS SOLD OUT -";}
			replaceText("tTitle", courseTitle)
			replaceText("tDate", courseDate)
//			replaceText("tLocation", courseCity + ", " + courseState)
			replaceText("tLocation", displayLoc)
			courseCostNum = courseCost;
			if(soldOut){courseCost = "- THIS COURSE HAS SOLD OUT -"; 
			            document.getElementById('trImage').src = "";
						document.getElementById('trImage').alt = "";
						document.getElementById('trImage').width = "1";
						document.getElementById('trImage').height = "1";}
						else if (color == 'gray')
						{courseCost = "- THIS COURSE IS OVER -";
			            document.getElementById('trImage').src = "";
						document.getElementById('trImage').alt = "";
						document.getElementById('trImage').width = "1";
						document.getElementById('trImage').height = "1";}

						else if (cancelled)
						{courseCost = "- THIS COURSE HAS BEEN CANCELED -";
			            document.getElementById('trImage').src = "";
						document.getElementById('trImage').alt = "";
						document.getElementById('trImage').width = "1";
						document.getElementById('trImage').height = "1";}

						else
						{courseCost = "$" + courseCost + " (per person)";
						document.getElementById('trImage').src = "images/wti_register_button_lg.gif";
						document.getElementById('trImage').alt = "Register for Training Course";
						document.getElementById('trImage').width = "88";
						document.getElementById('trImage').height = "14";};

			replaceText("tCost", courseCost)
//			alert("pic href before = " + document.getElementById('detailImage').href);
			document.getElementById('detailButton').href = courseID;
			document.getElementById('detailImage').href = courseID;
			var rtxt = "key=cftt&date=" +  escape(courseDate) + "&city=" + courseCity + ", " + courseState + "&nmbr=" + courseID + "&cost=" + courseCostNum + "&semn=" + escape(courseTitle) + "&semnum=" + semnum;
//			var rtxt = "key=cftt&date=" +  escape(courseDate);
//			rtxt2 = "key=cftt&date=Saturday%2C%20Sep%20%209%2C%202006&city=Las%20Vegas%2C%20NV&nmbr=SEM299&cost=325&semn=MBZ%20Engine%20Management";
			//alert (document.getElementById('buttonRegister').onclick);
			document.getElementById('buttonRegister').onclick = function() {alert(rtxt);mypopupx(rtxt,660);}
			
		    if(soldOut){};
			
//			document.getElementById('buttonRegister').onclick = test;  //'function() { alert("moot!"); };

			if (courseTitle.match("MBZ")){document.getElementById('tImage').src = "images/training_mcb_inset.gif";}
			if (courseTitle.match("BMW")){document.getElementById('tImage').src = "images/training_bmw_inset.gif";}
			if (courseTitle.match("Volvo")){document.getElementById('tImage').src = "images/training_volvo_inset.gif";}
			if (courseTitle.match("Toyota")){document.getElementById('tImage').src = "images/training_toyota_inset.gif";}
			if (courseTitle.match("Honda")){document.getElementById('tImage').src = "images/training_honda_inset.gif";}
			
//			alert("button href = " + document.getElementById('detailButton').href);
//			alert("pic href after = " + document.getElementById('detailImage').href);
			hidepre('bArea');
			showhidepre('aArea');
			//ToggleDiv(aArea)
			break;
			}	
}

/*	if (obj!=null && obj.options!=null) {
		obj.options[obj.options.length] = new Option(text, courseID, false, selected);
		}
*/
//alert("finaltext = " + finaltext);
//alert("courseTitle = " + courseTitle);
}

function rolloverFunc(rolloverButID){
	//alert("in func");
if (rolloverButID != "roll_bmw") {document.getElementById('roll_bmw').src = 'images/roll_bmw_off.gif';}else{document.getElementById('main').src = 'images/roll_bmw_text.gif';}
if (rolloverButID != "roll_vw") {document.getElementById('roll_vw').src = 'images/roll_vw_off.gif';}else{document.getElementById('main').src = 'images/roll_vw_text.gif';}
if (rolloverButID != "roll_honda") {document.getElementById('roll_honda').src = 'images/roll_honda_off.gif';}else{document.getElementById('main').src = 'images/roll_honda_text.gif';}
if (rolloverButID != "roll_nissan") {document.getElementById('roll_nissan').src = 'images/roll_nissan_off.gif';}else{document.getElementById('main').src = 'images/roll_nissan_text.gif';}
if (rolloverButID != "roll_toyota") {document.getElementById('roll_toyota').src = 'images/roll_toyota_off.gif';}else{document.getElementById('main').src = 'images/roll_toyota_text.gif';}
if (rolloverButID != "roll_mbz") {document.getElementById('roll_mbz').src = 'images/roll_mbz_off.gif';}else{document.getElementById('main').src = 'images/roll_mbz_text.gif';}
if (rolloverButID != "roll_volvo") {document.getElementById('roll_volvo').src = 'images/roll_volvo_off.gif';}else{document.getElementById('main').src = 'images/roll_volvo_text.gif';}
	
}

function ToggleDiv(div_in) {
var mydiv;
mydiv = document.getElementById(div_in);
if (mydiv.style.visibility == "hidden")
mydiv.style.visibility = "visible";
else
mydiv.style.visibility = "hidden";
}

function showhidepre (subcode) {
	
    if (document.getElementById(subcode).style.display == 'none') {
        document.getElementById(subcode).style.display='block';
    }
	//else 
	//{
//        document.getElementById(subcode).style.display='none';
//    }
}

function hidepre (subcode) {
	
    if (document.getElementById(subcode).style.display == 'block') {
        document.getElementById(subcode).style.display='none';
    }
	//else 
	//{
//        document.getElementById(subcode).style.display='none';
//    }
}

function writeDateSelector(){
	document.writeln ('<SELECT name="courseDates" id="courseDates" class="normal" ONCHANGE="pData(this.options[this.selectedIndex].value)" style="width:240px">');
//	document.write ('<OPTION VALUE="" SELECTED></OPTION>');
	document.writeln ('</SELECT>');
}



function replaceText(buttonId, text)
{//alert (text);
  if (document.getElementById)
  {
    var button=document.getElementById(buttonId);
    if (button)
    {
      if (button.childNodes[0])
      {
        button.childNodes[0].nodeValue=text;
      }
      else if (button.value)
      {
        button.value=text;
      }
      else //if (button.innerHTML)
      {
        button.innerHTML=text;
      }
    }
  }
}





function dmyOrdA(a, b){
a = a.replace(dateRE,"$3$2$1");
b = b.replace(dateRE,"$3$2$1");
if (a>b) return 1;
if (a <b) return -1;
return 0; }

function dmyOrdDx(a, b){
a = a.replace(dateRE,"$3$2$1");
b = b.replace(dateRE,"$3$2$1");
if (a>b) return -1;
if (a <b) return 1;
return 0; }

function mdyOrdA(a, b){
a = a.replace(dateRE,"$3$1$2");
b = b.replace(dateRE,"$3$1$2");
if (a>b) return 1;
if (a <b) return -1;
return 0; }

function mdyOrdDx(a, b){
a = a.replace(dateRE,"$3$1$2");
b = b.replace(dateRE,"$3$1$2");
if (a>b) return -1;
if (a <b) return 1;
return 0; }




var dat = new Array();

var t = 0;
dat[t++]="SEM193,3/31/2008,,Reno,NV,Canceled,,285,Introduction to Volvo";
dat[t++]="SEM193,3/22/2002,,Reno,NV,Canceled,,285,Introduction to Volvo";
dat[t++]="SEM193,3/12/2005,,Reno,NV,Canceled,,285,Introduction to Volvo";
dat[t++]="SEM175,5/2/2006 ,,San Diego,CA,,,275,Volkswagen Common Problems & Driveability";
dat[t++]="SEM176,8/1/2006 ,,Las Vegas,NV,,Sold Out,280,Mercedes Can & Body Systems";
dat[t++]="SEM177,7/19/2004,,Orlando,FL,,,275,Volkswagen Common Problems & Driveability";
dat[t++]="SEM178,06/9/2005,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,06/05/2007,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,6/13/2007,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,06/03/2007,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,06/14/2007,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,6/01/2007,,Newport News,VA,,,285,Introduction to Volvo";

var dateRE = /^(\d{1,2})[\/\- ](\d{1,2})[\/\- ](\d{4})/;

function dmyOrdD(a, b){

	var x = a.split(',');
	var y = b.split(',');
	
//	var o = x[1].replace(dateRE,"$3"+ pad(RegExp.$2,2) +"$1");
//	var p = y[1].replace(dateRE,"$3"+ pad(RegExp.$2,2) +"$1");
	var o = x[1].replace(dateRE,"$3$2$1");
	var p = y[1].replace(dateRE,"$3$2$1");
      if (o>p) return -1;
	  if (o <p) return 1;
	return 0; 
}

function mdyOrdD(a, b){

	var x = a.split(',');
	var y = b.split(',');
	
//	var o = x[1].replace(dateRE,"$3"+ pad(RegExp.$2,2) +"$1");
//	var p = y[1].replace(dateRE,"$3"+ pad(RegExp.$2,2) +"$1");
//alert (x[1]);
var o = x[1].replace(dateRE,"$3$1$2");
//	alert(o);
	var p = y[1].replace(dateRE,"$3$1$2");
//	alert(p);
      if (o>p) return -1;
	  if (o <p) return 1;
	return 0; 
}


dat.sort( mdyOrdD );
for (var z in dat) {
//	alert (dat[z]);
	d = dat[z].split(',');
//document.write (d[1] + "<br />");
}


function pad(number,length) {
    var str = '' + number;
    while (str.length < length)
       { str = '0' + str;}
//	   alert("padded str = " + str);
    return str;
}




/*var ar = dateRE.exec("03/02/2008");
document.write(ar.index, "<BR>",
               ar.input, "<BR>",
               ar[0],    "<BR>",
               ar[1],    "<BR>",
               ar[2],     "<br>");*/










String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}

Number.prototype.toDecimals=function(n){
    n=(isNaN(n))?
        2:
        n;
    var
        nT=Math.pow(10,n);
    function pad(s){
            s=s||'.';
            return (s.length>n)?
                s:
                pad(s+'0');
    }
    return (isNaN(this))?
        this:
        (new String(
            Math.round(this*nT)/nT
        )).replace(/(\.\d*)?$/,pad);
}

nYourNumber=3,
    sYourFormattedNumber=nYourNumber.toDecimals(2); // => '300.30'
//	alert(sYourFormattedNumber);

/*  TRIM WHITESPACE


var
    sOriginal='  text  ',
    sTrim=sOriginal.trim(),
    sLTrim=sOriginal.ltrim(),
    sRTrim=sOriginal.rtrim();

/* After execution:
    sOriginal is '  text  '
    sTrim is 'text'
    sLTrim is 'text  '
    sRTrim is '  text'
*/



/*
dateArray = new Array('15/10/2000','8/05/1999','17/09/2005','06/12/2004','2/01/1998');
dateArray.sort( dmyOrdDx );
document.write('Ascending : ' + dateArray + '<br />');

*/



//allCourses=allCourses.noduplicates();

/*Array.prototype.noduplicates=function(){
 if (this.length<2){ return this; }
 this.temp=[this[8]];
 for (this.i1=0;this.i1<this.length;this.i1++){
  this.ck=true;
  for (this.i2=0;this.i2<this.temp.length;this.i2++){ if (this.temp[this.i2]==this[this.i1]){ this.ck=false; } }
  if (this.ck){ this.temp.push(this[this.i1]); }
 }
 return this.temp;
} 
*/



/*myArray.sort();

function customCompare(){
for (var i=0; i<myArray.length - 1; i++)
	{
	  if (myArray[i] == myArray[i+1])
		myArray[i+1] = '';
	}
}
//Note that the above solution does not account for objects stored in 
//the array which may be technically different (== computes to false) 
//but trivially the same. For example:

var myArray = [
   { name:'Gavin', age:31 },
   { name:'Lisa',  age:30 },
   { name:'Gavin', age:23 },
   { name:'Gavin', age:31 }
];

//In the above, technically
//   myArray[0] != myArray[3]
//even though you know it is. For something like this you can write your 
//own comparison function:

Array.prototype.removeDuplicates = function( customCompare ){
   if ( customCompare ){
      this.sort(customCompare);
      for (var i=0; i<(this.length-1); i++)
      {
         if ( !customCompare(this[i],this[i+1]) ){
            this.splice( (i--)+1, 1 );
         }
      }
   }else{
      this.sort();
      for (var i=0; i<(this.length-1); i++)
      {
         if (this[i]==this[i+1]){
            this.splice( (i--)+1, 1 );
         }
      }
   }
   return this;
}


//You would call the above passing in the same sort of custom comparison 
//function as the myArray.sort() method takes:

myArray.removeDuplicates( function(a,b){
   return a.name<b.name ? -1 : a.name>b.name ? 1 :
      a.age<b.age ? -1 : a.age > b.age ? 1 : 0;
   } );

*/

