function objectad() {
  /* define variables*/
  this.adid        = 0;
  this.adtype      = 0;
  this.adname      = "";
  this.imgurl      = "";
  this.imgwidth    = 0;
  this.imgheight   = 0;
  this.flashwmode  = 0;
  this.linkurl     = "";
  this.linktarget  = 0;
  this.linkalt     = "";
  this.priority    = 0;
  this.countview   = 0;
  this.countclick  = 0;
  this.installdir  = "";
  this.addir       = "";
}

function bannerzonead(_id) {
  /* define constants */
  this.adnum       = 0;
  this.addelay     = 6000;

  /* define common variables*/
  this.id          = _id;
  this.zoneid      = 0;
  this.zonename    = "";
  this.zonewidth   = 0;
  this.zoneheight  = 0;
  this.showtype    = 1;
  this.divname     = "";
  this.div         = null;

  /* define unique variables*/

  /* define objects */
  this.allad       = new array();
  this.showad      = null;

  /* define functions */
  this.addad       = bannerzonead_addad;
  this.getshowad   = bannerzonead_getshowad;
  this.show        = bannerzonead_show;
  this.loopshow    = bannerzonead_loopshow;

}

function bannerzonead_addad(_ad) {
  this.allad[this.allad.length] = _ad;
}

function bannerzonead_getshowad() {
  if (this.showtype > 1) {
    this.showad = this.allad[0];
    return;
  }
  var num = this.allad.length;
  var sum = 0;
  for (var i = 0; i < num; i++) {
    sum = sum + this.allad[i].priority;
  }
  if (sum <= 0) {return ;}
  var rndnum = math.random() * sum;
  i = 0;
  j = 0;
  while (true) {
    j = j + this.allad[i].priority;
    if (j >= rndnum) {break;}
    i++;
  }
  this.showad = this.allad[i];
}

function bannerzonead_show() {
  if (!this.allad) {
    return;
  } else {
    this.getshowad();
  }

  if (this.showad == null) return false;
  this.divname = "bannerzonead_div" + this.zoneid;
  if (!this.showad.imgwidth) this.showad.imgwidth = this.zonewidth
  if (!this.showad.imgheight) this.showad.imgheight = this.zoneheight
  if (this.showad.addir=="") this.showad.addir = "ad"
  if (this.showtype == 3) {
    if(document.all) {
      document.write("<div id='" + this.divname + "' style='visibility:visible; z-index:1; width:" + this.zonewidth + "px; height:" + this.zoneheight + "px; filter: revealtrans(duration=2,transition=20);'>" + ad_content(this.showad) + "</div>");
    }
    else {
      document.write("<div id='" + this.divname + "' style='visibility:visible; z-index:1; width:" + this.zonewidth + "px; height:" + this.zoneheight + "px'>" + ad_content(this.showad) + "</div>");
    }
  } 
  else {
    document.write("<div id='" + this.divname + "' style='visibility:visible; z-index:1; width:" + this.zonewidth + "px; height:" + this.zoneheight + "px;'>" + ad_content(this.showad) + "</div>");
    if (this.showad.countview) {
      document.write ("<script src='" + this.showad.installdir + this.showad.addir + "/adcount.asp?action=view&adid=" + this.showad.adid + "'></" + "script>")
    }
  }
  this.div = document.getelementbyid(this.divname);
  if (this.showtype == 3) this.loopshow();
}

function bannerzonead_loopshow() {
  if(document.all) {
    if(this.adnum<this.allad.length-1) this.adnum++ ; 
    else this.adnum=0; 
    this.div.filters.revealtrans.transition=math.floor(math.random()*23); 
    this.div.filters.revealtrans.apply(); 
    if (this.allad[this.adnum].imgwidth) this.allad[this.adnum].imgwidth = this.zonewidth
    if (this.allad[this.adnum].imgheight) this.allad[this.adnum].imgheight = this.zoneheight
    this.div.innerhtml=ad_content(this.allad[this.adnum]);
    this.div.filters.revealtrans.play() 
    this.div.timer=settimeout(this.id+".loopshow()",this.addelay);
  }
  else {
    if(this.adnum<this.allad.length-1) this.adnum++ ; 
    else this.adnum=0;
    if (this.allad[this.adnum].imgwidth) this.allad[this.adnum].imgwidth = this.zonewidth
    if (this.allad[this.adnum].imgheight) this.allad[this.adnum].imgheight = this.zoneheight
    this.div.innerhtml=ad_content(this.allad[this.adnum]);
    this.div.timer=settimeout(this.id+".loopshow()",this.addelay);
  }
}

