
function hideInputBg(field)
{
	ipField = document.getElementById(field);
	ipField.style.background = "#fff";
}

function IE_Refresh(){
	if (document.all) location.reload();
}
window.onresize = IE_Refresh;

/* >> Standard Popup functions */
	function StandardPopup(Attrs){
		// @params IE and Gecko-Browser compatible window parameter attributes.
		this.params = ['left', 'top', 'location', 'menubar', 'resizable', 'scrollbars', 'status', 'toolbar', 'height', 'width'];
		this.href = Attrs.href ? Attrs.href : 'http://www.google.de'; // url to the popup content
		this.name = Attrs.name ? Attrs.name : 'standardPopup'; // standard window name
		this.height = Attrs.height ? Attrs.height : '550'; // standard height opened window
		this.width = Attrs.width ? Attrs.width : '650'; // standard width opened window
		this.left = Attrs.left ? Attrs.left : null; // window left position from the upper left corner of the client screen
		this.top = Attrs.top ? Attrs.top : null; // window top position from the top of the client screen
		this.locationbar = Attrs.location ? Attrs.location : 'no'; // ['yes', 'no'] display the locationbar
		this.menubar = Attrs.menubar ? Attrs.menubar : 'no'; // ['yes', 'no'] display the menubar
		this.resizable = Attrs.resizable ? Attrs.resizable : 'yes'; // ['yes', 'no'] allows the user to change the window size
		this.scrollbars = Attrs.scrollbars ? Attrs.scrollbars : 'yes'; // ['yes', 'no'] show scrollbars if necessary
		this.status = Attrs.status ? Attrs.status : 'no'; // ['yes', 'no'] show statusbar
		this.toolbar = Attrs.toolbar ? Attrs.toolbar : 'no'; // ['yes', 'no'] show toolbar
		this.wRef = null // window reference to make changes on the opened window
	}
	
	StandardPopup.prototype._formatParams = function()
	{
		var str = '\'';
		var objParam;
		for (var i = 0; i < this.params.length; ++i){
			objParam = this.params[i] == 'location' ? 'locationbar' : this.params[i];
			p = eval("this." + objParam);
			if (p){
				str += this.params[i] + '=' + p + ',';
			}
		}
		str = str.substring(0, str.length -1);
		str += '\'';
		return str;
	}
	
	StandardPopup.prototype.open = function(){
		var paraStr = this._formatParams();
		this.wRef = window.open(this.href, this.name, paraStr);
		if (this.wRef)
			this.wRef.focus();
		return false;
	}
/* << */


