// Copyright 2004, OSO Systems

var TimerOn = false;
var TimerID = null;

var TopMargin = 40;
var BottomMargin = 40;

var BigLogoHeight = 380;
var BigLogoWidth = 560;
var BigLogoImage = new Image();
BigLogoImage.src = "images/salsasabrosalogo.gif";

var SmallLogoHeight = 170;
var SmallLogoWidth = 250;
var SmallLogoImage = new Image();
SmallLogoImage.src = "images/salsasabrosalogosmall.gif";

var LogoHeight;
var LogoWidth;
var LogoHeightDelta;
var LogoWidthDelta;

function InitLogoAnimation()
{
  if (TimerOn)
    clearInterval(TimerID);
  if (document.all)
  {
    document.all.Header.style.pixelTop = 0;
    document.all.Header.style.pixelLeft = 0;
    document.all.Header.style.visibility = "visible";
    document.all.Footer.style.pixelTop = document.body.clientHeight - BottomMargin;
    document.all.Footer.style.pixelLeft = 0;
    document.all.Footer.style.visibility = "visible";
    LogoHeight = document.body.clientHeight - BottomMargin - TopMargin;
    LogoWidth = LogoHeight * BigLogoWidth / BigLogoHeight;
    document.all.LogoImg.src = BigLogoImage.src;
    if (LogoHeight < SmallLogoHeight)
    {
      LogoHeight = SmallLogoHeight;
      LogoWidth = SmallLogoWidth;
      document.all.LogoImg.src = SmallLogoImage.src;
    }
    else if (LogoHeight > BigLogoHeight)
    {
      LogoHeight = BigLogoHeight;
      LogoWidth = BigLogoWidth;
    }
    if (LogoWidth > document.body.clientWidth)
    {
      LogoHeight = document.body.clientWidth * LogoHeight / LogoWidth;
      LogoWidth = document.body.clientWidth;
    }
    LogoHeightDelta = LogoHeight / 20;
    LogoWidthDelta = LogoWidth / 20;
    document.all.LogoImg.width = LogoWidthDelta;
    document.all.LogoImg.height = LogoHeightDelta;
    document.all.Logo.style.pixelTop = TopMargin + (document.body.clientHeight - TopMargin - BottomMargin - LogoHeightDelta) / 2;
    document.all.Logo.style.pixelLeft = (document.body.clientWidth - LogoWidthDelta) / 2;
    document.all.Logo.style.visibility = "visible";
  }
  else if (document.getElementById)
  {
    document.getElementById("Header").style.top = 0;
    document.getElementById("Header").style.left = 0;
    document.getElementById("Header").style.visibility = "visible";
    document.getElementById("Footer").style.top = innerHeight - BottomMargin;
    document.getElementById("Footer").style.left = 0;
    document.getElementById("Footer").style.visibility = "visible";
    LogoHeight = innerHeight - BottomMargin - TopMargin;
    LogoWidth = LogoHeight * BigLogoWidth / BigLogoHeight;
    document.images.LogoImg.src = BigLogoImage.src;
    if (LogoHeight < SmallLogoHeight)
    {
      LogoHeight = SmallLogoHeight;
      LogoWidth = SmallLogoWidth;
      document.images.LogoImg.src = SmallLogoImage.src;
    }
    else if (LogoHeight > BigLogoHeight)
    {
      LogoHeight = BigLogoHeight;
      LogoWidth = BigLogoWidth;
    }
    if (LogoWidth > innerWidth)
    {
      LogoHeight = innerWidth * LogoHeight / LogoWidth;
      LogoWidth = innerWidth;
    }
    LogoHeightDelta = LogoHeight / 20;
    LogoWidthDelta = LogoWidth / 20;
    document.images.LogoImg.width = LogoWidthDelta;
    document.images.LogoImg.height = LogoHeightDelta;
    document.getElementById("Logo").style.top = TopMargin + (innerHeight - TopMargin - BottomMargin - LogoHeightDelta) / 2;
    document.getElementById("Logo").style.left = (innerWidth - LogoWidthDelta) / 2;
    document.getElementById("Logo").style.visibility = "visible";
  }
  else if (document.layers)
  {
    document.layers["Header"].moveTo(0, 0);
    document.layers["Header"].visibility = "show";
    document.layers["Footer"].moveTo(0, innerHeight - BottomMargin);
    document.layers["Footer"].visibility = "show";
    LogoHeight = innerHeight - BottomMargin - TopMargin;
    LogoWidth = LogoHeight * BigLogoWidth / BigLogoHeight;
    document.layers["Logo"].document.images.LogoImg.src = BigLogoImage.src;
    if (LogoHeight < SmallLogoHeight)
    {
      LogoHeight = SmallLogoHeight;
      LogoWidth = SmallLogoWidth;
      document.layers["Logo"].document.images.LogoImg.src = SmallLogoImage.src;
    }
    else if (LogoHeight > BigLogoHeight)
    {
      LogoHeight = BigLogoHeight;
      LogoWidth = BigLogoWidth;
    }
    if (LogoWidth > innerWidth)
    {
      LogoHeight = innerWidth * LogoHeight / LogoWidth;
      LogoWidth = innerWidth;
    }
    LogoHeightDelta = LogoHeight / 20;
    LogoWidthDelta = LogoWidth / 20;
    document.layers["Logo"].document.images.LogoImg.width = LogoWidthDelta;
    document.layers["Logo"].document.images.LogoImg.height = LogoHeightDelta;
    document.layers["Logo"].moveTo((innerWidth - LogoWidthDelta) / 2, TopMargin + (innerHeight - TopMargin - BottomMargin - LogoHeightDelta) / 2);
    document.layers["Logo"].visibility = "show";
  }
  TimerID = window.setInterval("ResizeLogo()", 20);
  TimerOn = true;
}

