function dyobject(src, width, height, type){
    if(!src) return false;
    this.src = src; 
	this.width = width? width : '100%'; 
	this.height = height? height : '100%';
	this.type = type || this.initSrc();
	
    this.html = '';
	this.paramIE = '';
	this.paramFF = '';
	this.alink = '';
	
	return true;
}

dyobject.prototype.init = function(){
    switch(this.type){
        case 'wmv': this.initWmv(); break;
		case 'flv': this.initFlv(); break;
		case 'flash': this.initFlash(); break;
        case 'img': this.initImg(); break;
		case 'online': this.paramIE += '<param name="autoStart" value="true" />'; this.initWmv(); break;
		default: return false;
	}
	this.html = this.html.replace(/\$width/gi, this.width)
	                     .replace(/\$height/gi, this.height)
			             .replace(/\$src/gi, this.src);
}

dyobject.prototype.initSrc = function(){
    var type = /^(.+)\.mp3|wmv|wma/i.test(this.src)? 'wmv' : 
	           /^(.+)\.flv/i.test(this.src)? 'flv' :
               /^(.+)\.swf/i.test(this.src)? 'flash' :
               /^(.+)\.jpg|jpeg|bmp|gif|png/i.test(this.src)? 'img' :
	           /^\s?mms:\/\/(.+)/i.test(this.src)? 'online': 'flash';
	return type;
}

dyobject.prototype.initFlash = function(){
    this.html = 
	  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,2,0" '
	+ 'width="$width" height="$height">'
	+ '<param name="quality" value="high"/>'
	+ '<param name="movie" value="$src"/>'
	+ this.paramIE
	+ '<embed pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '
	+ 'quality="high" src="$src" width="$width" height="$height" '
	+ this.paramFF
	+ '></embed></object>';
}

dyobject.prototype.initFlv = function(){
    this.html = 
	  '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=" http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '
	+ 'width="$width" height="$height">'
	+ '<param name="allowScriptAccess" value="sameDomain"/>'
	+ '<param name="allowFullScreen" value="true"/>'
	+ '<param name="quality" value="high">'
	+ '<param name="movie" value="http://flv.dayoo.com/player/flvplayer20081015.swf"/>'
	+ '<param name="FlashVars" value="sourceURL=$src"/>'
	+ this.paramIE
	+ '<embed pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '
	+ 'quality="high" src="http://flv.dayoo.com/player/flvplayer20081015.swf" width="$width" height="$height" allowScriptAccess="sameDomain" FlashVars="sourceURL=$src" '
	+ this.paramFF
	+ '></embed></object>';
}

dyobject.prototype.initWmv = function(){
    this.html =
	  '<object type="video/x-ms-wmv" data="$src" width="$width" height="$height" >'
	+ '<param name="src" value="$src" />'
	+ '<param name="controller" value="true" />'
	+ this.paramIE
	+ '<param name="autoStart" value="false" />'
	+ '</object>';
}

dyobject.prototype.initImg = function(){
    this.html = this.alink != ''? 
	  '<a href="' + this.alink + '" target="_blank"><img src="$src" width="$width" height="$height" '
	+ this.paramFF
	+ '/></a>'
	: '<img src="$src" width="$width" height="$height" '
	+ this.paramFF
	+ '/>';
}

dyobject.prototype.add = function(key, value){
    this.paramIE += '<param name="' + key + '" value="' + value +'"/>';
	this.paramFF += key + '="' + value + '" ';

	if(key == 'alink'){
        this.alink = value;
	}
}

dyobject.prototype.write = function(element){
    var id = document.getElementById(element);
	if(!id) return false;
	this.init();
	id.innerHTML = this.html;
}