function ad_content(o) {
  var str = "";
  if (o.adtype == 1 || o.adtype == 2) {
  imgurl = o.imgurl .tolowercase()
    if (o.installdir.indexof("http://") != - 1) imgurl = o.installdir.substr(0, o.installdir.length - 1) + imgurl;
    if (imgurl.indexof(".swf") !=  - 1) {
      str = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'";
      str += " name='ad_" + o.adid + "' id='ad_" + o.adid + "'";
      str += " width='" + o.imgwidth + "px'";
      str += " height='" + o.imgheight + "px'";
      if (o.style) str += " style='" + o.style + "'";
      if (o.extfunc) str += " " + o.extfunc + " ";
      str += ">";
      str += "<param name='movie' value='" + imgurl + "'>";
      if (o.flashwmode == 1) str += "<param name='wmode' value='transparent'>";
      if (o.play) str += "<param name='play' value='" + o.play + "'>";
      if (typeof(o.loop) != "undefined") str += "<param name='loop' value='" + o.loop + "'>";
      str += "<param name='quality' value='autohigh'>";
      str += "<embed ";
      str += " name='ad_" + o.adid + "' id='ad_" + o.adid + "'";
      str += " width='" + o.imgwidth + "px'";
      str += " height='" + o.imgheight + "px'";
      if (o.style) str += " style='" + o.style + "'";
      if (o.extfunc) str += " " + o.extfunc + " ";
      str += " src='" + imgurl + "'";
      if (o.flashwmode == 1) str += " wmode='transparent'";
      if (o.play) str += " play='" + o.play + "'";
      if (typeof(o.loop) != "undefined") str += " loop='" + o.loop + "'";
      str += " quality='autohigh'"
      str += " pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash'></embed>";
      str += "</object>";
    } else if (imgurl.indexof(".gif") !=  - 1 || imgurl.indexof(".jpg") !=  - 1 || imgurl.indexof(".jpeg") !=  - 1 || imgurl.indexof(".bmp") !=  - 1 || imgurl.indexof(".png") !=  - 1) {
      if (o.linkurl) {
        if (o.countclick) o.linkurl = o.installdir + o.addir + "/adcount.asp?action=click&adid=" + o.adid
        str += "<a href='" + o.linkurl + "' target='" + ((o.linktarget == 0) ? "_self" : "_blank") + "' title='" + o.linkalt + "'>";
      }
      str += "<img ";
      str += " name='ad_" + o.adid + "' id='ad_" + o.adid + "'";
      if (o.style) str += " style='" + o.style + "'";
      if (o.extfunc) str += " " + o.extfunc + " ";
      str += " src='" + imgurl + "'";
      if (o.imgwidth) str += " width='" + o.imgwidth + "px'";
      if (o.imgheight) str += " height='" + o.imgheight + "px'";
      str += " border='0'>";
      if (o.linkurl) str += "</a>";
    }
  } else if (o.adtype == 3 || o.adtype == 4) {
    str = o.adintro
  } else if (o.adtype == 5) {
    str = "<iframe id='" + "ad_" + o.adid + "' marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no width=100% height=100% src='" + o.adintro + "'>wait</iframe>";
  }
  return str;
}


var zonead_6 = new bannerzonead("zonead_6");
zonead_6.zoneid      = 6;
zonead_6.zonewidth   = 390;
zonead_6.zoneheight  = 50;
zonead_6.showtype    = 1;

var objad = new objectad();
objad.adid           = 6;
objad.adtype         = 2;
objad.adname         = "a1";
objad.imgurl         = "/news/pic_gg/uploadadpic/200908/2009082216180319.swf";
objad.installdir     = "/news/";
objad.imgwidth       = 390;
objad.imgheight      = 50;
objad.flashwmode     = 0;
objad.adintro        = "";
objad.linkurl        = "";
objad.linktarget     = 1;
objad.linkalt        = "";
objad.priority       = 1;
objad.countview      = 0;
objad.countclick     = 0;
objad.addir          = "pic_gg";
zonead_6.addad(objad);

zonead_6.show();