/* >> Generic Multimedia CMS tool, requires Mochikit 1.4+*/
	function GenericMultimedia(args){
		this.lang = this.getLang();
		this.altText = args.altText;
		this.altImg = args.altImg;
		this.data = args.data;
		if ($(args.target)) this.target = args.target;
		this.htmlSrcDom = this.getHtmlSrcDom(args.htmlSrc);
		this.javaApplet = this.isJavaApplet();
		this.modifyAndWriteDocumentElements();
	}
	
	GenericMultimedia.prototype.getLang = function(){
		var htmlEl = document.getElementsByTagName('html')[0];
		if (getNodeAttribute(htmlEl, 'lang')){
			return this.formatLang(getNodeAttribute(htmlEl, 'lang'));
		}else if(getNodeAttribute(htmlEl, 'xml:lang')){
			return this.formatLang(getNodeAttribute(htmlEl, 'xml:lang'));
		}
		return 'en';
	}
	
	GenericMultimedia.prototype.formatLang = function (lang){
		if (lang.search(/-/) > -1) return lang.substring(0, lang.search(/-/));
		return lang;
	}
	
	GenericMultimedia.prototype.getHtmlSrcDom = function(htmlSrc){
		if (typeof htmlSrc == 'string' && htmlSrc.length > 0){
			var outer = DIV(null);
			outer.innerHTML = '<xml>' + htmlSrc + '</xml>';
			return outer;
		}
		return null;
	}
	
	GenericMultimedia.prototype.isJavaApplet = function(){
		var elms = this.htmlSrcDom.childNodes[0].childNodes;
		if (elms.length > 0){
			for (var i = 0; i < elms.length; ++i){
				var elm = elms[i];
				if (elm.nodeType == 1 && elm.nodeName.toLowerCase() == 'object'){
					var classidAttr = getNodeAttribute(elm, 'classid');
					if (classidAttr){
						if (classidAttr.search('java:') > -1) return true;
					}
				}
			}
		}
		return false;
	}
	
	GenericMultimedia.prototype.modifyAndWriteDocumentElements = function(){
		var output = '';
		var elms = this.htmlSrcDom.childNodes[0].childNodes;
		var onlyEmbed = false;
		var model;
		if (elms.length > 0  && ! this.isFlashVideo()){
			for (var i = 0; i < elms.length; ++i){
				var node = elms[i];
				var name = elms[i].nodeName.toLowerCase();
				var type = elms[i].nodeType;
				if (this.javaApplet || (! this.useEmbed() && ! this.javaApplet)){
					if (type == 1 && name == 'object'){
						model = false;
						output += this.startElement('object', this.getNodeAttributes(node), model);
						var objChilds = node.childNodes;
						for (var j = 0; j < objChilds.length; ++j){
							node = objChilds[j];
							name = objChilds[j].nodeName.toLowerCase();
							type = objChilds[j].nodeType;
							if (type == 1 && name == 'param'){
								model = true;
								output += this.startElement('param', this.getNodeAttributes(node), model);
							}
							if (type == 1 && name == 'embed'){
								model = true;
								output += this.startElement('embed', this.getNodeAttributes(node), model);
							}
						}
					}
				}else{
					onlyEmbed = true;
					var objChilds = node.childNodes;
					for (var j = 0; j < objChilds.length; ++j){
						node = objChilds[j];
						name = objChilds[j].nodeName.toLowerCase();
						type = objChilds[j].nodeType;
						if (type == 1 && name == 'embed'){
							model = true;
							output += this.startElement('embed', this.getNodeAttributes(node), model);
						}
					}
				}
			}
			if (this.altText || this.altImg){
				if (this.altText) var text = '<p>' + this.altText + '</p>';
				if (this.altImg) var img = '<img src="' + this.altImg + '" alt="" title="" />';
				if (this.useEmbed() && ! this.javaApplet){
					output += '<noembed>' + text + img + '</noembed>';
				}else{
					output += text + img;
				}
			}
			if (! onlyEmbed) output += this.endElement('object');
			document.write(output);
		}else{
			var width = 380;
			var height = 318;
			var params = {};
			var flashvars = {};
			var attributes = {};
			for (var i = 0; i < elms.length; ++i){
				var node = elms[i];
				for(var j = 0; j < node.childNodes.length; ++j){
					var n = node.childNodes[j];
					var nName = n.nodeName;
					if (n.name.toLowerCase() == 'width') width = n.value;
					if (n.name.toLowerCase() == 'height') height = n.value;
					params[n.name] = n.value;
				}
			}
			var file = this.data.substring(this.data.lastIndexOf('/') + 1, this.data.length);
			var url = window.location.href;
			var urlUpload = 'http://' + window.location.host + '/upload';
			var urlSlicePos = url.search(/\/static\//);
			if (urlSlicePos > -1){
				var urlPlayer = url.substring(0, urlSlicePos) + '/web/flvplayer';
				var urlUpload = url.substring(0, urlSlicePos + 8) + 'img';
			}else{
				var urlSlicePos = url.search(/\/web\//);
				var urlPlayer = url.substring(0, urlSlicePos + 5) + 'flvplayer';
			}

			flashvars.playerpath = urlPlayer;
			flashvars.contentpath = urlUpload;
			flashvars.video = file;
			flashvars.autoscale = "false";
			flashvars.videowidth = width;
			flashvars.videoheight = height - 40;

			attributes.align = "left";

			params.scale = "noscale";
			params.allowfullscreen = "true";
			params.salign = "tl";

			swfobject.embedSWF('../web/flvplayer/flvplayer.swf', this.target, width, height, "9.0.28","../web/swfobject/expressInstall.swf", flashvars, params, attributes);
		}
	}
	
	GenericMultimedia.prototype.useEmbed = function(){
		var agent = navigator.userAgent;
		if (agent.search(/MSIE | Safari/) > -1) return false;
		return true;
	}
	
	GenericMultimedia.prototype.isFlashVideo = function(){
		if (this.hasFileExtension(this.data, 'flv')) return true;
		return false;
	}
	
	GenericMultimedia.prototype.hasFileExtension = function(filename, ext){
		var delimiter = filename.lastIndexOf('.');
		if (delimiter > -1){
			var extension = filename.substring(delimiter + 1, filename.length).toLowerCase();
			if (extension == ext.toLowerCase()) return true;
		}
		return false;
	}
	
	GenericMultimedia.prototype.getNodeAttributes = function(node){
		var name = node.nodeName.toLowerCase();
		var codebase = false;
		if (node.attributes.length > 0){
			var attrs = {};
			var attrValue = '';
			for (var i = 0; i < node.attributes.length; ++i){
				var attrName = node.attributes[i].nodeName.toLowerCase();
				var attrValue = node.attributes[i].nodeValue;
				if (name == 'object' && (attrName == 'classid' || attrName == 'movie' || attrName == 'data')){
					if (attrName == 'classid'){
						attrs[attrName] = this.makeClassidAttribute(attrValue);
					}else if (this.javaApplet && attrName == 'codebase'){
						codebase = true;
						attrs[attrName] = this. makeJavaAppletCodebaseAttribute();
					}else{
						if (attrName == 'codebase') codebase = true;
						attrs[attrName] = this.data + this.copyCgiArgs(attrValue);
					}
				}else if (name == 'embed' && attrName == 'src'){
					attrs[attrName] = this.data + this.copyCgiArgs(attrValue);
				}else{
					attrs[attrName] = attrValue;
				}
			}
			if (this.javaApplet && ! codebase){
						codebase = true;
						attrs['codebase'] = this. makeJavaAppletCodebaseAttribute();
			}
			if (name == 'param'){
				attrNameValue = attrs.name.toLowerCase();
				attrValueValue = attrs.value;
				if (attrNameValue == 'filename' || attrNameValue == 'movie' || attrNameValue == 'src'){
					attrs.value = this.data + this.copyCgiArgs(attrValueValue);
				}
			}
			return attrs;
		}
		return null;
	}
	
	GenericMultimedia.prototype.copyCgiArgs = function(value){
		if (value.lastIndexOf('?') > -1){
			return value.substring(value.lastIndexOf('?'), value.length);
		}
		return '';
	}
	
	GenericMultimedia.prototype.startElement = function(name, attrs, single){
		var element = '<' + name;
		for (var attrName in attrs){
			element += ' ' + attrName + '="' + attrs[attrName] + '"';
		}
		if (single){
			element += '/>';
		}else{
			element += '>';
		}
		return element;
	}

	GenericMultimedia.prototype.endElement = function(name){
		return '</' + name + '>';
	}

	GenericMultimedia.prototype.makeClassidAttribute = function(value){
		var data = this.data;
		if (value.search('java:') > -1){
			return 'java:' + data.substring(data.lastIndexOf('/') +1, data.length) + this.copyCgiArgs(value);
		}
		return value;
	}
	
	GenericMultimedia.prototype.makeJavaAppletCodebaseAttribute = function(){
		var data = this.data;
		return data.substring(0, data.lastIndexOf('/') +1);
	}
/* << */



