<!--
 //
 //
 //
 // ndpwScripts.js
 //
 //



function newButton(buttonText, buttonLink)
{
	// document.write (' <td class="lnk" onClick="loadNewPage(\'../' + buttonLink + '\')" onMouseOut="this.bgColor=\'#CCCC99\'" onMouseOver="this.bgColor=\'red\'" width="20%" align="center" bgcolor="#1188BB"> ') ;

	 document.write (' <td class="lnk" onClick="loadNewPage(\'../' + buttonLink + '\')" onMouseOut="this.className=\'lnk\'" onMouseOver="this.className=\'lnkOver\';" ><span class="navButton">' + buttonText + '<\/span><\/td> ' );
}


function loadNewPage(newpage)
{
 //alert(location.href);
 document.location.href= "./"+ newpage ;

}

function initializeFontSize()
 {
 getFontSize('p');
}

// Changes the font size of the element and stores the size in a cookie
function changeFontSize( strSize, tagName)
{
//alert('changeFontSize - strSize = '  + strSize + ' tagName = ' + tagName);
inputArray = document.getElementsByTagName(tagName)
var L=inputArray.length;

for(i=0; i< L; i++) {
    inputArray[i].style.fontSize=strSize;
}

	// set the cookie
	SetCookie("fontSize",strSize,"December,31,2029");
	//var cookieWas = document.cookie.toString();
	//alert('the cookie is ' + cookieWas);
	var temp = 'fs' + strSize;
	var fsAnchors = getElementsByClass("fs"+strSize);

    makeLinkCurrent(fsAnchors[0]);
}

// Function to find any cookied font size on the clients machine and set the font to their preference as specified in the cookie
function getFontSize(tagName) {
	// check if the object whose id is given exists
	if(document.getElementsByTagName(tagName)) {

		// create regular expression to match pattern 'fontSize=.......' till a semicolon is encountered or the string ends
		var regEx = new RegExp("fontSize=[^;]+");

		// if cookie exists
		if(regEx.test(document.cookie)){

			// if match found, then extract the part of the string matching the regular expression pattern
			var cookieEntry = document.cookie.toString().match(regEx);

			if(cookieEntry != '') {
				// from the match, extract the font size
				var fontSize = cookieEntry.toString().substring(9, cookieEntry.toString().length);
//alert(cookieEntry + ' -- ' + fontSize.toString() + ' and tagName is ' + tagName);
				// call the function to change the font size accordingly
				changeFontSize( fontSize.toString(),tagName);
			}
		}
	}
}

function SetCookie(name,value,expires)
{
	var exp = new Date(expires);
	document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString(); + ";";
//	alert(document.cookie + ' is the cookie');
}


 //Change the current link to overline, underline and red
function makeLinkCurrent(obj)
{

var i;
var fsAnchors = getElementsByClass("fs");
       for (i=0; i < fsAnchors.length; i++)
	if (fsAnchors[i] == obj) 
       {
	       obj.style.color = 'red';
	       obj.style.textDecoration = 'underline overline ';
	       obj.style.backgroundColor = 'blue';
       }
       else
       {
	       fsAnchors[i].style.color = 'blue';
	       fsAnchors[i].style.textDecoration = 'none';
	       fsAnchors[i].style.backgroundColor = '' ;
	       
       }

}

function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}


function toggleDisplay(clickSpan)  // this is the SPAN that has the "Click Here for More..." text
	{
	//			<span>
	//					<SPAN onclick="toggleDisplay(this)" STYLE="background-color: #FFFF00">Click Here for More...
	//					</SPAN> 
	//			
	//				<div id="whatever" style="position:relative;display:none">
	//					area to show or hide
	//			 	</div>
	//			</span>
	  var theDiv;
	  
	  var toggleDiv;	// this is the DIV that will be hidden/shown - must be a child of a second span 
	  var clickSpan;  // this is the actual click here text
	  var me2;
	
	  //meId = theDiv.id +'_theArea';

	  //me = document.getElementById(meId);
	  parentSpan = clickSpan.parentNode ;
	  //alert(parentSpan.id);
	  temp = parentSpan.getElementsByTagName('DIV');  //array of DIV elements within the div
	  clickHere = clickSpan.firstChild;
	  toggleDiv = temp[0]; // the FIRST DIV should define the area to show/hide
	  //alert(toggleDiv.id + ' ---> ' +toggleDiv.style.display);

	  //alert(me2[1].id);
	  	   
		//if (me.style.display=="block"){
		//	me.style.display="inline";
		//	alert("Text is now 'inline'.");
		//	}
		//else {
			if (!(toggleDiv.style.display == "inline")){
				toggleDiv.style.display="inline";
				clickHere.nodeValue = 'Click Here for LESS...';
				//  alert(clickHere);

			//	alert("Text is now 'none'. It will reappear in three seconds.");
			//	window.setTimeout("blueText.style.display='block';",3000,"JavaScript");
				}
			else {
				toggleDiv.style.display="none";
				clickHere.nodeValue = 'Click Here for MORE...';
				//	alert("Text is now 'block'.");
				}
			//}

	}//-->
