//Don't get the page caught in someone else's frame.
// use in body tag:  <body onload = "unFrame()">

function unFrame() {
 if (self != top)
   top.location.href = self.location.href;
}


//Show the theme selector on JS enabled pages, using the cookie to initialize to the currently set theme
function drawThemeSelecter() { 
	document.write('<form id="switchform2">');
	var theCookie = getCookie("mysheet");

	document.write('Theme:&nbsp;&nbsp;');

	document.write('<select name="switchcontrol" size="1" onChange="chooseStyle(this.options[this.selectedIndex].value)">');

	// put in the selected style
	if (theCookie == "gold-theme"){
		document.write('<option value="none">Default</option>');
		document.write('<option value="gold-theme" selected="selected">Gold</option>');
		document.write('<option value="blue-right">Blue-R</option>');
		document.write('<option value="gold-right">Gold-R</option>');
	}
	
	else if (theCookie == "blue-right"){
		document.write('<option value="none">Default</option>');
		document.write('<option value="gold-theme">Gold</option>');
		document.write('<option value="blue-right" selected="selected">Blue-R</option>');
		document.write('<option value="gold-right">Gold-R</option>');
	}
	
	else if (theCookie == "gold-right"){
		document.write('<option value="none">Default</option>');
		document.write('<option value="gold-theme">Gold</option>');
		document.write('<option value="blue-right">Blue-R</option>');
		document.write('<option value="gold-right" selected="selected">Gold-R</option>');
	}
	
	else {
		document.write('<option value="none" selected="selected">Default</option>');
		document.write('<option value="gold-theme">Gold</option>');
		document.write('<option value="blue-right">Blue-R</option>');
		document.write('<option value="gold-right">Gold-R</option>');
	}


	document.write('</select>');
	document.write('</form>');
}




//used to hide or show the contents of an article on the main page
function showHide(vThis)
// this is for one that starts showing
{
// modified from a script from http://www.javascriptjunkie.com
// alert("Hello From www.javascriptjunkie.com" + vThis.tagName);
	vParent = vThis.parentNode;
	vSibling = vParent.nextSibling;
	while (vSibling.nodeType==3) {   // Fix for Mozilla/FireFox Empty Space becomes a TextNode or Something
    	vSibling = vSibling.nextSibling;
  	};
  	
	if(vSibling.style.display == "none")
	{
		vThis.src="pics/collapse.gif";
		vThis.alt = "Hide";
		vSibling.style.display = "block";
	} 
	else {
		vSibling.style.display = "none";
		vThis.src="pics/expand.gif";
		vThis.alt = "Show";
	}
return;
}

// this one is for an item that starts from hidden.  Initially, vSibling.style.display
// returns "", regardless of it it's actually hidden or showing
function showHidden(vThis)
// this is for one that starts hidden
{
// modified from a script from http://www.javascriptjunkie.com
// alert("Hello From www.javascriptjunkie.com" + vThis.tagName);
	vParent = vThis.parentNode;
	vSibling = vParent.nextSibling;
	while (vSibling.nodeType==3) {   // Fix for Mozilla/FireFox Empty Space becomes a TextNode or Something
    	vSibling = vSibling.nextSibling;
  	};
  	
	if (vSibling.style.display == "block") {
		vSibling.style.display = "none";
		vThis.src="pics/expand.gif";
		vThis.alt = "Show";
	}
	else
	{
		vThis.src="pics/collapse.gif";
		vThis.alt = "Hide";
		vSibling.style.display = "block";
	} 

return;
}





function hideMenu(){
	//  written by wa4akb - hide or display the menu and the "show menu" button
	//  show is actually a pagerefresh

	var menu = document.getElementById("menu");
	menu.style.display = "none";
		
	// fix the margins on the page
	var content = document.getElementById("pageContent");
	content.style.marginLeft = "0px";
	content.style.marginRight = "0px";
	content.style.margin = "0px";
	
	// display the show menu item
	var sw = document.getElementById("mshow"); 
	sw.style.display="inline";
	
	
	// since there is only one column now, 
	// adjust size for those with a minWidth set on the body so we don't
	// get too much scrolling
	// no problem with menus since redisplaying the menu reloads the page.
	document.body.style.minWidth = "0px";
}


function toggleMenu(sender){
	var text = sender.textContent;

	if (text == "Hide Menu"){
	  sender.textContent = "Show Menu";	  
	  var menu = document.getElementById("menu");
	  menu.style.display = "none";
	  var content = document.getElementById("pageContent");
	  content.style.marginLeft = "0px";
	  content.style.marginRight = "0px";
	  content.style.margin = "0px";		 
	}else{
	    window.location.reload();
	}

	

}




function monthSelector(){
	document.writeln ('<form action="../">');
	document.writeln('<b>Previous Issues:&nbsp;&nbsp;</b>');
	document.writeln ("<select onchange=\"window.open(this.options[this.selectedIndex].value,\'_top\')\">");
	document.writeln('<option value ="" selected>Select one:</option>');
	document.writeln('<option value="http://www.ncarrl.org/Newsletters/August2010.html">August 2010</option>');
	document.writeln('<option value="http://www.ncarrl.org/Newsletters/July2010.html">July 2010</option>');
	document.writeln('<option value="http://www.ncarrl.org/Newsletters/June2010.html">June 2010</option>');
	document.writeln('<option value="http://www.ncarrl.org/Newsletters/May2010.html">May 2010</option>');
	document.writeln('</select>');
	document.writeln('</form>');
}