Gucci.Video = Class.create();
Gucci.Video.prototype = {
  flashvars: null,
  attributes: null,
  params: null,
  localid: null,
  hidden: false,
  initialize: function(item){
	
	var initialhide = (document.cookie.indexOf('forceCountryRedirectOverlay=') != -1);
    var container = item.down('.video-wrapper');
    if (!container) return;
    var a = container.down('[href]');
    this.localid = container.identify();
    
    // Use a poster if available
    if(img = a.down('img'))
      var poster = img.readAttribute('src');
    
	if (typeof swfobject == 'undefined' || !swfobject) return;
    var h264 = swfobject.hasFlashPlayerVersion('9.0.115');
    var video = a.readAttribute('href');

    //remove the href link
    a.writeAttribute('href', '#').observe('click', function(e) { e.stop(); });
    a.writeAttribute('style', 'cursor:default;');
   
    this.params = {
      menu: 'false',
      quality: 'high',
      wmode: 'direct',
      allowfullscreen:'true'
    };
	
    this.flashvars = {
     skin:'http://images.gucci.com/videos/swf/skin.swf',
     autostart: true,
     image: poster ? poster : '',
     file: video
    };

    this.attributes = {};

	if (initialhide && ($$('.video-overlay').size() > 0) && ($$('.video-altcontent').size() > 0)) {
		$$('.video-overlay')[0].hide();
		$$('.video-altcontent')[0].hide();
		this.hidden = true;
	}
	
	if (!this.hidden)
		this.play();
  },
  play: function() {
	if (this.hidden) {
		$$('.video-overlay')[0].show();
		$$('.video-altcontent')[0].show();
		this.hidden = false;
	}
	swfobject.embedSWF('http://images.gucci.com/videos/swf/player.swf', this.localid, '100%', '100%', '9.0.115', false, this.flashvars, this.params, this.attributes);
  }
};
