
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}
		
function detectbrowser(){		

	if( OS == 'Mac' && browser == 'Internet Explorer'){			
		document.getElementById("browserwarning").innerHTML= '<br>Note: This page is optimized to work in Safari and may not display properly if viewed in Mac IE.<br><br><br><br>';
	}
		
}

	
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


// old 'showLesson' where the lesson is opened from copies in the same directory.. if something happens with the
// new pilot setup, you can always revert to the old way by un-commenting this function.. 
// then comment out all the other showLesson(..) in here,
// then make the index pages just call a showLesson (instead of the specific showTeacherLesson_berkeley for example).
/*
function showLesson(lesson_id)
{
		
	pagewidth = screen.availWidth;
	pageheight= screen.availHeight;
	leftpos = 0; //half the screen width minus half the new window width.
	toppos = 0;
	
	lessonwin = window.open(lesson_id + '/html/index.html','lessonpage','width=' + pagewidth + ',height=' + pageheight + ',resizable=yes,left=' + leftpos + ',top=' + toppos + ',screenX=' + leftpos + ',screenY=' + toppos + ',scrolling=yes, scrollbars=yes');	
	lessonwin.focus();	
	
}
*/

// Open lesson in a full window, Basic Function:
function showLesson(lesson_id, usertype, pilot_code)
{		
	
	if(!usertype){
		usertype = 'student';
	}
	if(!pilot_code){
		pilot_code = 'demo';
	}
	
	
	pagewidth = screen.availWidth;
	pageheight= screen.availHeight;
	leftpos = 0; //half the screen width minus half the new window width.
	toppos = 0;
	
	lessonwin = window.open('http://www.letsdomath.com/cgi-bin/ism_pilot/access.cgi?pilot_code=' + pilot_code + '&lesson_code=' + lesson_id + '&redirect=http://www.mathresources.com/pilot_' + usertype + '/' + lesson_id + '/html/index.html','lessonpage','width=' + pagewidth + ',height=' + pageheight + ',resizable=yes,left=' + leftpos + ',top=' + toppos + ',screenX=' + leftpos + ',screenY=' + toppos + ',scrolling=yes, scrollbars=yes');	
	lessonwin.focus();		
}

//--------------------------------------------------------------------
// Wrapper Functions - used by Pilot entry pages:
// Current Pilot codes:
//  	demo -- for samples web page
//		berkeley_teacher, berkeley_student
//		naperville_teacher, naperville_student
//		quitman_teacher, quitman_student
//		thecenter_teacher, thecenter_student
//		westside_teacher, westside_student
//--------------------------------------------------------------------

// For Sample ISM Lessons - from ISM Product/Samples page: -----
function showGuestLesson(lesson_id)
{		
	showLesson(lesson_id,'guest','demo'); // lesson_id, usertype, pilot_code	
}

//Berkely: -----------------------------------------------------
function showTeacherLesson_berkeley(lesson_id)
{		
	showLesson(lesson_id,'teacher','berkeley_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_berkeley(lesson_id)
{		
	showLesson(lesson_id,'student','berkeley_student');	 // lesson_id, usertype, pilot_code
}

//Naperville: -----------------------------------------------------
function showTeacherLesson_naperville(lesson_id)
{		
	showLesson(lesson_id,'teacher','naperville_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_naperville(lesson_id)
{		
	showLesson(lesson_id,'student','naperville_student');	 // lesson_id, usertype, pilot_code
}

//quitman: -----------------------------------------------------
function showTeacherLesson_quitman(lesson_id)
{		
	showLesson(lesson_id,'teacher','quitman_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_quitman(lesson_id)
{		
	showLesson(lesson_id,'student','quitman_student');	 // lesson_id, usertype, pilot_code
}

//thecenter: -----------------------------------------------------
function showTeacherLesson_thecenter(lesson_id)
{		
	showLesson(lesson_id,'teacher','thecenter_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_thecenter(lesson_id)
{		
	showLesson(lesson_id,'student','thecenter_student');	 // lesson_id, usertype, pilot_code
}

//westside: -----------------------------------------------------
function showTeacherLesson_westside(lesson_id)
{		
	showLesson(lesson_id,'teacher','westside_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_westside(lesson_id)
{		
	showLesson(lesson_id,'student','westside_student');	 // lesson_id, usertype, pilot_code
}

//whitfield: -----------------------------------------------------
function showTeacherLesson_whitfield(lesson_id)
{		
	showLesson(lesson_id,'teacher','whitfield_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_whitfield(lesson_id)
{		
	showLesson(lesson_id,'student','whitfield_student');	 // lesson_id, usertype, pilot_code
}

//garcia: -----------------------------------------------------
function showTeacherLesson_garcia(lesson_id)
{		
	showLesson(lesson_id,'teacher','garcia_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_garcia(lesson_id)
{		
	showLesson(lesson_id,'student','garcia_student');	 // lesson_id, usertype, pilot_code
}

//stelisabeth: -----------------------------------------------------
function showTeacherLesson_stelisabeth(lesson_id)
{		
	showLesson(lesson_id,'teacher','stelisabeth_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_stelisabeth(lesson_id)
{		
	showLesson(lesson_id,'student','stelisabeth_student');	 // lesson_id, usertype, pilot_code
}

//parkway: -----------------------------------------------------
function showTeacherLesson_parkway(lesson_id)
{		
	showLesson(lesson_id,'teacher','parkway_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_parkway(lesson_id)
{		
	showLesson(lesson_id,'student','parkway_student');	 // lesson_id, usertype, pilot_code
}

//jefferson: -----------------------------------------------------
function showTeacherLesson_jefferson(lesson_id)
{		
	showLesson(lesson_id,'teacher','jefferson_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_jefferson(lesson_id)
{		
	showLesson(lesson_id,'student','jefferson_student');	 // lesson_id, usertype, pilot_code
}

//wjhs (part of naperville): -----------------------------------------------------
function showTeacherLesson_wjhs(lesson_id)
{		
	showLesson(lesson_id,'teacher','wjhs_teacher');	 // lesson_id, usertype, pilot_code
}
function showStudentLesson_wjhs(lesson_id)
{		
	showLesson(lesson_id,'student','wjhs_student');	 // lesson_id, usertype, pilot_code
}