dojo.provide("Z2h.Slide.CorporateVid");

dojo.require("dojo.fx");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");

dojo.require("Z2h.Slide");

dojo.declare("Z2h.Slide.CorporateVid", [Z2h.Slide], {
		 templateString: null,
		 templatePath: dojo.moduleUrl("Z2h","Slide/templates/CorporateVid.html"),
		 widgetsInTemplate : true,

		 /**
		  * Public variables
		  */
		 video_title: '',
		 video_file: '',
		 video_thumb: '/flash/history/history_vid.jpg',

		 /**
		  * Private variables
		  */
		 _currentlyShown: false,
		 _swfPlayer: null,
		 _videoPlayerId: '',
		 _slideshow: null,

		 /**
		  * Methods
		  */
		 show: function(slideshow){
		     this._videoPlayerId = this.videoPlayerContainer.id;
		     if ( swfobject.hasFlashPlayerVersion("9.0.0") ){
			 var attributes = { data: "/flash/SlideVideoPlayer.swf", width: "700", height: "394" };
			 var parameters = {
			     flashvars: "videoPath="+this.video_file+"&bufferlength=1&image="+this.video_thumb,
			     "wmode" : "opaque",
			     "allowFullScreen" : "true",
			     "allowscriptaccess" : "always",
			     "allowScriptAccess" : "always",
			     "swliveconnect":"true"
			 };
			 this._swfPlayer = swfobject.createSWF(attributes,parameters,this._videoPlayerId);

			 this._currentlyShown = true;
		     }
		 },

		 okayToSlide: function(){
		     /*
		     var player = dojo.byId(this._videoPlayerId);
		     if ( player.getFlashVideoState && player.getFlashVideoState() == "Play"){
			 return false;
		     }*/
		     return true;
		 },

		 hide: function(){
		     if ( this._swfPlayer ) {
			 this._swfPlayer = null;
			 this._currentlyShown = false;
			 swfobject.removeSWF(this._videoPlayerId);
			 var playerContainer = dojo.create('div');
			 dojo.attr(playerContainer,'id',this._videoPlayerId);
			 var imgPlaceholder = dojo.create('img');
			 dojo.attr(imgPlaceholder,'src',this.video_thumb);
			 dojo.attr(imgPlaceholder,'alt','Z2H Media Slideshow Video Thumbnail');
			 dojo.place(imgPlaceholder,playerContainer,'last');
			 dojo.place(playerContainer,this.videoPlayerDiv,'last');
		     }
		 }

	     });
