// toggle visibility
function getElementsByClassName(needle) {
   var my_array = document.getElementsByTagName("*");
   var retvalue = new Array();
   var i;
   var j;

   for (i=0,j=0;i<my_array.length;i++) {
	  var c = " " + my_array[i].className + " ";
	  if (c.indexOf(" " + needle + " ") != -1) retvalue[j++] = my_array[i];
   }
   return retvalue;
} 

var FINlength = 0;

function stripID(stripee) {  // get passed stringID into a local string variable (stripee) containing example "content-box1"
	// alert("stripee value is" + " " + stripee);
	var IDlength = stripee.length;  // get the length of passed string containing example "12"
	// alert("IDlength value is" + " " + IDlength);
	var last_char = stripee.charAt(IDlength-1);  // get last character of string containing example "1"
	// alert("last_char value is" + " " + last_char);
	var last_2char = stripee.charAt(IDlength-2);  // get second-to-last character of string containing example "x"
	// alert("last_2char value is" + " " + last_2char);
	if (last_char >= "0" && last_char <= "9") {  // check to see if last character is a number, in this example TRUE.
		var ALTlength = IDlength-1;  // if TRUE, reduce the string length count by one and put it in another bucket, for example "11".
		// alert("ALTlength value is" + " " + ALTlength);
	}
	if (last_2char >= "0" && last_2char <= "9") {  // check to see if second-to-last character is a number, in this example FALSE.
		FINlength = ALTlength-1;  // if TRUE, reduce the string ALT length count by one and put it in another bucket.
								  // in example is FALSE so nothing happens.
		// alert("FINlength passed from second character value is" + " " + FINlength);
		return FINlength;
	}
	else {
		FINlength = ALTlength;
		// alert("FINlength value in stripID function is" + " " + FINlength);
		return FINlength;
	}
}

function toggleOff(stringID) {  // get passed string called target containing example "content-box1"
	// alert("stringID value is" + " " + stringID);
	// alert("FINlength value in toggleOff function before is" + " " + FINlength);
	stripID(stringID);  // need to process groups of DIV IDs so need to get the base string without number distinguisher.  Pass "content-box1".
	// alert("FINlength value in toggleOff function after is" + " " + FINlength);
	var IDoff = stringID.substring(0,FINlength);  // process example "content-box1" (stringID) by taking a portion of the string to process 
											  // from first letter to the last letter passed back from the stripping function (FINlength).
											  // Put result into new string bucket (IDoff)containing example "content-box"
	// alert("IDoff value is" + " " + IDoff);
	switch (IDoff) {
		case "content-box":
			document.getElementById('content-box1').style.display = "none";
			document.getElementById('content-box2').style.display = "none";
			document.getElementById('content-box3').style.display = "none";
			break;
		case "selector":
			document.getElementById('selector1').style.display = "none";
			document.getElementById('selector2').style.display = "none";
			document.getElementById('selector3').style.display = "none";
			document.getElementById('selector4').style.display = "none";
			document.getElementById('selector5').style.display = "none";
			document.getElementById('selector6').style.display = "none";
			break;
		case "display":
			document.getElementById('display').style.display = "none";
			break;
}
	return;
}

function toggle(targetId) { // get passed the DIV ID from HTML doc containing example "content-box1"
	if (document.getElementById) {
        var target = document.getElementById(targetId);  // DIV ID put into string (target) containing example "content-box1"
           if (target.style.display == "block") {
			   target.style.display = "none";
           }
		   else {
			   // alert("targetId value is" + " " + targetId);
			   toggleOff(targetId);  // pass contents of target string to toggleOff function containing example "content-box1"
			   target.style.display = "block";
           }
	}
}

function showPic (whichpic) {
	if (document.getElementById) {
		document.getElementById('placeholder').src = whichpic.href;
  		if (whichpic.title) {
  			document.getElementById('desc').innerHTML = document.getElementById(whichpic.title).innerHTML;
  		}
		else {
  			document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  		}
  		return false;
 	}
	else {
  		return true;
 	}
}