
function myreload() {window.location.reload()}
window.onresize=myreload; // note no round brackets!!

parent.safetolook=true;
function thatsitguys() {
 if (parent) {parent.safetolook=false}
}
self.onunload=thatsitguys;

function pulldownactivitymenu() {
	document.write('<br><dl><dt><center><form METHOD="GET" name="activityform">');
	document.write('<select name="activity" size=1 ');
	document.write('onChange="if(options[selectedIndex].value){if(\'#\'!=options[selectedIndex].value){window.location.href=(options[selectedIndex].value)}else{document.forms.activityform.activity.options[0].selected=true}}">');
	document.write('<option value="#" selected>Select another activity...</option>');
	document.write('<option value="#">-------------------</option>');
	document.write('<option value="activities.html#The Three Strands">The Three Strands</option>');
	document.write('<option value="ssnoverview.html">Overview of this Strand</option>');
	document.write('<option value="starstory.html">Star Story Book</option>');
	document.write('<option value="#" selected>-------------------</option>');
	document.write('<option value="landmarks.html">1. Landmarks</option>');
	document.write('<option value="starcompass.html">2. The Stars as a Compass</option>');
	document.write('<option value="makestarwheel.html">3. Make a Star Wheel</option>');
	document.write('<option value="chasingstars.html">4. Chasing the Stars</option>');
	document.write('<option value="undermilkway.html">5. Under the Milky Way</option>');
	document.write('<option value="planethitlist.html">6. Planet Hit List</option>');
	document.write('<option value="shiftingstars.html">7. The Shifting Stars</option>');
	document.write('<option value="jewelsofthesky.html">8. Jewels of the Sky</option>');
	document.write('<option value="rollercoaster.html">9. Roller Coaster Stars</option>');
	document.write('</select></form></center></dt></dl>');
}

function stripafterdot(loc) { 
    	var begin = loc.indexOf('\.');       
	if (begin == -1)
		{ return (loc) }
	else	{ begin++;
		  return (loc.substring(begin,loc.length))}
	}

function stripfromhash(loc) { 
    	var begin = loc.indexOf('\#');       
	if (begin == -1)
		{ return (loc) }
	else	{ return (loc.substring(0,begin))	}
  }

function write_first_3_unencoded(textstring){
var l = 0;
for(var i=0;i<textstring.length;++i) {
	var ch = textstring.charAt(i);
	if (ch == '+') { document.write(' ') }
	else if (ch == '|') { 
		l++; 
		if (l <= 3 ) { document.write('<BR>') }; 
		if (l >= 3) {i = 999}
	}
	else if (ch == '<') { document.write('&lt;') }
	else if (ch == '%') { 
		document.write('&#x') ;
		i++;
		document.write(textstring.substring(i,i+2)+';');
		i++;
	}
	else { document.write(ch) }
}}

function writeAIYHCookie() {
  var cname = "AIYH=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        write_first_3_unencoded((dc.substring(begin, end)));
    } 
    else { document.write('This page is protected by copyright.<BR>Copies may be downloaded and<BR>printed for private use only.'); }
  }
  else { document.write('This page is protected by copyright.<BR>Copies may be downloaded and<BR>printed for private use only.'); }
}

function writeAIYHCookieNocopyright() {
  var cname = "AIYH=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        write_first_3_unencoded((dc.substring(begin, end)));
    } 
    else { document.write('&nbsp;<BR>&nbsp;<BR>&nbsp;'); }
  }
  else { document.write('&nbsp;<BR>&nbsp;<BR>&nbsp;'); };
}

function updatemenupanel() {
	if (parent.activitymenupanel) 
	{
	 if (parent.activitymenupanel.breakinpage != stripfromhash(location.href))
	   { 	
		parent.activitymenupanel.location.reload(); 
	   };
	 if (parent.activitymenupanel.pagename)
	   {
		 parent.activitymenupanel.rolled_one=parent.activitymenupanel.pagename();
		 parent.activitymenupanel.clickme();
	   }
	} 
}

function jim(){document.write("Jim was here.")}

function bookmarkmenu(xposition, yposition, backgrimage) {
// anchors that start with . are not included in the menu
// anchors that start with 1. are indented in the menu
	if (document.anchors)
		{
		var lastindent=0;
		var last_to_use = document.anchors.length-1;
		while ((last_to_use > 0)
		&& (document.anchors[last_to_use].name.charAt(0) == "."))
		{	last_to_use--};

		var winwidth;
		if (window.innerWidth) { winwidth = window.innerWidth }
		else { if (document.body.clientWidth) { winwidth = document.body.clientWidth }
				   else {winwidth = 0 }
					 		 }
							 winwidth = ((winwidth-780)/2)-((winwidth-780)%2/2)-1; // forces it to be integer
							 if (winwidth < 0) {winwidth=yposition} else {winwidth=yposition+winwidth};
		document.write('<div style="z-index:3; z-order:3; top:');
		document.write(xposition);
		document.write('; left:');
		document.write(winwidth);
		document.write('; position:absolute;">');
		document.write('<table bgcolor="lightblue" width=200 cellpadding=15 ');
		if (backgrimage != '')
		{
			document.write('style="background-image: url(');
			document.write(backgrimage);
			document.write('); background-repeat: no-repeat; background-position: 0 0"');
		};
		document.write('><tr><td>');
		document.write("<table border=0 cellspacing=0 cellpadding=0 align='center'><tr><td width=20></td><td></td></tr>");
		for (var i=0;i<document.anchors.length;i++)
			{
			if (document.anchors[i].name && 
			(document.anchors[i].name.charAt(0) != "."))
				{
				var linkname = document.anchors[i].name;
				var dashloc = linkname.indexOf('\.');
				var indent, linktitle;
				if (dashloc == 1) {indent=linkname.charAt(0); linktitle=stripafterdot(linkname);}
				else 				     {indent=0; linktitle=linkname;};
				document.write("<tr>");
				if (indent == 0) {document.write("<td colspan=2>")}
				else 
				{
				 		 if (lastindent == 0)
						 {
				if (true)
				{document.write("<td colspan=2 width=100% height=1 valign='top'><img src='../blue2.gif' height=1 width=100% border=0></td></tr><tr><td width=20><br></td><td>")}
				else {document.write("<td width=20 valign='top'><img src='../clear.gif' height=5 width=100% border=0><br clear='left'></td><td>")};
						 }
						 else {document.write("<td width=20><br></td><td>")}
				};
				if (true)
				{if (indent == 0 || ((indent != 0) && (lastindent !=0))) {document.write("<img src='../blue2.gif' height=1 width=100% border=0>")}}
				else {document.write("<img src='../clear.gif' height=5 width=100% border=0>")};
			document.write("<font face='arial' size =2><a href=\""
				+
				"#"
				+linkname+
				"\" style='text-decoration: none'>");
				document.write(linktitle);
				document.write("</a></font>");
				if (i==(last_to_use))
				{
				if (true)
				{document.write("<img src='../blue2.gif' height=1 width=100% border=0>")}
				else {document.write("<img src='../clear.gif' height=5 width=100% border=0>")}
				};
				document.write("</td></tr>");
				lastindent=indent;
				}
			}
		}
				document.write('</table></td></tr></table>');
}

function automenu() {
 bookmarkmenu(230, 560, '');
 pulldownactivitymenu();
 document.write("</div>");

 document.forms.activityform.activity.options[0].selected=true;
 updatemenupanel();
}

function starwheelmenu() {
 bookmarkmenu(200, 560, 'menubackg.gif');
 document.write("</div>");
 updatemenupanel();
}
