/****************************** Marieb, Human Anatomy & Physiology, 8e Open Access site / WebDevr Dario Wong */

//load external google analytics file
function loadScript(url) {document.write('<script src="', url, '" type="text/javascript"></script>');}
loadScript("http://www.google-analytics.com/urchin.js");
loadScript("http://media.pearsoncmg.com/bc/bc_0media_ap/casestudies/hap/inc/scripts.js");

var htmlBuffer;
var wpsBasePath;
var projCode;
var msBasePath = 'http://media.pearsoncmg.com/';

if (document.referrer.indexOf('wps.aw.com') >= 0)
{
	wpsBasePath = 'http://wps.aw.com/bc_marieb_hap_8_oa/';
	projCode = 'hap8';
}
else
{
	wpsBasePath = 'http://wpscms.pearsoncmg.com/bc_marieb_hap_8_oa/';
	projCode = 'hap8cms';
}

var chTitleArray = new Array();
var chTitleIndx = 1;

/*1*/	chTitleArray[chTitleIndx++]	=	"The Human Body: An Orientation";
/*2*/	chTitleArray[chTitleIndx++]	=	"Chemistry Comes Alive";
/*3*/	chTitleArray[chTitleIndx++]	=	"Cells: The Living Units";
/*4*/	chTitleArray[chTitleIndx++]	=	"Tissue: The Living Fabric";
/*5*/	chTitleArray[chTitleIndx++]	=	"The Integumentary System";
/*6*/	chTitleArray[chTitleIndx++]	=	"Bones and Skeletal Tissue";
/*7*/	chTitleArray[chTitleIndx++]	=	"The Skeleton";
/*8*/	chTitleArray[chTitleIndx++]	=	"Joints";
/*9*/	chTitleArray[chTitleIndx++]	=	"Muscles and Muscle Tissue";
/*10*/	chTitleArray[chTitleIndx++]	=	"The Muscular System";
/*11*/	chTitleArray[chTitleIndx++]	=	"Fundamentals of the Nervous System and Nervous Tissue";
/*12*/	chTitleArray[chTitleIndx++]	=	"The Central Nervous System";
/*13*/	chTitleArray[chTitleIndx++]	=	"The Peripheral Nervous System and Reflex Activity";
/*14*/	chTitleArray[chTitleIndx++]	=	"The Autonomic Nervous System";
/*15*/	chTitleArray[chTitleIndx++]	=	"The Special Senses";
/*16*/	chTitleArray[chTitleIndx++]	=	"The Endocrine System";
/*17*/	chTitleArray[chTitleIndx++]	=	"Blood";
/*18*/	chTitleArray[chTitleIndx++]	=	"The Cardiovascular System: The Heart";
/*19*/	chTitleArray[chTitleIndx++]	=	"The Cardiovascular System: Blood Vessels";
/*20*/	chTitleArray[chTitleIndx++]	=	"The Lymphatic System and Lymphoid Organs and Tissues";
/*21*/	chTitleArray[chTitleIndx++]	=	"The Immune System: Innate and Adaptive Body Defenses";
/*22*/	chTitleArray[chTitleIndx++]	=	"The Respiratory System";
/*23*/	chTitleArray[chTitleIndx++]	=	"The Digestive System";
/*24*/	chTitleArray[chTitleIndx++]	=	"Nutrition, Metabolism, and Body Temperature Regulation";
/*25*/	chTitleArray[chTitleIndx++]	=	"The Urinary System";
/*26*/	chTitleArray[chTitleIndx++]	=	"Fluid, Electrolyte, and Acid-Base Balance";
/*27*/	chTitleArray[chTitleIndx++]	=	"The Reproductive System";
/*28*/	chTitleArray[chTitleIndx++]	=	"Pregnancy and Human Development";
/*29*/	chTitleArray[chTitleIndx++]	=	"Heredity";

function writeChTitleForCh(chNum)
{
	htmlBuffer = '<span class="chTitle">Chapter ' + chNum + ': ' + chTitleArray[chNum] + '</span>\n';
	htmlBuffer += '<br /><br />\n';
	document.write(htmlBuffer);
}

