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 PopZoneAD(_id) {
  /* 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*/
  this.PopType     = 0;
  this.Left        = 0;
  this.Top         = 0;
  this.CookieHour  = 0;

  /* Define Objects */
  this.AllAD       = new Array();
  this.ShowAD      = null;

  /* Define Functions */
  this.AddAD       = PopZoneAD_AddAD;
  this.GetShowAD   = PopZoneAD_GetShowAD;
  this.CookieCheck = PopZoneAD_CookieCheck;
  this.Show        = PopZoneAD_Show;
  this.Struct      = PopZoneAD_Struct;
  this.Window      = PopZoneAD_Window;

}

function PopZoneAD_AddAD(_AD) {
  this.AllAD[this.AllAD.length] = _AD;
}

function PopZoneAD_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 PopZoneAD_Show() {
  if (!this.AllAD) {
    return;
  } else {
    this.GetShowAD();
  }

  if (this.ShowAD == null) return false;
  if (this.CookieCheck()) return false;
  this.DivName = "PopZoneAD_Div" + this.ZoneID;
  if (this.ShowAD.ADDIR=="") this.ShowAD.ADDIR = "AD"
  if (this.PopType == 3) {
    window.showModelessDialog("" + this.ShowAD.InstallDir + this.ShowAD.ADDIR + "/ADShow.asp?ADID=" + this.ShowAD.ADID + "","","scroll:0;status:0;help:0;toolbar=0;resizable:0;dialogTop:" + this.Top + "px;dialogLeft:" + this.Left + "px;dialogWidth:" + this.ZoneWidth + "px;dialogHeight:" + this.ZoneHeight + "px");
  } else {
    var OK = this.Struct();
    if (OK) OK.document.write(this.Window());
  }
  if (this.ShowAD.CountView) {
    document.write ("<script src='" + this.ShowAD.InstallDir + this.ShowAD.ADDIR + "/ADCount.asp?Action=View&ADID=" + this.ShowAD.ADID + "'></script>")
  }
}

function PopZoneAD_Struct() {
  var winwidth = (this.PopType==4) ? (screen.width - 9): (parseInt((this.ShowAD.ImgWidth) ? this.ShowAD.ImgWidth : 350) - 4);
  var winheight = (this.PopType==4) ? (screen.height - 56): (parseInt((this.ShowAD.ImgHeight) ? this.ShowAD.ImgHeight : 250) - 4);
  var winleft = (this.PopType==4) ? 0: ((this.Left) ? this.Left : 0);
  var wintop = (this.PopType==4) ? 0: ((this.Top) ? this.Top : 0);
  return window.open("about:blank", "","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=" + winwidth + ",height=" + winheight + ",top=" + wintop + ",left=" + winleft);
}

function PopZoneAD_Window() {
  var strWin;
  strWin = "<html><head><meta http-equiv='content-type' content='text/html; charset=gb2312'><title>";
  strWin += (this.PopType==4) ? "背投广告" : "POPAD";
  strWin += "</title>";
  if (this.PopType==2||this.PopType==4) {
    strWin += "\n<Script language='Javascript'>\n";
    strWin += "blur();\n";
    strWin += "<\/Script>";
  }
  strWin += "</head><body scroll=no style='margin:0;border:none'>";
  strWin += AD_Content(this.ShowAD);
  strWin += "</body></html>";
  return strWin;
}

function PopZoneAD_CookieCheck() {
  if (!this.CookieHour) return false;
  var Now = new Date();
  var strToday = String(Now.getYear()) + String(Now.getMonth() + 1) + String(Now.getDate());
  var ADCookie = "AD_Cookie_" + this.ZoneID
  if (GetCookie(ADCookie) == strToday)
    return true;
  else {
    Now.setTime(Now.getTime() + (parseFloat(typeof(this.CookieHour) == "undefined" ? 24 : parseFloat(this.CookieHour)) * 60 * 60 * 1000));
    AD_SetCookie(ADCookie, strToday, Now);
    return false;
  }
}

function GetCookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return GetCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function GetCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function AD_SetCookie(name, value)
{
    var argv = AD_SetCookie.arguments;
    var argc = AD_SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2]: null;
    var path = (argc > 3) ? argv[3]: null;
    var domain = (argc > 4) ? argv[4]: null;
    var secure = (argc > 5) ? argv[5]: false;
    document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function AD_Content(o) {
  var str = "";
  if (o.ADType == 1 || o.ADType == 2) {
    o.ImgUrl = o.ImgUrl.toLowerCase()
    if (o.InstallDir.indexOf("http://") != - 1) o.ImgUrl = o.InstallDir.substr(0, o.InstallDir.length - 1) + o.ImgUrl;
    if (o.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 + "'";
      str += " height='" + o.ImgHeight + "'";
      if (o.style) str += " style='" + o.style + "'";
      if (o.extfunc) str += " " + o.extfunc + " ";
      str += ">";
      str += "<param name='movie' value='" + o.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 + "'";
      str += " height='" + o.ImgHeight + "'";
      if (o.style) str += " style='" + o.style + "'";
      if (o.extfunc) str += " " + o.extfunc + " ";
      str += " src='" + o.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 (o.ImgUrl.indexOf(".gif") !=  - 1 || o.ImgUrl.indexOf(".jpg") !=  - 1 || o.ImgUrl.indexOf(".jpeg") !=  - 1 || o.ImgUrl.indexOf(".bmp") !=  - 1 || o.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='" + o.ImgUrl + "'";
      if (o.ImgWidth) str += " width='" + o.ImgWidth + "'";
      if (o.ImgHeight) str += " height='" + o.ImgHeight + "'";
      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_1 = new PopZoneAD("ZoneAD_1");
ZoneAD_1.ZoneID      = 1;
ZoneAD_1.ZoneWidth   = 300;
ZoneAD_1.ZoneHeight  = 545;
ZoneAD_1.ShowType    = 1;
ZoneAD_1.PopType     = 3;
ZoneAD_1.Left        = 650;
ZoneAD_1.Top         = 100;
ZoneAD_1.CookieHour  = 1;

var objAD = new ObjectAD();
objAD.ADID           = 3;
objAD.ADType         = 4;
objAD.ADName         = "食品药品举报投诉";
objAD.ImgUrl         = "";
objAD.ImgWidth       = 0;
objAD.ImgHeight      = 0;
objAD.FlashWmode     = 0;
objAD.ADIntro        = "<%@LANGUAGE=\"VBSCRIPT\" CODEPAGE=\"936\"%><style type=\"text/css\">\n\r<!--\n\rbody,td,th {\n\r	font-size: 14px;\n\r}\n\r.style1 {font-size: 12px}\n\r.style2 {\n\r	color: #FF6633;\n\r	font-weight: bold;\n\r}\n\r-->\n\r</style>\n\r\n\r<table width=\"299\"  height=257 border=0 cellPadding=3 cellSpacing=1 bordercolor=\"#FF9900\" bgColor=#FF9933 >\n\r    <tr bgColor=#f7f7f7>\n\r      <td height=\"22\" colspan=\"3\" bgcolor=\"#FFFF99\">\n\r<div align=center class=\"style2\">食 品 安 全 投 诉  </div>\n\r      </td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td width=\"63\"  align=\"center\">\n\r      <div  align=center>受理单位</div></td>\n\r      <td width=\"72\">\n\r      <div  align=center>举报电话</div></td>\n\r      <td width=\"152\" height=\"18\"><div align=\"center\"><span >受 理 范 围</span></div></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"42\"><div align=\"center\"><span >区工商局</span></div></td>\n\r      <td>\n\r      <div align=center><span >12315</span></div></td>\n\r      <td height=\"40\"><span class=\"style1\" >超市、商场、集贸市场、农副产品批发市场、食品展销市场的食品质量问题。</span></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"42\"><div align=\"center\"><span >区药监局</span></div></td>\n\r      <td>      <div align=\"center\"><span >89357110</span></div>\n\r      </div></td>\n\r      <td height=\"40\"><span class=\"style1\" >宾馆、酒店、食堂、饮食摊点等餐饮场所的食品质量问题。</span></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"45\">\n\r      <div align=center><span>区质监局</span></div></td>\n\r      <td height=\"42\">\n\r      <div align=center><span >86921747</span></div></td>\n\r      <td height=\"40\"><span class=\"style1\" >非法加工食品的窝点、生产假冒伪劣食品的企业和个人。 </span></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"33\"><div align=\"center\"><span >区畜牧局</span></div></td>\n\r      <td><div align=\"center\"><span >86921526</span> </div></td>\n\r      <td height=\"40\"><span class=\"style1\" >畜禽场生产的农产品的食品安全问题。</span></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"15\" colspan=\"3\">&nbsp;</td>\n\r    </tr>\n\r</table>\n\r  <table width=\"299\"  height=236 border=0 cellPadding=3 cellSpacing=1 bordercolor=\"#FF9900\" bgColor=#FF9933 >\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"22\" bgcolor=\"#FFFF99\" colspan=\"2\">\n\r      <div  align=center class=\"style2\"><strong>药 品 投 诉</strong></div>      </td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td width=\"144\" height=\"44\"><div align=\"center\"><span >质量投诉（区药监局)</span> </div></td>\n\r      <td width=\"140\" height=\"44\"><div align=\"center\"><span >89357110</span></div></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"41\"><div align=\"center\"><span >广告投诉（区工商局)</span></div></td>\n\r      <td height=\"41\"><div align=\"center\"><span >12315</span> </div></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"40\">\n\r      <div  align=center><span >价格投诉（区物价局)</span></div>\n\r      <div  align=center></div></td>\n\r      <td height=\"40\"><div align=\"center\"><span >12358</span></div></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"41\"><div align=\"center\"><span >医疗投诉（区卫生局)</span></div></td>\n\r      <td height=\"41\"><div align=\"center\"><SPAN >86923958</SPAN></div></td>\n\r    </tr>\n\r    <tr bgColor=#ffffff>\n\r      <td height=\"41\"><div align=\"center\"><span >回扣投诉（区工商局)</span>\n\r        </div>\n\r      <div class=style52 align=center></div>        </td>\n\r      <td height=\"41\"><div class=style52 align=center></div>\n\r      <div align=\"center\"><SPAN >12315</SPAN></div></td>\n\r    </tr>\n\r</table>\n\r";
objAD.LinkUrl        = "";
objAD.LinkTarget     = 1;
objAD.LinkAlt        = "";
objAD.Priority       = 1;
objAD.CountView      = 1;
objAD.CountClick     = 0;
objAD.InstallDir     = "/";
objAD.ADDIR          = "AD";
ZoneAD_1.AddAD(objAD);

ZoneAD_1.Show();
