// JavaScript Document

jQuery(document).ready(function(){
	
	if(location.hostname!="localhost") var mmppath = "http://" + location.hostname + "/extensions/MedicalMediaPlayer";
	else var mmppath = "http://localhost/wiki1160/extensions/MedicalMediaPlayer";
	
	var fpkey;
	if(location.hostname=="www.wikiskripta.eu") fpkey = "#@5cd89ae96e189621fb0";
	else if(location.hostname=="www.wikilectures.eu") fpkey = "#@29274a66781c6480561";
	else fpkey = "#@29274a66781c6480561";
	
	jQuery("a.ePlayer").flowplayer(mmppath + "/flowplayer.commercial-3.2.5.swf", {
		key: fpkey,
		play: {
			url: mmppath + '/flowplayerPlayButton.png',
			width: 95,
			height: 95
		},
		clip: { 
			provider: 'rtmp',
			/*connectionArgs:['mp4:124-1.mp4'],*/
			autoPlay: true, 
			scaling: 'fit'
		},
		plugins:  {
			// the RTMP plugin
			rtmp: {
				url: mmppath + '/flowplayer.rtmp-3.2.3.swf',
				netConnectionUrl: 'rtmp://server14.streaming.cesnet.cz/medicalmedias'
			}
		}
	});
	
	$f("*").each(function() {
		this.onBeforeLoad(function() {
			var ca = this.getClip(0).url;
			//var ca = "mp4:124-1.mp4";
			this.getClip(0).update({connectionArgs: [ca] });
			//this.getClip(0).update({connectionArgs: ["mp4:124-1.mp4"] });
		});
	})
	
	
	jQuery(".exPlayer").click(function(){
		var url = jQuery(this).attr('href');
		var px = url.split('-');
		var vWidth = parseInt(px[1])+80;
		var vHeight  = parseInt(px[2])+80;
		jQuery(this).html("<iframe src=http://www.medicalmedia.eu/ePlayer.aspx?ID=" + px[0] + "&w=" + vWidth + " width='" + vWidth + "px' height='" + vHeight + "px' frameborder='0'></iframe><br />");
		return false;
	});
	
});

