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_8 = new BannerZoneAD("ZoneAD_8");
ZoneAD_8.ZoneID      = 8;
ZoneAD_8.ZoneWidth   = 290;
ZoneAD_8.ZoneHeight  = 330;
ZoneAD_8.ShowType    = 1;

var objAD = new ObjectAD();
objAD.ADID           = 11;
objAD.ADType         = 4;
objAD.ADName         = "首页幻灯";
objAD.ImgUrl         = "";
objAD.InstallDir     = "/";
objAD.ImgWidth       = 0;
objAD.ImgHeight      = 0;
objAD.FlashWmode     = 0;
objAD.ADIntro        = "<script type=\"text/javascript\">\n\r<!--\n\rimgUrl1=\"http://img.zgrtys.com/tp/flash/2010.1.29fm.jpg\"\n\rimgLink1=\"http://www.zgrtys.com/renti/mote/2010-02-07/3493.html\"\n\rimgtext1=\"Metcn模特傲蕾人体艺术专集增补\"\n\rimgUrl2=\"http://img.zgrtys.com/tp/flash/2009.12.23fm.jpg\"\n\rimgLink2=\"http://www.zgrtys.com/renti/mote/2009-12-25/3198.html\"\n\rimgtext2=\"Metcn模特邓晶人体艺术《海边美少女》\"\n\rimgUrl3=\"http://img.zgrtys.com/tp/flash/2009.12.16fm.jpg\"\n\rimgLink3=\"http://www.zgrtys.com/renti/mote/2009-12-17/3140.html\"\n\rimgtext3=\"Metcn模特奥雷人体艺术《Barn》\"\n\rimgUrl4=\"http://img.zgrtys.com/tp/flash/2009.11.30fm.jpg\"\n\rimgLink4=\"http://www.zgrtys.com/renti/mote/2009-12-01/3010.html\"\n\rimgtext4=\"Metcn模特奥雷人体艺术《Summer Style》\"\n\rimgUrl5=\"http://img.zgrtys.com/tp/flash/2009.11.7fm.jpg\"\n\rimgLink5=\"http://www.zgrtys.com/renti/mote/2009-11-08/2831.html\"\n\rimgtext5=\"Metcn模特奥雷人体艺术《雷》\"\n\rvar focus_width=290\n\rvar focus_height=320\n\rvar text_height=18\n\rvar swf_height = focus_height+text_height\n\rvar imgUrl1,imgUrl2,imgUrl3,imgUrl4,imgUrl5; \n\rvar imgLink1,imgLink2,imgLink3,imgLink4,imgLink5;\n\rvar imgtext1,imgtext2,imgtext3,imgtext4,imgtext5;\n\rvar pics=imgUrl1+\"|\"+imgUrl2+\"|\"+imgUrl3+\"|\"+imgUrl4+\"|\"+imgUrl5\n\rvar links=imgLink1+\"|\"+imgLink2+\"|\"+imgLink3+\"|\"+imgLink4+\"|\"+imgLink5\n\rvar texts=imgtext1+\"|\"+imgtext2+\"|\"+imgtext3+\"|\"+imgtext4+\"|\"+imgtext5\n\rdocument.write(\'<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0\" width=\"\'+ focus_width +\'\" height=\"\'+ swf_height +\'\">\');\n\rdocument.write(\'<param name=\"allowScriptAccess\" value=\"sameDomain\"><param name=\"movie\" value=\"/Skin/alex/flash01.swf\"><param name=\"quality\" value=\"high\"><param name=\"bgcolor\" value=ffffff>\');\n\rdocument.write(\'<param name=\"menu\" value=\"false\"><param name=wmode value=\"opaque\">\');\n\rdocument.write(\'<param name=\"FlashVars\" value=\"pics=\'+pics+\'&links=\'+links+\'&texts=\'+texts+\'&borderwidth=\'+focus_width+\'&borderheight=\'+focus_height+\'&textheight=\'+text_height+\'\">\');\n\rdocument.write(\'<embed src=\"/Skin/alex/flash01.swf\" wmode=\"opaque\" FlashVars=\"pics=\'+pics+\'&links=\'+links+\'&texts=\'+texts+\'&borderwidth=\'+focus_width+\'&borderheight=\'+focus_height+\'&textheight=\'+text_height+\'\" menu=\"false\" bgcolor=ffffff quality=\"high\" width=\"\'+ focus_width +\'\" height=\"\'+ swf_height +\'\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\');\n\rdocument.write(\'</object>\');\n\r//-->\n\r</script>";
objAD.LinkUrl        = "";
objAD.LinkTarget     = 1;
objAD.LinkAlt        = "";
objAD.Priority       = 1;
objAD.CountView      = 0;
objAD.CountClick     = 0;
objAD.ADDIR          = "AD";
ZoneAD_8.AddAD(objAD);

ZoneAD_8.Show();
