			// 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('preview').style.margin="0";
						document.getElementById('preview').innerHTML ='<a href="http://www.michaelshouse.com/treatment-program/"><img src="images/statement-3.jpg" border="0" alt=""></a>';
					}
				} // end function 


				
				// USE THIS, NOT CREATE VIDEO
				
				function showVideo(){
					var s1 = new SWFObject('http://www.michaelshouse.com/video-upload/player.swf','ply','352','260','9','#');
					s1.addParam('allowfullscreen','false');
					s1.addParam('allowscriptaccess','always');
					s1.addParam('wmode','opaque');
					s1.addParam('id','ply');
					s1.addParam('name','ply');
					s1.addParam('flashvars','image=http://www.michaelshouse.com/video-upload/preview.jpg&file=http://www.michaelshouse.com/video-upload/mhvideo.flv&skin=http://www.michaelshouse.com/video-upload/overlay.swf&frontcolor=ffffff&lightcolor=cc9900&controlbar=over&stretching=fill&autostart=true');
					s1.write('preview');
					document.getElementById('preview').style.margin="8px 30px 0 0";
	
				}// end function