function openHistology()
{
	var histologyWin = window.open('http://media.pearsoncmg.com/bc/bc_histology/index.html','histology','toolbar=no,scrollbars=auto,resizable=yes,height=600,width=800,screenX=100,screenY=100,left=100,top=100');
	
	if (histologyWin.opener == null)
	{
		histologyWin.opener = window;
	}
	histologyWin.focus();
}

function writeHdr(hdrType)
{
	htmlBuffer = '<span class="header1">';
	switch(hdrType)
	{
		case 'cq':
			htmlBuffer += 'Chapter Quizzes';
			break;
		
		case 'cga':
			htmlBuffer += 'Chapter Games and Activities';
			break;
		
		case 'alq':
			htmlBuffer += 'Art-Labeling Quiz';
			break;
			
		case 'mq':
			htmlBuffer += 'Matching Quiz';
			break;
			
		case 'mcq':
			htmlBuffer += 'Multiple-Choice Quiz';
			break;
			
		case 'tfq':
			htmlBuffer += 'True-False Quiz';
			break;
		
		case 'wl':
			htmlBuffer += 'Web Links';
			break;
			
		case 'st':
			htmlBuffer += 'Study Tools';
			break;
			
		case 'fdbk':
			htmlBuffer += 'Feedback';
			break;
			
		default:
			break;
	}
	htmlBuffer += '</span>\n';
	htmlBuffer += '<br /><br />\n';
	
	document.write(htmlBuffer);
}

var webLinksArray = new Array();
var webLinksIndx = 1;

/*1*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817608";
/*2*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817619";
/*3*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817635";
/*4*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817642";
/*5*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817649";
/*6*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817660";
/*7*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817693";
/*8*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817702";
/*9*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817710";
/*10*/	webLinksArray[webLinksIndx++]	=	"119/30537/7817719";
/*11*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817729";
/*12*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817758";
/*13*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817768";
/*14*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817775";
/*15*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817789";
/*16*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817819";
/*17*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817828";
/*18*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817859";
/*19*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817875";
/*20*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817883";
/*21*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817890";
/*22*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817922";
/*23*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817934";
/*24*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817941";
/*25*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817947";
/*26*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817972";
/*27*/	webLinksArray[webLinksIndx++]	=	"119/30538/7817983";
/*28*/	webLinksArray[webLinksIndx++]	=	"119/30539/7817990";
/*29*/	webLinksArray[webLinksIndx++]	=	"119/30539/7817995";

var qzsTestsArray = new Array();
var qzsTestsIndx = 1;

