/********************************************************
    Codes for Inserting Flash Object
	@author Han Sanghun (http://hangunsworld.com, hanguns@gmail.com)
	@created 2008-07-25
	@last modified 2008-08-06
********************************************************/
/**
 * Returns the tags of a Flash object.
 *
 * @param path SWF Path of the Flash file.
 * @param width Width of the Flash object.
 * @param height Height of the Flash object.
 * @param flashvars FlalshVars parameter to be sent to the Flash object.
 * @param idname ID and name properties of the Flash object.
 * @param saccess Script access control.
 * @param wmode Tranparency setting.
 * @param fullscreen Fullscreen access control.
 *
 * @return String of Flash object tag.
 */
function getFlashObjectString(path, width, height, flashvars, idname, saccess, wmode, fullscreen){

	// Initializes the flashvars parameter.
	if(flashvars == undefined){
		flashvars = "";
	}
	// Initializes the ID and name of the Flash object.
	if(idname == undefined){
		idname = "";
	}
	
	// Initializes the script access control.
	if(saccess != "never" && saccess != "always"){
		saccess = "sameDomain";
	}
	
	// Initializes the transparency.
	if(wmode != "transparent" && wmode != "opaque"){
		wmode = "window";	
	}
	
	// Initializes the fullscreen access control.
	if(fullscreen==true || fullscreen=="true" || fullscreen==1 || fullscreen=="1" || fullscreen=="yes"){
		fullscreen = "true";
	}else{
		fullscreen = "false";	
	}
	
	var str = '';
	str = '<object id="' + idname + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	str += 'width="' + width + '" height="' + height + '">';
  	str += '<param name="movie" value="' + path + '" />';
  	str += '<!-- The following object tag is for browsers other than IE. Hide this tag with IECC, in case of IE. -->';
  	str += '<!--[if !IE]>-->';
  	str += '<object name="' + idname + '" type="application/x-shockwave-flash"';
	str += ' data="' + path + '" width="' + width + '" height="' + height +'">';
    str += '<!--<![endif]-->';
	str += '<param name="FlashVars" value="' + flashvars + '" />';
    str += '<param name="quality" value="high" />';
	str += '<param name="allowFullscreen" value="' + fullscreen + '" />';
    str += '<param name="wmode" value="' + wmode + '" />';
	str += '<param name="allowScriptAccess" value="' + saccess + '" />';
    str += '<param name="swfversion" value="10.0.2.54" />';
    str += '<!--[if !IE]>-->';
  	str += '</object>';
  	str += '<!--<![endif]-->';
	str += '</object>';
	
	return str;
	
}

/**
 * Inserts a Flash object in the current position.
 *
 * @param path SWF Path of the Flash file.
 * @param width Width of the Flash object.
 * @param height Height of the Flash object.
 * @param flashvars FlalshVars parameter to be sent to the Flash object.
 * @param idname ID and name properties of the Flash object.
 * @param saccess Script access control.
 * @param wmode Tranparency setting.
 * @param fullscreen Fullscreen access control.
 */
function insertFlashObject(path, width, height, flashvars, idname, saccess, wmode, fullscreen){
	
	var str = getFlashObjectString(path, width, height, flashvars, idname, saccess, wmode, fullscreen);
	document.write(str);
	
}

/**
 * Inserts a Flash object in the specified DIV layer.
 *
 * @param layerid ID of the layer in which the Flash object inserted.
 * @param path SWF Path of the Flash file.
 * @param width Width of the Flash object.
 * @param height Height of the Flash object.
 * @param flashvars FlalshVars parameter to be sent to the Flash object.
 * @param idname ID and name properties of the Flash object.
 * @param saccess Script access control.
 * @param wmode Tranparency setting.
 * @param fullscreen Fullscreen access control.
 */
function insertFlashObjectLayer(layerid, path, width, height, flashvars, idname, saccess, wmode, fullscreen){
	
	var str = getFlashObjectString(path, width, height, flashvars, idname, saccess, wmode, fullscreen);
	var theLayer = document.getElementById(layerid);
	theLayer.innerHTML = str;
	
}



/**
 * Inserts a Flash object after the specific time.
 *
 * @param delay Delayed time (Millisecond)
 * @param layerid ID of the layer in which the Flash object inserted.
 * @param path SWF Path of the Flash file.
 * @param width Width of the Flash object.
 * @param height Height of the Flash object.
 * @param flashvars FlalshVars parameter to be sent to the Flash object.
 * @param idname ID and name properties of the Flash object.
 * @param saccess Script access control.
 * @param wmode Tranparency setting.
 * @param fullscreen Fullscreen access control.
 */
function insertFlashObjectDelay(delay, layerid, path, width, height, flashvars, idname, saccess, wmode, fullscreen){
	
	var expression = "insertFlashObjectLayer(";
	expression += "'" + layerid + "'";
	expression += ", '" + path + "'";
	expression += ", '" + width + "'";
	expression += ", '" + height + "'";
	expression += ", '" + flashvars + "'";
	expression += ", '" + idname + "'";
	expression += ", '" + saccess + "'";
	expression += ", '" + wmode + "'";
	expression += ", '" + fullscreen + "'";
	expression += ");";
	
	setTimeout(expression, delay);
	
}
/********************************************************
    Codes for Inserting Flash Object
********************************************************/
