function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
var ADM_DIV = "ADAREA", ADM_LOADED = false;
var ADM_O1, ADM_O2, AD, ADM_Ver = "1.0", ADM_S = new Array();
var ADM_RESIZE = new Array(), ADM_F = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0";
var ADM_CE = document.all ? 1 : (document.getElementById ? 0 : -1);
document.write("<div id='" + ADM_DIV + "'></div>");

function InitSchedule() {
  ADM_S.sort(ADM_sort);
  for (iAI = 0; iAI < ADM_S.length; iAI++) {
	ADM_S[iAI].i = iAI;
  }
}

function ADM_sort(a, b) {
  return (a.p > b.p) ? 1 : ( (a.p == b.p) ? 0 : -1);
}

function ADM_Start(o) {
  if (eval("typeof(" + o.t + "_main)") == "function") {
	eval(o.t + "_main(o)");
  }
}

function DoSchedule() {
  var p = -1;
  for (dAI = 0; dAI < ADM_S.length; dAI++) {
	switch (ADM_S[dAI].s) {
	  case 0:
		if (p == -1) {
		  p = ADM_S[dAI].p;
		}
		if (p == ADM_S[dAI].p) {
		  ADM_S[dAI].s = 1;
		  ADM_Start(ADM_S[dAI]); /*开始调用对应的方法*/
		  break;
		}
	  case 1:
		setTimeout("DoSchedule()", 300);
		return;
	  default:
	}
  }
}

/*开始初始化*/
function ADM_PUSH() {
	if (!ADM_LOADED) {
	  ADM_LOADED = true;
	  InitSchedule();
	  DoSchedule();
	}
}
if (ADM_CE > -1) {
  addLoadEvent(ADM_PUSH);
  window.onresize = function() {
	for (oAI = 0; oAI < ADM_RESIZE.length; oAI++) {
	  eval(ADM_RESIZE[oAI]);
	}
  }
}

function WriteAd(id, s) {
  var o0 = document.getElementById(id);
  if (o0 == null) {
	o0 = document.createElement("div");
	o0.id = id;
	if (ADM_CE == 1) {
	  document.getElementById(ADM_DIV).insertAdjacentElement("beforeBegin",o0);
	}
	else {
	  document.getElementById(ADM_DIV).insertBefore(o0, null);
	}
  }
  o0.innerHTML = s;
}

function AddSchedule(oo) {
  if (oo != null && oo instanceof ADM) {
	ADM_S[ADM_S.length] = oo;
  }
}

/*构造函数，t：对象名称；p：显示顺序*/
function ADM(t, p) {
  this.t = t;
  this.p = p;
  this.s = 0;
  this.i = 0;
  if(t=="NORMAL" || t=="INBUILT"){
	this.style="position:static;";
  }else{
	this.style="position:absolute;";
  }
}

function ADM_Check(o) {
  var checkCookie = o.CookieHour && ADM_CheckCookie(o.t + o.p + location.host.substring(0, location.host.indexOf(".")),o);
  if(o.CookieHour == 0){checkCookie = false;}
  return checkCookie;
}

function ADM_CheckCookie(E, o) {
  var Now = new Date();
  var s = String(Now.getYear()) + String(Now.getMonth() + 1) + String(Now.getDate());
  if (ADM_GetCookie(E) == s) {
	return true;
  }
  else {
	Now.setTime(Now.getTime() + (parseFloat(typeof(o.CookieHour) == "undefined" ? 24 : parseFloat(o.CookieHour)) * 60 * 60 * 1000));
	ADM_SetCookie(E, s, Now);
	return false;
  }
}

function ADM_GetCookie(n) {
  var args = n + "=";
  var aLength = args.length, cLength = document.cookie.length, AAi = 0;
  while (AAi < cLength) {
	var AAj = AAi + aLength;
	if (document.cookie.substring(AAi, AAj) == args) {
	  return ADM_GetCookieVal(AAj);
	}
	AAi = document.cookie.indexOf(" ", AAi) + 1;
	if (AAi == 0) {
	  break;
	}
  }
  return null;
}

function ADM_GetCookieVal(offset) {
  var endstr = document.cookie.indexOf(";", offset);
  if (endstr == -1) {
	endstr = document.cookie.length;
  }
  return unescape(document.cookie.substring(offset, endstr));
}

