// JavaScript Document - functions for displaying episode lists & descriptions

// fills in an entire list of episodes for a given season;
// the "season" variable indicates the number of each season,
// and "listID" the DIV in which its description is stored
function fillSection(season,listID){
     var mySeason; // determine which season we are displaying
	 var arrowID; // determine ID of arrow preceding each episode number and title
	 var newContent='<p>'+season_summary[season]+'</p><ul>'; // start with summary of season
	 var seasonLength;
	 // determine how many episodes are in each season
	 if ((season==1)||(season==5)||(season==6)||(season==11))
	 { seasonLength=13; } // seasons 1, 5, 6 and 11 each have 13 episodes
	 else if (season==2) { seasonLength=15; } // season 2 has 15 episodes
	 else { seasonLength=20; } // all other seasons are 20 episode sets
	 mySeason=document.getElementById(listID); // get ID for season being displayed
	 // repeat this procedure for each individual episode in that season
	 for (i=1; i<(seasonLength+1); i++){
		 var k;
	     if (i<10) { k = season+'0'+i; } // list episode numbers as they appear in show descriptions (eg. 101, 102, etc.)
	     else { k = season+''+i; }
		 if (k=='610'){ i++; } // skip episode 610, since it is part of 609
		 if (k=='819'){ i++; } // skip episode 819, since it is part of 818
		 arrowID = 'arrow'+k; // assign ID to arrow preceding each episode number and title
	     function1 = "showDescription("+season+","+i+",'"+k+"','"+arrowID+"')"; // display a full description of the show as its title is being moused over 
	     function2 = "hideDescription('"+k+"')"; // hide description on mouse out
         newContent=newContent+'<li><a href="#" onMouseOver="'+function1+'" onMouseOut="'+function2+'">'; // set link up for mouseover and mouseout functions
		 newContent=newContent+'<img name="'+arrowID+'" border="0" src="images/arrow.jpg"> '; // add arrow on left
		 // print episode number and title after arrow (choose by episode number and season)
		 if (season==1) { newContent=newContent+'Episode '+season1_title[i]; }
	     if (season==2) { newContent=newContent+'Episode '+season2_title[i]; }
	     if (season==3) { newContent=newContent+'Episode '+season3_title[i]; }
	     if (season==4) { newContent=newContent+'Episode '+season4_title[i]; }
	     if (season==5) { newContent=newContent+'Episode '+season5_title[i]; }
	     if (season==6) { // list episode 609/610 as a double episode
		     if (k=='609') { newContent=newContent+'Episodes '+season6_title[i]; }
		     else { newContent=newContent+'Episode '+season6_title[i]; }}
	     if (season==7) { newContent=newContent+'Episode '+season7_title[i]; }
	     if (season==8) { // episode 818/819 is also a double episode
		     if (k=='818') { newContent=newContent+'Episodes '+season8_title[i]; }
		     else { newContent=newContent+'Episode '+season8_title[i]; }}
	     if (season==9) { newContent=newContent+'Episode '+season9_title[i]; }
	     if (season==10) { newContent=newContent+'Episode '+season10_title[i]; }
	     if (season==11) { newContent=newContent+'Episode '+season11_title[i]; }
		 newContent=newContent+'</a><span id="'+k+'"></span><br>&nbsp;</li>';
		 //end of each episode link; follow with the span in which the episode description will be stored
	 }
	 newContent=newContent+'</ul>';// end of episode list
	 newContent=newContent+'<p>'+season_price+'<br><br>'+episode_price+'</p>'; // price descriptions follow	 
	 closeFunction="txtRestore('"+listID+"')"; // function to close episode list
	 buyFunction="return gotoStore('"+listID+"')"; // function to go to store
	 // both functions are accessed by buttons at the very bottom of the season description
	 newContent=newContent+'<p align="center"><a class="closeBtn" href="#seasons" onClick="'+closeFunction+'">Close List</a>';
	 newContent=newContent+'&nbsp;&nbsp;&nbsp;&nbsp;<a class="closeBtn" href="javascript: void();" onClick="'+buyFunction+'">Buy Now</a></p>';
	 newContent=newContent+'<p>&nbsp;</p>'; // add extra space below buttons
	 mySeason.innerHTML=newContent; // finalize season description
}
// fills in an entire list of episodes for a "best of" or "special" boxed set
function fillBoxSet(boxSet,listID,firstEp,lastEp){
     var mySet; // indicate which set we are displaying
	 var arrowID; // arrow ID as for season box sets
	 var textID; // indicate individual episode description
	 // start with main description for boxed set
	 var newContent='<p>';
	 if (listID=='BClist') { newContent=newContent+BCsummary[1]; } // Best of BC description
	 if (listID=='BClist2') { newContent=newContent+BCsummary[2]; } // Best of BC, Part 2
	 if (listID=='BClist3') { newContent=newContent+BCsummary[3]; } // Best of BC, Part 3
	 if (listID=='VIlist') { newContent=newContent+VIsummary; } // Best of Vancouver Island description
	 if (listID=='YukonShows') { newContent=newContent+YKsummary; } // Best of the Yukon
	 if (listID=='NWTshows') { newContent=newContent+NWTsummary; } // Best of NWT
	 if (listID=='SaskShows') { newContent=newContent+SKsummary; } // Best of Saskatchewan
	 if (listID=='OntShows') { newContent=newContent+ONsummary; } // Best of Ontario
	 if (listID=='QuebecShows') { newContent=newContent+PQsummary; } // Best of Quebec
	 if (listID=='MarShows') { newContent=newContent+MRsummary; } // Best of the Maritimes
	 if (listID=='seeker') { newContent=newContent+GSsummary; } // Goldseekers description
	 if (listID=='ghosts1') { newContent=newContent+GTsummary[1]; } // Ghost Towns descriptions
	 if (listID=='ghosts2') { newContent=newContent+GTsummary[2]; }
	 if (listID=='bush1') { newContent=newContent+BFsummary[1]; } // Bush Flying sets
	 if (listID=='bush2') { newContent=newContent+BFsummary[2]; }
	 if (listID=='aviation') { newContent=newContent+AVsummary; } // Canadian Aviators set
	 newContent=newContent+'</p><ul>'; // end set description, begin list of episodes
	 // get episode list for box set
	 mySet=document.getElementById(listID); // get ID for box set being displayed
	 // repeat below for each individual episode
	 for (i=firstEp; i<(lastEp+1); i++){
		 var season; // episode by season
		 var ep; // episode by number
		 arrowID = boxSet+i; // ID for arrow at beginning of title
		 textID = boxSet+'txt'+i; // start with each episode number
		 if (boxSet=='BC') { season=parseInt(BCepisode[i]/100); ep=(BCepisode[i]-(season*100)); }
		 if (boxSet=='VI') { season=parseInt(VIepisode[i]/100); ep=(VIepisode[i]-(season*100)); }
	     if (boxSet=='Sask') { season=parseInt(SKepisode[i]/100); ep=(SKepisode[i]-(season*100)); }
	     if (boxSet=='YK') { season=parseInt(YKepisode[i]/100); ep=(YKepisode[i]-(season*100)); }
	     if (boxSet=='NWT') { season=parseInt(NWTepisode[i]/100); ep=(NWTepisode[i]-(season*100)); }
	     if (boxSet=='Ontario') { season=parseInt(ONepisode[i]/100); ep=(ONepisode[i]-(season*100)); }
	     if (boxSet=='Quebec') { season=parseInt(PQepisode[i]/100); ep=(PQepisode[i]-(season*100)); }
	     if (boxSet=='Maritime') { season=parseInt(MRepisode[i]/100); ep=(MRepisode[i]-(season*100)); }
	     if (boxSet=='aviators') { season=parseInt(AVepisode[i]/100); ep=(AVepisode[i]-(season*100)); }
	     if (boxSet=='Bush') { season=parseInt(BFepisode[i]/100); ep=(BFepisode[i]-(season*100)); }
	     if (boxSet=='Ghost') { season=parseInt(GTepisode[i]/100); ep=(GTepisode[i]-(season*100)); }
	     if (boxSet=='gold') { season=parseInt(GSepisode[i]/100); ep=(GSepisode[i]-(season*100)); }
	     // set each episode listing to show its description on mouseover, hide it on mouseout
		 function1 = "showDescription("+season+","+ep+",'"+textID+"','"+arrowID+"')";
	     function2 = "hideDescription('"+textID+"')";
         newContent=newContent+'<li><a href="#" onMouseOver="'+function1+'" onMouseOut="'+function2+'">';
		 newContent=newContent+'<img name="'+arrowID+'" border="0" src="images/arrow.jpg"> ';
		 // print number and title of each episode
		 if (boxSet=='BC') { newContent=newContent+'Episode '+BestOfBC[i]; }
		 if (boxSet=='VI') { newContent=newContent+'Episode '+BestOfVI[i]; }
	     if (boxSet=='Sask') { newContent=newContent+'Episode '+BestOfSask[i]; }
	     if (boxSet=='YK') { newContent=newContent+'Episode '+BestOfYukon[i]; }
	     if (boxSet=='NWT') { newContent=newContent+'Episode '+BestOfNWT[i]; }
	     if (boxSet=='Ontario') { newContent=newContent+'Episode '+BestOfOnt[i]; }
	     if (boxSet=='Quebec') { newContent=newContent+'Episode '+BestOfQuebec[i]; }
	     if (boxSet=='Maritime') { newContent=newContent+'Episode '+Maritimers[i]; }
	     if (boxSet=='aviators') { newContent=newContent+'Episode '+Aviators[i]; }
	     if (boxSet=='Bush') { newContent=newContent+'Episode '+BushFlying[i]; }
	     if (boxSet=='Ghost') { newContent=newContent+'Episode '+GhostTowns[i]; }
	     if (boxSet=='gold') { newContent=newContent+'Episode '+Goldseekers[i]; }
		 // add description cell for each episode
		 newContent=newContent+'</a><span id="'+textID+'"></span><br>&nbsp;</li>';
	 }
	 newContent=newContent+'</ul>'; // end episode list
	 // if in the Wings Over Canada store, also list the price of the set
		 newContent=newContent+'<p>';
	     if (listID=='BClist'){ newContent=newContent+BCprice[1]; }
	     if (listID=='BClist2') { newContent=newContent+BCprice[2]; }
	     if (listID=='BClist3') { newContent=newContent+BCprice[3]; }
	     if (listID=='VIlist') { newContent=newContent+VIprice; }
	     if (listID=='YukonShows') { newContent=newContent+YKprice; }
	     if (listID=='NWTshows') { newContent=newContent+NWTprice; }
	     if (listID=='SaskShows') { newContent=newContent+SKprice; }
	     if (listID=='OntShows') {newContent=newContent+ONprice; }
	     if (listID=='QuebecShows') { newContent=newContent+PQprice; }
	     if (listID=='MarShows') { newContent=newContent+MRprice; }
	     if (listID=='seeker') { newContent=newContent+GSprice; }
	     if (listID=='ghosts1') { newContent=newContent+GTprice[1]; }
	     if (listID=='ghosts2') { newContent=newContent+GTprice[2]; }
	     if (listID=='bush1') { newContent=newContent+BFprice[1]; }
	     if (listID=='bush2') { newContent=newContent+BFprice[2]; }
	     if (listID=='aviation') { newContent=newContent+AVprice; }	
	     newContent=newContent+'</p>';		
	 // last, but not least, the "Close List" and "Buy Now" (go to store) buttons
	 closeFunction="txtRestore('"+listID+"')";
	 buyFunction="return gotoStore('"+listID+"')";
	 newContent=newContent+'<p align="center"><a class="closeBtn" href="#seasons" onClick="'+closeFunction+'">Close List</a>';
	 newContent=newContent+'&nbsp;&nbsp;&nbsp;&nbsp;<a class="closeBtn" href="javascript: void();" onClick="'+buyFunction+'">Buy Now</a></p>';
	 newContent=newContent+'<p>&nbsp;</p>';
	 mySet.innerHTML=newContent; // finalize content
}

