function writeMovie(movie, width, height, controller, autoplay, title){
	if(controller!==false) controller=true;
	if(autoplay  !==false) autoplay  =true;

	width  = width  || 720;
	height = height || 368;
	var id = writeMovie.id++;

	document.write(
		'<div align="left" id="MovieContainer'+id+'" style="width:'+width+'px;height:'+(height+1)+'px;overflow:hidden;"><object classid=clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+width+'" height="'+height+'" id="pm'+id+'" style="z-index:1"><param name="wmode" value="transparent"><param name="bgcolor" value="#000000"><param name="src" value="'+movie+'?"><param name="autoplay" value="'+autoplay+'"><param name="controller" value="true"><param name="enablejavascript" value="false"><embed id="pme'+id+'" wmode="transparent" bgcolor="#000000" width="'+width+'" height="'+height+'" pluginspage="http://www.apple.com/quicktime/download/" src="'+movie+'?" type="video/quicktime" controller="true" autoplay="'+autoplay+'" name="pm" enablejavascript="true" style="z-index:1"></embed></object></div>'+

		'<div align="left" ID="MovieControl'+id+'" style="overflow:hidden;background-color:#000;width:'+width+'px;height:1px;position:relative;"><div style="position:relative;left:'+((width-(title?315:210))/2)+'px;top:'+((height-110)/2)+'px;" ID="ControlButtons'+id+'"><img src="/images/resume_zoom_out.gif" id="resumeImg'+id+'"><img src="/images/email_zoom_out.gif" id="emailImg'+id+'"><img src="/images/link_zoom_out.gif" id="linkImg'+id+'"></div>'+(title?'<div style="position:absolute;bottom:30px;height:29px;border-top:1px solid #FFF;width:100%;color:#FFF;font-family:tahoma, verdana, sans-serif;font-weight:bold;font-size:11px;">&nbsp;&nbsp;You Are Now Watching: '+title+'</div>':'')+
		
			
		'</div>');

	var div1 = document.getElementById('MovieControl'   +id);
	var div2 = document.getElementById('MovieContainer' +id);
	var div3 = document.getElementById('ControlButtons' +id);
	var div4 = document.getElementById('EmailControl'   +id);
	var div5 = document.getElementById('LinkControl'    +id);
	var img1 = document.getElementById('resumeImg'      +id);
	var img2 = document.getElementById('emailImg'       +id);
	var img3 = document.getElementById('linkImg'        +id);
	var btn1 = document.getElementById('EmailSendButton'+id);
	var btn2 = document.getElementById('EmailBackButton'+id);
	var btn3 = document.getElementById('LinkBackButton' +id);
	var cS   = document.getElementById(document.getElementById('pme'+id)?'pme'+id:'pm'+id);
	var mD   = false;

//	addEvent(cS, 'mousedown', function(){ 

	var friendEmail = document.getElementById('friendEmail'+id);
	var yourEmail   = document.getElementById('yourEmail'+id);
	var yourMessage = document.getElementById('yourMessage'+id);

	if(!title){
		img2.style.display = 'none';
	}

	img1.onmouseover = function(){ this.src = '/images/resume_zoom_in.gif';  }
	img1.onmouseout  = function(){ this.src = '/images/resume_zoom_out.gif'; }

	img2.onmouseover = function(){ this.src = '/images/email_zoom_in.gif';   }
	img2.onmouseout  = function(){ this.src = '/images/email_zoom_out.gif';  }
	
	img3.onmouseover = function(){ this.src = '/images/link_zoom_in.gif';    }
	img3.onmouseout  = function(){ this.src = '/images/link_zoom_out.gif';   }

	img1.onclick     = function(){
		showController(cS, controller);
		cS  .style.height   =
		div2.style.height   = (height+1)+'px';
		cS  .style.width    = width+'px';
		cS.style.visibility = '';
		cS.SetRate(1);
		div1.style.height   = '1px';
	}

	img2.onclick     = function(){
		div3.style.display = 'none';
		div4.style.display = 'block';
	}

	img3.onclick     = function(){
		div3.style.display = 'none';
		div5.style.display = 'block';
	}

	btn1.onclick = function(){
		var img = new Image();
		img.src = '/scripts/interviewEmail.asp?fromAddr=' + escape(yourEmail.value) + '&toAddr=' + escape(friendEmail.value) + '&title=' + escape(title) + '&msg=' + escape(yourMessage.value);

		btn2.onclick();
		img1.onclick();
	}

	btn2.onclick = btn3.onclick = function(){
		div3.style.display = 'block';
		div4.style.display =
		div5.style.display = 'none';

		return false;
	}

	document.body.onmousemove = function(ev){
		// left = 34, right = 50, bottom = 16
		var pos = getPos(cS);
		var mC  = mouseCoords(ev);
		var h   = parseInt(cS.height);
		var w   = parseInt(cS.width);

		mD      = (mC.y>pos.y+h-16) && (mC.y<pos.y+h) && (mC.x>pos.x+34) && (mC.x<pos.x+w-50);
	}

	cS.onmouseover   = function(){ showController(cS, controller); };
	cS.onmouseout    = function(){ hideController(cS, controller); };

	var beenPlaying  = false;
	setTimeout(function(){ hideController(cS, controller); }, 1000);
	setInterval(function(){
		if(mD && cS.GetRate()==0) beenPlaying=false; // user is dragging the time control
		try{
			if(!beenPlaying && (cS.GetRate()!=0)){
				beenPlaying = true;
			}else if(beenPlaying && (cS.GetRate()==0) && (div1.style.height=='1px')){
				div1.style.height  = height+'px';
				div3.style.display = 'block';
				cS  .style.height  =
				cS  .style.width   = 
				div2.style.height  = '1px';
				div4.style.display =
				div5.style.display = 'none';
			}
		}catch(err){}
	}, 50);
}
writeMovie.id = 0;

function mouseCoords(e){if(typeof(e)=='undefined')e=window.event; if (e.pageX || e.pageY) return {x:e.pageX, y:e.pageY}; return {x:e.clientX+document.body.scrollLeft-document.body.clientLeft, y:e.clientY+document.body.scrollTop-document.body.clientTop};}

function getPos(e){
	var left=0;
	var top=0;
	while (e.offsetParent){
		left+=e.offsetLeft;
		top+=e.offsetTop;
		e=e.offsetParent;
	}
	left+=e.offsetLeft;
	top+=e.offsetTop;
	return {x:left, y:top};
}

function showController(cS, controller){
	if(!controller){
		try{
			cS.SetControllerVisible(true);
		}catch(err){}
	}
}

function hideController(cS, controller){
	if(!controller){
		try{
			cS.SetControllerVisible(false);
		}catch(err){
			setTimeout(function(){ hideController(cS, controller); }, 1000);
		}
	}
}
