YAHOO.namespace('roths');

YAHOO.roths.opacityMax = 0.93; // 92% opaque
YAHOO.roths.opacityMin = 0.0; // 100% transparent
YAHOO.roths.opacitySpeed = 1; // opacity animation takes 1 second

//ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
// Info
//________________
YAHOO.roths.init = function() {
  var showInfoBox;
  showInfoBox = YAHOO.util.Dom.get('sbox') || YAHOO.util.Dom.get('sbox_page');

   var sboxFadeIn = function(e) {
      YAHOO.util.Event.preventDefault(e); // block the default link
      YAHOO.util.Dom.setStyle(showInfoBox, 'opacity', YAHOO.roths.opacityMin); // ensure the correct opacity is shown before we show the block
      YAHOO.util.Dom.setStyle(showInfoBox, 'display', 'block'); // show the block
      var anim = new YAHOO.util.Anim(showInfoBox, { opacity: { from: YAHOO.roths.opacityMin, to: YAHOO.roths.opacityMax } }, YAHOO.roths.opacitySpeed, YAHOO.util.Easing.easeOut); // setup the animation
	  YAHOO.util.Dom.setStyle('sboxlink', 'display', 'none');
	  YAHOO.util.Dom.setStyle('sboxlink2', 'display', '');
	  YAHOO.util.Dom.setStyle('sboxlinkpage', 'display', 'block');
      anim.animate(); // animate
	  hideAL1();hideAL2();hideAL3();hideAL4(); // hide the drop menus
   };
   
   var sboxFadeOut = function(e) {
      YAHOO.util.Event.preventDefault(e); // block the default link
      var anim = new YAHOO.util.Anim(showInfoBox, { opacity: { from: YAHOO.roths.opacityMax, to: YAHOO.roths.opacityMin } }, YAHOO.roths.opacitySpeed, YAHOO.util.Easing.easeOut); // setup the animation
      var hide = function(e) { YAHOO.util.Dom.setStyle(showInfoBox, 'display', 'none'); }; // setup the hide function so that it can be called using the onComplete
      anim.onComplete.subscribe(hide); // subscribe to the onComplete event
	  YAHOO.util.Dom.setStyle('sboxlink', 'display', 'inline');
	  YAHOO.util.Dom.setStyle('sboxlink2', 'display', 'inline');	  
	  YAHOO.util.Dom.setStyle('sboxlinkpage', 'display', 'inline');
      anim.animate(); // animate
	  hideAL1();hideAL2();hideAL3();hideAL4(); // hide the drop menus
   };

   YAHOO.util.Event.addListener('sboxlink', 'click', sboxFadeIn);
   YAHOO.util.Event.addListener('sboxlink2', 'click', sboxFadeIn);   
   YAHOO.util.Event.addListener('sboxlinkpage', 'click', sboxFadeIn);
   YAHOO.util.Event.addListener('sboxoff', 'click', sboxFadeOut);
};

YAHOO.util.Event.onAvailable('sboxlink', YAHOO.roths.init); // only initialize if we have the sbox div in the page
YAHOO.util.Event.onAvailable('sboxlinkpage', YAHOO.roths.init); // only initialize if we have the sbox div in the page

//ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
// Search
//________________
YAHOO.roths.init = function() {
  var showSearchBox;
  showSearchBox = YAHOO.util.Dom.get('search_panel');

   var searchFadeIn = function(e) {
      YAHOO.util.Event.preventDefault(e); // block the default link
      YAHOO.util.Dom.setStyle(showSearchBox, 'opacity', YAHOO.roths.opacityMin); // ensure the correct opacity is shown before we show the block
      YAHOO.util.Dom.setStyle(showSearchBox, 'display', 'block'); // show the block
      var anim = new YAHOO.util.Anim(showSearchBox, { opacity: { from: YAHOO.roths.opacityMin, to: YAHOO.roths.opacityMax } }, YAHOO.roths.opacitySpeed, YAHOO.util.Easing.easeOut); // setup the animation
	  YAHOO.util.Dom.setStyle('searchlink', 'display', 'none');
      anim.animate(); // animate
   };
   
   var searchFadeOut = function(e) {
      YAHOO.util.Event.preventDefault(e); // block the default link
      var anim = new YAHOO.util.Anim(showSearchBox, { opacity: { from: YAHOO.roths.opacityMax, to: YAHOO.roths.opacityMin } }, YAHOO.roths.opacitySpeed, YAHOO.util.Easing.easeOut); // setup the animation
      var hide = function(e) { YAHOO.util.Dom.setStyle(showSearchBox, 'display', 'none'); }; // setup the hide function so that it can be called using the onComplete
      anim.onComplete.subscribe(hide); // subscribe to the onComplete event
	  YAHOO.util.Dom.setStyle('searchlink', 'display', 'inline');
      anim.animate(); // animate
   };

   YAHOO.util.Event.addListener('searchlink', 'click', searchFadeIn);
   YAHOO.util.Event.addListener('searchoff', 'click', searchFadeOut);
};

YAHOO.util.Event.onAvailable('searchlink', YAHOO.roths.init); // only initialize if we have the search div in the page