﻿	
		function positionChange(currentTime, currentPosition) {				           
			var pb = $get('videoprogress');			
			pb.style.width = Math.floor((currentTime / currentPosition) * barwidth) + "px";			
		}

		function playerStateChange(newState) {			
			switch(parseInt(newState)) {

				case 0:
					// end, stop
					$get('playbutton').src = 'images/buttons/play.png';
					seekTo(0);
					pause();
					break;
					
				case 1:
					// playing					
					$get('playbutton').src = 'images/buttons/pause.png';
					break;

				case 2:
					// paused					
					$get('playbutton').src = 'images/buttons/play.png';
					break;
			}
		}
		
		function progressBarClick(e) {						
			var timeloc = Math.floor((e.offsetX / barwidth) * getDuration());
			seekTo(timeloc);			
		}

		function onplayclick() {
			if (isPlaying())
				pause();			
			else 				
				play();			
		}
			
			
		var barwidth = 162;
		$addHandler($get('glassLayer'), 'click', processGlassClick);
		$addHandler($get('videoprogressglass'), 'click', progressBarClick);
		onCurrentPositionChange = positionChange;
		onPlayerStateChange = playerStateChange;
	
		
		var fadeTimer;
		var showing = false;
		
		function showfbmenu() {
			if (!showing) {
				showing = true;
				if (fadeTimer) {
					window.clearTimeout(fadeTimer);
					fadeTimer = null;
				}
				var menupanel = $get("fbmenu");
				var confPanelAnimation = new AjaxControlToolkit.Animation.FadeInAnimation(menupanel, .5, 30, 0, 100, true);
				confPanelAnimation.play();
				//$get("fbmenu1").className = "fbmenuon";
				
			}
		}

		function hidefbmenu() {
			if (showing) {				
				if (fadeTimer) {
					window.clearTimeout(fadeTimer);
					fadeTimer = null;					
				}								
				var menupanel = $get("fbmenu");
				var confPanelAnimation = new AjaxControlToolkit.Animation.FadeOutAnimation(menupanel, .2, 30, 0, 100, true);
				confPanelAnimation.play();
				showing = false;				
			}
			
			//$get("fbmenu1").className = "fbmenuoff";
		}
		
		function startfade() {			
			fadeTimer = window.setTimeout("hidefbmenu()", 500);				
		}

		function clearfade() {
			if (fadeTimer) {
				window.clearTimeout(fadeTimer);
				fadeTimer = null;					
			}			
		}
	