  // (c)2003-2008 activeweave, inc. - http://www.activeweave.com
// author: Alexandre Gellibert - mailto:alex@activeweave.com

var Activeweave = window.Activeweave || {};

/* Temporary Redefinition in order to function both  in Rover and Stickis */
Activeweave.Utils               = Activeweave.Utils               || {};
Activeweave.Utils.isIE          = Activeweave.Utils.isIE          || Activeweave.isIE;
Activeweave.Utils.isIE6         = Activeweave.Utils.isIE6         || Activeweave.isIE6;
Activeweave.Utils.isMacFF       = Activeweave.Utils.isMacFF       || Activeweave.isMacFF;
Activeweave.Utils.swap          = Activeweave.Utils.swap          || Activeweave.swap;
Activeweave.Utils.USER          = Activeweave.Utils.USER          || Activeweave.USER;

Activeweave.Splash =
  {
  DEFAULT_POPUP_WIDTH: 400,

  showPopup: function(width)
    {
    width = width || Activeweave.Splash.DEFAULT_POPUP_WIDTH;
    var topOffset = 0;
    var shadowW  = $('shadow');
    if(shadowW)
      {
      shadowW.style.visibility = 'visible';
      shadowW.style.display    = 'block';
      shadowW.style.height     = Math.max(document.body.offsetHeight,document.documentElement.clientHeight)+"px";
      if(Activeweave.Utils.isMacFF())
        {
        var anim = $('animation');
        if(anim)
          {
          anim.style.display = 'none';
          }
        }
      }
    var popupW  = $('signinPopup');
    if(popupW)
      {
      popupW.style.display     = 'block';
      popupW.style.visibility  = 'visible';
      popupW.style.width = width+"px";
      var x = (document.body.offsetWidth-width)/2;
      popupW.style.left        = x+"px";
      var offsetFromTop = Activeweave.Utils.isIE6()?document.documentElement.scrollTop:0;        
      popupW.style.top         = offsetFromTop+Math.max(10,((document.documentElement.clientHeight-popupW.offsetHeight)/2)-topOffset)+"px";
      }
    if(Activeweave.defaultRenewPasswordMessage)
      {
      var statusElt = $('authRenew');
      if(statusElt) statusElt.innerHTML = Activeweave.defaultRenewPasswordMessage;
      }
    var userInput = $(Activeweave.Utils.USER);
    if(userInput) userInput.focus();
    },

   hidePopup: function()
    {
    var popupW  = $('signinPopup');
    if(popupW)
      {
      popupW.style.visibility  = 'hidden';
      popupW.style.display     = 'none';
      }
    var shadowW  = $('shadow');
    if(shadowW)
      {
      shadowW.style.visibility = 'hidden';
      shadowW.style.display    = 'none';
      }
    if(Activeweave.Utils.isMacFF())
        {
        var anim = $('animation');
        if(anim)
          {
          anim.style.display = 'block';
          }
        }
    var userW  = $(Activeweave.Utils.USER);
    if(userW)
      {
      userW.value = '';
      }
    var passW  = $('authPass');
    if(passW)
      {
      passW.value = '';
      }
    var authInvalidW  = $('authInvalid');
    if(authInvalidW)
      {
      authInvalidW.style.visibility = 'hidden';
      authInvalidW.style.display    = 'none';
      }
    }
  }

if(Activeweave.Utils&&Activeweave.Utils.resize)
  {
  window.onresize = Activeweave.Utils.resize;
  }
