function mediaplayer(video) {
	this.init = function() {
		this.video = video;
		this.debug = false;
	}
	this.displayBlock = function(id, arg) {
		this.d("Display block: " + id + ", status: " + arg);
		var e = document.getElementById(id);
		switch (arg) {
			case false:
			document.getElementById(id).style.display = "none";
			break;
			case true:
			document.getElementById(id).style.display = "block";
			break;
		}
	}
	this.moveBlock = function(id, arg) { // So that MIKR headings work; display: none breaks them
		this.d("Move block: " + id + ", status: " + arg);
		var e = document.getElementById(id);
		if (e) {
			switch (arg) {
				case false:
					e.style.position = "relative";
					e.style.left = 0 + "px";
					e.style.top = 0 + "px";
					e.style.width = "100%";
				break;
				case true:
					e.style.position = "absolute";
					e.style.left = -3000 + "px";
					e.style.top = -3000 + "px";
			}
		}
	}
	this.checkSWF = function(video) {
		this.video = video;
		this.moveBlock("mediaSection", true);
		this.displayBlock("mediaContentBlock", true);
		this.generateSWF();
	}	
	this.checkVideo = function(video) {
		this.video = video;
		this.moveBlock("mediaSection", true);
		this.displayBlock("mediaContentBlock", true);
		this.generateVideo();
	}
	this.generateSWF = function() {
		document.getElementById("mediaContentBlock").style.height = "auto";
		this.d("Play flash");
		var so = new SWFObject(this.video, this.video, "480", "385", "8", "#000000");
		so.addVariable('file', this.video);
		so.addVariable('autoStart','true');
		so.addParam("wmode", "normal");
		so.addParam("scale", "exactfit");		
		so.write("mediaContentBlock");
		var soSuccess = document.getElementById("mediaContentBlock").innerHTML;
		if (soSuccess.indexOf("IMG") != -1) {
			this.displayBlock("flashErrorBlock", true);
		}
		this.d(document.getElementById("mediaContentBlock").innerHTML);
	}	
	this.generateVideo = function() {
		document.getElementById("mediaContentBlock").style.height = "auto";
		this.d("Play video");
		var so = new SWFObject("fileadmin/flvPlayer.swf?videoPath="+ this.video +"&autoStart=true&autoHide=false&autoHideTime=5&hideLogo=true&volAudio=60&newWidth=480&newHeight=270&disableMiddleButton=false&playSounds=true&soundBarColor=0xD32232&barColor=0xD32232&barShadowColor=0xCCCCCC&subbarColor=0xffffff", this.video, "480", "270", "8", "#000000");
		so.addParam("allowFullScreen", "true");
		so.addVariable("autoStart","true");
		so.addParam("wmode", "normal");
		so.write("mediaContentBlock");
		var soSuccess = document.getElementById("mediaContentBlock").innerHTML;
		if (soSuccess.indexOf("IMG") != -1) {
			this.displayBlock("flashErrorBlock", true);
		}
		this.d(document.getElementById("mediaContentBlock").innerHTML);
	}
	this.previewImage = function() {
		var img = arguments[0];
		var alt = 'Missing Alt';
		if (arguments.length > 1) alt = arguments[1];
		this.d("Preview: " + img);
		if (document.images) {
			this.moveBlock("mediaSection", true);
			this.displayBlock("mediaContentBlock", true);
			document.getElementById("mediaContentBlock").style.height = 385 + "px";
			document.getElementById("mediaContentBlock").innerHTML = "<IMG id='imgsrc' class='galleryImage'>";
			var i = new Image();
			i.src = img;
			i.alt = alt;
 			document.getElementById("imgsrc").src= i.src;
 			document.getElementById("imgsrc").alt= i.alt;
			return false;
		}
	}
	this.d = function(arg) {
		if (this.debug == true) alert(arg);
	}
	this.init();
}		

