function launchCourse(url, course, lesson, topic, topicTitle, skinPath, adPad){
	var padding = 17;
	var width = 800;
	var height = 590;

        topicTitle = topicTitle.replace("'", "\\'");

	if(course == 'Algebra IA' || course == 'Algebra IB' || course == 'Elementary Algebra' || course == 'Curso de Algebra IA' || course == 'Curso de Algebra IB'){
		width = 995;
		height = 735;
	}
	else if(course == 'AP Biology I' || course == 'AP Biology II'){
		width = 600;
		height = 390;
	}

    if(adPad){
        if(course == 'AP Biology I' || course == 'AP Biology II')
            height += 64;
        else
            height += 94;
    }

	if(lesson.length < 2)
		lesson = '0' + lesson;
            
	window.open(
		url + '?course=' + course
		+ '&lesson=' + lesson
		+ '&topic=' + topic
		+ '&width=' + width
		+ '&height=' + height
		+ '&topicTitle=' + escape(topicTitle)
                + '&skinPath=' + skinPath
		, 'HippoCampusPlayer'
		, 'width=' + (width + padding) + ',height=' + (height + padding + 26) + ',scrollbars'
	).focus();
}
function launchTextPreview(url, course, sectionTitle, topicTitle){
	var filename = sectionTitle + '_' + topicTitle;

	while(filename.indexOf('/') >= 0)
		filename = filename.replace('/', ' or ');
	while(filename.indexOf('"') >= 0)
		filename = filename.replace('"', "'");
	while(filename.indexOf('?') >= 0)
		filename = filename.replace('?', "");
	while(filename.indexOf(':') >= 0)
		filename = filename.replace(':', "-");
	switch(course){
		case 'Algebra IA':
		case 'Algebra IB':
                    course = 'Algebra';
                    break;
		case 'US History I':
		case 'US History II':
		case 'AP US History I':
		case 'AP US History II':
			course = 'US-History';
			break;
		case 'American Government':
		case 'AP Government and Politics':
			course = 'American-Government';
			break;
		case 'AP Biology I':
		case 'AP Biology II':
			course = 'Biology';
			break;
		case 'AP Calculus BC I':
		case 'AP Calculus BC II':
		case 'AP Calculus AB I':
		case 'AP Calculus AB II':
		case 'Introductory Calculus I':
		case 'Introductory Calculus II':
		case 'General Calculus I':
		case 'General Calculus II':
			course = 'Calculus';
			break;
		case 'Introductory Physics I':
		case 'Introductory Physics II':
		case 'AP Physics B I':
		case 'AP Physics B II':
			course = 'Physics-B';
			break;
		case 'General Physics I':
		case 'General Physics II':
		case 'AP Physics C I':
		case 'AP Physics C II':
			course = 'Physics-C';
			break;
		case 'College Preparatory Physics I':
		case 'College Preparatory Physics II':
			course = 'Physics-CP';
			break;
	}

        var semicolonPosition = url.indexOf(';');
        if(semicolonPosition >= 0)
            url = url.substring(0, semicolonPosition);

        openPlayerSidePane();
	window.open(
		url + 'homework-help/' + course + '/' + filename + '.html'
		, 'misc'
		, 'width=1000,height=700,scrollbars'
	);
}
function openMaybe(subjectTitle){
	if(opener != null && !opener.closed && opener.location.href.indexOf("hippocampus.org") >= 0)
            window.close();
	else
            location.href = "http://www.hippocampus.org/" + subjectTitle;
}
