			// player state variables
				var currentState = "NONE"; 
				var previousState = "NONE"; 
				
				// the player object
				var player = null;
				
				// load the player
				function playerReady(thePlayer) {
					player = document.getElementById(thePlayer.id);
					addListeners();
				} // end function

				// add the listeners, keep checking the state
				function addListeners() {
					if (player) { 
						player.addModelListener("STATE", "stateListener");
					} else {
						setTimeout("addListeners()",100);
					}
				} // end function

				// if the state changes, lets do something
				function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
					currentState = obj.newstate; 
					previousState = obj.oldstate; 
					
					/* 
						var tmp = document.getElementById("stat");
						if (tmp) { 
							tmp.innerHTML = "current state: " + currentState + 
							"<br>previous state: " + previousState; 
						}
					*/

					if ((currentState == "COMPLETED")&&(previousState == "PLAYING")) {
						// document.location.href="http://www.jeroenwijering.com/?item=JW_FLV_Media_Player"; 
						//alert('video done');
						document.getElementById('play_video').innerHTML ='<a href="javascript:showVideo(\'biofeedback.flv\');"><img src="http://www.sovcal.com/images/video-thumb.jpg" border="0" alt="Biofeedback"></a>';
					}
				} // end function 


				
				// USE THIS, NOT CREATE VIDEO
				
				function showVideo(video){
					var s1 = new SWFObject('http://www.sovcal.com/video/flvplayer.swf','ply','294','214','9','#');
					s1.addParam('allowfullscreen','true');
					s1.addParam('allowscriptaccess','always');
					s1.addParam('wmode','opaque');
					s1.addParam('id','ply');
					s1.addParam('name','ply');
					s1.addParam('flashvars','image=http://www.sovcal.com/images/video-thumb.jpg&file=http://www.sovcal.com/video/' + video + '&backcolor=4f5597&frontcolor=ffffff&lightcolor=#FFCC00&screencolor=#000000&autostart=true');
					s1.write('play_video');
	
				}// end function


				function videoPage(video){
					var s1 = new SWFObject('http://www.sovcal.com/video/flvplayer.swf','ply','495','380','9','#');
					s1.addParam('allowfullscreen','true');
					s1.addParam('allowscriptaccess','always');
					s1.addParam('wmode','opaque');
					s1.addParam('id','ply');
					s1.addParam('name','ply');
					s1.addParam('flashvars','file=http://www.sovcal.com/video/' + video + '&backcolor=4f5597&frontcolor=ffffff&lightcolor=#FFCC00&screencolor=#000000&controlbar=over&stretching=fill&autostart=true');
					s1.write('play_video');
	
				}// end function