acObject = function(src, id, w, h, version, bgcolor, redirect, skipdetect) {
	this.objectParams = new Object();
	this.objAttributes = new Object();
	this.requiredVersion = version.split(".");
	this.redirect = redirect ? redirect : false;
	this.skipdetect = skipdetect ? skipdetect : true;
	if(src){
		this.addAttribute("swf", src);
	}
	if(id){
		this.addAttribute("id", id);
	}
	if(w){
		this.addAttribute("width", w);
	}
	if(h){
		this.addAttribute("height", h);
	}
	if(redirect){
		this.addAttribute("redirectURL", redirect);
	}
	if(bgcolor){
		this.addParam("bgcolor", bgcolor);	
	}
}

acObject.prototype.addParam = function(param, value) {
	this.objectParams[param] = value;
}
acObject.prototype.addAttribute = function(attr, value) {
	this.objAttributes[attr] = value;
}

acObject.prototype.useAutoInstall = function(url){
	this.addAttribute("expressInstall", url);
}
acObject.prototype.alternateContent = function(content){
	this.addAttribute("alternateContent", content);
}
acObject.prototype.checkVersion = function() {
	var clientVersion = new Array();
    if (navigator.plugins && navigator.mimeTypes.length) {
        var plugin = navigator.plugins["Shockwave Flash"];
        if (plugin && plugin.description) {
            clientVersion = plugin.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".");
        };
    } else {
        if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) {
            var axo = 1;
            var version = 3;
            while (axo) {
                try {
                    version++;
                    axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + version);
                    clientVersion =[version, 0, 0];
                } catch(e) {
                    axo = null;
                }
            }
        } else {
            try {
                var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
            } catch(e) {
                try {
                    var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                    clientVersion = [6, 0, 21];
                    axo.AllowScriptAccess = "always";
                } catch(e) {
                    if (clientVersion.major == 6) {
                        return clientVersion;
                    }
                }
                try {
                    axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
                } catch(e) {}
            }
            if (axo != null) {
                clientVersion = axo.GetVariable("$version").split(" ")[1].split(",");
            };
        };
    };
	if (parseInt(clientVersion[0]) < parseInt(this.requiredVersion[0])) {
        return false;
    };
    if (parseInt(clientVersion[0]) > parseInt(this.requiredVersion[0])) {
        return true;
    };
    if (parseInt(clientVersion[1]) < parseInt(this.requiredVersion[1])) {
        return false;
    };
    if (parseInt(clientVersion[1]) > parseInt(this.requiredVersion[1])) {
        return true;
    };
    if (parseInt(clientVersion[2]) < parseInt(this.requiredVersion[2])) {
        return false;
    };
    return true;	
}
acObject.prototype.createString = function(objAttributes, objectParams) {
	if (!this.objectParams["quality"]){
		this.addParam("quality", "high");
	};
	var objectString = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
		objectString += "<embed type=\"application/x-shockwave-flash\" src=\"" + objAttributes["swf"] + "\" width=\"" + objAttributes["width"] + "\" height=\"" + objAttributes["height"] + "\" align=\"B\"";
		objectString += " id=\"" + objAttributes["id"] + "\" name=\"" + objAttributes["id"] + "\" ";
		for (var key in objectParams) {
			objectString += [key] + "=\"" + objectParams[key] + "\" ";
		}
		objectString += "/>";
	} else {
		objectString += "<object id=\"" + objAttributes["id"] + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + objAttributes["width"] + "\" height=\"" + objAttributes["height"] + "\" align=\"B\">";
		objectString += "<param name=\"movie\" value=\"" + objAttributes["swf"] + "\" />";
		for (var key in objectParams) {
			objectString += "<param name=\"" + key + "\" value=\"" + objectParams[key] + "\" />";
		}
		objectString += "</object>";
	};
	return objectString;
}
acObject.prototype.generate = function(elementId) {
	if (this.skipDetect || this.checkVersion()) {
		if(!elementId){
			document.write(this.createString(this.objAttributes,this.objectParams));
		}else{
			document.getElementById(elementId).innerHTML =	this.createString(this.objAttributes,this.objectParams);
		}
	} else {
		if (this.objAttributes["expressInstall"]) {
			this.addAttribute("swf", this.objAttributes["expressInstall"]);
			this.addParam("FlashVars","majorVersion="+this.requiredVersion[0]);
			document.title = "Adobe Flash Player Update - "+document.title;
			if(!elementId){
				document.write(this.createString(this.objAttributes,this.objectParams));
			}else{
				document.getElementById(elementId).innerHTML =	this.createString(this.objAttributes,this.objectParams);
			}
			return;
		};
		if (this.objAttributes["redirectURL"]) {
			document.location.replace(this.objAttributes["redirectURL"]);
			return;
		};
		if (this.objAttributes["alternateContent"]) {
			if(!elementId){
				document.write(this.objAttributes["alternateContent"]);
			}else{
				document.getElementById(elementId).innerHTML =	this.objAttributes["alternateContent"];
			}
			return;
		}
	};
}
var ac = new acObject("http://promotools.islive.nl/webcamclips/player/413x343/player.swf?u=http%3A%2F%2Fpromotools.islive.nl%2Fwebcamclips%2F1879%2F413x343%2Fx.xml%3Fgeslacht%3Dv", "modelmovie", "413", "343", "8", "#FFFFFF");
ac.addParam("allowScriptAccess","always");
ac.addParam("wmode","transparent");
ac.addParam("allowFullscreen","true");
ac.addParam("quality","best");
ac.addParam("menu","false");
ac.generate();