// fills in episodes for a town boxed set (eg.: Kitsault or Ocean Falls)
function townBoxSet(townID){
     var mySet; // indicate which town
	 var arrowID; // arrow ID for each episode
	 var textID; // ID for episode description content
	 // get summary for town set on display
	 var newContent='<p>';
	 if (townID=='kitsault') { newContent=newContent+kits_summary; }
	 if (townID=='ocean_falls') { newContent=newContent+falls_summary; }
	 newContent=newContent+'</p><ul>'; // end summary; begin list of episodes
	 mySet=document.getElementById(townID); // get ID for DIV to be filled
	 // repeat this procedure for each individual episode
	 for (i=1; i<4; i++){
		 var season; // season number for episode
		 var ep; // episode number
		 // Ocean Falls is only 2 episodes long, so list third episode only for the Kitsault set
		 if ((i<3)||(townID=='kitsault')){
		 arrowID = townID+i; // identify arrow on left
		 textID = townID+'txt'+i; // indicate ID for episode description
		 // get episode & season number to find description
		 if (townID=='kitsault') { season=parseInt(kitsault_ep[i]/100); ep=(kitsault_ep[i]-(season*100)); }
		 if (townID=='ocean_falls') { season=parseInt(ocean_falls_ep[i]/100); ep=(ocean_falls_ep[i]-(season*100)); }
	     // program to open episode descriptions on mouseover, hide them on mouseout
		 function1 = "showDescription("+season+","+ep+",'"+textID+"','"+arrowID+"')";
	     function2 = "hideDescription('"+textID+"')";
         newContent=newContent+'<li><a href="#" onMouseOver="'+function1+'" onMouseOut="'+function2+'">';
		 newContent=newContent+'<img name="'+arrowID+'" border="0" src="images/arrow.jpg"> '; // arrow on left
		 // display episode number and title
		 if (townID=='kitsault') { newContent=newContent+'Episode '+kitsault_title[i]; }
		 if (townID=='ocean_falls') { newContent=newContent+'Episode '+ocean_falls_title[i]; }
		 newContent=newContent+'</a><span id="'+textID+'"></span><br>&nbsp;</li>'; // display episode description
	 }}
	 newContent=newContent+'</ul>'; // end episode list
	 // display price description for set
	 newContent=newContent+'<p>';
	 if (townID=='kitsault') { newContent=newContent+kits_price; }
	 if (townID=='ocean_falls') { newContent=newContent+falls_price; }
	 newContent=newContent+'</p>';	
	 // "Close List" and "Buy Now" buttons
	 closeFunction="txtRestore('"+townID+"')";
	 buyFunction="return gotoStore('"+townID+"')";
	 newContent=newContent+'<p align="center"><a class="closeBtn" href="#seasons" onClick="'+closeFunction+'">Close List</a>';
	 newContent=newContent+'&nbsp;&nbsp;&nbsp;&nbsp;<a class="closeBtn" href="javascript: void();" onClick="'+buyFunction+'">Buy Now</a></p>';
	 newContent=newContent+'<p>&nbsp;</p>';
	 mySet.innerHTML=newContent; // finalize list
}

