// Inventing v.1 media popups

/* The following functions are for launching the various types of resources from the resource listings. 
   or from the annotation/feature listing. (The features will need to be made to handle these.)
   Tyler DeWall, 7-15-02
*/

var myWindow; 
var filename;  
var fileTitle;

function loadDocument(titleRef, fileNameRef){
	// This function loads a text-only document(html)
	// titleRef is the text of the link clicked on, for use in title tag of popup
	// fileNameRef is the filename of the document to load
	
	myWindow = window.open(fileNameRef, 'openwin','width=640,height=480,scrollbars=yes');
    myWindow.focus;
}

function loadImage(titleRef, fileNameRef){
	//This function displays an image
	// titleRef is the text of the link clicked on, for use in title tag of popup
	// fileNameRef is the filename of the image to load

	var title;	
	title = unescape(titleRef);
	filename = fileNameRef.substr(14, (fileNameRef.length - 14));
	//change size from width=590,height=440 TD-8-15-02
    myWindow = window.open('../../v1/imageloader.html','','width=740,height=540');
}

function loadMap(titleRef, fileNameRef){
	// This function displays a map
	// titleRef is the text of the link clicked on, for use in title tag of popup
	// Note that maps can be static (.jpg) or animated(.swf)
	// fileNameRef is the filename of the map to load


    var title;
	myRegEx = new RegExp("\w*\.jpg$") 
	title = unescape(titleRef);
	filename = fileNameRef.substr(14, (fileNameRef.length - 14));

	if(myRegEx.test(fileNameRef)) {
		//change size from width=590,height=440 TD-8-15-02
	    myWindow = window.open('../../v1/imageloader.html','','width=740,height=540');
	}
	else {	
		myWindow = window.open('','','toolbar=no,width=580,height=680');
		myWindow.document.writeln('<html><head><title>');
		myWindow.document.write(title);
		myWindow.document.write('</title></head><body>');
		myWindow.document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="560" height="660">');
		myWindow.document.write('<param name=movie value="../../short/js/');
		myWindow.document.write(fileNameRef);
		myWindow.document.write('">');
		myWindow.document.write('<param name=quality value=high>');
		myWindow.document.write('<embed src="../../short/js/');
		myWindow.document.write(fileNameRef);
		myWindow.document.write('" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="560" height="660">');
		myWindow.document.write('</embed></object>');
		myWindow.document.write('</body></html>');
		myWindow.document.close();
	    myWindow.focus;
	}
}
function streamILG (fileNameRef){
		var title = "Stream iLG";
		
		myWindow = window.open('','','toolbar=no,width=660,height=650');
		myWindow.document.writeln('<html><head><title>');
		myWindow.document.write(title);
		myWindow.document.write('</title>');
		//myWindow.document.write('<scr'+'ipt src="http://www.wwnorton.com/college/music/enj10/common/js/AC_QuickTime.js" language="javascript"> ');
		//myWindow.document.write('</scr'+'ipt>');
		myWindow.document.write('</head><body>');
		
		//myWindow.document.write('<scr'+'ipt language="JavaScript" type="text/javascript">');
		//myWindow.document.write('QT_WriteOBJECT');
		//myWindow.document.write('(\'http://www.wwnorton.com/college/music/enj10/iLGs_streaming/' + fileNameRef + '\'');
		//myWindow.document.write(',\'640\',\'500\',\'\',\'controller\',\'TRUE\',\'type\',\'video/quicktime\',\'kioskmode\', \'true\'');
		//myWindow.document.write(');');
		//myWindow.document.write('</scr'+'ipt>');
		
		myWindow.document.write('<object classid="clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b" height="650" width="640" codebase="http://www.apple.com/qtactivex/qtplugin.cab" >');
		myWindow.document.write('<param name="src" value="http://www.wwnorton.com/college/music/enj10/iLGs_streaming/'+fileNameRef+'" >');
		myWindow.document.write('<param name="autoplay" value="true" >');
		myWindow.document.write('<param name="controller" value="true" >');
		myWindow.document.write('<param name="kioskmode" value="true" >');
		myWindow.document.write('<embed height="650" width="640" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" src="http://www.wwnorton.com/college/music/enj10/iLGs_streaming/'+fileNameRef+'" autoplay="true" controller="true" kioskmode="true" ></embed>');
		myWindow.document.write('</object>');
		
		myWindow.document.write('</body></html>');
		myWindow.document.close();
	    myWindow.focus;
}
function loadAudio (titleRef, fileNameRef, narrationFileRef){
	// This function plays an audio resource
	// titleRef is the title of the audio file, it'll be displayed if no narration
	// fileNameRef is the file to be played
	// narrationFileRef is the text of the audio, display it if available.

    var title;
	fileTitle = titleRef;
	title = unescape(titleRef);
	filename = fileNameRef.substr(14, (fileNameRef.length - 14));

  	if (narrationFileRef != "") {
            textWindow = window.open(narrationFileRef, 'openwin','width=640,height=480,scrollbars=yes');
  	}

    myWindow = window.open('../../v1/audioPlayer.html','','width=140,height=15');
    myWindow.focus;
}

