/**
 * @author Lt. Commander Data
 */

var BackgroundShade = new Class({
  initialize: function(color){
    this.color = (color != "" && color != null) ? color : '#000000';
    this.duration = 550;
    this.active = false;
    this.shade = new Element('span', {
      'id': 'bgshade',
      'styles': {
        'position': 'absolute',
        'top': '0',
        'left': '0',
        'z-index': '10',
        'width': window.getSize().x + 'px',
        'height': window.getScrollSize().y + 'px',
        'background-color': this.color,
        'opacity': '0'
      }
    });
    this.fadeshade = new Fx.Tween(this.shade, {
      duration: this.duration
    });
  },
  fadeIn: function(){
    this.shade.inject(document.getElementsByTagName('body')[0]);
    this.fadeshade.start('opacity', '0.85');
    this.active = true;
  },
  kill: function(){
    this.fadeshade.start('opacity', '0');
    window.setTimeout(function(){
      this.active = false;
      $('bgshade').destroy();
    }, this.duration);
  }
});


 window.addEvent("domready", function(){
 	
	$$('.printpage').each(function(el){
		el.setStyle('display', 'block');
		
	});
	$$('.printlink').each(function(el){
		el.addEvent('click', function(){
			window.print();
		});
		
	});
	
	if($defined($('singleArtwork'))){
		var aid = $('singleArtwork').className.substring($('singleArtwork').className.indexOf('_')+1);
		$('singleArtwork').setStyle('cursor','pointer');
		var wrap = new Element('div',{
			'class': 'single_artwork_wrap'
		});
		var hint = new Element('span', {
			'id': 'popuphint',
			'styles':{
				'position': 'absolute',
				'background-color':'#000',
				'color': '#fff',
				'opacity': '0',
				'padding': '8px'
			},
			'html': 'click to enlarge'
		});
		hint.set('tween', {duration:300});
		wrap.adopt(hint);
		wrap.wraps('singleArtwork');
		$('singleArtwork').addEvents({
			'click': function(){
				var pu = new ArtworkPopup(aid);
			},
			'mouseover': function(){
				$('popuphint').fade('0.8');
			},
			'mouseout': function(){
				$('popuphint').fade('out');
			}
		});
	}
	
 });

