
if(typeof(cFlash) == 'undefined'){
	function cFlash(swf, version, width, height, id){
		this.generateId = function(l){
			if (!l) l = 10;
			var s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890-_';
			var out = '';
			while(l--){
				out += s.substr(Math.round(Math.random() * s.length), 1);
			}
			return out;
		}
		
		this.setParameter = function(p, v){
			this.parameters[p] = v;
		}
		
		this.getParameter = function(p){
			if (!this.parameters[p]) return false;
			return this.parameters[p];
		}
		
		this.setAttribute = function(a, v){
			this.attributes[a] = v;
		}
		
		this.getAttribute = function(a){
			if (!this.attributes[a]) return false;
			return this.attributes[a];
		}
		
		this.setVariable = function(fv, v){
			this.variables[fv] = v;
		}
		
		this.getVariable = function(fv){
			if (!this.variables[fv]) return false;
			return this.variables[fv];
		}
		
		this.getVariables = function(){
			var v, out = [];
			for(v in this.variables){
				if (!this.variables[v]) continue;
				out.push(v + '=' + this.variables[v]);
			}
			return out.join('&');
		}
		
		this.getFlashVersion = function(){
			if (this.__fv == null){
				var e, p, version = 0;
				if (this.AX){
					e  = 'try';
					e += '{';
					e += '	p = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");';
					e += '	version = p.GetVariable("$version").split(" ")[1].split(",")[0];';
					e += '}';
					e += 'catch(err){}';
					eval(e);
				}else{
					p = navigator.plugins['Shockwave Flash'];
					if (p && p.description){
						version = p.description.replace(/([a-z]|[A-Z]|\s)+/, '').replace(/(\s+r|\s+b[0-9]+)/, '.').split('.')[0];
					}
				}
				this.__fv = version;
			}
			return this.__fv;
		}
		
		this.canDisplay = function(){
			return (this.getAttribute('version') <= this.getFlashVersion());
		}
		
		this.getFlashHTML = function(){
			var html = '', k, variables;
			variables = this.getVariables();
			if (this.AX){
				html  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
				html += 'id="' + this.id + '" ';
				html += 'width="' + this.getAttribute('width') + '" ';
				html += 'height="' + this.getAttribute('height') + '">';
				
				html += '<param name="movie" value="' + this.getAttribute('swf') + '" />';
				
				for(var k in this.parameters){
					html += '<param name="' + k + '" value="' + this.parameters[k] + '" />';
				}
				
				if (variables) html += '<param name="flashvars" value="' + variables + '" />';
				
				html += '</object>';
			}else{
				html  = '<embed type="application/x-shockwave-flash" ';
				html += 'id="' + this.id + '" ';
				html += 'src="' + this.getAttribute('swf') + '" ';
				html += 'width="' + this.getAttribute('width') + '" ';
				html += 'height="' + this.getAttribute('height') + '"';
				
				for(var k in this.parameters)
				{
					html += ' ' + k + '="' + this.parameters[k] + '"';
				}
				
				if (variables) html += ' flashvars="' + variables + '"';
				
				html += '></embed>';
			}
			
			return html;
		}
		
		this.setAltHTML = function(s){
			this.altHTML = s;
		}
		
		this.getAltHTML = function(){
			if (!this.altHTML){
				var h = '<p style="text-align:center">This section of this page requires Macromedia Flash Player ' + this.getAttribute('version') + '.';
				h += '<br /><br /><a href="http://www.macromedia.com/go/getflashplayer" target="_blank">Get Flash Player</a></p>';
				return h;
			}
			return this.altHTML;
		}
		
		this.getElement = function(id){
			if (!document.getElementById){
				if (document.all) return document.all(i);
				if (document.layers) return document.layers[i];
				return null;
			}
			return document.getElementById(id);
		}
		
		this.writeIn = function(id){
			var obj = this.getElement(id);
			if (this.canDisplay()){
				obj.innerHTML = this.getFlashHTML();
				this.__fo = this.getElement(this.id);
				return true;
			}else{
				obj.innerHTML = this.getAltHTML();
				return false;
			}
		}
		
		this.__fo = null;
		this.__fv = null;
		this.altHTML = '';
		
		this.parameters = {};
		this.attributes = {};
		this.variables = {};
		this.AX = (window.ActiveXObject ? true : false);
		if (swf) this.setAttribute('swf', swf);
		
		this.setAttribute('version', 6);
		if (version) this.setAttribute('version', version);
		
		if (!width) width = '100%';
		if (!height) height = '100%';
		this.setAttribute('width', width);
		this.setAttribute('height', height);
		
		if (!id) id = this.generateId();
		this.id = id;
		this.setParameter('name', id);
		
		this.__fo = this.getElement(this.id);
	}	
}