/*
alq	=	Art-Labeling Quiz (only available through CC/CMS)
mq	=	Matching Quiz
mcq	=	Multiple-Choice Quiz
tfq	=	True/False Quiz
*/
/*1*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817603", mq:"107/27576/7059497", mcq:"107/27576/7059514", tfq:"107/27576/7059545"};
/*2*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817610", mq:"107/27576/7059553", mcq:"107/27576/7059561", tfq:"107/27576/7059592"};
/*3*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817621", mq:"107/27576/7059610", mcq:"107/27576/7059630", tfq:"107/27576/7059661"};
/*4*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817637", mq:"107/27576/7059678", mcq:"107/27576/7059700", tfq:"107/27577/7059731"};
/*5*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817644", mq:"107/27577/7059752", mcq:"107/27577/7059773", tfq:"107/27577/7059804"};
/*6*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817651", mq:"107/27577/7059827", mcq:"107/27577/7059850", tfq:"107/27577/7059881"};
/*7*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817662", mq:"107/27577/7059904", mcq:"107/27577/7059927", tfq:"107/27577/7059958"};
/*8*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817695", mq:"107/27578/7059981", mcq:"107/27578/7060001", tfq:"107/27578/7060032"};
/*9*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817704", mq:"107/27578/7060053", mcq:"107/27578/7060074", tfq:"107/27578/7060105"};
/*10*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817712", mq:"107/27578/7060128", mcq:"107/27578/7060149", tfq:"107/27578/7060180"};
/*11*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30537/7817721", mq:"107/27578/7060200", mcq:"107/27578/7060208", tfq:"107/27579/7060239"};
/*12*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817751", mq:"107/27579/7060257", mcq:"107/27579/7060267", tfq:"107/27579/7060298"};
/*13*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817760", mq:"107/27579/7060318", mcq:"107/27579/7060328", tfq:"107/27579/7060359"};
/*14*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817770", mq:"107/27579/7060379", mcq:"107/27579/7060389", tfq:"107/27579/7060420"};
/*15*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817777", mq:"107/27579/7060435", mcq:"107/27579/7060453", tfq:"107/27580/7060484"};
/*16*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817811", mq:"107/27580/7060500", mcq:"107/27580/7060523", tfq:"107/27580/7060554"};
/*17*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817821", mq:"107/27580/7060577", mcq:"107/27580/7060586", tfq:"107/27580/7060617"};
/*18*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817830", mq:"107/27580/7060635", mcq:"107/27580/7060644", tfq:"107/27580/7060675"};
/*19*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817861", mq:"107/27580/7060692", mcq:"107/27580/7060700", tfq:"107/27580/7060731"};
/*20*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817877", mq:"107/27581/7060741", mcq:"107/27581/7060750", tfq:"107/27581/7060781"};
/*21*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817885", mq:"107/27581/7060798", mcq:"107/27581/7060810", tfq:"107/27581/7060841"};
/*22*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817912", mq:"107/27581/7060857", mcq:"107/27581/7060865", tfq:"107/27581/7060896"};
/*23*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817924", mq:"107/27581/7060909", mcq:"107/27581/7060921", tfq:"107/27581/7060952"};
/*24*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817936", mq:"107/27581/7060970", mcq:"107/27581/7060979", tfq:"107/27582/7061010"};
/*25*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817943", mq:"107/27582/7061027", mcq:"107/27582/7061039", tfq:"107/27582/7061070"};
/*26*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817949", mq:"107/27582/7061087", mcq:"107/27582/7061096", tfq:"107/27582/7061127"};
/*27*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30538/7817974", mq:"107/27582/7061144", mcq:"107/27582/7061153", tfq:"107/27582/7061184"};
/*28*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30539/7817985", mq:"107/27582/7061202", mcq:"107/27582/7061211", tfq:"107/27582/7061242"};
/*29*/	qzsTestsArray[qzsTestsIndx++]	=	{alq:"119/30539/7817992", mq:"107/27583/7061260", mcq:"107/27583/7061267", tfq:"107/27583/7061298"};

function writeAllCrossPuzzles(chNum, totalPuzzles)
{
	var chNumStr;
	var puzzleNumStr;
	var tmpHtmlBuffer;
	
	tmpHtmlBuffer = '';
	
	if (chNum < 10) // If the chapter number is less than 10
	{
		chNumStr = '0' + chNum; // add a '0' at the beginning for file naming purposes
	}
	else
	{
		chNumStr = chNum; // else, just use the same chapter number
	}
	
	for(i = 1; i <= totalPuzzles; i++)
	{
		if (i < 10) // If the crossword number is less than 10
		{
			puzzleNumStr = '0' + i; // add a '0' at the beginning for file naming purposes
		}
		else
		{
			puzzleNumStr = i; // else, just use the same crossword number
		}
		
		tmpHtmlBuffer += '<a href="javascript://" onclick="javascript:openCrossPuzzle(\'crossword_' + chNumStr + '_' + puzzleNumStr + '.html\'); return false;" class="aLink">Crossword Puzzle ' + chNum + '.' + i + '</a>';
		
		if (i != totalPuzzles)
		{
			tmpHtmlBuffer += '<br />\n';
		}
	}
	
	return tmpHtmlBuffer;
}

function writeWebLinksLink(chNum)
{
	var tmpHtmlBuffer;
	
	tmpHtmlBuffer = '';
	
	if (webLinksArray[chNum] != "")
	{
		if (document.title.indexOf('Chapter Games and Activities') >= 0)
		{
			tmpHtmlBuffer += '<a href="' + wpsBasePath + webLinksArray[chNum] + '.cw/index.html" class="aLink">Chapter ' + chNum + ' Web Links</a>\n';
		}
		else
		{
			tmpHtmlBuffer += '<br />\n';
			tmpHtmlBuffer += '<a href="' + wpsBasePath + webLinksArray[chNum] + '.cw/index.html" class="aLink">Web Links</a>\n';
		}
	}
	
	return tmpHtmlBuffer;
}

function writeChQzsPgContent(chNum)
{
	htmlBuffer = writeChQzsLinks(chNum);
	document.write(htmlBuffer);
}

