var total = 0;
var current = 0;
var elements = [];
var showCnt = function(dir) {
	var c = Ext.get(elements[current]);
	pager.hide();
	var extd = 'l';
	var extd2 = 'r';
	switch (dir) {
		case 'next' :
			current++;
			if (current > total - 1) {
				current = 0;
			}
			;
			break;
		case 'prev' :
			extd = 'r';
			extd2 = 'l';
			current--;
			if (current < 0) {
				current = total - 1;
			}
			;
			break;
	};
	c.slideOut(extd, {
		callback : function(pr) {
			pr.dom.style.display = 'none';
			var c = Ext.get(elements[current]);
			c.slideIn(extd2, {
				callback : function(pr) {
					Ext.get('panelinnercontent').setHeight(pr.getBox().height + 50, {
						callback : function() {
							if (!pager) {
								return;
							};
							pager.alignTo('panelinnercontent', 'br-br', [
								-30, -10
							]);
							pager.show();
						}
					});
				}
			});
			Ext.getDom('pcnt').innerHTML = current + 1;
		}
	});
};
var pager = null;
runOnLoad( function() {
	Ext.ux.Lightbox.register('a.lightbox', false);
	var els = Ext.select('div[class=mfcontainer]');
	total = els.getCount();
	if (total > 0) {
		els.each( function(el) {
			elements.push(el.dom.id);
		});
		els.first().dom.style.display = 'block';
		Ext.get('panelinnercontent').setHeight(els.first().getBox().height + 50, {
			callback : function() {
				if (!pager) {
					return;
				};
				pager.alignTo('panelinnercontent', 'br-br', [
					-30, -10
				]);
				pager.show();
			}
		});
		if (total > 1) {
			var html = '<a href="#" onclick="showCnt(\'prev\'); return(false);">&lt;&lt;</a>&nbsp;<span id="pcnt">' + (current + 1) + '</span>&nbsp;/&nbsp;' + total + '&nbsp;<a href="#" onclick="showCnt(\'next\'); return(false);">&gt;&gt;</a>';
			pager = Ext.DomHelper.insertAfter('panelcontent', {
				tag : 'div',
				id : 'mfpager',
				html : html
			}, true);
			pager.alignTo('panelinnercontent', 'br-br', [
				-30, -10
			]);
			pager.hide();
		}
	}
});
var pMoviePlayer = function(src, w, h, v) {
	var id = getUniqueID();
	var txt = '<div style="width:' + w + 'px; height:' + (h - 30) + 'px;" id="flash' + id + '"></div>';
	var swf = new SWFObject(basepath + '_/flash/moviePlayer.swf', "flash" + id + "obj", w, h, v || "8");
	swf.addParam('wmode', 'transparent');
	swf.addVariable("skinSource", basepath + '_/flash/SteelExternalAll.swf');
	swf.addVariable("streamSource", src);
	swf.useExpressInstall(basepath + '_/flash/expressinstall.swf');
	var m = Ext.Msg.show({
		title : '',
		msg : txt,
		buttons : false,
		modal : false,
		width : w,
		fn : function(btn) {
			Ext.get("flash" + id).remove();
		}
	});
	swf.write("flash" + id);
	// Ext.Msg.getDialog().resizeTo(w + 30, h + 50);
};
var playvideo = function(id) {
	var myPlayer = '';
	myPlayer += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="384" height="325">';
	myPlayer += '<param name="FlashVars" value="&autoplay=0&clipId=' + id + '"/>';
	myPlayer += '<param name="movie" value="http://player.videocluster.de/externClip.swf" />';
	myPlayer += '<embed src="http://player.videocluster.de/externClip.swf" type="application/x-shockwave-flash"';
	myPlayer += 'width="384" height="325" FlashVars="&autoplay=0&clipId=' + id + '"></embed>';
	myPlayer += '</object>';
	var box = Ext.MessageBox.show({
		title : '',
		msg : myPlayer,
		animEl : null,
		width : 420,
		height : 200,
		modal : false,
		fn : function() {
			Ext.MessageBox.hide();
		}
	});
};
var playExtVideo = function(url, w, h) {
	var box = Ext.MessageBox.show({
		title : '',
		msg : '<iframe src="' + url + '" width="' + (w + 50) + '" height="' + h + '" frameborder="0"></iframe>',
		animEl : null,
		width : w + 50,
		height : h,
		modal : false,
		fn : function() {
			Ext.MessageBox.hide();
		}
	});
}