function ADM_SetCookie(name, value) {
  var argv = ADM_SetCookie.arguments;
  var argc = ADM_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 ADM_Media(a, w, h, o, id, href, f) {
  var s = new Array();
  if (a.toLowerCase().indexOf(".swf") != -1) {
	 
	if (ADM_CE == 1) {
	  s.push("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='");
	  s.push(ADM_F + "' id='" + ( (id == null) ? o.t : id) + "' width='" + w + "' height='" + h + "' ");
	  if (o.style && !f) {
		s.push(" style='" + o.style + "'");
	  }
	  if (o.extfunc) {
		s.push(" " + o.extfunc + " ");
	  }
	  s.push(" ><param name='movie' value='" + a + "'>");
	  if (o.play) {
		s.push("<param name='play' value='" + o.play + "'>");
	  }
	  if (o.wmode && o.wmode != "") {
		s.push("<param name='wmode' value='" + o.wmode + "'>");
	  }
	  if (typeof(o.loop) != "undefined") {
		s.push("<param name='loop' value='" + o.loop + "'>");
	  }
	  s.push("<param name='quality' value='autohigh'></object>");
	}
	else {
	  s.push("<embed ");
	  if (o.style && !f) {
		s.push(" style='" + o.style + "'");
	  }
	  if (o.extfunc) {
		s.push(" " + o.extfunc + " ");
	  }
	  s.push(" src='" + a + "'" + " quality='autohigh' id='" +
		  ( (id == null) ? o.t : id) + "' name='" +
		  ( (id == null) ? o.t : id) + "' width='" + w + "' height='" + h + "' ");
	  if (o.wmode && o.wmode != "") {
		s.push(" wmode='" + o.wmode + "' ");
	  }
	  if (typeof(o.loop) != "undefined") {
		s.push(" loop='" + o.loop + "' ");
	  }
	  s.push("type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></embed>");
	}
  }
  else if (a.toLowerCase().indexOf(".gif") != -1 || a.toLowerCase().indexOf(".jpg") != -1) {
	 
	s.push("<a href='" + ( (href == null) ? o.href : href) + "' target='_blank'"+(o.href=='####'?' onclick=\'return false;\'':'')+"><img ");
	if (o.style && !f) {
	  s.push(" style='" + o.style + "'");
	}
	if (o.extfunc) {
	  s.push(" " + o.extfunc + " ");
	}
	s.push(" id='" + ( (id == null) ? o.t : id) + "' src='" + a + "' border='0' width='" + w + "' height='" + h + "'></a>");
  }
  //if(o.t=='FLOAT')
  	//alert(o.style);
  return s.join("");
}

function ADM_FSCommand(o, id) {
  /*alert(o.t+"__"+id);*/
  var s = new Array();
  if (ADM_CE == 1) {
	s.push("<Script language='Javascript' for='" + ( (id == null) ? o.t : id));
	s.push("' event='FSCommand(command,args)'>\n" + "");
	s.push(( (id == null) ? o.t : id) + "_DoFSCommand(command,args);\n" + "<\/Script>\n");
  }
  return s.join("");
}

function ADM_Close(o, n) {
  ADM_S[o].s = 2;
  var OBJ = document.getElementById(n);
  if (OBJ) {
	OBJ.style.display = "none";
  }
}

function FULL_main(o) {
  if (ADM_Check(o)) {
	o.s = 2;
	return;
  }
  var IS_Find = false;
  if (o.StartTime.length == o.EndTime.length && o.EndTime.length == o.src.length && o.src.length == o.href.length) {
	for (FAi = 0; FAi < o.src.length; FAi++) {
	  var ST = new Date(o.StartTime[FAi]);
	  var ET = new Date(o.EndTime[FAi]);
	  var NT = new Date();
	  if ( (ST <= ET) && (NT < ET) && (NT >= ST)) {
		var OBJ = document.getElementById("fullscreenad");
		if (OBJ != null) {
		  self.scroll(0, 0);
		  OBJ.style.display = "block";
		  o.style = "";
		  OBJ.innerHTML = ADM_Media(o.src[FAi], 760, 480, o, "", o.href[FAi]);
		  IS_Find = true;
		  setTimeout("ADM_Close(" + o.i + ",'fullscreenad')", isNaN(parseInt(o.timeout)) ? 7000 : parseInt(o.timeout));
		  return;
		}
		else {
		  o.s = 2;
		  return;
		}
	  }
	}
	if (!IS_Find) {
	  ADM_Close(o.i, "fullscreenad");
	}
  }
}

function POP_STRUCT(o) {
  o.s = 2;
  var WN = (o.name) ? o.name : "";
  var Wi = (o.superad) ? (screen.width - 9) :
	  (parseInt( (o.width) ? o.width : 350) - 4);
  var Wh = (o.superad) ? (screen.height - 56) :
	  (parseInt( (o.height) ? o.height : 250) - 4);
  var Wl = (o.t == "POPUP") ? ( (o.left) ? o.left : 0) : (screen.width + 10);
  var Wt = (o.t == "POPUP") ? ( (o.top) ? o.top : 0) : (screen.height + 10);
  var a = window.open("about:blank", "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=" + Wi + ",height=" + Wh + ",top=" + Wt + ",left=" + Wl);
  a.focus();
  return a;
}

function POP_WINDOW(o) {
  var SK = new Array();
  SK.push("<html><head><meta http-equiv='content-type' content='text/html; charset=gb2312'><title>");
 // SK.push((o.title) ? o.title : ( (o.superad) ? ("EHM.com 背投广告") : ("EHM.com " + o.t + " Ad")));
  SK.push("</title>");
  SK.push("\n<Script language='Javascript'>\n");
  if (o.t == "POPUP") {
	SK.push("function Load(){\n");
	if (ADM_CE == 1) {
	  SK.push("setTimeout('blur();',");
	}
	else {
	  SK.push("setTimeout('self.opener.focus()',");
	}
	SK.push(isNaN(parseInt(o.timeout)) ? 7000 : o.timeout);
	SK.push(");\n}\n");
  }
  SK.push("<\/Script>");
  SK.push("</head><body scroll=no style='margin:0;border:none'>");
  SK.push("<iframe id='iFrame' ");
  if (o.t == "POPUP") {
	SK.push(" onload='Load()' ");
  }
  SK.push(" marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no width=100% height=100% src='" + o.src + "'>wait</iframe>");
  SK.push("</body></html>");
  return SK.join("");
}

function POPUP_main(o) {
  if (ADM_Check(o)) {
	o.s = 2;
	return;
  }
  if (o.src && o.src != "") {
	var OK = POP_STRUCT(o);
	if (OK) {
	  OK.document.write(POP_WINDOW(o));
	}
  }
}

function POPUNDER_main(o) {
  if (ADM_Check(o)) {
	o.s = 2;
	return;
  }
  if (o.src && o.src != "") {
	var OK = POP_STRUCT(o);
	if (OK) {
	  if (ADM_CE == 1) {
		OK.blur();
	  }
	  else {
		OK.opener.focus();
	  }
	  OK.moveTo( ( (o.left) ? o.left : 0), ( (o.top) ? o.top : 0));
	  OK.document.write(POP_WINDOW(o));
	}
  }
}

function SUPERAD_main(o){
	o.superad = true;
	POPUNDER_main(o);
}

function MOVEFLOAT_main(o){
  o.style += "z-index:100;";
  if (!o.href) {
	o.href = "";
  }
  if (!o.href2) {
	o.href2 = "";
  }
  if (isNaN(parseInt(o.offsetX))) {
	o.offsetX = 30;
  }
  if (screen.width < 1024) {
	o.offsetX += 100;
  }
  if (isNaN(parseInt(o.offsetY))) {
	o.offsetY = 20;
  }
  var s = "";
  if (o.src && o.src != "") {
	s += ADM_Media(o.src, 80, 80, o, ADM_DIV + "move", o.href);
  }
  if (o.wmode2) {
	o.wmode = o.wmode2;
  }
  if (o.style2) {
	o.style += o.style2;
  }
  if (o.src2 && o.src2 != "") {
	s += ADM_Media(o.src2, 80, 80, o, ADM_DIV + "move2", o.href2);
  }
  if (s != "") {
	WriteAd(ADM_DIV + "MOVEFLOAT", s);
	var tmpADM_O1 = document.getElementById(ADM_DIV + "move");
	var tmpADM_O2 = document.getElementById(ADM_DIV + "move2");
	if (tmpADM_O1 != null) {
	  tmpADM_O1.style.top = parseInt( (parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - ((parseInt(o.offsetY) + 80)))) + "px";
	  tmpADM_O1.style.left = parseInt( (parseInt(document.body.scrollLeft) + o.offsetX)) + "px";
	}
	if (tmpADM_O2 != null) {
	  tmpADM_O2.style.top = parseInt( (parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - ((parseInt(o.offsetY) + 80)))) + "px";
	  tmpADM_O2.style.left = parseInt( (parseInt(document.body.scrollLeft) + parseInt(document.body.clientWidth) - 80 - o.offsetX)) + "px";
	}
  }
  o.s = 2;
}

function MOVEFLOAT_position(a, b) {
  if (ADM_CE == 1) {
	if (ADM_O1 != null) {
	  ADM_O1.style.top = parseInt( (parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - b)) + "px";
	  ADM_O1.style.left = parseInt( (parseInt(document.body.scrollLeft) + a)) + "px";
	}
	if (ADM_O2 != null) {
	  ADM_O2.style.top = parseInt( (parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - b)) + "px";
	  ADM_O2.style.left = parseInt( (parseInt(document.body.scrollLeft) + parseInt(document.body.clientWidth) - 80 - a)) + "px";
	}
  }
  else {
	if (ADM_O1 != null) {
	  ADM_O1.style.top = parseInt(0.75 * (parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - b)) + "pt";
	  ADM_O1.style.left = parseInt(0.75 * (parseInt(document.body.scrollLeft) + a)) + "pt";
	}
	if (ADM_O2 != null) {
	  ADM_O2.style.top = parseInt(0.75 * (parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - b)) + "pt";
	  ADM_O2.style.left = parseInt(0.75 * (parseInt(document.body.scrollLeft) + parseInt(document.body.clientWidth) - 80 - a)) + "pt";
	}
  }
}

function FLOAT_main(o) {
  var TrueHeight = 0,TrueHeightL = 0,TrueHeightR = 0;
  var HasBOOKTURN = false;
  for (CAI = 0; CAI < ADM_S.length; CAI++) {
	if (ADM_S[CAI].t == "BOOKTURN") {
	  HasBOOKTURN = true;
	  break;
	}
  }
  var HasCOUPLET = false;
  for (CAC = 0; CAC < ADM_S.length; CAC++) {
	if (ADM_S[CAC].t == "COUPLET") {
	  HasCOUPLET = true;
	  break;
	}
  }
  o.style += "z-index:24;";
  if (!o.leftHref) {
	o.leftHref = new Array("");
  }
  if (!o.rightHref) {
	o.rightHref = new Array("");
  }
  if (isNaN(parseInt(o.offsetX))) {
	o.offsetX = 30;
  }
  if (screen.width < 1024) {
	o.offsetX += 100;
  }
  if (isNaN(parseInt(o.offsetY))) {
	o.offsetY = (HasBOOKTURN && HasCOUPLET) ? 0 : 20;
  }
  if (!o.Width || isNaN(parseInt(o.Width))) {
	o.Width = new Array("80");
  }
  if (!o.Height || isNaN(parseInt(o.Height))) {
	o.Height = new Array("80");
  }
  if (!o.Timer) {
	o.Timer = 400;
  }
  if (o.Style) {
	o.style += o.Style;
  }
  //alert(o.style);
  var s = new Array();
  if (o.leftSrc && o.leftSrc.length > 0 && (o.leftSrc.length == o.leftHref.length)) {
	  s.push("<div id="+ADM_DIV+"left style=\""+o.style+"\">");
	  for(var i=0;i<o.leftSrc.length;i++){
		s.push("<div style=\"width:"+parseInt(o.Width[i])+"px;height:"+parseInt(o.Height[i])+"px;margin-top:10px;\">");
		s.push(ADM_Media(o.leftSrc[i], o.Width[i], o.Height[i], o, null, o.leftHref[i], true));
		s.push("</div>");
		TrueHeightL += parseInt(o.Height[i]);
	  }
	  s.push("</div>");
	  TrueHeightL += 24;
  }
  if (o.wmode2) {
	o.wmode = o.wmode2;
  }
  if (o.style2) {
	o.style += o.style2;
  }
  if (o.rightSrc && o.rightSrc.length > 0 && (o.rightSrc.length == o.rightHref.length)) {
	  s.push("<div id="+ADM_DIV + "right style=\""+o.style+"\">");
	  for(var i=0;i<o.rightSrc.length;i++){
		s.push("<div style=\"width:"+parseInt(o.Width[i])+"px;height:"+parseInt(o.Height[i])+"px;margin-top:10px;\">");
		s.push(ADM_Media(o.rightSrc[i], o.Width[i], o.Height[i], o, null, o.rightHref[i], true));
		s.push("</div>");
		TrueHeightR += parseInt(o.Height[i]);
	  }
	  s.push("</div>");
	  TrueHeightR += 24;
  }
  //alert(s);
  if (s) {
	WriteAd(ADM_DIV + "FLOAT", s.join(""));
	ADM_O1 = document.getElementById(ADM_DIV + "left");
	ADM_O2 = document.getElementById(ADM_DIV + "right");
	//alert(ADM_01.outerHTML)
    //document.getElementById("_tmpInner").value=ADM_O2.outerHTML;
	if (ADM_O1 != null || ADM_O2 != null) {
	  TrueHeight = TrueHeightL > 0 ? TrueHeightL : TrueHeightR > 0 ? TrueHeightR : 80;
	  TrueLeft = Sort(o.Width).shift() - 30;
	  window.setInterval("FLOAT_position(" + o.offsetX + "," + (parseInt(o.offsetY) + TrueHeight) + "," + TrueHeight + "," + TrueLeft + "," + o.FixPlace + ")", o.Timer);
	}
  }
  o.s = 2;
}

function FLOAT_position(a, b, h, l,f) {//alert(!f)
  if (ADM_CE == 1) {
	var tmp = parseInt( (parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - b));
	if (ADM_O1 != null) {
	  ADM_O1.style.top = tmp + "px";
	  if(!f)
		  ADM_O1.style.left = parseInt( (parseInt(document.body.scrollLeft) + a)) + "px";
	}
	if (ADM_O2 != null) {
	  ADM_O2.style.top = tmp + "px";
	  if(!f)
		  ADM_O2.style.left = parseInt( (parseInt(document.body.scrollLeft) + parseInt(document.body.clientWidth) - l - a)) + "px";
	  //alert(ADM_O2.style.top);
	}
  }
  else {
	var tmp = parseInt(0.75 * (parseInt(document.body.scrollTop) + parseInt(document.body.clientHeight) - b));
	if (ADM_O1 != null) {
	  ADM_O1.style.top = tmp + "pt";
	  if(!f)
		  ADM_O1.style.left = parseInt(0.75 * (parseInt(document.body.scrollLeft) + a)) + "pt";
	}
	if (ADM_O2 != null) {
	  ADM_O2.style.top = tmp + "pt";
	  if(!f)
		  ADM_O2.style.left = parseInt(0.75 * (parseInt(document.body.scrollLeft) + parseInt(document.body.clientWidth) - h - a)) + "pt";
	}
  }
}

function Sort(a){
	for(var i=0;i<a.length;i++){
		for(var j=i;j<a.length;j++){
			if(parseInt(a[i])<parseInt(a[j])){
				var tmp=a[i];
				a[i]=a[j];
				a[j]=tmp;
			}
		}
	}
return a;
}

function LIUMEITI_main(o) {
  if (ADM_Check(o)) {
	o.s = 2;
	if (typeof(LIUMEITI_CALL) == "function") {
	  LIUMEITI_CALL();
	}
	return;
  }
  if (!o.width) {
	o.width = 200;
  }
  if (!o.height) {
	o.height = 150;
  }
  if (!o.top) {
	o.top = "0";
  }
  if (!o.left) {
	o.left = "-0";
  }
  if (o.src && o.src != "") {
	o.style += "top:" + (parseInt(document.body.scrollTop) + ( (String(o.top).indexOf("-") == -1) ? parseInt(o.top) : (parseInt(document.body.clientHeight) + parseInt(o.top) - o.height)));
	o.style += ";left:" + ( (String(o.left).indexOf("-") == -1) ? parseInt(o.left) : (parseInt(document.body.clientWidth) - o.width + parseInt(o.left)));
	ADM_RESIZE[ADM_RESIZE.length] = "document.getElementById('" + ADM_DIV + "lmt').style.left=(('" + o.left + "'.indexOf('-')==-1)?" + o.left + ":(parseInt(document.body.clientWidth)-" + (o.width + parseInt(o.left)) + "))";
	WriteAd(ADM_DIV + "LIUMEITI", ADM_Media(o.src, o.width, o.height, o, ADM_DIV + "lmt"));
	if (o.eval && o.eval != "") {
	  eval(o.eval);
	}
	setTimeout("ADM_Close(" + o.i + ",'" + ADM_DIV + "lmt')", isNaN(parseInt(o.timeout)) ? 7000 : parseInt(o.timeout));
  }
}

/*Outside Advert Begin======================================================================*/
/*增加的方法，遮罩广告*/
var timer = null;
var timer2 = null;

function ADAREAout_DoFSCommand(commands, args) {
  try{
	document.getElementById(ADM_DIV + "out").style.display = 'none';
  }catch(e){
	  //alert(e.message);
	document.getElementById(ADM_DIV + "out").style.display = 'none';
  }
  for (_i = 0; _i < ADM_S.length; _i++) {
    if (ADM_S[_i].t == 'OUTSIDE') {
	  ADM_S[_i].s = 2;
	  break;
    }
  }
}

function OUTSIDE_CALL() {
  try{
    document.getElementById(ADM_DIV + "out").style.display = "block";
  }catch(e){}
  if (timer != null) {
	clearTimeout(timer);
  }
  if (timer2 != null) {
	clearTimeout(timer2);
  }
}

function OUT_Hidden() {
  ADAREAout_DoFSCommand(event,event);
}

function OUT_PerHidden() {
  if (timer != null) {
	clearTimeout(timer);
  }
  timer = setTimeout("OUT_Hidden()", isNaN(parseInt(o.timeout)) ? 7000 : parseInt(o.timeout));
}

function OUTSIDE_main(o) {
  var tmpLeft;
  if (!o.width) {
	o.width = 760;
  }
  if (!o.height) {
	o.height = 400;
  }
  if (!o.top) {
	o.top = 150;
  }
  if (!o.left) {
	o.left = parseInt(document.body.scrollLeft) + (parseInt(document.body.scrollWidth)-650)/2 - 56;
  }
  if (o.src && o.src != "") {
	o.style += "z-index:1000;position:absolute";
    o.style += ";top:" +
  	  (parseInt(document.body.scrollTop) +
  	  ( (String(o.top).indexOf("-") == -1) ? parseInt(o.top) :
 	  (parseInt(document.body.clientHeight) + parseInt(o.top) - o.height))) + "px";
    o.style += ";left:" +
      ( (String(o.left).indexOf("-") == -1) ? parseInt(o.left) :
      (parseInt(document.body.clientWidth) - o.width + parseInt(o.left))) + "px";
    if (ADM_Check(o)) {
	  o.s = 2;
	  if (typeof(OUTSIDE_CALL) == "function") {
	    OUTSIDE_CALL();
	  }
	  o.style += ";display:none;";
	  WriteAd(ADM_DIV + "OUTSIDE",ADM_Media(o.src, o.width, o.height, o, ADM_DIV + "out") + ADM_FSCommand(o, ADM_DIV + "out"));
	  return;
    }
	WriteAd(ADM_DIV + "OUTSIDE",ADM_Media(o.src, o.width, o.height, o, ADM_DIV + "out") + ADM_FSCommand(o, ADM_DIV + "out"));
	timer2 = setTimeout("OUT_Hidden()",isNaN(parseInt(o.timeout)) ? 7000 : parseInt(o.timeout));
  }
}
/*Outside Advert End======================================================================*/

/*Normal Advert Begin======================================================================*/
var AdNormalC = 0;/*普通广告计数*/
function NORMAL_main(o){
  //alert(ANPC.length);
  var sid,place,cid,name;
  if (!o.width) {
    o.width = "100%";
  }
  if (!o.height) {
    o.height = 50;
  }
  if (!o.AdPlace) {
	o.AdPlace = 924;  
  }
  //o.style += "margin-top:5px;margin-bottom:5px;";
  if (o.wait == true){/*如果广告位闲置状态则显示招租信息*/
    sid = (o.sid) ? o.sid : 0;
    place = (o.place) ? o.place : "";
    cid = (o.cid) ? o.cid : 0;
    name = (o.name) ? o.name : "";
    if (!o.src || o.src == "") {
      o.src = "/Advert/advertReg.jsp";
    }
    WriteNormalAd(ADM_DIV + "_normal_" + o.AdPlace + AdNormalC,o.width,o.height,o.wait,o.AdPlace,sid,place,cid,name,ADM_Media(o.src, o.width, o.height, o, ADM_DIV + "normal"));
  }else{
    WriteNormalAd(ADM_DIV + "_normal_" + o.AdPlace + AdNormalC,o.width,o.height,o.wait,o.AdPlace,sid,place,cid,name,ADM_Media(o.src, o.width, o.height, o, ADM_DIV + "normal"));
  }
  o.s = 2;
}

function WriteNormalAd(id,w,h,wt,pid,sid,place,cid,name,s) {
  var nmObj = document.getElementById("AdNormal_" + pid + "_" + AdNormalC);
  if(!nmObj) return;
  var tmpName = (name) ? "（"+name+"）" : "";
  /*if(name) { name = "（"+name+"）";}*/
  if(!wt || wt == false){
	  if (nmObj != null) {
		if (s && s != "") {
			nmObj.innerHTML = s;
		} else {
			wt = true;
		}
	  }
  }else if(wt == true){
		var tmpS = new Array();
		tmpS.push("<table width=" + w + " height=" + h + " border=1 cellpadding=0 cellspacing=0 bordercolor=\"#D0E3FF\">");
		tmpS.push("<form name=\"AdNormalFrm" + AdNormalC + "\" action=\"/Advert/advertReg.jsp\" method=\"post\" target=\"_blank\">");
		tmpS.push("<tr><td align=\"center\" style=\"font-size:24px;color:#003399;\">");
		tmpS.push("<a href=\"javascript:WaitingAdvert(AdNormalFrm" + AdNormalC + ");\">广告招租"+tmpName+"</a>");
		tmpS.push("</td></tr>");
		tmpS.push("<input type=hidden name=\"sid\" value=\""+sid+"\">");
		tmpS.push("<input type=hidden name=\"place\" value=\""+place+"\">");
		tmpS.push("<input type=hidden name=\"cid\" value=\""+cid+"\">");
		tmpS.push("<input type=hidden name=\"name\" value=\""+name+"\">");
		tmpS.push("</form>");
		tmpS.push("</table>");
		nmObj.innerHTML = tmpS.join("");
  }
  //每个广告位只能显示一个广告
  //AdNormalC = AdNormalC + 1; 
}
/*Normal Advert End======================================================================*/

/*Inbuilt Advert Begin======================================================================*/
var AdInbuiltC = 0;/*嵌入式广告计数*/
function INBUILT_main(o){
  var sid,place,cid,name;
  if (!o.width) {
    o.width = 350;
  }
  if (!o.height) {
    o.height = 250;
  }
  //o.style += "margin-top:4px;margin-bottom:4px;";
  if (o.wait == true){/*如果广告位闲置状态则显示招租信息*/
    sid = (o.sid) ? o.sid : 0;
    place = (o.place) ? o.place : "";
    cid = (o.cid) ? o.cid : 0;
    name = (o.name) ? o.name : "";
    if (!o.src || o.src == "") {
      o.src = "/Advert/advertReg.jsp";
    }
    WriteInbuiltAd(ADM_DIV + "Inbuilt" + AdInbuiltC,o.width,o.height,o.wait,sid,place,cid,name,ADM_Media(o.src, o.width, o.height, o, ADM_DIV + "Inbuilt"));
  }else{
    WriteInbuiltAd(ADM_DIV + "Inbuilt" + AdInbuiltC,o.width,o.height,o.wait,sid,place,cid,name,ADM_Media(o.src, o.width, o.height, o, ADM_DIV + "Inbuilt"));
  }
  o.s = 2;
}

function WriteInbuiltAd(id,w,h,wt,sid,place,cid,name,s) {
  var nmObj = document.getElementById("AdInbuilt" + AdInbuiltC);
  var tmpName = (name) ? "（"+name+"）" : "";
  /*if(name) { name = "（"+name+"）";}*/
  if(!wt || wt == false){
	  if (nmObj != null) {
		if (s && s != "") {
			var tmp = "";
			tmp += "<table border=0 cellspacing=4 cellpadding=0>";
			tmp += "  <tr>";
			tmp += "    <td>" + s + "</td>";
			tmp += "  </tr>";
			tmp += "</table>";
			nmObj.innerHTML = tmp;
		} else {
			wt = true;
		}
	  }
  }else if(wt == true){
		var tmpS = "";
		tmpS += "<table width=" + w + " height=" + h + " border=1 cellpadding=0 cellspacing=0 bordercolor=\"#D0E3FF\" style=\"margin:4px;\">";
		tmpS += "<form name=\"AdInbuiltFrm" + AdInbuiltC + "\" action=\"/Advert/advertReg.jsp\" method=\"post\" target=\"_blank\">";
		tmpS += "<tr><td align=\"center\" style=\"line-height:24px;font-size:24px;color:#003399;\">";
		tmpS += "<a href=\"javascript:WaitingAdvert(AdInbuiltFrm" + AdInbuiltC + ");\">广告招租"+tmpName+"</a>";
		tmpS += "</td></tr>";
		tmpS += "<input type=hidden name=\"sid\" value=\""+sid+"\">";
		tmpS += "<input type=hidden name=\"place\" value=\""+place+"\">";
		tmpS += "<input type=hidden name=\"cid\" value=\""+cid+"\">";
		tmpS += "<input type=hidden name=\"name\" value=\""+name+"\">";
		tmpS += "</form>";
		tmpS += "</table>";
		nmObj.innerHTML = tmpS;
  }
  AdInbuiltC = AdInbuiltC + 1; 
}
/*Inbuilt Advert End======================================================================*/

function WaitingAdvert(frm){
	if(frm){
		try{
			frm.submit();
		}catch(e){
			document.forms[frm].submit();
		}
	}
}

function BOOKTURN_main(o) {
  self.scroll(0, 0);
  if (!o.top) {
	o.top = "0";
  }
  if (!o.left) {
	o.left = "-0";
  }
  if (!o.loop) {
	o.loop = false;
  }
  if (!o.loop2) {
	o.loop2 = true;
  }
  if (!o.CookieHour) {
	o.CookieHour = 1;
  }
  if (o.src && o.srcButton) {
	var show = (ADM_Check(o));
	o.style += "z-index:10000;";
	if (show) {
	  o.style += "visibility:hidden;display:none;";
	}
	o.style += "top:" +
		(parseInt(document.body.scrollTop) +
		 (String(o.top).indexOf("-") == -1) ? parseInt(o.top) :
		 (parseInt(document.body.clientHeight) + parseInt(o.top) - 250));
	o.style += ";left:" +
		( (String(o.left).indexOf("-") == -1) ? parseInt(o.left) :
		 (parseInt(document.body.clientWidth) - 350 + parseInt(o.left)));
	var s1 = ADM_Media(o.src, 350, 250, o, ADM_DIV + "book1");
	o.wmode = (o.wmode2) ? o.wmode2 : "";
	o.style = o.style.substring(0, o.style.lastIndexOf("z-index:10000;"));
	if (!show) {
	  o.style += "visibility:hidden;display:none;";
	}
	o.style += "z-index:11;";
	o.style += "top:" +
		(parseInt(document.body.scrollTop) +
		 (String(o.top).indexOf("-") == -1) ? parseInt(o.top) :
		 (parseInt(document.body.clientHeight) + parseInt(o.top) - 250));
	o.style += ";left:" +
		( (String(o.left).indexOf("-") == -1) ? parseInt(o.left) :
		 (parseInt(document.body.clientWidth) - 80 + parseInt(o.left)));
	s1 += ADM_Media(o.srcButton, 80, 80, o, ADM_DIV + "book2");
	ADM_RESIZE[ADM_RESIZE.length] = "document.getElementById('" + ADM_DIV +
		"book1').style.left=(('" + o.left + "'.indexOf('-')==-1)?" + o.left +
		":(parseInt(document.body.clientWidth)-" + (350 + parseInt(o.left)) +
		"))";
	ADM_RESIZE[ADM_RESIZE.length] = "document.getElementById('" + ADM_DIV +
		"book2').style.left=(('" + o.left + "'.indexOf('-')==-1)?" + o.left +
		":(parseInt(document.body.clientWidth)-"
		+ (80 + parseInt(o.left)) + "))";
	s1 += ADM_FSCommand(o, ADM_DIV + "book1");
	s1 += ADM_FSCommand(o, ADM_DIV + "book2");
	WriteAd(ADM_DIV + "book", s1);
	document.getElementById(ADM_DIV).i = o.i;
	if (show) {
	  o.s = 2;
	}
  }
  else {
	o.s = 2;
  }
}

function ADAREAbook1_DoFSCommand(commands, args) {
  ADM_S[document.getElementById(ADM_DIV).i].s = 2;
  try{
    document.getElementById(ADM_DIV + "book1").style.visibility = 'hidden ';
	document.getElementById(ADM_DIV + "book1").style.display = 'none';
  }catch(e){
	document.getElementById(ADM_DIV + "book1").style.display = 'none';
  }
  var OBJ = document.getElementById(ADM_DIV + "book2");
  try{
    OBJ.style.visibility = 'visible';
    OBJ.style.display = 'block'; 
  }catch(e){
    OBJ.style.display = 'block'; 
    OBJ.style.visibility = 'visible';
  }
}

function ADAREAbook2_DoFSCommand(commands, args) {
  try{
    document.getElementById(ADM_DIV + "book2").style.visibility = 'hidden ';
	document.getElementById(ADM_DIV + "book2").style.display = 'none';
  }catch(e){
	document.getElementById(ADM_DIV + "book2").style.display = 'none';
  }
  var OBJ = document.getElementById(ADM_DIV + "book1");
  try{
    OBJ.style.visibility = 'visible';
    OBJ.style.display = 'block'; 
  }catch(e){
    OBJ.style.display = 'block'; 
    OBJ.style.visibility = 'visible';
  }
  try{OBJ.Play();}catch(e){}
}

function COUPLET_main(o) {
  if ( ( (ADM_CE == 1) && (screen.width < 1000)) ||
	  ( (ADM_CE == 0) && (document.body.scrollWidth < 1000))) {
	o.s = 2;
	return;
  }
  var HasBOOKTURN = false;
  for (CAI = 0; CAI < ADM_S.length; CAI++) {
	if (ADM_S[CAI].t == "BOOKTURN") {
	  HasBOOKTURN = true;
	  break;
	}
  }
  if (ADM_Check(o)) {
	o.s = 2;
	return;
  }
  if (!o.offsetX) {
	o.offsetX = 0;
  }
  if (!o.offsetY) {
	o.offsetY = (HasBOOKTURN) ? 250 : 100;
  }
  if (o.src || o.src2) {
	if (!o.src) {
	  o.src = o.src2;
	}
	if (!o.wmode) {
	  o.wmode = "opaque";
	}
	if (!o.src2) {
	  o.src2 = o.src;
	}
	var UseCache = (o.src.toLowerCase() == o.src2.toLowerCase());/*如果两边相同*/
	o.style += "top:" + o.offsetY;
	o.style += ";left:" + (parseInt(document.body.scrollLeft) + o.offsetX);
	var s1 = new Array();
	s1.push(ADM_Media(o.src, 120, 270, o, ADM_DIV + "Couplet1"));
	o.style = o.style.substring(0, o.style.lastIndexOf("left:"));
	o.style += "left:" + ( (parseInt(document.body.scrollLeft) +  parseInt(document.body.clientWidth) - 120 - o.offsetX));
	if (!UseCache) {
	  if (o.wmode2) { o.wmode = o.wmode2; }
	  if(!o.href2) { o.href2 = o.href; }
	  s1.push(ADM_Media(o.src2, 120, 270, o, ADM_DIV + "Couplet2",o.href2));
	  s1.push(ADM_FSCommand(o, ADM_DIV + "Couplet2"));
	  ADM_RESIZE[ADM_RESIZE.length] = "document.getElementById('" + ADM_DIV + "Couplet2').style.left=parseInt(document.body.scrollLeft)+parseInt(document.body.clientWidth)-" +
		  (120 + o.offsetX);
	}
	else {
	  s1.push("<div id='" + ADM_DIV + "CoupletCache' style='display:none'>" + o.i + "</div>");
	}
	s1.push(ADM_FSCommand(o, ADM_DIV + "Couplet1"));
	if (ADM_CE == 1 && UseCache) {
	  s1.push("\n<Script language='javascript' for='" + ADM_DIV + "Couplet1' event='OnReadyStateChange(a)'>\n");
	  s1.push("" + ADM_DIV + "Couplet1_Cache(a);\n");
	  s1.push("<\/Script>");
	}
	WriteAd(ADM_DIV + "Couplet", s1.join(""));
	var percentloaded = false;
	try{
		if(document.getElementById(ADM_DIV + "Couplet1").tagName == "IMG"){
			percentloaded = true;
		}else{
			percentloaded = (document.getElementById(ADM_DIV + "Couplet1").PercentLoaded() == 100);
		}
	}catch(e){}
	if (ADM_CE == 1 && UseCache && percentloaded) {
	  ADAREACouplet1_Cache(4);
	}
	else if (ADM_CE == 0 && UseCache) {
	  ADAREACouplet1_Check();
	}
	if (o.timeout) {
	  setTimeout("ADAREACouplet1_DoFSCommand()", o.timeout);
	}
  }
  o.s = 2;
}

function ADAREACouplet1_Check() {
  if (document.getElementById(ADM_DIV + "Couplet1").PercentLoaded() == 100) {
	ADAREACouplet1_Cache(4);
	return;
  }
  setTimeout("ADAREACouplet1_Check()", 100);
}

function ADAREACouplet1_Cache(a) {
  if (a == 4) {
	var OBJ = document.getElementById(ADM_DIV + "CoupletCache");
	var o = ADM_S[parseInt(OBJ.innerHTML)];
	OBJ.innerHTML = ADM_Media(o.src, 120, 270, o, ADM_DIV + "Couplet2") +
		ADM_FSCommand(o, ADM_DIV + "Couplet2");
	OBJ.style.display = "block";
	ADM_RESIZE[ADM_RESIZE.length] = "document.getElementById('" + ADM_DIV + "Couplet2').style.left=parseInt(document.body.scrollLeft)+parseInt(document.body.clientWidth)-" +
		(120 + o.offsetX);
  }
}

function ADAREACouplet1_DoFSCommand(commands, args) {
  try{
    document.getElementById(ADM_DIV + "Couplet1").style.visibility = 'hidden ';
	document.getElementById(ADM_DIV + "Couplet1").style.display = 'none';
    document.getElementById(ADM_DIV + "Couplet2").style.visibility = 'hidden ';
	document.getElementById(ADM_DIV + "Couplet2").style.display = 'none';
  }catch(e){
	document.getElementById(ADM_DIV + "Couplet1").style.display = 'none';
	document.getElementById(ADM_DIV + "Couplet2").style.display = 'none';
  }
}

function ADAREACouplet2_DoFSCommand(commands, args) {
  ADAREACouplet1_DoFSCommand(commands, args);
}

function VIDEO_main(o) {
  if (ADM_CE != 1 || (ADM_Check(o))) {
	o.s = 2;
	return;
  }
  if (!o.codebase) {
	o.codebase = "/Advert/AdvertFiles/mcadplayer.cab";
  }
  if (!o.adpicurl) {
	o.adpicurl = "/Advert/AdvertFiles/back.jpg";
  }
  if (!o.title) {
	o.title = "SUPERCAST";
  }
  if (!o.cx) {
	o.cx = 350;
  }
  if (!o.cy) {
	o.cy = 280;
  }
  if (!o.popx) {
	o.popx = screen.width - o.cx + 1;
  }
  if (!o.popy) {
	o.popy = screen.height - o.cy - 25;
  }
  if (!o.billserver) {
	o.billserver = "61.135.145.33";
  }
  if (!o.loop) {
	o.loop = -1;
  }
  if (!o.soundtime) {
	o.soundtime = 1;
  }
  if (!o.mode) {
	o.mode = 1;
  }
  if (!o.buttonmode) {
	o.buttonmode = 2;
  }
  if (!o.slidemode) {
	o.slidemode = 2;
  }
  if (!o.timeout) {
	o.timeout = 7000;
  }
  if (!o.playcount) {
	o.playcount = 2;
  }
  if (!o.wmppopx) {
	o.wmppopx = screen.width - 350;
  }
  if (!o.hideafterplayover) {
	o.hideafterplayover = 0;
  }
  if (!o.wmppopy) {
	o.wmppopy = screen.height;
  }
  if (!o.popuphtmurl) {
	o.popuphtmurl = "/Advert/AdvertFiles/SUPERCAST.htm";
  }
  if (o.divxadurl && o.divxadurl != "") {
	if (ADM_GetCookie("VIDEO") != null) {
	  VIDEO_media(o.i);
	}
	else {
	  VIDEO_code(o);
	}
  }
  o.s = 2;
}

function VIDEO_code(o) {
  var s = "<OBJECT classid='clsid:2D0C7226-747E-11D6-83F0-00E04C4A2F90' codebase='" +
	  o.codebase + "' onerror='VIDEO_media(" + o.i +
	  ")' style='width:0px;height:0px'><param name='adurl' value='" +
	  o.divxadurl + "'><param name='adpicurl' value='" + o.adpicurl +
	  "'><param name='clickurl' value='" + o.adclickurl +
	  "'><param name='cx' value='" + o.cx + "'><param name='cy' value='" +
	  o.cy + "'><param name='popx' value='" + o.popx + "'>";
  s += "<param name='popy' value='" + o.popy +
	  "'><param name='billserver' value='" + o.billserver +
	  "'><param name='loop' value='" + o.loop +
	  "'><param name='soundtime' value='" + o.soundtime +
	  "'><param name='mode' value='" + o.mode +
	  "'><param name='buttonmode' value='" + o.buttonmode +
	  "'><param name='hideafterplayover' value='" + o.hideafterplayover +
	  "'><param name='windowtitle' value='" + o.title +
	  "'><param name='SlideMode' value='" + o.slidemode + "'></OBJECT>";
  WriteAd(ADM_DIV + "Video", s);
}

function VIDEO_media(o) {
  if (ADM_GetCookie("VIDEO") == null) {
	var Now = new Date();
	Now.setTime(Now.getTime() + (o.plugindelay ? parseFloat(o.plugindelay) * 60 * 60 * 1000 : 7 * 24 * 60 * 60 * 1000));
	ADM_SetCookie("VIDEO", "videodelay", Now);
  }
  o = ADM_S[o];
  if (o.wmvadurl && o.wmvadurl != "") {
	var s = o.popuphtmurl + "?OpenerName=" + window.location + "&wmvadurl=" +
		o.wmvadurl + "&adpicurl=" + o.adpicurl + "&adclickurl=" +
		o.adclickurl + "&timeout=" + o.timeout + "&soundtime=" +
		o.soundtime + "&playcount=" + o.playcount + "&windowtitle=" +
		o.title;
	if (o.download) {
	  s += "&download=" + o.download + "&";
	}
	var a = window.open(s, "", "left=" + o.wmppopx + ",top=" + o.wmppopy + ", width=350, height=250");
	a.focus();
  }
}

function IMVIDEO_main(o) {
  if ( (ADM_Check(o))) {
	o.s = 2;
	return;
  }
  if (!o.IMWidth) {
	o.IMWidth = 350;
  }
  if (!o.IMHeight) {
	o.IMHeight = 250;
  }
  if (!o.Str) {
	o.Str = "IM";
  }
  if (o.VideoID > 0) {
	var width = o.IMWidth;
	var height = o.IMHeight + 26;
	var left = screen.availWidth - width - 10;
	var top = screen.availHeight;
	var popUrl = "http://im.imchina.com.cn/client/client.aspx?id=" +
		o.VideoID + "&url=" + "http://im.imchina.com.cn/cgi-bin/adgate.cgi" +
		"&width=" + o.IMWidth + "&height=" + o.IMHeight;
	var params = "left=" + left + ",top=" + top + ",width=" + width +
		",height=" + height + ",scrollbars=0,resizable=0,toolbar=0,location=0,menubar=0,status=0,directories=0,dependent=0,titlebar=0";
	var winid = o.Str + o.VideoID;
	var a = window.open(popUrl, winid, params);
	a.focus();
  }
  o.s = 2;
}
setTimeout("ADM_PUSH()", 4000);