function writeChQzsLinks(chNum)
{
	var chQzsHtmlBuffer = '';
	chQzsHtmlBuffer += '<div class="indent30">\n';
	if (document.location.href.indexOf('wpscms') >= 0)
	{
		chQzsHtmlBuffer += '<a href="' + wpsBasePath + qzsTestsArray[chNum]['alq'] + '.cw/index.html" class="aLink">Art-Labeling Quiz</a><br />\n';
	}
	chQzsHtmlBuffer += '<a href="' + wpsBasePath + qzsTestsArray[chNum]['mq'] + '.cw/index.html" class="aLink">Matching Quiz</a><br />\n';
	chQzsHtmlBuffer += '<a href="' + wpsBasePath + qzsTestsArray[chNum]['mcq'] + '.cw/index.html" class="aLink">Multiple-Choice Quiz</a><br />\n';
	chQzsHtmlBuffer += '<a href="' + wpsBasePath + qzsTestsArray[chNum]['tfq'] + '.cw/index.html" class="aLink">True/False Quiz</a>\n';
	chQzsHtmlBuffer += '</div>\n';
	
	return chQzsHtmlBuffer;
}

function openCrossPuzzle(crossPuzzleFile)
{
	var crossPuzzleWin = window.open('http://media.pearsoncmg.com/bc/bc_marieb_hap_8/crosswords/' + crossPuzzleFile, '_self');
	return false;
}

/***** Animations *****/
function openAnimation(animPath)
{
	var pathToOpen = msBasePath + animPath;
	var animationWin = window.open(pathToOpen, 'ani', 'toolbar=no,scrollbars=no,resizable=yes,height=360,width=480,screenX=100,screenY=100,left=100,top=100');
    if (animationWin.opener == null)
	{
		animationWin.opener = window;
	}
	animationWin.focus();
	return false;
}

function openActivity(actPath)
{
	var pathToOpen = msBasePath + actPath;
	var actWin = window.open(pathToOpen, 'act', 'toolbar=no,scrollbars=auto,resizable=yes,height=600,width=790,screenX=100,screenY=100,left=100,top=100');
    if (actWin.opener == null)
	{
		actWin.opener = window;
	}
	actWin.focus();
	return false;
}

function openCaseStudy(csPath)
{
	var pathToOpen = msBasePath + 'bc/bc_0media_ap/casestudies/hap/' + csPath;
	var csWin = window.open(pathToOpen, '_self');
	return false;
}

function openMemoryGame(mgFile)
{
	var memoryGameWin = window.open(mgFile, 'memWin', 'menubar=0,toolbar=0,location=0,status=0,scrollbars=auto,resizable=0,width=650,height=440,screenX=10,screenY=10,left=10,top=10');
	if (memoryGameWin.opener == null)
	{
		memoryGameWin.opener = window;
	}
	memoryGameWin.focus();
	
	return false;
}

function openArtLabeling(alFile)
{
	var artLablActMSBasePath = 'http://media.pearsoncmg.com/bc/bc_marieb_hap_8/artLblAct/';
	var artLabelingWin = window.open(artLablActMSBasePath + alFile + '/' + alFile + '.html', 'alWin', 'menubar=0,toolbar=0,location=0,status=0,scrollbars=1,resizable=0,width=1000,height=640,screenX=10,screenY=10,left=10,top=10');

	if (artLabelingWin.opener == null)
	{
		artLabelingWin.opener = window;
	}
	artLabelingWin.focus();
	
	return false;
}

function openFlashcards()
{
	var flashWin = window.open('http://flashcards.pearsoncmg.com/?bookID=679', 'flash', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=1080,height=720,screenX=10,screenY=10,left=10,top=10');
	if (flashWin.opener == null)
	{
		flashWin.opener = window;
	}
	flashWin.focus();
	
	return false;
}

function openGlossary()
{
	var glossWin = window.open('http://media.pearsoncmg.com/bc/bc_marieb_hap_8/glossary/glossary.html', 'gloss', 'menubar=0,toolbar=0,location=0,status=0,scrollbars=1,resizable=1,width=1024,height=768,screenX=10,screenY=10,left=10,top=10');
	if (glossWin.opener == null)
	{
		glossWin.opener = window;
	}
	glossWin.focus();
	
	return false;
}