// gets the individual description for each episode
function showDescription(season,episode,textID,imageID){
     var myText; // indicate which episode description to fill
	 var newString; // content for description cell
	 myText=document.getElementById(textID); // get ID for description cell
	 MM_swapImage(imageID,'','images/redArrow.jpg',1); // arrow turns red as title is moused over
	 // get episode # by season
     if (season==1)
	  { newString='<br>'+season1[episode]; // insert description on line directly below title
	  }
	 if (season==2)
	  { newString='<br>'+season2[episode];
	  }
	 if (season==3)
	  { newString='<br>'+season3[episode];
	  }
	 if (season==4)
	  { newString='<br>'+season4[episode];
	  }
	 if (season==5)
	  { newString='<br>'+season5[episode];
	  }
	 if (season==6)
	  { newString='<br>'+season6[episode];
	  }
	 if (season==7)
	  { newString='<br>'+season7[episode];
	  }
	 if (season==8)
	  { newString='<br>'+season8[episode];
	  }
	 if (season==9)
	  { newString='<br>'+season9[episode];
	  }
	 if (season==10)
	  { newString='<br>'+season10[episode];
	  }
	 if (season==11)
	  { newString='<br>'+season11[episode];
	  }
	 myText.innerHTML=newString; // assign content to description cell
}
// hides the content of an episode description
function hideDescription(textID){
     var myText; // indicate element to be emptied
	 myText=document.getElementById(textID);
	 myText.innerHTML=''; // empty content
	 MM_swapImgRestore(); // restore arrow to original colour
}

