var win;

Ext.onReady(function(){
    var videoButton = Ext.get('theVideo');

	if (videoButton){
    	videoButton.on('click', function(){
			// create the window on the first click and reuse on subsequent clicks
			if(!win){
				win = new Ext.Window({
					animateTarget:'show-btn',
					layout:'fit',
					border:false,
					ctCls:'nepPopu',
					id:'nepPopup',
					autoScroll:true,
					width:382,
					height:390,
					closeAction:'hide',
					plain: true,
					modal: true,
					title:''
				});
				win.on('hide',callStopFLV); // on hiding("closing") call that function which will stop the stream
				
			}
			win.show(this);
			win.load({url:siteroot + "en/home/video",callback:playMovie});
		});
	}

	Ext.QuickTips.init();
	
	Ext.apply(Ext.QuickTips.getQuickTip(), {
		hideDelay: 2000
	});
	
	
});

var playMovie = function(){

var so = new SWFObject(siteroot + "local/flash/FLVPlaybackPro.swf", "flash01", "340", "325", "9", "#f0f2f2");
so.addParam("allowFullScreen","true"); // adds fullscreen functionality to the player
so.addVariable("videoSrc", siteroot + "local/flash/videos/Neuropathic_Pain_04_NeP.flv"); // sources the video (siteroot replaces ~)
    so.addParam("AllowScriptAccess","sameDomain"); // this means that js can talk to the flash (through actionscript)
    so.write("flashcontent"); // typical write stuff to the div with id called flashcontent
}


// function to stop the netstream of the video
function callStopFLV() {
	getMovieName("flash01").callStopFLV(); // id for the movie and the actual actionscript function
}

// this is a crossbrowser helper that is required no matter what
function getMovieName(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}
