function isSpecial(tag,param) {
	var result = false;
	switch(param) {
		case 'w':
		case 'h':
		case 'id':
		case 'top':
		case 'left':
		case 'bottom':
		case 'right':
		case 'file':
		case 'MV':
		case 'mV':
		case 'rV':
		case 'bV':
			result = true;
			break;
	}
	if ((tag == 'object') && (param == 'swliveconnect')) {
		result = true;
	}
	return result;
}

function doFlash(args) {
	
	var info = navigator.userAgent.toLowerCase();
	var isGecko = /gecko/.test(info) && !/applewebkit/.test(info);
	var isActiveX = (/msie/.test(info) && !/opera/.test(info)) && /windows/.test(info);
	
	var flashName = args.id+'_swf';
	var div = document.getElementById(args.id);
		
	if (!isActiveX) {
		if (isGecko) {
			while (div.hasChildNodes()) {
				div.removeChild(div.firstChild);
			}
			
			var obj = document.createElement('object');
			obj.setAttribute('type','application/x-shockwave-flash');
			obj.setAttribute('data',args.file);
			obj.setAttribute('width',args.w);
			obj.setAttribute('height',args.h);
			obj.setAttribute('id',flashName);
			
			var param;
			
			for (var i in args) {
				if (!isSpecial('object',i)) {
					param = document.createElement('param');
					param.setAttribute('name',i);
					param.setAttribute('value',args[i]);
					obj.appendChild(param);
				}
			}
			
			div.appendChild(obj);
		}
		else {
			var attr = '';
			for (var i in args) {
				if (!isSpecial('embed',i)) {
					attr += ' '+i+'="'+args[i]+'"';
				}
			}
			div.innerHTML = '<embed src="'+args.file+'" name="'+flashName+'" width="'+args.w+'" height="'+args.h+'"'+attr+' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
		}
	}
	else {
		var _params = '';
		for (var i in args) {
			if (!isSpecial('object',i)) {
				_params += '<param name="'+i+'" value="'+args[i]+'"></param>';
			}
		}
		var version = args.MV+','+(args.mV?args.mV:0)+','+(args.rV?args.rV:0)+','+(args.bV?args.bV:0);
		div.innerHTML = '<object id="'+flashName+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" width="'+args.w+'" height="'+args.h+'" /><param name="movie" value="'+args.file+'"></param>'+_params+'</object>';
	}
	
	for (i in args) {
		switch (i) {
			case 'top':
			case 'left':
			case 'bottom':
			case 'right':
				div.style.position = 'absolute';
				div.style[i] = args[i]+'px';
				break;
		}
	}
}
