// set env
var plugin = getFlashPlugIn();

// set default
var defaultBgColor = '#ffffff';
var defaultId      = 'defaultId';

function isGecko() {
	if((navigator) && (navigator.userAgent) && (navigator.userAgent.indexOf("Gecko/") != -1)) {
		return true;
	} else {
		return false;
	}
}

function isIe() {
	if((navigator) && (navigator.userAgent) && (navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {
		return true;
	} else {
		return false;
	}
}

function isWin() {
	if((navigator) && (navigator.userAgent) && (navigator.appVersion.indexOf("Win",0) != -1)) {
		return true;
	} else {
		return false;
	}
}

function isMac() {
	if((navigator) && (navigator.userAgent) && (navigator.appVersion.indexOf("Mac",0) != -1)) {
		return true;
	} else {
		return false;
	}
}

function writeDocument(doc) {
	document.write(doc);
}

function getFlashPlugIn() {
	if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) {
		return navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	} else {
		0;
	}
}

function printObject() {
	// check object param
	if (!obj)             { return; }
	if (!obj.Id)          { obj.id      = defaultId; }
	if (!obj.bgcolor)     { obj.bgcolor = defaultBgColor; }
	if (!obj.file && !obj.width && !obj.height) { return; }

	document.open(); 
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + obj.width + '" height="' + obj.height + '" id="main" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain">');
	document.write('<param name="movie" value="' + obj.file + '">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="bgcolor" value="' + obj.bgcolor + '">');
	if (plugin && (isGecko() || (isMac() && isIe()))) {
		document.write('<embed src="' + obj.file + '" quality="high" bgcolor="' + obj.bgcolor + '" width="' + obj.width + '" height="' + obj.height + '" name="main" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
	}
	document.write(' </object>');
	document.close();
}
