function content_switch() {
	var thisid = '';
	var thisdiv = '';
	var result = '';
	
	var content_layers = document.getElementsByTagName("div");
	for (var i = 0; i <= (content_layers.length - 1); i++) {
		thisid = content_layers[i].id
		result = thisid.match(/content_layer_(.+)/);
		if (result != null) {
			// Check to see if this div's id matches any of the arguments.
			// If there's a match, this div will be toggled "On", otherwise "Off".
			var arg_match = 0;
			for (var j = 0; j <= (arguments.length - 1); j++) {
				if (thisid == ('content_layer_' + arguments[j])) {
					arg_match++;
				}
			}
			
			thisdiv = document.getElementById(thisid);
			var tempahrefid = 'layer_link_' + result[1];	// result[1] is the (matched) portion of the regex above
			var thisahref = document.getElementById(tempahrefid);
			if (arg_match > 0) {
				thisdiv.style.display = "";
				if (thisahref != null) {
					thisahref.style.background = "url('http://www2.ku.edu/~hipaa/images/icons/box_black.gif') no-repeat 0 0.5em";
					thisahref.style.font = "bold 1em Arial, Helvetica, sans-serif";
					thisahref.style.color = "#000";
				}
			} else {
				thisdiv.style.display = "none";
				if (thisahref != null) {
					thisahref.style.background = "url('http://www2.ku.edu/~hipaa/images/icons/box_grey.gif') no-repeat 0 0.5em";
					thisahref.style.font = "normal 1em Arial, Helvetica, sans-serif";
					thisahref.style.color = "#0049ae";
				}
			}
			
		} // if (result != null)
	} // for (var i = 0...)
} // function content_switch

function content_switch2() {
	var thisid = '';
	var thisdiv = '';
	var result = '';
	
	var content_layers = document.getElementsByTagName("div");
	for (var i = 0; i <= (content_layers.length - 1); i++) {
		thisid = content_layers[i].id
		result = thisid.match(/content_layer_(.+)/);
		if (result != null) {
			// Check to see if this div's id matches any of the arguments.
			// If there's a match, this div will be toggled "On", otherwise "Off".
			var arg_match = 0;
			for (var j = 0; j <= (arguments.length - 1); j++) {
				if (thisid == ('content_layer_' + arguments[j])) {
					arg_match++;
				}
			}
			
			thisdiv = document.getElementById(thisid);
			var tempahrefid = 'layer_link_' + result[1];	// result[1] is the (matched) portion of the regex above
			var thisahref = document.getElementById(tempahrefid);
			if (arg_match > 0) {
				thisdiv.style.display = "";
				if (thisahref != null) {
					thisahref.style.background = "url('http://www2.ku.edu/~hipaa/images/icons/arrow_down.gif') no-repeat 0 0.3em";
					thisahref.style.font = "bold 1em Arial, Helvetica, sans-serif";
					thisahref.style.color = "#000";
					thisahref.style.lineHeight = "1.7";
				}
			} else {
				thisdiv.style.display = "none";
				if (thisahref != null) {
					//thisahref.style.background = "url('') no-repeat 0 0.6em";
					thisahref.style.background = "url('') no-repeat 0 0.5em";
					thisahref.style.font = "normal 1em Arial, Helvetica, sans-serif";
					thisahref.style.color = "#0049AE";
					thisahref.style.lineHeight = "1.7";
				}
			}
			
		} // if (result != null)
	} // for (var i = 0...)
} // function content_switch2

function content_switch3() {
	var thisid = '';
	var thisdiv = '';
	var result = '';
	
	var content_layers = document.getElementsByTagName("div");
	for (var i = 0; i <= (content_layers.length - 1); i++) {
		thisid = content_layers[i].id
		result = thisid.match(/content_layer_(.+)/);
		if (result != null) {
			// Check to see if this div's id matches any of the arguments.
			// If there's a match, this div will be toggled "On", otherwise "Off".
			var arg_match = 0;
			for (var j = 0; j <= (arguments.length - 1); j++) {
				if (thisid == ('content_layer_' + arguments[j])) {
					arg_match++;
				}
			}
			
			thisdiv = document.getElementById(thisid);
			var tempahrefid = 'layer_link_' + result[1];	// result[1] is the (matched) portion of the regex above
			var thisahref = document.getElementById(tempahrefid);
			if (arg_match > 0) {
				thisdiv.style.display = "";
				if (thisahref != null) {
				}
			} else {
				thisdiv.style.display = "none";
				if (thisahref != null) {
				}
			}
			
		} // if (result != null)
	} // for (var i = 0...)
} // function content_switch3

