/****************************
	flashSetter class
	ver 1.00
*****************************/

//propaty
var pluginsURI = new Object();
pluginsURI.en = "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";	// English
pluginsURI.ja = "http://www.macromedia.com/jp/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";	// Japanese
	
var retPluginVer = 0;
var plugin = 0;
var retWork = "";	


// Constructor
var FlashSetter = function (getObj) {

	if (!getObj.specifiedVer) getObj.specifiedVer = 9;
	if (!getObj.swfDir) getObj.swfDir = '';
	if (!getObj.idName) getObj.idName = 'flashSetter';
	if (!getObj.bgcolor) getObj.bgcolor = "#ffffff";
	if (!getObj.quality) getObj.quality = "high";
	if (!getObj.pluginLang) getObj.pluginLang = 'en';
	if (!getObj.altURI) getObj.altURI = "";
	if (!getObj.altSrc) getObj.altSrc = "";
	if (!getObj.swLiveConnect) getObj.swLiveConnect = "false";
	if (!getObj.menu) getObj.menu = "false";
	if (!getObj.flashVars) getObj.flashVars= '';

	
	plugin = pluginGetter();


	if (plugin) {
		retPluginVer = parseInt(plugin.description.substring(plugin.description.indexOf("Flash") +6));
		//retPluginVer = parseInt(plugin.description.substring(plugin.description.indexOf(".") -1));
	} else {
		// for Win MSIE
		document.writeln('<script type="text/vbscript">');
		document.writeln('On Error Resume Next');
		document.writeln('Private swfEnableFlag');
		document.writeln('swfEnableFlag = false');
		document.writeln('swfEnableFlag = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + getObj.specifiedVer + '"))');
		document.writeln('If swfEnableFlag Then');
		document.writeln('retPluginVer = ' + getObj.specifiedVer);
		document.writeln('End If');
		document.writeln('</script>');
	}

	document.open();
	if (getObj.hedSRC) document.write(getObj.hedSRC);
	if (retPluginVer < getObj.specifiedVer){
		document.write(putAltURI());
	} else {
 		document.write(getObjectElement());
	}
	if (getObj.fotSRC) document.write(getObj.fotSRC);
	document.close();


	//Method
	function pluginGetter () {
		if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
			return navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
		}
	}

	//Method
	function putAltURI () {
		if (getObj.altURI != '') location.href = getObj.altURI;
		return getObj.altSrc;
	}

	//Method
	function putAltSrc () {
		if (getObj.altURI != '') return "";
		return getObj.altSrc;
	}

	//Method
	function getObjectElement (){
	//	if (window.opera)  return putAltURI();
		
		if (!getObj.swfFile || !getObj.width || !getObj.height || !getObj.idName) return "";
	
		retWork += '<Object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';

		if(!getObj.disableCodebase){
			retWork += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
		}
		retWork += ' id="' + getObj.idName + '" width="' + getObj.width + '" height="' + getObj.height + '" name="' + getObj.idName + '">';
		retWork += '<param name="movie" value="' + getObj.swfDir + getObj.swfFile + '"/>';
		retWork += '<param name="quality" value="' + getObj.quality + '"/>';
		retWork += '<param name="bgcolor" value="' + getObj.bgcolor + '"/>';
		retWork += '<param name="menu" value="' + getObj.menu + '"' + '/>';
		if (getObj.salign) retWork += '<param name="salign" value="' + getObj.salign + '"' + '/>';
		if (getObj.scale) retWork += '<param name="scale" value=' + getObj.scale + '' + '/>';
		if (getObj.flashVars) retWork += '<param name="FlashVars" value="' + getObj.flashVars+ '"' + '/>';

		if ((navigator.appVersion.indexOf('Win',0) != -1 && navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1) && !window.opera){
			retWork += putAltSrc();
		} else {
			getEmbedElement();
		}
		retWork += '</Object>';
		return retWork;
	}


	//Method
	function getEmbedElement(){
		
	/*
		if (Obj.moz_exec != 1 && (navigator.userAgent.indexOf("Gecko/") != -1)) return pfAltAction(Obj);

		if (Obj.macie4exec != 1 && (navigator.appVersion.indexOf('Mac',0) != -1)){
			if (navigator.appVersion.indexOf('MSIE 4.',0) != -1) return pfAltAction(Obj);
			if (navigator.appVersion.indexOf('MSIE 3.',0) != -1) return pfAltAction(Obj);
		}
	*/
		retWork += '<embed src="' + getObj.swfDir + getObj.swfFile + '"';
		retWork += ' menu="' + getObj.menu + '"';
		retWork += ' quality="' + getObj.quality + '"';
		retWork += ' swLiveConnect="' + getObj.swLiveConnect + '"';
		retWork += ' bgcolor="' + getObj.bgcolor + '"';
		retWork += ' width="' + getObj.width + '"';
		retWork += ' height="' + getObj.height + '"';
		if (getObj.salign) retWork += ' salign="' + getObj.salign + '"';
		if (getObj.scale) retWork += ' scale="' + getObj.scale + '"';
		if (getObj.flashVars) retWork += ' FlashVars="' + getObj.flashVars + '"';
		retWork += ' type="application/x-shockwave-flash"';
		retWork += ' pluginspage="' + pluginsURI[getObj.pluginLang] + '"';
		retWork += ' name="' + getObj.idName + '"';
		retWork += '></embed></br>';

		//return retWork;

	}


}

