/*
	swfbanner.js		
*/


/* constructor */
function SwfBanner() {
	this.swfFile = null;
	this.width = null;
	this.height = null;
	this.clickTag = null;
	this.clickTagDestination = null;	
	this.backupImage = null;	
	this.backupTarget = null;	
	this.paramNames = new Array();
	this.paramValues = new Array();
}

SwfBanner.prototype.setSwfFile = function(filename) {
	this.swfFile = filename;
}

SwfBanner.prototype.setWidth = function(width) {
	this.width = width;
}

SwfBanner.prototype.setHeight = function(height) {
	this.height = height;
}

SwfBanner.prototype.setDimensions = function(width, height) {
	this.width = width;
	this.height = height;
}

SwfBanner.prototype.setClickTag = function(clickTag, destinationUrl) {
	this.clickTag = clickTag;
	this.clickTagDestination = destinationUrl;
}

SwfBanner.prototype.setBackupImage = function(imagefile) {
	this.backupImage = imagefile;
}

SwfBanner.prototype.setBackupTarget = function(target) {
	this.backupTarget = target;
}

SwfBanner.prototype.addParam = function(name, value) {
	this.paramNames.push(name);
	this.paramValues.push(value);
}

SwfBanner.prototype.write = function() {
	if ((this.swfFile != null) && (this.width != null) && (this.height != null)) {
		swfFullUrl = this.swfFile;
		if ((this.clickTag != null) && (this.clickTagDestination != null)) {
			swfFullUrl += "?" + this.clickTag + "=" + this.clickTagDestination;
		}
		document.write('<object type = "application/x-shockwave-flash" data = "' + swfFullUrl + '" width = "' + this.width + '" height = "' + this.height + '">');		
		document.write('<param name = "movie" value= "' + swfFullUrl + '" />');

		// write the extra params		
		for (var i = 0; i < this.paramNames.length; i++) {
			document.write('<param name = "');
			document.write(this.paramNames[i]);
			document.write('" value = "');
			document.write(this.paramValues[i]);
			document.write('" />');						
		}
		
		if ((this.backupImage != null) && (this.clickTagDestination != null)) {
			document.write('<a href = "' + this.clickTagDestination + '"');
			if (this.backupTarget != null) {
				document.write(' target = "' + this.backupTarget + '"');
			}
			document.write('>');
			document.write('<img src = "' + this.backupImage + '" width = "' + this.width + '" height = "' + this.height + '" border = "0" />');
			document.write('</a>');
		}
		document.write('</object>');
	}
}
