function _logo() {
  this.preLoad = preLoad;
  var logo = document.getElementById('logo');
  var lwidth = logo.width;
  var ctx = logo.getContext('2d');
  var img1;
  var img2;
  var image1loaded = false;
  var image2loaded = false;
  var alpha = 0;

  var imagepath = '/flash/source/logo/logo/';
  var images = [];
  images['spring']    = ['sneeuwklok.jpg', 'bloesem.jpg'];
  images['summer']    = ['sunshine.jpg', 'zeezicht.jpg'];
  images['autumn']    = ['mist.jpg', 'autumn_pathway.jpg'];
  images['winter']    = ['dauw.jpg', 'rijp.jpg'];
  images['christmas'] = ['christmas_wallpaper_fancyredballs.jpg', 'christmas_layout_31.jpg'];

  function getSeason() {
    var tmpDate = new Date();
    var md = (tmpDate.getMonth() +1) * 100 + tmpDate.getDate();

    season = 'winter';
    if (md >= 321) season = 'spring';
    if (md >= 621) season = 'summer';
    if (md >= 921) season = 'autumn';
    if ((md >= 1221) || (md == 101)) season = 'christmas';

    return(season);
  }

  function preLoad(startalpha) {
    startalpha = typeof(startalpha) != 'undefined' ? startalpha : 0;
    alpha = startalpha;
    season = getSeason();

    if (alpha == 1) ShowImageScrollerDirect();

    img1 = new Image();
    img1.onload = function() {
      image1loaded = true;
      drawImage();
      if (alpha != 1) $(function() { setTimeout(Animate, 1500); });
    }
    img1.src = imagepath + images[season][0];

    img2 = new Image();
    img2.onload = function() {
      image2loaded = true;
      drawImage();
      if (alpha != 1) $(function() { setTimeout(Animate, 1500); });
    }
    img2.src = imagepath + images[season][1];
  }

  function drawImage() {
    if (image1loaded && image2loaded) {
      ctx.globalAlpha = 1 - alpha;
      ctx.drawImage(img1, alpha * 103, 0, lwidth - alpha * 103, 103 - alpha * 10, 0, 0, lwidth, 103);

      ctx.shadowOffsetX = 3;
      ctx.shadowOffsetY = 3;
      ctx.shadowBlur    = 4;
      ctx.shadowColor   = 'rgba(0, 0, 0, ' + ((1 - alpha) * 0.8) + ')';

      ctx.font = 'bold 20px verdana';
      ctx.fillStyle = "rgba(255,255,255," + (1 - alpha) + ")";
      ctx.fillText('', 0, 0);
      ctx.fillText('24 uur per dag', 30, 80);
      ctx.fillText('7 dagen in de week', 400, 40);
      ctx.fillText('altijd actueel', 750, 60);

      ctx.globalAlpha = alpha;
      displacement = (Math.cos(alpha * Math.PI + Math.PI) +1) * 0.5;
      ctx.drawImage(img2, 0, 0, lwidth - displacement * 103, 103 - displacement * 10, 0, 0, lwidth, 103);

      ctx.shadowColor   = 'rgba(0, 0, 0, ' + (alpha * 0.8) + ')';

      ctx.font = 'bold 35px verdana';
      ctx.fillStyle = "rgba(255,255,255," + alpha + ")";
      ctx.fillText('', 0, 0);

      ctx.fillText('Meteo IJsselmuiden ', 30, 55);

      var tw = ctx.measureText('MeteoIJsselmuiden ').width;
      ctx.font = 'italic bold 35px verdana';
      ctx.fillText(' .nl', 30 + tw, 55);

      ctx.font = 'bold 14px verdana';
      ctx.fillStyle = "rgba(255,255,255," + alpha + ")";
      ctx.fillText('De actuele weersite van IJsselmuiden én omstreken', 70, 82);

      ctx.font = 'italic bold 35px verdana';
      var tw = ctx.measureText('MeteoIJsselmuiden  .nl').width;
      ctx.font = 'italic bold 13px verdana';
      ctx.fillStyle = "rgba(255,255,255," + alpha + ")";
      ctx.fillText('(nu ook via 8271.nl)', 40 + tw, 55);

      ctx.font = 'bold 11px verdana';
      var tw = ctx.measureText('Disclaimer').width;
      ctx.fillStyle = "rgba(255,255,255," + alpha + ")";
      ctx.fillText('Disclaimer', lwidth - 20 - tw, 40);
      var tw = ctx.measureText('Contact').width;
      ctx.fillStyle = "rgba(255,255,255," + alpha + ")";
      ctx.fillText('Contact', lwidth - 20 - tw, 55);
      var tw = ctx.measureText('Zoeken').width;
      ctx.fillStyle = "rgba(255,255,255," + alpha + ")";
      ctx.fillText('Zoeken', lwidth - 20 - tw, 70);
    }
  }
  
  function Animate() {
    drawImage();
    if (alpha < 1) {
      alpha += 0.01;

      if (Math.round(alpha*100)/100 == 0.5) ShowImageScroller();
      setTimeout(Animate, 50);
    }  
  }
}
