	

	/*

	Class: VidPlayer 
	
	Description:
		
	*/
	
	var VidPlayer = Class.create();
	
	VidPlayer.prototype = {
	
		_name: "VidPlayer",
		_version: "0.5a",
		
		
		initialize: function(id,w,h,src) {
				
			if (id == '') {
				return false;
			} else {
				this.$id = id;
			}
		
			if (w) {
				this.$width = w;
			} else {
				this.$width = 300;
			}
			
			if (h) {
				this.$height = h;
			} else {
				this.$height = 195;
			}
			
			if (src == "youtube") {
				this.src = "youtube";
			} else {
				this.src = "google";
			}
			
			this.createView();

		},
		
		
		setPosition: function() {
		
			/*
			
				- get window width and height
				- determine center for player view
				- set array position {Top, Left, Width, Height}
				
			*/

			$window = document.viewport.getDimensions();
			$scroll = document.viewport.getScrollOffsets();
			this.$left = Math.round($window['width']/2) - Math.round(this.$width/2);
			this.$top = Math.round($window['height']/2) - Math.round(this.$height/2);
			this.$top += $scroll['top'];
			this.$view = $("vidplayer");
			this.$view.absolutize();

			this.$view.setStyle("width:"+this.$width+"px");
			this.$view.setStyle("height:"+this.$height+"px");
			this.$view.setStyle("top:"+this.$top+"px");
			this.$view.setStyle("left:"+this.$left+"px");
			this.$view.setStyle("background-color:#000000");

			this.insertDragBar();
		
		},
		
		
		createView: function() {
		
			/*
				- generate HTML for player window
				- set appropriate style 
				- insert view container
			*/
			
			$view = "<div id='vidplayer'></div>";			
			$body = $(document.body);
			$body.insert($view);
			this.$view = $('vidplayer');
			
			this.setPosition();		

		},
		
		
		insertDragBar: function() {
			$dragbar = "<div id='dragbar'><div id='dragbarleft'></div><div id='dragbarcenter'></div><div id='dragbarright' onclick='$(\"vidplayer\").remove();'></div></div>";
			this.$view.insert($dragbar);			
			this.$dragbar = $('dragbar');
			this.$dragbar.setStyle("width:100%");
			this.$dragbar.setStyle("height:25px");
			this.makeDraggable();

		},
		
		
		generateObjectTag: function() {						
			this.$object = "<embed id=\"VideoPlayback\" style=\"width:300px;height:250px\" allowFullScreen=\"false\" src=\"http://video.google.com/googleplayer.swf?docid="+this.$id+"&autoplay=1\" type=\"application/x-shockwave-flash\"> </embed>";
			this.$view.insert(this.$object);
		},


		doGoogleTag: function() {						
			this.$object = "<embed id=\"VideoPlayback\" style=\"width:300px;height:250px\" allowFullScreen=\"false\" src=\"http://video.google.com/googleplayer.swf?docid="+this.$id+"&autoplay=1\" type=\"application/x-shockwave-flash\"> </embed>";
			this.$view.insert(this.$object);
		},


		doYouTubeTag: function() {
			this.$object = "<object width='"+this.$width+"' height='"+this.$height+"'><param name='movie' value='http://www.youtube.com/v/"+this.$id+"&color1=0xb1b1b1&color2=0xcfcfcf&hl=en&feature=player_embedded&fs=1&rel=0&autoplay=1'></param><param name='allowFullScreen' value='true'></param><embed src='http://www.youtube.com/v/"+this.$id+"&color1=0xb1b1b1&color2=0xcfcfcf&hl=en&feature=player_embedded&fs=1&rel=0&autoplay=1' type='application/x-shockwave-flash' allowfullscreen='true' width='"+this.$width+"' height='"+this.$height+"'></embed></object>";

			this.$view.insert(this.$object);
		},
		
		
		makeDraggable: function() {
			this.$Drag = new Draggable(this.$view,{handle:"dragbar",starteffect:'',endeffect:''});			
			if (this.src=="google") {
				this.doGoogleTag();
			} else if (this.src=="youtube") {
				this.doYouTubeTag();
			}
		},
		
		
		attachViewFunctions: function() {
		
			/* attach functions to close window */
			
			/* other view control functions (expand, fullscreen, etc?) */
		
		}
		

	/* END VidPlayer */
		
	}
		