// fills the entire "One-Hour Specials" list
function fillSpecial(listID){
     var mySection;
	 mySection=document.getElementById(listID); // identify DIV to store the list in
	 var arrowID; // identify arrow for each individual title
	 var k;
	 var newContent='<p>'+special_summary; // summarize general description for one-hour specials
	 newContent=newContent+'</p><ul>'; // end general description, begin list of specials
	 // repeat for each individual special
	 for (i=0; i<6; i++) {
		 k = 'special_item'+i; // indicate which special is being moused over
		 arrowID = 'special_arrow'+i; // identify arrow to the left of each title		 
	     function1 = "showSpecial("+i+",'"+k+"','"+arrowID+"')"; // display each special description on mouseover
	     function2 = "hideDescription('"+k+"')"; // hide on mouseout
		 // indicate functions in link description
         newContent=newContent+'<li><a href="#" onMouseOver="'+function1+'" onMouseOut="'+function2+'">';
		 newContent=newContent+'<img name="'+arrowID+'" border="0" src="images/arrow.jpg"> '; // print arrow
		 newContent=newContent+special_title[i]; // print title of one-hour special
		 newContent=newContent+'</a><span id="'+k+'"></span><br>&nbsp;</li>';
		 // end link, assign cell for special's description
	 }
	 newContent=newContent+'</ul>'; // end list of specials
	 newContent=newContent+'<p>'+special_price+'</p>'; // price description for each one-hour special
	 // "Close List" & "Buy Now" buttons
	 closeFunction="txtRestore('"+listID+"')";
	 buyFunction="return gotoStore('"+listID+"')";
	 newContent=newContent+'<p align="center"><a class="closeBtn" href="#seasons" onClick="'+closeFunction+'">Close List</a>';
	 newContent=newContent+'&nbsp;&nbsp;&nbsp;&nbsp;<a class="closeBtn" href="javascript: void();" onClick="'+buyFunction+'">Buy Now</a></p>';
	 newContent=newContent+'<p>&nbsp;</p>'; // space at bottom
	 mySection.innerHTML=newContent; // finalize content
}
// gets the individual description for each one-hour special
function showSpecial(specialNum,textID,arrowID){
     var myText;
	 var newString;
	 myText=document.getElementById(textID); // identify which text field is being filled
	 MM_swapImage(arrowID,'','images/redArrow.jpg',1); // arrow turns red on mouseover
	 newString=special[specialNum]; // get description of special by number
	 myText.innerHTML=newString; // assign content to text field
}

