
function createMedia(url, el, width, height) {
	w = width ? width: 320
	h = height ? height: 240
	
	var sAgent = navigator.userAgent.toLowerCase()
	var is_ie = (sAgent.indexOf("msie") != -1)
	var is_gecko = !is_ie
	
	// for quicktime
	isQTR = new RegExp("\\.mov$")
	is_qt = (isQTR.exec(url)) ? true : false
	
	// QT includes toolbar to the height
	if (is_qt) {
		if (is_gecko) h = h + 16;
		else h = h + 32;
	}
	else {
		// FF includes toolbar to the height
		if (is_gecko) h = h + 42
		else h = h + 64
	}
	
	
	supported = 1
	notSupportedSrc = 'Не установлен плагин для проигрывания. Загрузите <a href="'+url+'">ролик</a> на диск.<br/>'
	
	
	// delete link
	el.href=''
	el.removeAttribute('onclick', 0)
	el.removeAttribute('onmousedown', 0)
	el.innerHTML = ''
	
	if (!is_qt) {
		src='<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="player" width="'+w+'" height="'+h+'">' +
		'<param name="url" value="'+url+'"/><param name="src" value="'+url+'"/>'+
		'<param name="showcontrols" value="true"/><param name="autostart" value="true"/>'+
		'<!--[if !IE]>-->'+
		'<object type="video/x-ms-wmv" data="'+url+'" width="'+w+'" height="'+h+'">'+
		'  <param name="src" value="'+url+'"/>'+
		'  <param name="controller" value="true"/><param name="autostart" value="true"/>'+
		'</object>'+
		'<!--<![endif]-->'+
		'</object>';
	}
	if (is_qt) {
		src='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" '+
		'width="'+w+'" height="'+h+'">'+
		'<param name="src" value="'+url+'"/>'+
		'<param name="autoplay" value="true"/>'+
		'<param name="controller" value="true"/>'+
		'<param name="type" value="video/quicktime"/>'+
		'<embed src="'+url+'" autoplay="true" type="video/quicktime" width="'+w+'" height="'+h+'" controller="true" '+
		'pluginspage="http://www.apple.com/quicktime/download/"></embed>'+
		'</object>';
	}
	
	if (is_gecko) {
		if (opar = el.parentNode) {
			try {
				oel = document.createElement('div')
				oel.innerHTML = src
				opar.insertBefore(oel, el)
			}
			catch (ex) {
				//alert("Error occured: " + ex.message); 
				el.innerHTML = notSupportedSrc
			}
		}
	}
	else if (is_ie) {
		try {
			el.insertAdjacentHTML('AfterEnd', src)
		}
		catch (ex) {
			//alert("Error occured: " + ex.message); 
			el.insertAdjacentHTML('AfterEnd', notSupportedSrc)
		}
	}
	
	return
		
	if (is_qt) {
		//if (is_ie) {
		src='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" '+
		'width="'+w+'" height="'+h+'">'+
		'<param name="src" value="'+url+'"/>'+
		'<param name="autoplay" value="true"/>'+
		'<param name="controller" value="true"/>'+
		'<param name="type" value="video/quicktime"/>'+
		'</object>';
		//}
		//else if (is_gecko) {
		src='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" '+
		'width="'+w+'" height="'+h+'">'+
		'<param name="src" value="'+url+'"/>'+
		'<param name="autoplay" value="true"/>'+
		'<param name="controller" value="true"/>'+
		'<param name="type" value="video/quicktime"/>'+
		'<embed src="'+url+'" autoplay="true" type="video/quicktime" width="'+w+'" height="'+h+'" controller="true" '+
		'pluginspage="http://www.apple.com/quicktime/download/"></embed>'+
		'</object>';
		//}
		
		if (opar = el.parentNode) {
			try {
				//oel = document.createElement('div')
				//oel.innerHTML = src
				//opar.insertBefore(oel, el)
				el.insertAdjacentHTML('AfterEnd', src)
				//alert(el.tagName)
				//alert(oel.tagName)
				//alert(opar.tagName)
				//alert(oel.nextSibling)
			}
			catch (ex) {
				alert("Error occured: " + ex.message); 
				el.innerHTML = notSupportedSrc
			}
			return
		}
		
		
		
		
		
		return
		
		
		
		//src='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" '+
		//'width="'+w+'" height="'+h+'">'+
		//'hello</object>';
		
		//'http://www.domain.com/sample.mov', '480', '288', '', 'emb#bgcolor', '#FFFFFF'
		//src = QT_GenerateOBJECTText_XHTML(url, w, h, '',"controller","TRUE","autostart","FALSE","target","myself","type", "video/quicktime")
		//QT_WriteOBJECT(url, w, h, '')
		if (!(opar = el.parentNode)) return
		if (!(oel = document.createElement('object'))) return
		opar.insertBefore(oel, el)
		
		oel.setAttribute('classid','clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B')
		oel.setAttribute('codebase','http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0')
		oel.setAttribute('width',w)
		oel.setAttribute('height',h)
		
		oparam = document.createElement('param')
		oparam.setAttribute('name','src')
		oparam.setAttribute('value',url)
		oel.appendChild(oparam)
		
		oparam = document.createElement('param')
		oparam.setAttribute('name','type')
		oparam.setAttribute('value','video/quicktime')
		//oparam.setAttribute('width',w)
		//oparam.setAttribute('height',h)
		oel.appendChild(oparam)
		
		oparam = document.createElement('param')
		oparam.setAttribute('name','autoplay')
		oparam.setAttribute('value','true')
		oel.appendChild(oparam)
		
		oparam = document.createElement('param')
		oparam.setAttribute('name','controller')
		oparam.setAttribute('value','true')
		oel.appendChild(oparam)
		
		oparam = document.createElement('param')
		oparam.setAttribute('name','type')
		oparam.setAttribute('value','video/quicktime')
		oel.appendChild(oparam)
		
		if (is_ie) {
			oel.standby = 'loading...'
		}
		
		if (is_gecko) {
			oparam = document.createElement('embed')
			oparam.setAttribute('src',url)
			oparam.setAttribute('width',w)
			oparam.setAttribute('height',h)
			oparam.setAttribute('pluginspage','http://www.apple.com/quicktime/download/')
			oparam.setAttribute('controller','true')
			oel.appendChild(oparam)
		}
		//alert(oel.innerHTML)
		
		//document.write("<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" width=\"256\" height=\"275\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\"><param name=\"src\" value=\"weemovie.mov\"><param name=\"autoplay\" value=\"false\"></"+"object>");
		
		//el.href=''
		//el.removeAttribute('onclick', 0)
		//el.removeAttribute('onmousedown', 0)
		//el.innerHTML = ''
	}
	
	return false
}

