function flashDetect(version) {
	if (navigator.plugins['Shockwave Flash']) {
		plugin_descr = navigator.plugins['Shockwave Flash'].description;
		return (parseInt(plugin_descr.substring(plugin_descr.indexOf(".") - 2)) >= version) 
	}
	return false
}

function isFlash() {
	return !(navigator.userAgent.indexOf("iCab") != -1 || navigator.userAgent.indexOf("MSIE 3") != -1);
}

function ieFlashDetect(version) {
	try {
        flash = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.' + version);
    } catch (err) {
        return false;
    }
    return flash;
	//window.onerror = function() { return true; }
	//return new ActiveXObject('ShockwaveFlash.ShockwaveFlash.' + version);
}

function flashEnable(version) {
	if (!isFlash()) return false;
	if (navigator.userAgent.indexOf("MSIE") != -1 && 
		navigator.userAgent.indexOf("Windows") != -1 && 
		navigator.userAgent.indexOf("Opera") == -1) 
		return ieFlashDetect(version);
	return flashDetect(version);
}

function flashRegister(name) {
   var today = new Date();
   var expires = new Date();
   expires.setTime(today.getTime() + 1000*60*60*24*365);
   setCookie("flash", name, expires);
}

function setCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
   + "; path=/";
}

function getCookie(Name) {
	var search = Name + '=';
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search);
		if (offset != -1) { // if cookie exists
			offset += search.length;
			// set index of beginning of value
			end = document.cookie.indexOf(';', offset);
			// set index of end of cookie value
			if (end == -1) 
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
	}
	return '';
}

function isFlashDisabled() {
	return getCookie("flash_is") == "off";
}

function flashSettings(settings) {	
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 1000*60*60*24*365);
	setCookie("flash_is", settings, expires);
	document.location.reload();	
}

function putFlash(fname,width,height,color,text) {	
	document.writeln ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id="'+fname+'" align="middle">');
	document.writeln ('<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+fname+'.swf'+text+'" /><param name="quality" value="high" /><param name="bgcolor" value="'+color+'" />');
	document.writeln ('<embed src="'+fname+'.swf'+text+'" quality="high" bgcolor="'+color+'" width="'+width+'" height="'+height+'" name="'+fname+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
} 