function content_switch_gallery() {
	var thisid = '';
	var thisdiv = '';
	var result = '';
	
	var content_layers = document.getElementsByTagName("div");
	for (var i = 0; i <= (content_layers.length - 1); i++) {
		thisid = content_layers[i].id
		result = thisid.match(/content_layer_(.+)/);
		if (result != null) {
			// Check to see if this div's id matches any of the arguments.
			// If there's a match, this div will be toggled "On", otherwise "Off".
			var arg_match = 0;
			for (var j = 0; j <= (arguments.length - 1); j++) {
				if (thisid == ('content_layer_' + arguments[j])) {
					arg_match++;
				}
			}
			
			thisdiv = document.getElementById(thisid);
			var tempahrefid = 'layer_link_' + result[1];	// result[1] is the (matched) portion of the regex above
			var thisahref = document.getElementById(tempahrefid);
			if (arg_match > 0) {
				thisdiv.style.display = "";
				if (thisahref != null) {
					className = "provost_shade";
				}
			} else {
				thisdiv.style.display = "none";
				if (thisahref != null) {
					className = "provost_shade";
				}
			}
			
		} // if (result != null)
	} // for (var i = 0...)
} // function content_switch_gallery

function content_switch_plus() {
	var thisid = '';
	var thisdiv = '';
	var result = '';
	
	var content_layers = document.getElementsByTagName("div");
	for (var i = 0; i <= (content_layers.length - 1); i++) {
		thisid = content_layers[i].id
		result = thisid.match(/content_layer_(.+)/);
		if (result != null) {
			// Check to see if this div's id matches any of the arguments.
			// If there's a match, this div will be toggled "On", otherwise "Off".
			var arg_match = 0;
			for (var j = 0; j <= (arguments.length - 1); j++) {
				if (thisid == ('content_layer_' + arguments[j])) {
					arg_match++;
				}
			}
			
			thisdiv = document.getElementById(thisid);
			var tempahrefid = 'layer_link_' + result[1];	// result[1] is the (matched) portion of the regex above
			var thisahref = document.getElementById(tempahrefid);
			if (arg_match > 0) {
				thisdiv.style.display = "";
				if (thisahref != null) {
					thisahref.style.font = "bold 1em Arial, Helvetica, sans-serif";
					thisahref.style.color = "#000";
					thisahref.style.listStyleImage = "url('http://www2.ku.edu/~hipaa/images/icons/minus.png')";
				}
			} else {
				thisdiv.style.display = "none";
				if (thisahref != null) {
					thisahref.style.font = "normal 1em Arial, Helvetica, sans-serif";
					thisahref.style.color = "#0049AE";
					thisahref.style.listStyleImage = "url('http://www2.ku.edu/~hipaa/images/icons/plus.png')";
				}
			}
			
		} // if (result != null)
	} // for (var i = 0...)
} // function content_switch_plus

function content_switch_folder() {
	var thisid = '';
	var thisdiv = '';
	var result = '';
	
	var content_layers = document.getElementsByTagName("ul");
	for (var i = 0; i <= (content_layers.length - 1); i++) {
		thisid = content_layers[i].id
		result = thisid.match(/content_layer_(.+)/);
		if (result != null) {
			// Check to see if this div's id matches any of the arguments.
			// If there's a match, this div will be toggled "On", otherwise "Off".
			var arg_match = 0;
			for (var j = 0; j <= (arguments.length - 1); j++) {
				if (thisid == ('content_layer_' + arguments[j])) {
					arg_match++;
				}
			}
			
			thisdiv = document.getElementById(thisid);
			var tempahrefid = 'layer_link_' + result[1];	// result[1] is the (matched) portion of the regex above
			var thisahref = document.getElementById(tempahrefid);
			if (arg_match > 0) {
				thisdiv.style.display = "";
				if (thisahref != null) {
					thisahref.style.background = "url('') no-repeat 0 0.5em";
					thisahref.style.font = "normal 1em Arial, Helvetica, sans-serif";
					thisahref.style.color = "#000";
				}
			} else {
				thisdiv.style.display = "none";
				if (thisahref != null) {
					thisahref.style.background = "url('') no-repeat 0 0.5em";
					thisahref.style.font = "normal 1em Arial, Helvetica, sans-serif";
					thisahref.style.color = "#0049ae";
				}
			}
			
		} // if (result != null)
	} // for (var i = 0...)
} // function content_switch_folder

var temp, temp2, cookieArray, cookieArray2, cookieCount;
function initiate(){
  cookieCount=0;
  if(document.cookie){
    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();
    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }
  }
  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();
  temp=document.getElementById("containerul");
  for(var o=0;o<temp.getElementsByTagName("li").length;o++){
    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(minus.png)":"url(plus.png)"):"url(plus.png)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        writeCookie();
      }
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)
      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";
      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }
      cookieCount++;
    }
    else{
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = "url(page.png)";
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);
    }
  }
}

function showhide(el){
  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";
  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(minus.png)":"url(plus.png)";
}

function writeCookie(){ // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.
  cookieArray=new Array()
  for(var q=0;q<temp.getElementsByTagName("li").length;q++){
    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){
        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");
      }
    }
  }
  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();
}