// JavaScript Document

// JAVASCRIPT FUNCTIONS FOR DISPLAY AREAS OF THE CHEER HEALTH SITE


// switches the visibility of elements on and off
function vis_switch(e) {
	
	if(document.all.e) {
		el = document.all.e;
	} else {
		el = document.getElementById(e);
	}
	
	
	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}	
// end switch vis
	
	
// to toggle div areas on and off
function showArea(targetID) {

	if (document.getElementById) {
	target = document.getElementById(targetID);
	
		if (target.style.display == "none") {
			target.style.display = "block";
		} else {
			target.style.display = "none";
		}
	} // end if getElementById
}
// end of function showArea()

// to toggle two div areas on and off
function showTwoAreas(targetOneID, targetTwoID) {

	if (document.getElementById) {
	targetOne	= document.getElementById(targetOneID);
	targetTwo	= document.getElementById(targetTwoID);
	
		if (targetOne.style.display == "none") {
			targetOne.style.display = "block";
			targetTwo.style.display = "none";
		} else {
			targetOne.style.display = "none";
			targetTwo.style.display = "block";
		}
	} // end if getElementById
}
// end of function showTwoAreas()
	
	
	
// To show or hide the section tree
function toggleList(id){
	ul = "ul_" + id;
	img = "img_" + id;
	ulElement = document.getElementById(ul);
	imgElement = document.getElementById(img);
	if (ulElement){
		
			if (ulElement.className == 'sectionTreeClosed'){
			  ulElement.className = "sectionTreeOpen";
			  
			  // for hiding the other open areas
			  for(i=0; i < 10; i++) {
				  o	=	"ul_" + i; // our variable
				  oEl	=	document.getElementById(o); // our object
				  if(oEl && o!=ul && oEl.className == 'sectionTreeOpen') {
					  oEl.className = 'sectionTreeClosed';
				  } // end if
				  
			  } // end for loop
			  
			  
			  
			 }else{
			  ulElement.className = "sectionTreeClosed";
		}
  
	  }

}
// end toggleList

    

	
	// A little function to move from page to page..usually after a refresh
	function movePage ( p ) {
		document.location = p;
	}
	// end move page
	
	
/*  AJAX STUFF IF WE NEED IT */

var element=null;
http = getHTTPObject();		

function getHTTPObject(){
  var xmlhttp;		
 
  if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
    try {
      xmlhttp = new XMLHttpRequest();
    }catch(e){
      xmlhttp = false;
    }
  }
 
  return xmlhttp;
}
 
function getContent(url, el){
	
	element	=	el;
	
  	http.open("GET", url, true);
  	http.onreadystatechange = handleHttpResponse;		 
  	http.send(null);
} 


function handleHttpResponse(){			
	
  if(http.readyState == 4){		  	
  	document.getElementById(element).innerHTML = http.responseText;
  } 
  
}
// end of ajax stuff





