﻿/*
* @Description CREATEFLASHOBJECT
* @Author: YellowMind
* @Date: 29-05-2006
* 
* Avoids Internet Explorer 'click to activate' Flash Update
* Creates your flash object + embed script
* 
* Include createFlashObject.js in your HTML
* use createFlashObject(); to create Flash Object
* 
* PARAMS required
* @param swf:String; your SWF name
* @param width:Number; your SWF width
* @param height:Number; your SWF height
* @param version:Number; your SWF FlashVersion
* 
* PARAMS OPTIONAL
* @param bgcolor:String; your backgroundcolor
* @param vars:String; variables for your flash movie | example: "clickTag1=http://www.megajobs.nl&clickTag2=http://www.yellowmind.nl"
* @param name:String; your SWF object name (for JavaScript use)
* @param scriptAcces:String; your scriptacces propertie (never, samedomain or always)
* @param transparent:Boolean; option to make your SWF Object transparent
* 
*/

function createFlashObject(swf, width, height, version, bgcolor, vars, name, scriptAccess, transparent) {
	// Check for required PARAMS
	if(!swf){
		error('no swf defined');
		return false;
	}
	if(!width){
		error('no width defined');
		return false;
	}
	if(!height){
		error('no height defined');
		return false;
	}
	if(!version){
		error('no flash version defined');
		return false;
	}
	
	// Check optional PARAMS
	if(!name) name = 'flashObject';
	if(!bgcolor)bgcolor = '#ffffff';
	if(!scriptAccess)scriptAccess = 'alway';
	if(!transparent){
		transparent = false;
		wmode = '';
	} else {
		wmode = 'wmode=\"transparent\"';
	}
	if(!vars){
		vars = '';
	} else {
		vars = '?' + vars;
	}
	
	// Create code
	object = '<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version + ',0,0,0\" width=\"' + width + '\" height=\"' + height + '\" id=\"' + name + '\" align=\"middle\">';
	object += '<param name=\"allowScriptAccess\" value=\"' + scriptAccess + '\" />';
	if(transparent)object += '<param name=\"wmode\" value=\"transparent\">';
	object += '<param name=\"movie\" value=\"' + swf + vars + '\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"' + bgcolor + '\" /><embed id=\"' + name + '\" src=\"' + swf + vars + '\" quality=\"high\" bgcolor=\"' + bgcolor + '\" width=\"' + width + '\" height=\"' + height + '\" name=\"' + name + '\" align=\"middle\" allowScriptAccess=\"' + scriptAccess + '\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ' + wmode + ' />';
	object += '</object>';
	document.write(object);
}

function error(message){
	// Output error
	alert(message);
}