/* Show or hide specific elements, by ID, with an A tag */
function showhide(id) {
	if(document.getElementById) {
		obj = document.getElementById(id);
		if(obj.style.display == "none") {
			obj.style.display = "";
			setCookie(id,'true','1')
		} else {
			obj.style.display = "none";
			setCookie(id,'false','1')
		}
	}
}

function show(id) {
	if(document.getElementById) {
		obj = document.getElementById(id);
		obj.style.display = "";
	}
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
   if (document.cookie.length>0)
  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	  { 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
  	  } 
  }
  return "";
}

//checks if section was previously open and reopens it.
function preOpenedSections(){
	var hiddenSections=new Array();
	hiddenSections[0]="IEI";
	hiddenSections[1]="RR";
	hiddenSections[2]="DS";
	hiddenSections[3]="SH";
	hiddenSections[4]="L";
	hiddenSections[5]="U";
	hiddenSections[6]="OS";
	hiddenSections[7]="RH";
	hiddenSections[8]="MPRS";
	
	n = hiddenSections.length;
	
	for (var i = 0;  i < n; i++) { 
		if(getCookie(hiddenSections[i])== 'true')
		{
			show(hiddenSections[i]);
		}
	}
	
}

function showhideall (action) {
	//show or hideall of the descriptions
	if(document.getElementById) {
		var divs = document.getElementsByTagName("div");
		for (var i = 0, n = divs.length; i < n; i ++) { 
			if (divs[i].className == "sessionDescriptions") {
				if (action == "show") divs[i].style.display="";
				else divs[i].style.display="none";
			}
		}
	
		//change all the turnbuckles to + or - depending on whether we just showed all or hid all
		var imgs = document.images;
		for (var i = 0; i < imgs.length; i ++) {
			if (action == "show") {
				if(imgs[i].src == master_logo_path+"/turnbuckle-plus.gif" && imgs[i].attributes['id'].value != "turnbuckle_master_open" && imgs[i].attributes['id'].value != "turnbuckle_master_close") {
					imgs[i].src = master_logo_path+"/turnbuckle-minus.gif"
				} 
			} else if (action == "hide") {
				if(imgs[i].src == master_logo_path+"/turnbuckle-minus.gif" && imgs[i].attributes['id'].value != "turnbuckle_master_open" && imgs[i].attributes['id'].value != "turnbuckle_master_close") {
					imgs[i].src = master_logo_path+"/turnbuckle-plus.gif"
				}
			}
		}
	}
}