// DROPDOWN MENUS 

function subcurriculum() {
	document.getElementById('sub-curriculum').style.visibility='visible';
	document.getElementById('sub-grade').style.visibility='hidden';
	document.getElementById('sub-whyplayswork').style.visibility='hidden';
	document.getElementById('sub-contactus').style.visibility='hidden';
	setTimeout('nodrop()', 50000);
	}
	
function subgrade() {
	document.getElementById('sub-curriculum').style.visibility='hidden';
	document.getElementById('sub-grade').style.visibility='visible';
	document.getElementById('sub-whyplayswork').style.visibility='hidden';
	document.getElementById('sub-contactus').style.visibility='hidden';
	setTimeout('nodrop()', 50000);
	}

	
function subwhyplayswork() {
	document.getElementById('sub-curriculum').style.visibility='hidden';
	document.getElementById('sub-grade').style.visibility='hidden';
	document.getElementById('sub-whyplayswork').style.visibility='visible';
	document.getElementById('sub-contactus').style.visibility='hidden';
	}
	
	
function subcontactus() {
	document.getElementById('sub-curriculum').style.visibility='hidden';
	document.getElementById('sub-grade').style.visibility='hidden';
	document.getElementById('sub-whyplayswork').style.visibility='hidden';
	document.getElementById('sub-contactus').style.visibility='visible';
	}

function nodrop() {
	document.getElementById('sub-curriculum').style.visibility='hidden';
	document.getElementById('sub-grade').style.visibility='hidden';
	document.getElementById('sub-whyplayswork').style.visibility='hidden';
	document.getElementById('sub-contactus').style.visibility='hidden';
	}
	
/*var callFunction = "hideMenuHelper()";

function hideMenu() {
setTimeout(callFunction, 500);
}

function hideMenuHelper {
document.getElementById("elementID").style.visibility = "hidden";
}*/

var pwd = "";

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
} 


var tabLinks = new Array();
var contentDivs = new Array();

function tabinit(page) {

  // Grab the tab links and content divs from the page
  var tabListItems = document.getElementById('tabs').childNodes;
  for ( var i = 0; i < tabListItems.length; i++ ) {
	if ( tabListItems[i].nodeName == "LI" ) {
	  var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
	  var id = getHash( tabLink.getAttribute('href') );
	  tabLinks[id] = tabLink;
	  contentDivs[id] = document.getElementById( id );
	}
  }

  // Assign onclick events to the tab links, and
  // highlight the first tab
  var i = 0;

  for ( var id in tabLinks ) {
	tabLinks[id].onclick = showTab;
	tabLinks[id].onfocus = function() { this.blur() };
	if ( i == 0 ) tabLinks[id].className = 'selected';
	i++;
  }

  // Hide all content divs except the first
  var i = 0;

  for ( var id in contentDivs ) {
	if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
	i++;
  }
  // If a hash was supplied in the page URL,
  // display the corresponding tab (if found)
  if ( document.location.hash ) showTab( document.location.hash.substring(1) );
  if (page=="landing")
  	{
		scroll(0,0);	
	}
}

function showTab( selectedId ) {
  var has_hash = 0;
  if ( typeof selectedId != 'string' ) var selectedId = getHash( this.getAttribute('href') );
  // Highlight the selected tab, and dim all others.
  // Also show the selected content div, and hide all others.
  for ( var id in contentDivs ) {
	if ( id == selectedId ) {
	  tabLinks[id].className = 'selected';
	  contentDivs[id].className = 'tabContent';
	} else {
	  tabLinks[id].className = '';
	  contentDivs[id].className = 'tabContent hide';
	}
  }

  // Stop the browser following the link
  return false;
}

function getFirstChildWithTagName( element, tagName ) {
  for ( var i = 0; i < element.childNodes.length; i++ ) {
	if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
  }
}

function getHash( url ) {
  var hashPos = url.lastIndexOf ( '#' );
  return url.substring( hashPos + 1 );
}


var settings;
var winw;
var winh;
var TheNewWin;

function MM_openBrWindow(theURL,winName,winw,winh) {
	settings='width='+winw+',height='+winh+',scrollbars=yes,toolbar=no';
	TheNewWin = window.open(theURL,winName,settings);
	TheNewWin.moveTo((screen.width/2)-(winw/2),(screen.height/2)-(winh/2));
}


function doNode(node) {
	node.style.cursor = "pointer";
	var left = node.src.substring(0, node.src.indexOf(".png"));
	var right = node.src.substring(node.src.indexOf(".png"), node.src.length);
	
	var img = new Image();
	img.src = node.src;
	var rimg = new Image();
	rimg.src = left + "-over" + right;
	
	node.onmouseover = function() { node.src = rimg.src; }
	node.onmouseout = function() { node.src = img.src; }
}

function doRollovers() {
	var nodes = new Array();
	var elems = document.getElementsByTagName('*');
	var pattern = new RegExp("(^|\\s)rollover(\\s|$)");
	for (i = 0, j = 0; i < elems.length; i++) {
		if (pattern.test(elems[i].className)) {
			nodes[j] = elems[i];
			j++;
		}
	}

	for (var x = 0; x < nodes.length; x++) {
		doNode(nodes[x]);
	}
}

function doInit() {
	if (document.all && document.getElementById) {
		var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
		if (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7) {
			nav_root = document.getElementById("nav");
			for (i = 0; i < nav_root.childNodes.length; i++) {
				node = nav_root.childNodes[i];
				if (node.id && node.id.indexOf("nav-") != -1) {
					node.onmouseover = function() { this.className = "over"; }
					node.onmouseout = function() { this.className = this.className.replace("over", ""); }
				}
			}
		}
	}
	
	doRollovers();
}

