// Flash player writer.

function Write_flv_player( target_element, post_id, flv_location, width, height )
{
	var has_flash = DetectFlashVer( 6, 0, 65 );
	var has_required_version = DetectFlashVer( 9, 0, 28 );
	var result_text = "";

	result_text += "<a name=\"post_" + post_id + "_container_bookmark\" />";
	result_text += "<div id=\"post_" + post_id + "_container\">";
	if( has_required_version ) {
		result_text += AC_FL_RunContent(
			"src", "/gio_player/GIO_player",
			"width", width,
			"height", height,
			"align", "left",
			"id", "GIO_player_post_" + post_id,
			"quality", "high",
			"bgcolor", "#000000",
			"name", "GIO_player_post_" + post_id,
			"allowScriptAccess", "sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer",
			"flashvars", "source_file=" + flv_location
		);
	} else {
		result_text += "Flash is required to view this content.";
		result_text += "<a href=\"http://www.adobe.com/go/getflashplayer\" target=\"_blank\">Get Flash Player</a>";
	}
	result_text += "</div>";

	target_element.innerHTML += result_text;
}

function Write_flv_player_link( target_element, post_id, link_text )
{
	var result_text = "";
	
	result_text += "<div id=\"post_" + post_id + "_container_enabler\" style=\"display:block\">";
	result_text += "<a href=\"#post_" + post_id + "_container_bookmark\" onclick=\"Show_flv_player( " + post_id + ")\">" + link_text + "</a>";
	result_text += "</div>";

	target_element.innerHTML += result_text;
}

function Write_flv_player_link_and_player( target_id, post_id, link_text, flv_location, width, height )
{
	var target_element = GE( target_id );

	if( target_element == null ) {
		return;
	}
	Write_flv_player_link( target_element, post_id, link_text );
	Write_flv_player( target_element, post_id, flv_location, width, height );
}

function Show_flv_player( post_id )
{
	GE( "post_" + post_id + "_container_enabler" ).style.display = "none";
	GE( "post_" + post_id + "_container" ).style.display = "block";
}

function Launch_flash_player( post_id, flv_location, width, height )
{
	window.open( "/flash.viewer?post_id=" + post_id + "&flv_location=" + flv_location + "&width=" + width + "&height=" + height, "flash_player_window", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=" + height + ",width=" + width );
}