// description for each merchandise item
function showMerchandise(itemNum,textID){
     var myText;
	 var newString;
	 myText=document.getElementById(textID); // identify which item is on display
	 newString='<p>'+merchandise[itemNum]+'</p>'; // get description for item
	 newString=newString+'<p>'+merchant_price[itemNum]+'</p>'; // list price details for item
	 // "Close List" and "Buy Now" buttons
	 closeFunction="txtRestore('"+textID+"')";
	 buyFunction="return gotoStore('"+textID+"')";
	 newString=newString+'<p align="center"><a class="closeBtn" href="#seasons" onClick="'+closeFunction+'">Close List</a>';
	 newString=newString+'&nbsp;&nbsp;&nbsp;&nbsp;<a class="closeBtn" href="javascript: void();" onClick="'+buyFunction+'">Buy Now</a></div>';
	 newString=newString+'</p>'; // end of item description
	 myText.innerHTML=newString; // finalize content
}

// hides the content of an HTML tag (without the arrow in it)
function txtRestore(textID){
     var myText;
	 myText=document.getElementById(textID); // indicate which cell to empty
	 myText.innerHTML=''; // empty content
}


// go to the DVD store and buy item
function gotoStore(listID) {
	 if (listID == 'DGTlist') {
		    try { window.location.href = "store_special.html#DGT"; } // go to season 1 in store
	        catch(e) { document.location.href = "store_special.html#DGT"; }
	 }
	 if (listID == 'DGTlist2') {
		    try { window.location.href = "store_special.html#DGT2"; } // go to season 1 in store
	        catch(e) { document.location.href = "store_special.html#DGT2"; }
	 }
	 if (listID == 'np') {
		    try { window.location.href = "store_special.html#portraits"; } // go to season 1 in store
	        catch(e) { document.location.href = "store_special.html#portraits"; }
	 }
	 if ((listID == 'canadianBios') || (listID == 'southAsian')) {
		    try { window.location.href = "store_special.html#biomoments"; } // go to season 1 in store
	        catch(e) { document.location.href = "store_special.html#biomoments"; }
	 }
	 if (listID == 'first') {
		    try { window.location.href = "store_eps.html#season1"; } // go to season 1 in store
	        catch(e) { document.location.href = "store_eps.html#season1"; }
	 }
	 if (listID == 'second') {
		    try { window.location.href = "store_eps.html#season2"; } // go to season 2 in store
	        catch(e) { document.location.href = "store_eps.html#season2"; }
	 }
	 if (listID == 'third') {
		    try { window.location.href = "store_eps.html#season3"; } // go to season 3 in store
	        catch(e) { document.location.href = "store_eps.html#season3"; }
	 }
	 if (listID == 'fourth') {
		    try { window.location.href = "store_eps.html#season4"; } // go to season 4 in store
	        catch(e) { document.location.href = "store_eps.html#season4"; }
	 }
	 if (listID == 'fifth') {
		    try { window.location.href = "store_eps.html#season5"; } // go to season 5 in store
	        catch(e) { document.location.href = "store_eps.html#season5"; }
	 }
	 if (listID == 'sixth') {
		    try { window.location.href = "store_eps.html#season6"; } // go to season 6 in store
	        catch(e) { document.location.href = "store_eps.html#season6"; }
	 }
	 if (listID == 'seventh') {
		    try { window.location.href = "store_eps.html#season7"; } // go to season 7 in store
	        catch(e) { document.location.href = "store_eps.html#season7"; }
	 }
	 if (listID == 'eighth') {
		    try { window.location.href = "store_eps.html#season8"; } // go to season 8 in store
	        catch(e) { document.location.href = "store_eps.html#season8"; }
	 }
	 if (listID == 'ninth') {
		    try { window.location.href = "store_eps.html#season9"; } // go to season 9 in store
	        catch(e) { document.location.href = "store_eps.html#season9"; }
	 }
	 if (listID == 'tenth') {
		    try { window.location.href = "store_eps.html#season10"; } // go to season 10 in store
	        catch(e) { document.location.href = "store_eps.html#season10"; }
	 }
	 if (listID == 'eleven') {
		    try { window.location.href = "store_eps.html#season11"; } // go to season 11 in store
	        catch(e) { document.location.href = "store_eps.html#season11"; }
	 }
	 if (listID == 'BClist') {
		    try { window.location.href = "store_best_of.html#BC"; } // go to Best of BC box sets
	        catch(e) { document.location.href = "store_best_of.html#BC"; }
	 }
	 if ((listID == 'BClist2') || (listID == 'BClist3')) {
		    try { window.location.href = "store_best_of.html#BC"; } // go to Best of BC box sets
	        catch(e) { document.location.href = "store_best_of.html#BC"; }
	 }
	 if (listID == 'VIlist') {
		    try { window.location.href = "store_best_of.html#vanIsland"; } // go to Vancouver Island box set
	        catch(e) { document.location.href = "store_best_of.html#vanIsland"; }
	 }
	 if ((listID == 'YukonShows') || (listID == 'NWTshows') || (listID == 'SaskShows')) {
		    try { window.location.href = "store_best_of.html#Yukon"; } // go to Yukon box set
	        catch(e) { document.location.href = "store_best_of.html#Yukon"; }
	 }
	 if ((listID == 'OntShows') || (listID == 'QuebecShows') || (listID == 'MarShows')) {
		    try { window.location.href = "store_best_of.html#Ontario"; } // go to Ontario, Quebec & Maritime box set
	        catch(e) { document.location.href = "store_best_of.html#Ontario"; }
	 }
	 if (listID == 'seeker') {
		    try { window.location.href = "store_special.html#gold"; } // go to Goldseeker box set
	        catch(e) { document.location.href = "store_special.html#gold"; }
	 }
	 if ((listID == 'ghosts1') || (listID == 'ghosts2')) {
		    try { window.location.href = "store_special.html#ghost"; } // go to Ghost Town box sets
	        catch(e) { document.location.href = "store_special.html#ghost"; }
	 }
	 if ((listID == 'bush1') || (listID == 'bush2')) {
		    try { window.location.href = "store_special.html#bf"; } // go to Bush Flying box sets
	        catch(e) { document.location.href = "store_special.html#bf"; }
	 }
	 if (listID == 'aviation') {
		    try { window.location.href = "store_special.html#aviators"; } // go to Canadian Aviator box set
	        catch(e) { document.location.href = "store_special.html#aviators"; }
	 }
	 if (listID == 'specials') {
		    try { window.location.href = "store_special.html#specials"; } // go to One-Hour Specials
	        catch(e) { document.location.href = "store_special.html#specials"; }
	 }
	 if (listID == 'hats') {
		    try { window.location.href = "store_special.html#hats"; } // go to hat item in store
	        catch(e) { document.location.href = "store_special.html#hats"; }
	 }
	 if ((listID == 'vests') || (listID == 'shirts')) {
		    try { window.location.href = "store_special.html#vests"; } // go to polo shirt & vest descrptions
	        catch(e) { document.location.href = "store_special.html#vests"; }
	 }
	 if (listID == 'kitsault') {
		    try { window.location.href = "store_best_of.html#kits"; } // go to "Best of Kitsault" box set
	        catch(e) { document.location.href = "store_best_of.html#kits"; }
	 }
	 if (listID == 'ocean_falls') {
		    try { window.location.href = "store_special.html#ocean"; } // go to Ocean Falls box set
	        catch(e) { document.location.href = "store_special.html#ocean"; }
	 }
     return true; // make sure this function works; a "return false" will keep our site user on the "Catalog" page
}

