// 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"');
	document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
	document.write(' ID="header" WIDTH="' + obj.width + '" HEIGHT="' + obj.height + '" ALIGN="">');
	document.write(' <PARAM NAME=movie VALUE="' + obj.file + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=' + obj.bgcolor + '>  '); 
	if (plugin && (isGecko() || (isMac() && isIe()))) {
		document.write(' <EMBED src="' + obj.file + '" quality=high bgcolor=' + obj.bgcolor);
		document.write(' swLiveConnect=FALSE WIDTH="' + obj.width + '" HEIGHT="' + obj.height + '" NAME="header" ALIGN=""');
		document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
		document.write(' </EMBED>');
	}
	document.write(' </OBJECT>');
	document.close();
}
