// Serenity Functions, for the serenity.php page
dojo.require("dojo.lfx.*");

/* show/hide toggle the "suggestions" div */
function toggleSuggestions() {
   var suggestion = dojo.byId("suggestions");
   var hider = dojo.byId("hider");
   var display = suggestion.getAttribute('displayed');

   if (display == 'on') {
     dojo.lfx.toggle.fade.hide(suggestion, 1000);
     hider.setAttribute("src","media/images/show-suggestion.gif");
     display = 'off';
   } else {
     dojo.lfx.toggle.fade.show(suggestion, 1000);
     hider.setAttribute("src","media/images/hide-suggestion.gif");
     display = 'on';
   }
   suggestion.setAttribute('displayed', display);
}

/* dom hook and setup */
function serenityInit() {
   var hider = dojo.byId('hider');
   dojo.event.connect(hider,'onclick',toggleSuggestions);
   var suggestion = dojo.byId("suggestions");
   suggestion.setAttribute('displayed', 'on');
}

dojo.addOnLoad(serenityInit);