// use in any link from the Store to the Catalog section
function getBoxSet(CookieValue) {
   createCookie('listname',CookieValue,0); // create cookie to determine which list will be opened in Catalog
   CookieValue=readCookie('listname');
   try { window.location.href = 'catalog.html'; } // go to Catalog page
   catch(e) { document.location.href = 'catalog.html'; }
   return true;
}//-->
// function to open a pre-selected box set description when sent to Catalog from Store
function openList() {
   CookieValue=readCookie('listname'); // list ID is stored in a cookie
   if (CookieValue == 'specials') { // open list for One-Hour Specials
	 fillSpecial('specials');
	 try { window.location.href = '#onehour'; } // move to One-hour Specials position in catalog
	 catch(e) { document.location.href = '#onehour'; }
   }
   if (CookieValue == 'DGT') { // open list for Discovering Great Towns Season 1
	 fillDGT('DGTlist',1);
	 try { window.location.href = '#DGT'; } // move to DGT position in catalog
	 catch(e) { document.location.href = '#DGT'; }
   }
   if (CookieValue == 'DGT2') { // open list for Discovering Great Towns Season 2
	 fillDGT('DGTlist2',2);
	 try { window.location.href = '#DGT2'; } // move to DGT position in catalog
	 catch(e) { document.location.href = '#DGT2'; }
   }
   if (CookieValue == 'BC') {
	 fillBoxSet('BC','BClist',1,9); // open all three Best of BC box set descriptions
	 fillBoxSet('BC','BClist2',10,15);
	 fillBoxSet('BC','BClist3',16,21);
	 try { window.location.href = '#BC'; } // move to BC position in catalog
	 catch(e) { document.location.href = '#BC'; }
   }
   if (CookieValue == 'bush') {
	 fillBoxSet('Bush','bush1',1,4); // open both Bush Flying set descriptions
	 fillBoxSet('Bush','bush2',5,8);
	 try { window.location.href = '#Bush'; } // move to position in catalog
	 catch(e) { document.location.href = '#Bush'; }
   }
   if (CookieValue == 'first') { // open each seasonal description individually & move into position
	 fillSection(1,'first');
	 try { window.location.href = '#seasons'; }
	 catch(e) { document.location.href = '#seasons'; }
   }
   if (CookieValue == 'second') {
	 fillSection(2,'second');
	 try { window.location.href = '#season2'; }
	 catch(e) { document.location.href = '#season2'; }
   }
   if (CookieValue == 'third') {
	 fillSection(3,'third');
	 try { window.location.href = '#season3'; }
	 catch(e) { document.location.href = '#season3'; }
   }
   if (CookieValue == 'fourth') {
	 fillSection(4,'fourth');
	 try { window.location.href = '#season4'; }
	 catch(e) { document.location.href = '#season4'; }
   }
   if (CookieValue == 'fifth') {
	 fillSection(5,'fifth');
	 try { window.location.href = '#season5'; }
	 catch(e) { document.location.href = '#season5'; }
   }
   if (CookieValue == 'sixth') {
	 fillSection(6,'sixth');
	 try { window.location.href = '#season6'; }
	 catch(e) { document.location.href = '#season6'; }
   }
   if (CookieValue == 'seventh') {
	 fillSection(7,'seventh');
	 try { window.location.href = '#season7'; }
	 catch(e) { document.location.href = '#season7'; }
   }
   if (CookieValue == 'eighth') {
	 fillSection(8,'eighth');
	 try { window.location.href = '#season8'; }
	 catch(e) { document.location.href = '#season8'; }
   }
   if (CookieValue == 'ninth') {
	 fillSection(9,'ninth');
	 try { window.location.href = '#season9'; }
	 catch(e) { document.location.href = '#season9'; }
   }
   else if (CookieValue == 'tenth') {
	 fillSection(10,'tenth');
	 try { window.location.href = '#season10'; }
	 catch(e) { document.location.href = '#season10'; }
   }
   else if (CookieValue == 'eleven') {
     fillSection(11,'eleven');
	 try { window.location.href = '#season11'; }
	 catch(e) { document.location.href = '#season11'; }
   }
   else { return false; } // return false if link from store is not legit
   //createCookie('listname','',0); // clear cookie
   return true; // otherwise return true
}

// use any time a value needs to be passed from one page to another
function createCookie(name,value,days) {
     if (days)
	 { var date=new Date();
	    date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTstring();
		} else var expires ="";
		document.cookie = name+"="+value+expires+"; path=/";
}

// use to read the required cookie
function readCookie(name){
    var nameEQ = name + "=";
	var ca =document.cookie.split(";");
	for (var i=0;  i<ca.length; i++) {
	     var c = ca[i];
		 while (c.charAt(0)===" ")  { c= c.substring(1, c.length); }
		 if (c.indexOf(nameEQ)==0) { return c.substring(nameEQ.length, c.length); }
	}
	return null;
}


