function Creative (type,src,url,w,h,target) {
    this.w = w||468;
    this.h = h||60;
    this.src = src;
    this.url = url;
    this.target = target||"_blank";
    this.type=type;
}    
    Creative.prototype.set_target = function (value) {
        return this.target = value;
    }

function Gif (src,url,w,h) {
    this.base = Creative;
    this.base('gif',src,url,w,h);
    this.alt = "Click here !";
    this.additional_attributes = '';
}
    Gif.prototype = new Creative;
    Gif.prototype.write_s = function () {
        var s = "";
        s += '<a href="'+this.url+'" target="'+this.target+'" \>';
        s += '<img src="'+this.src+'" ';
        s += 'border=0 width='+this.w+' height='+this.h+' alt="'+this.alt+'"'+this.additional_attributes+' \/>';
        s += '<\/a\>\n';
        return s;
    }
    Gif.prototype.write = function () {
        document.write(this.write_s());
    }
    Gif.prototype.add_attribute = function (){
        var argv = this.add_attribute.arguments;
            for (var i = 0; i < argv.length; i+=2) {
                this.additional_attributes += ' ' + argv[i] + '="' + argv[i+1] + '" ';
            }
    }
    Gif.prototype.set_alt = function (value) {
        return this.alt = value;
    }

function Flash (src,url,w,h) {
    /*
    name,flashversion,target,bgcolor,wmode
    */
    this.base = Creative;
    this.base('flash',src,escape(url),w,h);
    this.target = '_blank';
    this.flashversion = "5";
    this.bgcolor = "";
    this.flash_ok = bw.flash(this.flashversion);
    this.flash_name = 'FLASH_AD';
    this.wmode = 'opaque';
    this.flashArgs = "";
    this.fsArgs = new Array;
    
}
    Flash.prototype = new Creative;
    Flash.prototype.set_flash_name = function (value) {
        return this.flash_name = value;
    }
    Flash.prototype.set_flash_version = function (value) {
        if(value >= 3 && value <= 7){
            this.flash_ok = bw.flash(value);
            return this.flash_version = value;
        }
        return false;
    }
    Flash.prototype.set_bgcolor = function (value) {
        return this.bgcolor = value;
    }
    Flash.prototype.set_wmode = function (value) {
        if(value == 'opaque'||'transparent'||'window'){
            return this.wmode = value;
        }
        return false;
    }
    Flash.prototype.write_s = function () {
        var s = "";
        s += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n';
        s += '  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0" \n';
        s += ' id="'+ this.flash_name +'"  width="'+ this.w +'" height="'+ this.h +'">\n';
        s += ' <param name="movie" value="' + this.src + '?clickTag='+ this.url +'&targetTAG='+this.target+this.flashArgs+'"> \n';
        s += '<param name="quality" value="autohigh"> <param name="wmode" value="'+this.wmode+'"><param name="bgcolor" value="#'+ this.bgcolor +'" > \n'; 
        s += ' <embed src="' + this.src + '?clickTag='+ this.url +'&targetTAG='+this.target+this.flashArgs+'" quality="autohigh" \n';
        s += ' swLiveConnect="TRUE" name="'+ this.flash_name +'" width="'+ this.w +'" height="'+ this.h +'" bgcolor="#'+ this.bgcolor+'"\n';
        s += ' type="application/x-shockwave-flash" wmode="'+this.wmode+'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">\n';
        s += ' </embed>\n';
        s += ' </object>\n';
        return s;
        }
    Flash.prototype.write = function () {
        document.write(this.write_s());
    }
    Flash.prototype.set_fscommand = function () {
        if(this.set_fscommand.arguments)this.fsArgs.concat(this.set_fscommand.arguments);
        document.write(this.set_fscommand_s());
    }
    Flash.prototype.set_fscommand_s = function () {
        var fsfunction;
        var s;
        var argv = this.set_fscommand_s.arguments;
        if (argv.length==0) argv = this.fsArgs;
        s = '<scr' + 'ipt language="JavaScript" type="text/javascript" \>\n';
        s += "function "+ this.flash_name +"_DoFSCommand(command, args) {\n";
        for (var i = 0; i < argv.length; i+=2) {
            s += "if (command=='"+argv[i]+"') {\n"+argv[i+1]+"\n}";
        }
        s += "}";
        s += '</scr' + 'ipt\> \n';
        s += '<scr' + 'ipt language="VBScript"\> \n';
        s += 'Sub '+ this.flash_name +'_FSCommand(ByVal command, ByVal args)'+'\n';
        s += '  call '+ this.flash_name +'_DoFSCommand(command, args)'+'\n';
        s += 'end sub'+'\n';
        s += '</scr' + 'ipt\> \n';
        //alert(s);
        return s;
    }

