/**
 * Copyright Ideakone Oy / antti@ideakone.fi
 */
var Album = {
  on: "/Kotisivukone/www/pics/star_yellow.gif",
  off: "/Kotisivukone/www/pics/star_grey.gif",
  clicked: false,
  loadAlbum: function () {
    if (window.opener != null && document.getElementById && document.getElementById('closeAlbumBtn')) {
      document.getElementById('closeAlbumBtn').style.display = 'block';
    }
    else {
      document.getElementById('backAlbumBtn').style.display = 'block';
    }
  },

  rating: function (elem) {
    if (Album.clicked || !document.getElementById) return;

    elem.src = Album.on;
    var i = elem.id.substring(6, 7); // rating1
    document.getElementById('rating2').src = (i < 2 ? Album.off : Album.on);
    document.getElementById('rating3').src = (i < 3 ? Album.off : Album.on);
    document.getElementById('rating4').src = (i < 4 ? Album.off : Album.on);
    document.getElementById('rating5').src = (i < 5 ? Album.off : Album.on);
  },

  rate: function(elem) {
    Album.clicked = true;
    window.location = '?rate=' + elem.id.substring(6, 7);
  },

  openSlideshow: function () {
    window.open('?slideshow', "slideshow", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=680, height=660");
  },

  doRate: function(on) {
    if (Album.clicked || !document.getElementById) return;
    if (document.getElementById('rate') == null) return;
    if (on) {
      document.getElementById('rating').style.display = 'none';
      document.getElementById('rate').style.display = 'block';
    }
    else {
      document.getElementById('rate').style.display = 'none';
      document.getElementById('rating').style.display = 'block';
    }
  }
  /*,
  setMaxWidth: function() {
    if ($('big_image')) {
      var image = $('big_image');
      
      var imageWidth = image.getWidth();
      
      var extra = 100;
      var maxWidth = $('content').getWidth() - extra;
      
      if (imageWidth > maxWidth) {
       image.setStyle({width:  (maxWidth - extra) + 'px'});
      }
    }
  }*/
};
