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 'mms': this.initMms(); 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' : 
			   /^\s?mms:\/\/(.+)/i.test(this.src)? 'mms' : 
	           /^(.+)\.flv/i.test(this.src)? 'flv' :
               /^(.+)\.swf/i.test(this.src)? 'flash' :
               /^(.+)\.jpg|jpeg|bmp|gif|png/i.test(this.src)? 'img' : 'flash';
	return type;
}



dyobject.prototype.initMms = function(){

this.html = '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp" '
				         + 'type="application/x-mplayer2" width="$width" height="$height" border="0">'
						 + '<param name="url" value="$src">'
						 + '<param name="ShowControls" value="1">'
						 + '<param name="ShowAudioControls" value="1">'
						 + '<param name="ShowTracker" value="1">'
						 + '<param name="ShowDisplay" value="1">'
						 + '<param name="ShowStatusBar" value="1">'
						 + '<param name="AutoStart" value="1">'
						 + '<param name="PlayCount" value="0">'
						 + '</object>';

}

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 =
	  '<embed type="application/x-ms-wmp" showControls="true" showstatusbar="true" autostart="false" '
	+ this.paramFF
	+ 'src="$src" width="$width" height="$height"  '
	+ '></embed>';
}

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;
}

//pictrue change
function imgA(ele, width, height){
    this.id = document.getElementById(ele);
    this.width = width || 400;
    this.height = height || 300;
    this.num = 1;
    this.dNum = 'true';
    this.dTxt = 'true';
    this.flash = 'http://rnd.dayoo.com/swf/Cpic.swf';
    
    this.sUrl = '';
    this.sTit = '';
    this.sLin = '';

    this.add = function(a, b, c){
        var t1 = a || '';
        var t2 = b || '';
        var t3 = c || '';
		t3 = t3.replace(/\&\#38\;/gi, '|');
     
        this.sUrl += 'picURL' + this.num + '=' + t1 + '&';
        this.sTit += 'picTitle' + this.num + '=' + t2 + '&';
        this.sLin += 'picLink' + this.num + '=' + t3 + '&';

        this.num++;
    };
    this.disNum = function(){
        this.dNum = 'false';
    };
    this.disTxt = function(){
        this.dTxt = 'false';
    };
    this.play = function(){
		if(!this.id) return false;

        this.sUrl = this.sUrl.replace(/\s/gi, '').slice(0, this.sUrl.length - 1);
        //replace the images url if it is not a full link of http://images.dayoo.com
        this.sUrl = this.sUrl.replace(/\/data\/attachement\//gi, 'http://images.dayoo.com/www/attachement/');
        this.sTit = this.sTit.replace(/\s/gi, '').slice(0, this.sTit.length - 1);
        this.sLin = this.sLin.replace(/\s/gi, '').slice(0, this.sLin.length - 1);
        
        var html = '<object id="fflashmovie" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
                 + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+this.width+'" height="'+this.height+'">'
                 + '<param name="movie" value="' + this.flash + '?'
                 + this.sUrl+'&flashWidth='+this.width+'&flashHeight='+this.height+'&picNum='+(this.num -1)+'&'
                 + this.sTit + this.sLin + '&titleDisplay=' + this.dTxt + '&numberDisplay=' + this.dNum + '" />'
                 + '<param name="quality" value="high" />'
				 + '<param name="wmode" value="opaque" />'
				 + '<param name="allowScriptAccess" value="always"/>'
                 + '<embed id="fflashmovie" src="' + this.flash + '?a=b&'
                 + this.sUrl+'&flashWidth='+this.width+'&flashHeight='+this.height+'&picNum='+(this.num -1)+'&'
                 + this.sTit + this.sLin + '&titleDisplay=' + this.dTxt + '&numberDisplay=' + this.dNum + '" quality="high" wmode="opaque" allowScriptAccess="always"'
                 + ' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '
                 + 'width="' + this.width + '" height="' + this.height + '"><\/embed><\/object>';
                 
        this.id.innerHTML = html;
    }
}