function hideTrays()
{
    for(i=1;i<6;i++)
      {
          var e = document.getElementById("aud_" + i + "_tray");
          e.style.display = "none";
      }
}
function slideUpActive(upId)
{
	var foundTray = false;
    for(i=1;i<6;i++)
    {
       e = document.getElementById("aud_" + i + "_tray");
       var trayId = "#aud_" + i + "_tray";
   	   if (e.style.display == "block")
   	   {
   		  // $(trayId).hide("slide", { direction: "up" }, 500);
   		   $(trayId).slideUp('slow', function (){
   			   $(upId).slideDown("slow");
   			   foundTray =true;
   			   //e.style.display = "none";
   	   	    });
  	   	    return false;
       }
    }
    if(foundTray==false)
    {
    	$(upId).slideDown("slow");
    }
}
function changeTray(element)
{
	//aud_1_inac
	var h = element.className;
	if(h.indexOf("nowShowing")!=-1)
	{
		return false;
	}
	h = h.replace("inac", "hover");
	element.className=h;
	
	return false;
}
function makeInactive(element)
{
	    var inactive = element.className;
	    if(inactive.indexOf("nowShowing")!=-1)
	    {
	        return false;
	    }
	    inactive = inactive.substring(0, 6)+"inac";
        element.className=inactive;
        return false;
}

function audienceTray(){
	 if(dont != "dontRun")
	 {
	     hideTrays();
	     $("li[id^=aud_]").each(
	             function(i){
	                 id = "#" + this.id;
	            	 $( id ).bind (
	                         "click",
	                         function(){
	                             var e = document.getElementById(this.id + "_tray");
	                             trayId = "#" + this.id + "_tray";
	                             if (e.style.display == "none") 
		                         {
	                                  slideUpActive(trayId);
	                                  if(lastElement!=null)
	                                  {
	                                        lastElement.className = lastElement.id + "_inac";
	                                  }
	                                  var z = document.getElementById(this.id);
	                                  z.className = this.id + "_act" + " nowShowing";
	                                  lastElement = z;
	                             }
	                             else
	                             {
	                            	 $(trayId).slideUp('slow', function(){
	                            		    e.style.display="none";
		                              });
		                              this.className = this.id + "_inac";
	                             }
	                         }
	                     )    
	             }
          )
	 }
};