//© CopyRight AdSolutions © 2006
//Author: Olaf Buitelaar

function HTMLFlash(params){
	var i,j;
	this.id = 'HTMLFlash'+Math.round(Math.random()*10000);
	this.name = this.id;
	this.showMenu = false;
	this.swliveconnect = true;
	this.allowScriptAccess = 'sameDomain';
	this.wmodes = ['Window','Opaque','Transparent'];
	this.wmode = 'Opaque';
	this.quality = 'high';
	this.salign = 'LT';
	this.align = 'middle';
	this.scale = 'noscale';
	this.flashvars = '';
	this.bgcolor = '';
	this.version = {major:7,minor:'0,0,0'};
	for(i in params){
		switch(i){
			default:
				this[i] = params[i];
			break;
		}
	}
}
pt = HTMLFlash.prototype;
pt.setSrc = function(src){
	this.src = src;
	var elm = document.getElementById(this.id);
	if(elm instanceof Object){
		elm.src = this.src;
	}
}
pt.setWmode = function(mode){
	if(typeof(mode) == 'number'){
		this.wmode = this.wmodes[mode];
	}else{
		this.wmode = mode;
	}
}
pt.getSrc = function(){
	if(this.flashvars.length > 0){
		var indx1,indx2;
		indx1 = this.src.indexOf('?');
		indx2 = this.flashvars.indexOf('?');
		//Make 'smarter'
		if(indx1>0 && indx2>0){
			return this.src+'&'+this.flashvars.substr(indx2+1,this.flashvars.length);
		}else if(indx2>0 && indx2<3 || indx1>0){
			return this.src+'&'+this.flashvars;
		}else{
			return this.src+'?'+this.flashvars;
		}
	}else{
		return this.src;
	}
}
pt.getVersion = function(){
	return this.version.major+','+this.version.minor;
}
pt.cParam = function(name,value){
	return '<param name="'+name+'" value="'+value+'"/>';
}
pt.setSize = function(w,h){
	var elm = document.getElementById(this.id);
	if(typeof(elm) == "object"){
		elm.width = w;
		elm.height = h;
	}
	
}
pt.setVariable = function(name,val){
	var elm = document.getElementById(this.id);
	if(typeof(elm) == "object"){
		elm.setVariable(name,val);
	}
}
pt.getHTML = function(){
	var html = '';
	html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=';
	html += this.getVersion()+'" ';
	html += 'width="'+this.width+'" height="'+this.height+'" ';
	if(typeof(this.id) != 'undefined' >0) html += 'id="'+this.id+'" ';
	if(typeof(this.name) != 'undefined' >0) html += 'name="'+this.name+'" ';
	html += 'align="'+this.align+'"';
	html += '>';
	
	html += this.cParam('allowScriptAccess',this.allowScriptAccess);
	html += this.cParam('movie',this.getSrc());
	if(!this.showMenu) html += this.cParam('menu','false');
	html += this.cParam('quality',this.quality);
	html += this.cParam('scale',this.scale);
	html += this.cParam('wmode',this.wmode);
	html += this.cParam('salign',this.salign);
	if(this.bgcolor.length > 0) html += this.cParam('bgcolor',this.bgcolor);
	if(this.version.major >= 6) html += this.cParam('flashvars',this.flashvars);
	
	html += '<embed ';
	html += 'src ="'+this.getSrc()+'" ';
	html += 'quality="'+this.quality+'" ';
	html += 'scale="'+this.scale+'" ';
	html += 'salign="'+this.salign+'" ';
	if(this.bgcolor.length > 0) html += 'bgcolor="'+this.salign+'" ';
	html += 'width="'+this.width+'" height="'+this.height+'" ';
	if(this.swliveconnect) html += 'swLiveConnect="true" ';
	if(typeof(this.id) != 'undefined' > 0) html += 'id="'+this.id+'" ';
	if(typeof(this.name) != 'undefined' > 0) html += 'name="'+this.name+'" ';
	html += 'align="'+this.align+'" ';
	html += 'allowScriptAccess="'+this.allowScriptAccess+'" ';
	html += 'type="application/x-shockwave-flash" ';
	html += 'pluginspage="http://www.macromedia.com/go/getflashplayer"';
	html += '/>';
	
	html += '</object>';
	return html;
}
pt.cWrite = function(){
	document.write(this.getHTML());
	var elm = document.getElementById(this.id);
	elm.obj = this;
}
pt.cInner = function(elm){
	elm.innerHTML = this.getHTML();
}
pt.cNode = function(elm){
	var root = elm.appendChild(document.createElement("object"));
}
delete pt;