function loadVideo (titleRef, fileNameRef){
	// This function displays a video resource
	// titleRef is the text of the link clicked on, for use in title tag of popup
	// fileNameRef is the filename of the video to load

    var title;
	fileTitle = titleRef;
	title = unescape(titleRef);
	filename = fileNameRef.substr(14, (fileNameRef.length - 14));
    myWindow = window.open('../../v1/vidPlayer.html','','width=250,height=210');
	myWindow.focus;
}

// Popup Windows

var newwindow;

function imap(url)
{
	newwindow=window.open(url,'name','height=421,width=761,resizable=1');
	if (window.focus) {newwindow.focus()}
}

var newwindow;

function imap2(url)
{
	newwindow=window.open(url,'imap','height=421,width=761,resizable=1');
	if (window.focus) {newwindow.focus()}
}

var newwindow;

function quiz(url)
{
	newwindow=window.open(url,'quiz','height=375,width=550,resizable=1,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

var newwindow;

function ebook(url)
{
	newwindow=window.open(url,'ebook','height=550,width=740,resizable=1');
	if (window.focus) {newwindow.focus()}
}

var newwindow;

function video(url)
{
	newwindow=window.open(url,'video','height=271,width=341');
	if (window.focus) {newwindow.focus()}
}

var newwindow;

function chrono(url)
{
	newwindow=window.open(url,'chrono','height=450,width=670,resizable=1,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

var newwindow;

function worksheet(url)
{
	newwindow=window.open(url,'worksheet','height=400,width=471,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

// resize popup image window

function PopupPic(sPicURL) { 
	window.open("../multimedia/images/popup.htm?"+sPicURL, "", "scrollbars=1,resizable=1,HEIGHT=200,WIDTH=500");
}

// Bookmark a page

function addToFavorites()
 {
  if (window.external)
  {
   window.external.AddFavorite(urlAddress,pageName)
  }
  else
  { 
   alert("Sorry! Your browser doesn't support this function.");
  }
 }

      function customImageLinks() {
              if (!document.getElementsByTagName) return;
              var anchors = document.getElementsByTagName('a');
              for (var i=0; i<anchors .length; i++) {
                   anchor = anchors[i];
                      var images = anchor.getElementsByTagName('img');
                      if (images[0] != null) {
                              anchor.className = "image";
                      }
              }
      }
       
      if (window.addEventListener)
              window.addEventListener("load", customImageLinks, false)
      else if (window.attachEvent)
              window.attachEvent("onload", customImageLinks)
      else if (document.getElementById)
              window.onload=customImageLinks
 
 // Email a friend
 
function e_friend()
{
	var e_add= prompt('Enter your friend\'s email address:',' ');
	var subj= prompt('Enter the subject of your message:',' ');
	if ((subj==" ") || (subj==null))
		subj="W. W. Norton and Company: The Enjoyment of Music, 10 ed. Website Referral";
	u = window.location;
	window.location="mailto:"+e_add+"?subject="+subj+"&body=Check out this W. W. Norton and Company: The Enjoyment of Music, 10 ed. Website Page: "+u;
}

// other right hand menu links

//goCalendar funtion not used due to differing links from index vs. chapter pages
//function goCalendar()
//{
//	document.location = "../../content/index/calendar.php";
//}
function goPodcast()
{
	document.location = "../../content/index/podcast.htm";
}
function goSearch(myChap)
{
	//document.location = "";
}
function goProgress(myChap)
{
	document.location = "../../content/ch" + ((myChap.charAt(0) == "i")?'_'+myChap:myChap) + "/progress.htm";
}
function goStudy(myChap)
{
	document.location = "../../content/ch" + ((myChap.charAt(0) == "i")?'_'+myChap:myChap) + "/study.htm";
}
function goeBook(myChap)
{
	document.location = "../../password/ch" + ((myChap.charAt(0) == "i")?'_'+myChap:myChap) + "/ebook.asp";
}
function goOutline(myChap)
{
	document.location = "../../content/ch" + ((myChap.charAt(0) == "i")?'_'+myChap:myChap) + "/outline.htm";
}
function goListen(myChap)
{
	document.location = "../../password/ch" + ((myChap.charAt(0) == "i")?'_'+myChap:myChap) + "/audio.asp";
}
function goFlashcards(myChap)
{
	document.location = "../../content/flashcards/ch" + ((myChap.charAt(0) == "i")?'_'+myChap:myChap) + ".htm";
}
function goQuiz(myChap)
{
	quiz("../../content/quizzes/mc_" + myChap + ".htm");
}
function goListenQuiz(myQuiz)
{
	quiz("http://www.wwnorton.com/college/music/enj10/listening%20quizzes/quizzer.asp?callquiz=" + myQuiz);
}
function goComposers(myChap)
{
	if (myChap == null) { //or typeof myChap == "undefined"
		myChap = getChap();
	}
	document.location = "../../content/ch" + ((myChap.charAt(0) == "i")?'_'+myChap:myChap) + "/composers.htm";
}
function goMusic(myChap, myMusic)
{
	if (myMusic == "eras") {
		document.location = "../../content/index/eras_music.htm"; //?chap="+myChap;
	} else {
		document.location = "../../content/unit/" + myMusic + ".htm?chap="+myChap;
	}
}
function goTransitions(myChap, myMusic)
{
	if (myMusic == "eras") {
		document.location = "../../content/index/eras_trans.htm"; //?chap="+myChap;
	} else {
		document.location = "../../content/unit/trans_" + myMusic + ".htm?chap="+myChap;
	}
}
function goPerspectives(myBook, myChap, myMusic)
{
  myPersp = "";
  num = myChap.valueOf(); //eval(myChap.valueOf());
  
  if (myBook == "short") {
	  if (num < 10) {
		myPersp = "01";
	  } else if ((num >= 10) && (num < 12)) {
		myPersp = "02";
	  } else if ((num >= 12) && (num < 13)) {
		myPersp = "03";
	  } else if ((num >= 13) && (num < 14)) {
		myPersp = "04";
	  //} else if (((num >= 14) && (num < 20)) || (myChap == "i")) { //changed to below so as not to cross over eras
	  } else if (((num >= 14) && (num < 19)) || (myChap == "i")) {
		myPersp = "05";
	  //} else if (((num >= 20) && (num < 33)) || (myChap == "ii")) { //changed to below so as not to cross over eras
	  } else if (((num >= 19) && (num < 30)) || (myChap == "ii")) {
		myPersp = "06";
	  //} else if ((num >= 33) && (num < 36)) { //changed to below so as not to cross over eras
	  } else if ((num >= 30) && (num < 36)) {
		myPersp = "07";
	  } else if ((num >= 36) && (num < 38)) {
		myPersp = "08";
	  //} else if (((num >= 38) && (num < 46)) || (myChap == "iii")) { //changed to below so as not to cross over eras
	  } else if (((num >= 38) && (num < 40)) || (myChap == "iii")) {
		myPersp = "09";
	  //} else if ((num >= 46) && (num < 51)) { //changed to below so as not to cross over eras
	  } else if ((num >= 40) && (num < 51)) {
		myPersp = "10";
	  } else if ((num >= 51) && (num < 52)) {
		myPersp = "11";
	  } else if ((num >= 52) && (num < 55)) {
		myPersp = "12";
	  } else if ((num >= 55) && (num < 57)) {
		myPersp = "13";
	  } else if (((num >= 57) && (num < 63)) || (myChap == "iv")) {
		myPersp = "14";
	  } else if ((num >= 63) && (num < 68)) {
		myPersp = "15";
	  } else if ((num >= 68) && (num < 69)) {
		myPersp = "16";
	  } else if ((num >= 69) && (num < 70)) {
		myPersp = "17";
	  } else if ((num >= 70) && (num < 71)) {
		myPersp = "18";
	  } else if ((num >= 71) && (num < 73)) {
		myPersp = "19";
	  } else if ((num >= 73) && (num < 75)) {
		myPersp = "20";
	  } else if ((num >= 75) && (num < 77)) {
		myPersp = "21";
	  } else if ((num >= 77) && (num < 79)) {
		myPersp = "22";
	  } else { //num >= 79
		myPersp = "23";
	  }
  } else { //myBook == "complete"
	  if (num < 10) {
		myPersp = "01";
	  } else if ((num >= 10) && (num < 12)) {
		myPersp = "02";
	  } else if ((num >= 12) && (num < 13)) {
		myPersp = "03";
	  } else if ((num >= 13) && (num < 14)) {
		myPersp = "04";
	  //} else if (((num >= 14) && (num < 20)) || (myChap == "i")) { //changed to below so as not to cross over eras
	  } else if (((num >= 14) && (num < 19)) || (myChap == "i")) {
		myPersp = "05";
	  //} else if (((num >= 20) && (num < 33)) || (myChap == "ii")) { //changed to below so as not to cross over eras
	  } else if (((num >= 19) && (num < 30)) || (myChap == "ii")) {
		myPersp = "06";
	  //} else if ((num >= 33) && (num < 36)) { //changed to below so as not to cross over eras
	  } else if ((num >= 30) && (num < 36)) {
		myPersp = "07";
	  } else if ((num >= 36) && (num < 38)) {
		myPersp = "08";
	  //} else if (((num >= 38) && (num < 46)) || (myChap == "iii")) { //changed to below so as not to cross over eras
	  } else if (((num >= 38) && (num < 40)) || (myChap == "iii")) {
		myPersp = "09";
	  //} else if ((num >= 46) && (num < 51)) { //changed to below so as not to cross over eras
	  } else if ((num >= 40) && (num < 51)) {
		myPersp = "10";
	  } else if ((num >= 51) && (num < 52)) {
		myPersp = "11";
	  } else if ((num >= 52) && (num < 55)) {
		myPersp = "12";
	  } else if ((num >= 55) && (num < 57)) {
		myPersp = "13";
	  } else if (((num >= 57) && (num < 63)) || (myChap == "iv")) {
		myPersp = "14";
	  } else if ((num >= 63) && (num < 68)) {
		myPersp = "15";
	  } else if ((num >= 68) && (num < 69)) {
		myPersp = "16";
	  } else if ((num >= 69) && (num < 70)) {
		myPersp = "17";
	  } else if ((num >= 70) && (num < 71)) {
		myPersp = "18";
	  } else if ((num >= 71) && (num < 73)) {
		myPersp = "19";
	  } else if ((num >= 73) && (num < 75)) {
		myPersp = "20";
	  } else if ((num >= 75) && (num < 77)) {
		myPersp = "21";
	  } else if ((num >= 77) && (num < 79)) {
		myPersp = "22";
	  } else { //num >= 79
		myPersp = "23";
	  }
  }
  document.location = "../../content/unit/persp_" + myPersp + ".htm?chap="+myChap;
}
function goTimeline(myChap, myMusic)
{
	num = myChap.valueOf()
	if (num < 11) {
		var timeline="../../content/multimedia/images/timeline.htm";
		newwindow=window.open(timeline,'time','width=795,height=465,scrollbars=yes,resizable=yes');
	  } else if ((num >= 75) && (myMusic == "eras")) { //this should cover both short and complete books
		var timeline="../../content/multimedia/images/timeline_beyond.htm";
		newwindow=window.open(timeline,'time','width=800,height=600,scrollbars=yes,resizable=yes');
	  } else {
		var timeline="../../content/multimedia/images/timeline_" + myMusic + ".htm";
		newwindow=window.open(timeline,'time','width=800,height=600,scrollbars=yes,resizable=yes');
	  }
	if (window.focus) {newwindow.focus()}
}
function goGlossary()
{
	document.location = "../../content/index/glossary.htm";
}
function goMaterials(myBook, myChap, myMusic)
{
	//if (myBook == "short") {
		switch (myChap) {
			case '01':
			case '02':
			case '03':
			case '04':
			case '05':
			case '06':
			case '07':
			case '08':
			case '09':
			case '27':
			case '29':
				document.location = "../../content/ch"+myChap+"/momi.asp";
				break;
			default:
				document.location = "../../content/materials/index.asp?chap="+myChap;
				break;
		}
		
	//} else {
	//	document.location = "../../content/materials/momindex.htm";
	//}
}
function goOLL()
{
//online learning lab link
	var url = "http://www.wwnorton.com/web/listenonline/";
	newwindow=window.open(url,'oll');
	if (window.focus) {newwindow.focus()}
}
function goeBookURL()
{
//eBook link
	var url = "http://www.nortonebooks.com/";
	newwindow=window.open(url,'ebook');
	if (window.focus) {newwindow.focus()}
}
function goJukebox(myJbox)
{
//link
	//var url = "http://www.wwnorton.com/college/music/enj9/shared/jukebox/" + myJbox + ".swf";

	//OPTION #1 & #2 OPEN A NEW WINDOW
	//myWindow = window.open('','','toolbar=no,scrollbars=no,resizable=yes,width=175,height=300,left=50,top=50');
	//myWindow.document.write('<html><head><title>');
	//myWindow.document.write('Jukebox');
	//myWindow.document.writeln('</title></head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');

	//OPTION #1 EMBEDS THE SWF IN THE NEW WINDOW -- WHICH DOESN'T APPEAR TO WORK			
	//myWindow.document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="175" height="273">');
	//myWindow.document.writeln('<param name="movie" value="'+url+'" />');
	//myWindow.document.writeln('<param name="quality" value="high" />');
	//myWindow.document.writeln('<embed src="'+url+'" quality="high" width="175" height="273" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />');
	//myWindow.document.writeln('</object>');

	//OPTION #2 USES AN IFRAME IN THE NEW WINDOW
	//myWindow.document.writeln('<iframe src="'+url+'" width="175" height="273" frameborder="0" marginheight="0" marginwidth="0">');
	//myWindow.document.writeln('</iframe>');

	//myWindow.document.writeln('</body></html>');
	//myWindow.document.close();
	//myWindow.focus;


	//OPTION #3 OPENS THE SWF DIRECTLY
	//newwindow=window.open(url,'jbox','width=175,height=300,scrollbars=no,resizable=yes');
	//if (window.focus) {newwindow.focus()}
	
	//OPTION #4 USES MODIFIED XML TO LOAD MP3 IN WIMPY PLAYER JUKEBOX
	var url = document.URL;
	var thisDir=url.substring(0,url.lastIndexOf("\/"));
	thisDir=thisDir.replace(/(complete|short|essentials)\//,"common\/");
	var myLink=url.substring(0,thisDir.lastIndexOf("common\/")) + "common/jukebox/jukebox.php?xf=" + myJbox;
	newwindow=window.open(myLink,'jbox','width=400,height=300,scrollbars=no,resizable=yes');
	if (window.focus) {newwindow.focus()}

	
}
function writeMenu(myBook, myMusic, myChap)
{
	if (myChap == -1) { //write generic menu
		//global
		document.writeln('<ul style="margin-top:20px;">');
		document.writeln('  <li id="podcasts"><a href="javascript:goPodcast()" title="Podcasts: Audio &amp; Video">Podcasts: Audio &amp; Video </a></li>');
		document.writeln('  <li id="search"><a href="javascript:goSearch('+myChap+')" title="Search the Site">Search the Site </a></li>');
		document.writeln('  <li id="progress"><a href="../index/chapters.htm" title="Progress Report">Progress Report</a></li>');
		document.writeln('</ul>');
		//Organize
		document.writeln('<h3 id="organize">Organize</h3>');
		document.writeln('<ul>');
		document.writeln('  <li><a href="../index/chapters.htm" title="Study Plan">Study Plan</a></li>');
		if (myBook == "short") {
			document.writeln('  <li class="lock"><a href="../index/chapters.htm" title="This Chapter in the eBook">eBook</a></li>');
		}
		document.writeln('  <li><a href="../index/chapters.htm" title="Chapter Outline">Chapter Outline</a></li>');
		document.writeln('</ul>');
		//Learn
		document.writeln('<h3 id="learn">Learn</h3>');
		document.writeln('<ul>');
		document.writeln('  <li class="lock"><a href="../index/chapters.htm" title="Listen &amp; Download">Listen &amp; Download</a></li>');
		document.writeln('  <li><a href="../index/chapters.htm" title="Flashcards">Flashcards</a></li>');
		document.writeln('  <li><a href="../index/chapters.htm" title="Chapter Quiz">Chapter Quiz</a></li>');
		document.writeln('</ul>');
		//Connect
		document.writeln('<h3 id="connect">Connect</h3>');
		document.writeln('<ul>');
		document.writeln('<li><a href="../index/chapters.htm" title="Composers">Composers</a></li>');
		document.writeln('  <li><a href="../index/eras_music.htm" title="Musical Eras">Musical Eras</a></li>');
		document.writeln('  <li><a href="../index/eras_persp.htm" title="Cultural Perspectives">Cultural Perspectives</a></li>');
		document.writeln('  <li><a href="../index/eras_trans.htm" title="Transitions">Transitions</a></li>');
		document.writeln('  <li><a href="../index/eras_timeline.htm" title="Timeline">Timeline</a></li>');
		document.writeln('  <li><a href="javascript:goGlossary()" title="Glossary">Glossary</a></li>');
		//if (myBook == "short") {
			document.writeln('  <li class="twoline"><a href="../materials/index.asp" title="Materials of Music">Materials of Music Interactive</a></li>');
		//} else {
		//	document.writeln('  <li><a href="../materials/momindex.htm" title="Materials of Music">Materials of Music</a></li>');
		//}
		document.writeln('</ul>');
	
	} else { // write chapter menu
	
		var myMusicProper =  findProper(myMusic); //myMusic.charAt(0).toUpperCase() + myMusic.substring(1, myMusic.length);
		//global
		document.writeln('<ul style="margin-top:20px;">');
		writeNextPrev(myBook, myChap);
		document.writeln('  <li id="hr"></li>');
		document.writeln('  <li id="podcasts"><a href="javascript:goPodcast()" title="Podcasts: Audio &amp; Video">Podcasts: Audio &amp; Video </a></li>');
		document.writeln('  <li id="search"><a href="javascript:goSearch(\''+myChap+'\')" title="Search the Site">Search the Site </a></li>');
		document.writeln('  <li id="progress"><a href="javascript:goProgress(\''+myChap+'\')" title="Progress Report">Progress Report</a></li>');
		document.writeln('</ul>');
		//Organize
		document.writeln('<h3 id="organize">Organize</h3>');
		document.writeln('<ul>');
		document.writeln('  <li><a href="javascript:goStudy(\''+myChap+'\')" title="Study Plan">Study Plan</a></li>');
		if (myBook == "short") {
			document.writeln('  <li class="lock"><a href="javascript:goeBook(\''+myChap+'\')" title="This Chapter in the eBook">eBook</a></li>');
		}
		document.writeln('  <li><a href="javascript:goOutline(\''+myChap+'\')" title="Chapter Outline">Chapter Outline</a></li>');
		document.writeln('</ul>');
		//Learn
		document.writeln('<h3 id="learn">Learn</h3>');
		document.writeln('<ul>');
		document.writeln('  <li class="lock"><a href="javascript:goListen(\''+myChap+'\')" title="Listen &amp; Download">Listen &amp; Download</a></li>');
		document.writeln('  <li><a href="javascript:goFlashcards(\''+myChap+'\')" title="Flashcards">Flashcards</a></li>');
		document.writeln('  <li><a href="javascript:goQuiz(\''+myChap+'\')" title="Chapter Quiz">Chapter Quiz</a></li>');
		document.writeln('</ul>');
		//Connect
		document.writeln('<h3 id="connect">Connect</h3>');
		document.writeln('<ul>');
		document.writeln('<li><a href="javascript:goComposers(\''+myChap+'\')" title="Composers">Composers</a></li>');
		document.writeln('  <li><a href="javascript:goMusic(\''+myChap+'\',\''+myMusic+'\')" title="'+((findProper(myMusic))? findProper(myMusic)+' Music' :'Musical Eras')+'">'+((findProper(myMusic))? findProper(myMusic)+' Music' :'Musical Eras')+'</a></li>');
		document.writeln('  <li><a href="javascript:goPerspectives(\''+myBook+'\',\''+myChap+'\',\''+myMusic+'\')" title="Cultural Perspectives">Cultural Perspectives</a></li>');
		document.writeln('  <li><a href="javascript:goTransitions(\''+myChap+'\',\''+myMusic+'\')" title="Transitions">Transitions</a></li>');
		document.writeln('  <li><a href="javascript:goTimeline(\''+myChap+'\',\''+myMusic+'\')" title="Timeline">Timeline</a></li>');
		document.writeln('  <li><a href="javascript:goGlossary()" title="Glossary">Glossary</a></li>');
		//if (myBook == "short") {
			document.writeln('  <li class="twoline"><a href="javascript:goMaterials(\''+myBook+'\',\''+myChap+'\',\''+myMusic+'\')" title="Materials of Music">Materials of Music Interactive</a></li>');
		//} else {
		//	document.writeln('  <li><a href="javascript:goMaterials(\''+myBook+'\',\''+myChap+'\',\''+myMusic+'\')" title="Materials of Music">Materials of Music</a></li>');
		//}
		
		document.writeln('</ul>');
	}
	//Multimedia?
	
}
function writeNextPrev (myBook, myChap)
{
	if (myBook == 'short') { //write generic menu
		switch (myChap) {
			case '00':
				document.writeln('  <li id="chapternav">&nbsp;&nbsp;&nbsp;&nbsp;Chapter <a href="javascript:goStudy(\'01\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '80':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'79\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter&nbsp;&nbsp;&nbsp;&nbsp;</li>');
				break;
			case '16':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'15\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'i\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case 'i':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'16\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'17\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '17':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'i\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'18\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '27':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'26\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'ii\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case 'ii':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'27\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'28\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '28':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'ii\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'29\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '39':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'38\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'iii\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case 'iii':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'39\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'40\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '40':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'iii\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'41\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '62':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'61\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'iv\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case 'iv':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'62\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'63\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '63':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'iv\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'64\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			default:
				nextChap = eval(myChap.valueOf()) + 1; //eval needed because it wasn't working on Composer & similar pages (with chap=## arg)
				//alert (nextChap);
				prevChap = myChap.valueOf() - 1;
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\''+((prevChap < 10)?'0'+prevChap:prevChap)+'\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\''+((nextChap < 10)?'0'+nextChap:nextChap)+'\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
		}
	} else { //myBook == 'complete'
		switch (myChap) {
			case '00':
				document.writeln('  <li id="chapternav">&nbsp;&nbsp;&nbsp;&nbsp;Chapter <a href="javascript:goStudy(\'01\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '88':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'87\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter&nbsp;&nbsp;&nbsp;&nbsp;</li>');
				break;
			case '16':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'15\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'i\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case 'i':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'16\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'17\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '17':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'i\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'18\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '27':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'26\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'ii\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case 'ii':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'27\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'28\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '28':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'ii\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'29\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '40':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'39\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'iii\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case 'iii':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'40\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'41\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '41':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'iii\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'42\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '67':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'66\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'iv\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case 'iv':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'67\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'68\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			case '68':
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\'iv\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\'69\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
			default:
				nextChap = eval(myChap.valueOf()) + 1; //eval needed because it wasn't working on Composer & similar pages (with chap=## arg)
				//alert (nextChap);
				prevChap = myChap.valueOf() - 1;
				document.writeln('  <li id="chapternav"><a href="javascript:goStudy(\''+((prevChap < 10)?'0'+prevChap:prevChap)+'\')" title="Previous Chapter">&nbsp;&lt;&nbsp;</a> Chapter <a href="javascript:goStudy(\''+((nextChap < 10)?'0'+nextChap:nextChap)+'\')" title="Next Chapter">&nbsp;&gt;&nbsp;</a></li>');
				break;
		}
	}
}
function writeStudy (myBook, myMusic, myChap)
{
	// write study page description
	
		var myMusicProper =  findProper(myMusic); //myMusic.charAt(0).toUpperCase() + myMusic.substring(1, myMusic.length);
		//global
		document.writeln('<p class="heading">ORGANIZE</p>');
		document.writeln('<ol>');
		if (myBook == "short") {
			document.writeln('<li>Read this chapter in your textbook, <i>The Enjoyment of Music, Shorter 10<sup>th</sup> edition</i>, or access this chapter\'s online <a href="javascript:goeBook(\''+myChap+'\')">eBook</a>.</li>');
		} else {
			document.writeln('<li>Read this chapter in your textbook, <i>The Enjoyment of Music, Complete 10<sup>th</sup> edition</i>.</li>');
		}
		document.writeln('<li>Print out the <a href="javascript:goOutline(\''+myChap+'\')">chapter outline</a> and check the items that your instructor has assigned or covered in class.  Then read the text closely to better understand the topics.</li>');
		document.writeln('<li>As you work through the other sections, don\'t forget to generate a <a href="javascript:goProgress(\''+myChap+'\')">Progress Report</a>.  Fill out the sections you have completed and send a copy to your email account.</li>');
		document.writeln('</ol>');


		document.writeln('<p class="heading">LEARN</p>');
		document.writeln('<ol>');
		document.writeln('<li>Listen to the online <a href="javascript:goListen(\''+myChap+'\')">selections</a> or use the Electronic Listening Guides from the Student Resource DVD to interact with the selections on your set of CDs.</li>');
		document.writeln('<li>Master the key events and terms for this chapter by working through the deck of  <a href="javascript:goFlashcards(\''+myChap+'\')">FlashCards</a>.  You can shuffle cards from earlier chapters, print them out or download them to your computer.</li>');
		document.writeln('<li>Take the <a href="javascript:goQuiz(\''+myChap+'\')">Chapter Quiz</a>.  You can email the results to your instructor\'s gradebook and track your progress in you own student gradebook.</li>');
		document.writeln('</ol>');

		document.writeln('<p class="heading">CONNECT</p>');
		document.writeln('<p>The following links access a number of additional resources.</p>');
		document.writeln('<ol>');
		document.writeln('<li><b><a href="javascript:goPerspectives(\''+myBook+'\',\''+myChap+'\',\''+myMusic+'\')">Cultural Perspectives</a></b> focus on music\'s connections to society, culture, politics, and technology.</li>');
		document.writeln('<li><b><a href="javascript:goTransitions(\''+myChap+'\',\''+myMusic+'\')">Transitions</a></b>.  These exercises help you connect the qualities, styles and composers with their correct musical era.</li>');
		document.writeln('<li><b><a href="javascript:goMusic(\''+myChap+'\',\''+myMusic+'\')">'+ ((findProper(myMusic))? findProper(myMusic)+' Music' :'Musical Eras') +'</a> </b>offers helpful hints as you approach the music of this era.</li>');
		document.writeln('<li>Use the <b><a href="javascript:goTimeline(\''+myChap+'\',\''+myMusic+'\')">Timeline</a></b> to connect musical events with other important cultural milestones for this era.</li>');
		document.writeln('</ol>');

		document.writeln('<p class="heading"><a href="javascript:goOLL()">Norton\'s Online Listening Lab</a></p>');
		document.writeln('<p class="heading"><a href="javascript:goMaterials(\''+myBook+'\',\''+myChap+'\',\''+myMusic+'\')">Materials of Music Interactive</a></p>');
		document.writeln('<p class="heading"><a href="javascript:goGlossary()">Glossary</a></p>');
	
}

function findMusic (myBook, myChap){
  myMusic = "";
  num = myChap.valueOf(); //eval(myChap.valueOf());
  
  if (myBook == "short") {
	  if ((num >= 11) && (num <= 13)) {
		myMusic = "middleages";
	  } else if ((num >= 14) && (num <= 16)) {
		myMusic = "renaissance";
	  } else if (((num >= 17) && (num <= 27)) || (myChap == "i")) {
		myMusic = "baroque";
	  } else if (((num >= 28) && (num <= 39)) || (myChap == "ii")) {
		myMusic = "classical";
	  } else if (((num >= 40) && (num <= 62)) || (myChap == "iii")) {
		myMusic = "romantic";
	  } else if (((num >= 63) && (num <= 74)) || (myChap == "iv")) {
		myMusic = "20century";
	  } else {
		myMusic = "eras";
	  }
  } else { //myBook == "complete"
	  if ((num >= 11) && (num <= 13)) {
		myMusic = "middleages";
	  } else if ((num >= 14) && (num <= 16)) {
		myMusic = "renaissance";
	  } else if (((num >= 17) && (num <= 27)) || (myChap == "i")) {
		myMusic = "baroque";
	  } else if (((num >= 28) && (num <= 40)) || (myChap == "ii")) {
		myMusic = "classical";
	  } else if (((num >= 41) && (num <= 67)) || (myChap == "iii")) {
		myMusic = "romantic";
	  } else if (((num >= 68) && (num <= 82)) || (myChap == "iv")) {
		myMusic = "20century";
	  } else {
		myMusic = "eras";
	  }
  }
  return myMusic;
}

function findProper(myMusic) {
//find proper name of given music name
	switch (myMusic) {
		case "middleages":
			return "Middle Ages";
			break;
		case "renaissance":
			return "Renaissance";
			break;
		case "baroque": 
			return "Baroque";
			break;
		case "classical": 
			return "Classical";
			break;
		case "romantic": 
			return "Romantic";
			break;
		case "20century": 
			return "20th Century";
			break;
		default:
			return false;
	}
}

//used in 'Transition' popups

function popUp2(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,left = 50,top = 50, width = 530, height = 350');");
}
//used in 'podcast' audio popups
function popUp(URL,dimW,dimH) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,left = 50,top = 50, width = "+dimW+", height = "+dimH+"');");
}
//used in 'podcast' video popups
function popUpPod(myURL,dimW,dimH) {
	day = new Date();
	id = day.getTime();
	
	
	var url = document.URL;
	var thisDir=url.substring(0,url.lastIndexOf("\/"));
	thisDir=thisDir.replace(/(complete|short)\//,"common\/");
	var myFLV=url.substring(0,thisDir.lastIndexOf("common\/")) + "common/podcast/" + myURL;
	var myFLVPlayer = url.substring(0,thisDir.lastIndexOf("common\/")) + "common/podcast/" + "flvplayer.swf?file=";
	
	
	//objType = myURL.split(".");
	//objType = objType[objType.length - 1];
	//objType = (objType=="mpg"||objType=="mpeg")?"video/mpeg":
	//                (objType=="avi"||objType=="wmv") ?"video/x-msvideo":"video/quicktime";
	//var pluginspage = (objType=="video/x-msvideo")?"http://www.microsoft.com/windows/windowsmedia/default.aspx":(objType=="video/quicktime")?"http://www.apple.com/quicktime/download/":"";
	//   var codebase = (objType=="video/x-msvideo")?"http://www.microsoft.com/windows/windowsmedia/default.aspx":(objType=="video/quicktime")?"http://www.apple.com/qtactivex/qtplugin.cab":"";
	
	//myWindow = window.open('','','toolbar=no,width='+(dimW+25)+',height='+(dimH+40)+',left=50,top=50');
	myWindow = window.open('','','toolbar=no,width=425,height=360,left=50,top=50');
	myWindow.document.write('<html><head><title>');
	myWindow.document.write('Media Player');
	myWindow.document.writeln('</title></head><body>');
			
	myWindow.document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="400" height="320" id="master" align="middle">');
	myWindow.document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	myWindow.document.writeln('<param name="movie" value="'+myFLVPlayer+myFLV+'" />');
	myWindow.document.writeln('<param name="quality" value="high" />');
	myWindow.document.writeln('<param name="bgcolor" value="#ffffff" />');
	myWindow.document.writeln('<embed src="'+myFLVPlayer+myFLV+'" quality="high" bgcolor="#ffffff" width="400" height="320" name="master" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	myWindow.document.writeln('</object>');
		
	myWindow.document.writeln('</body></html>');
	myWindow.document.close();
	myWindow.focus;
				
	//eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,left = 50,top = 50, width = " + dimW + ", height = " + dimH + "');");
}

//used to determine chapter # in unit pages (music, perspectives, transitions)
function getArgs() {
   var args = new Object();
   var query = location.search.substring(1); //Get query string.
   var pairs = query.split("&");             //Break at &
   for (var i = 0; i < pairs.length; i++) {
      var pos = pairs[i].indexOf('=');       //Look for "name=value".
      if (pos == -1) continue;               //If not found, skip.
      var argname = pairs[i].substring(0,pos);  //Extract the name.
      var value = pairs[i].substring(pos+1);    //Extract the value.

      //while (value.indexOf('+') > -1) {
        //value = value.substring(0,value.indexOf('+')) + '/' + value.substring(value.indexOf('+') + 1);
        // Replace each '+' in data string with a '/'.
      //}

      args[argname] = unescape(value);      //Store as a property.
   }
   return args;                            //Return the object.
}

function getChap(){
//	if !(currentChap) {
		var args = getArgs();
		if (args.chap) {
			//return args.chap.valueOf();
			return args.chap;
		} else {
			return -1;
		}
//	}
}



//General Pop up window script - Windows Media files

function flvFPW1(){//v1.44
// Copyright 2002-2004, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16;v11=new Array("width,left,"+v4,"height,top,"+v5);for (i=0;i<v11.length;i++){v12=v11[i].split(",");l_iTarget=parseInt(v12[2]);if (l_iTarget>1||v1[2].indexOf("%")>-1){v13=eval("screen."+v12[0]);for (v6=0;v6<v2.length;v6++){v10=v2[v6].split("=");if (v10[0]==v12[0]){v14=parseInt(v10[1]);if (v10[1].indexOf("%")>-1){v14=(v14/100)*v13;v2[v6]=v12[0]+"="+v14;}}if (v10[0]==v12[1]){v16=parseInt(v10[1]);v15=v6;}}if (l_iTarget==2){v7=(v13-v14)/2;v15=v2.length;}else if (l_iTarget==3){v7=v13-v14-v16;}v2[v15]=v12[1]+"="+v7;}}v8=v2.join(",");v9=window.open(v1[0],v1[1],v8);if (v3){v9.focus();}document.MM_returnValue=false;return v9;}
