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 CodeZoneAD(_id) {
  /* Define Common Variables*/
  this.ID          = _id;
  this.ZoneID      = 0;

  /* Define Unique Variables*/

  /* Define Objects */
  this.AllAD       = new Array();
  this.ShowAD      = null;

  /* Define Functions */
  this.AddAD       = CodeZoneAD_AddAD;
  this.GetShowAD   = CodeZoneAD_GetShowAD;
  this.Show        = CodeZoneAD_Show;

}

function CodeZoneAD_AddAD(_AD) {
  this.AllAD[this.AllAD.length] = _AD;
}

function CodeZoneAD_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 CodeZoneAD_Show() {
  if (!this.AllAD) {
    return;
  } else {
    this.GetShowAD();
  }

  if (this.ShowAD == null) return false;
  document.write(this.ShowAD.ADIntro);
}

var ZoneAD_1 = new CodeZoneAD("ZoneAD_1");
ZoneAD_1.ZoneID      = 1;
ZoneAD_1.ZoneWidth   = 0;
ZoneAD_1.ZoneHeight  = 0;
ZoneAD_1.ShowType    = 1;

var objAD = new ObjectAD();
objAD.ADID           = 1;
objAD.ADType         = 4;
objAD.ADName         = "0911广告";
objAD.ImgUrl         = "";
objAD.InstallDir     = "/";
objAD.ImgWidth       = 0;
objAD.ImgHeight      = 0;
objAD.FlashWmode     = 0;
objAD.ADIntro        = "<script>\n\rvar links = new Array();\n\rlinks[1] = \"http://www.tgstar.net/\";\n\rlinks[2] = \"http://www.tgstar.net/\";\n\rlinks[3] = \"http://www.tgstar.net/\";\n\rlinks[4] = \"http://www.tgstar.net/\";\n\rvar imgs = new Array();\n\rfor(var n = 1; n <= 5; n++) imgs[n] = new Image();\n\rimgs[1].src = \"http://www.tgstar.net/adjpg/001.jpg\";\n\rimgs[2].src = \"http://www.tgstar.net/adjpg/002.jpg\";\n\rimgs[3].src = \"http://www.tgstar.net/adjpg/003.jpg\";\n\rimgs[4].src = \"http://www.tgstar.net/Skin/tgstar/ad01_bg.gif\";\n\rvar tits = new Array();\n\rtits[1] =\"星城电玩网\";\n\rtits[2] = \"星城电玩网\";\n\rtits[3] = \"星城电玩网\";\n\rtits[4] = \"星城电玩网\";\n\rvar imgwidth = 720;//图片宽度\n\rvar imgheight = 226;//图片宽度\n\rvar str = \"<style type=\'text/css\'>\";\n\rstr += \"#imgnv{display:none;position:absolute;bottom:-1px;right:0;height:16px;}#imgnv div{float:left;margin-right:1px;}\";\n\rstr += \"#imgnv div.on,#imgnv div.off{margin-bottom:1px;width:30px;height:15px;line-height:18px!important;line-height:15px;font-size:9px;text-align:center;cursor:pointer;cursor:hand}\";\n\rstr += \"#imgnv div.on{background:#CE0609;color:#FFF;font-weight:bold}\";\n\rstr += \"#imgnv div.off{background:#323232;color:#FFF;text-decoration:none}\";\n\rstr += \"#titnv{margin-top:3px;color:#000;text-align:center;display:none;}\";\n\rstr += \"</style>\";\n\rstr += \"<div style=\'position:relative\'>\";\n\rstr += \"<div><a id=\'dlink\' href=\'\" + links[1] + \"\' target=\'_blank\'><img id=\'dimg\' src=\'\" + imgs[1].src + \"\' border=\'0\' width=\'\" + imgwidth + \"\' height=\'\"+imgheight+\"\' style=\'filter:Alpha(opacity=100)\' onmouseover=\'Pause(true)\' onmouseout=\'Pause(false)\'></a></div>\";\n\r//修改点1：循环添加内层div内容以增加个数\n\rstr += \"<div id=\'imgnv\'><div id=\'it1\' class=\'on\' onmouseover=\'ImgSwitch(1, true)\' onmouseout=\'Pause(false)\'>1</div><div id=\'it2\' class=\'off\' onmouseover=\'ImgSwitch(2, true)\' onmouseout=\'Pause(false)\'>2</div><div id=\'it3\' class=\'on\' onmouseover=\'ImgSwitch(3, true)\' onmouseout=\'Pause(false)\'>3</div><div id=\'it4\' class=\'off\' onmouseover=\'ImgSwitch(4, true)\' onmouseout=\'Pause(false)\'>4</div></div>\";\n\rstr += \"<div id=\'titnv\'><b>\" + tits[1] + \"</b></div>\";\n\rstr += \"</div>\";\n\rdocument.write(str);\n\rvar oi = document.getElementById(\"dimg\");\n\rvar pause = false;\n\rvar curid = 1;\n\rvar lastid = 1;\n\rvar sw = 1;\n\rvar opacity = 100;\n\rvar speed = 15;\n\rvar delay = (document.all)? 400:700;\n\rfunction SetAlpha(){\n\rif(document.all){\n\rif(oi.filters && oi.filters.Alpha) oi.filters.Alpha.opacity = opacity;\n\r}else{\n\roi.style.MozOpacity = ((opacity >= 100)? 99:opacity) / 100;\n\r}\n\r}\n\rfunction ImgSwitch(id, p){\n\rif(p){\n\rpause = true;\n\ropacity = 100;\n\rSetAlpha();\n\r}\n\roi.src = imgs[id].src;\n\rdocument.getElementById(\"dlink\").href = links[id];\n\rdocument.getElementById(\"it\" + lastid).className = \"off\";\n\rdocument.getElementById(\"it\" + id).className = \"on\";\n\rdocument.getElementById(\"titnv\").innerHTML = \"<b>\" + tits[id] + \"</b>\";\n\rcurid = lastid = id;\n\r}\n\rfunction ScrollImg(){\n\rif(pause && opacity >= 100) return;\n\rif(sw == 0){\n\ropacity += 2;\n\rif(opacity > delay){ opacity = 100; sw = 1; }\n\r}\n\rif(sw == 1){\n\ropacity -= 3;\n\rif(opacity < 10){ opacity = 10; sw = 3; }\n\r}\n\rSetAlpha();\n\rif(sw != 3) return;\n\rsw = 0;\n\rcurid++;\n\r//修改点2：这里的4也是个数\n\rif(curid > 4) curid = 1;\n\rImgSwitch(curid, false);\n\r}\n\rfunction Pause(s){\n\rpause = s;\n\r}\n\rfunction StartScroll(){\n\rsetInterval(ScrollImg, speed);\n\r}\n\rfunction CheckLoad(){\n\rif (imgs[1].complete == true && imgs[2].complete == true) {\n\rclearInterval(checkid);\n\rsetTimeout(StartScroll, 2000);\n\r}\n\r}\n\rvar checkid = setInterval(CheckLoad, 10);\n\r</script>";
objAD.LinkUrl        = "";
objAD.LinkTarget     = 1;
objAD.LinkAlt        = "";
objAD.Priority       = 1;
objAD.CountView      = 0;
objAD.CountClick     = 0;
objAD.ADDIR          = "AD";
ZoneAD_1.AddAD(objAD);

ZoneAD_1.Show();
