Ext.onReady(function(){

	var clips=Ext.getBody().query('.clip');
	
	Ext.each(clips,function(el){
		var fname=el.href;
		el.href='#'; 
		el.onclick=function(){return false}
		Ext.get(el).on({ click: function(){showVideo(fname,{},el.title,394,298)} });
	},this);

	parent.closeWindow=function(){ Ext.getCmp('mainWin').close(); }
});


function showVideo(swf,vars,title,w,h){
	var animLength=1;

	new Ext.ux.MediaWindow({ id: 'mainWin', height: h+30, width: w+12, renderTo:Ext.getBody(), title: title, 
		resizable:false, autoScroll: false, plain:true, modal:true, border:true, constrain: true,
		listeners:{ beforeshow:function(win){win.center()} },
		mediaCfg: { 
			mediaType:'SWF', url:swf, width:w, height:h, autoSize:false, controls: true, start: false, loop: true, 
			unsupportedText: 'Flash Player not installed!', 
			params:{wmode:'transparent', allowscriptaccess : 'always', flashvars: vars }
		}, tools: [ {id:'refresh',handler:function(e,t,p){p.refreshMedia();} } ]
	});

	var x=Ext.get('mainWin').getCenterXY()[0]; var y=Ext.get('mainWin').getCenterXY()[1];
	
	new Ext.Window({ id: 'winBG', renderTo:Ext.getBody(), style:'background:#fff', height: 1, width: 1, modal:true, frame:false, closable:false });
	Ext.getCmp('winBG').show();
	Ext.get('winBG').setOpacity(0);

	Ext.get('winBG').shift({ width:w, x: x, height: 15, opacity:.5, duration: animLength/2, easing:'easeIn' });
	Ext.get('winBG').shift({ height:h, y: y, opacity:1, duration: animLength/2, easing:'easeOut' });
	setTimeout(function(){ Ext.getCmp('mainWin').show(); Ext.getCmp('winBG').close(); },animLength*1000);
}