function ResizeLogo()
{
  if (document.all)
  {
    document.all.LogoImg.width += LogoWidthDelta;
    document.all.LogoImg.height += LogoHeightDelta;
    document.all.Logo.style.pixelTop = TopMargin + (document.body.clientHeight - TopMargin - BottomMargin - document.all.LogoImg.height) / 2;
    document.all.Logo.style.pixelLeft = (document.body.clientWidth - document.all.LogoImg.width) / 2;
    if (document.all.LogoImg.width >= LogoWidth)
    {
      document.all.LogoImg.width = LogoWidth;
      document.all.LogoImg.height = LogoHeight;
      document.all.Logo.style.pixelTop = TopMargin + (document.body.clientHeight - TopMargin - BottomMargin - LogoHeight) / 2;
      document.all.Logo.style.pixelLeft = (document.body.clientWidth - LogoWidth) / 2;
      window.clearInterval(TimerID);
      TimerOn = false;
    }
  }
  else if (document.getElementById)
  {
    document.images.LogoImg.width += LogoWidthDelta;
    document.images.LogoImg.height += LogoHeightDelta;
    document.getElementById("Logo").style.top = TopMargin + (innerHeight - TopMargin - BottomMargin - document.images.LogoImg.height) / 2;
    document.getElementById("Logo").style.left = (innerWidth - document.images.LogoImg.width) / 2;
    if (document.images.LogoImg.width >= LogoWidth)
    {
      document.images.LogoImg.width = LogoWidth;
      document.images.LogoImg.height = LogoHeight;
      document.getElementById("Logo").style.top = TopMargin + (innerHeight - TopMargin - BottomMargin - LogoHeight) / 2;
      document.getElementById("Logo").style.left = (innerWidth - LogoWidth) / 2;
      window.clearInterval(TimerID);
      TimerOn = false;
    }
  }
  else if (document.layers)
  {
    document.layers["Logo"].document.images.LogoImg.width += LogoWidthDelta;
    document.layers["Logo"].document.images.LogoImg.height += LogoHeightDelta;
    document.layers["Logo"].moveTo((innerWidth - document.layers["Logo"].document.images.LogoImg.width) / 2, TopMargin + (innerHeight - TopMargin - BottomMargin - document.layers["Logo"].document.images.LogoImg.height) / 2);
    if (document.layers["Logo"].document.images.LogoImg.width >= LogoWidth)
    {
      document.layers["Logo"].document.images.LogoImg.width = LogoWidth;
      document.layers["Logo"].document.images.LogoImg.height = LogoHeight;
      document.layers["Logo"].moveTo((innerWidth - LogoWidth) / 2, TopMargin + (innerHeight - TopMargin - BottomMargin - LogoHeight) / 2);
      window.clearInterval(TimerID);
      TimerOn = false;
    }
  }
}

