﻿Date.prototype.dateDiff = function(interval,objDate){
if(arguments.length<2||objDate.constructor!=Date) return undefined;
    switch (interval) {
      case "s":return parseInt((objDate-this)/1000);
      case "n":return parseInt((objDate-this)/60000);
      case "h":return parseInt((objDate-this)/3600000);
      case "d":return parseInt((objDate-this)/86400000);
      case "w":return parseInt((objDate-this)/(86400000*7));
      case "m":return (objDate.getMonth()+1)+((objDate.getFullYear()-this.getFullYear())*12)-(this.getMonth()+1);
      case "y":return objDate.getFullYear()-this.getFullYear();
      default:return undefined;
    }
  }


var gj = 0, MyliAutoPage;
var rtimeout, adArray = new Array();

function showFile3(f, c, e, w, h, t, rd, cd)
{
	var ts = "<div style=\"background-color: #ededed; border: 0px;table-layout: fixed;word-wrap: break-word;overflow: hidden; width: " + w + "px; height: " + h + "px;  \">";
	//var ts = "";
	ts += "";
	if (t!=""){
		ts += "<div id=\"_bedingEvent$$$" + rd + "\" style=\"position: absolute;\" MyliOnClickHref=\"" +  rd+ "\" MyliStatusOverString=\"" + c + "\" MyliStatusOutString=\"\"><a href=\"" + t + "\" target=\"_blank\"><img alt=\"" + c + "\" src=\"http://are.0715es.com/t.gif\" style=\"border: 0px; width: " + w + "px; height: " + h + "px;\"></a>";
	}else{
		ts += "<div style=\"position: absolute;\"><img alt=\"" + c + "\" src=\"http://are.0715es.com/t.gif\" style=\"border: 0px; width:  "+ w + "px; height: " + h + "px;\">";
	}
	ts += "</div>";
	if (e=="gif" || e=="jpg" || e=="png" || e=="bmp")
	{
		ts += "<img src=\"" + f + "\" style=\"border: 0px; width: " + w + "px; height: " + h + "px;\" \/>";
	}
	else if (e=="swf")
	{
		ts += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"   codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" name=\"Flash1\" width=\"" + w + "\" height=\"" + h + "\" id=\"Flash1\" border=\"1\"><param name=\"movie\" value=\"" + f + "\"><param name=\"quality\" value=\"high\"><param name=\"wmode\" value=\"Opaque\"><embed src=\"" + f + "\" width=\"" + w + "\" height=\"" + h + "\" wmode=\"Opaque\" quality=\"high\"  pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" name=\"Flash1\"></embed></object>";
	}

	ts += "</div>";

	//document.write(ts);
	//alert(cd);

	var SA = document.getElementById("ShowAdsArea$$$" + cd);
		SA.style.display = "block";
		SA.style.width   = w;
		SA.style.height  = h;
		//alert(cd);
		SA.innerHTML     = ts;

	var tg = document.getElementById("XNIE_ADVERTISE_FRAME_" + rd);
		tg.src = "http://are.0715es.com/Show.Asp?Action=ShowNum&Id=" + rd;
	
	var bE = document.getElementById("_bedingEvent$$$" + rd);
		if (bE!=null){
			bE.onclick     = Function("clickEvent(this, 'MyliOnClickHref');");
			bE.onfocus     = Function("ss(this, 'MyliStatusOverString');");
			bE.onmouseover = Function("return ss(this, 'MyliStatusOverString');");
			bE.onmouseout  = Function("cs(this, 'MyliStatusOutString');");
		}
	


}


function ss(obj, gAb) {
	var txt = obj.getAttribute(gAb).toString();
	window.status = "[广告]键连至 " + txt;
	return true;
}

function cs(){
	window.status = "";
}

function ShowAds(AdId)
{

	try {
		adArray = eval("adArray_" + AdId);
	}
	catch (e){
		return ;
	}

	for (var i=0;i<adArray.length;i++)
	{
		var f, c, e, w, h, t, at, ht, mht, sw, msw, sd, ed, cd;
		c   = adArray[i][0];
		t   = adArray[i][1];
		e   = adArray[i][2];
		f   = adArray[i][3];
		w   = adArray[i][4];
		h   = adArray[i][5];
		at  = parseInt(adArray[i][6]);
		ht  = parseInt(adArray[i][7]);
		mht = parseInt(adArray[i][8]);
		sw  = parseInt(adArray[i][9]);
		msw = parseInt(adArray[i][10]);
		sd  = new Date(adArray[i][11]);
		ed  = new Date(adArray[i][12]);
		rd  = parseInt(adArray[i][13]);
		cd  = parseInt(adArray[i][15]);
		//alert((ed.getTime()-sd.getTime())/3600/1000/24);
		//alert(sd.dateDiff("d",ed));
		//alert(sd);

		if (at==1)
		{
			if (sw<msw)
			{
				showFile3(f, c, e, w, h, t, rd, cd);
				break;
			}
		}
		else if (at==2)
		{
			if (ht<mht)
			{
				showFile3(f, c, e, w, h, t, rd, cd);
				break;
			}
		}
		else if (at==3)
		{

			var SA = document.getElementById("ShowAdsArea$$$" + cd);
			var Ri = eval("rtimeout_" + AdId);
			if (SA!=null){
				SA.onmouseover = Function("window.clearTimeout(MyliAutoPage);");
				SA.onmouseout  = Function("MyliAutoPage = window.setTimeout(\"ShowAds(" + AdId + ")\", " + eval("rtimeout_" + AdId) + ");");
			}

			if (gj==adArray.length) {
				window.clearTimeout(MyliAutoPage);
				gj = 0;
				MyliAutoPage = window.setTimeout("ShowAds(" + AdId + ")", Ri);
			}
			if (i==gj)
			{
				showFile3(f, c, e, w, h, t, rd, cd);
				if (typeof(MyliAutoPage)=="number") {
					window.clearTimeout(MyliAutoPage);
				}
				MyliAutoPage = window.setTimeout("ShowAds(" + AdId + ")", Ri);
				
				gj++;
				break;
			}

		}
		else
		{
			if (sd.dateDiff("d",ed)>0)
			{
				showFile3(f, c, e, w, h, t, rd, cd);
				break;
			}

		}

	}
}

function clickEvent(obj, gAb){
	var id = parseInt(obj.getAttribute(gAb));
	var tg = document.getElementById("XNIE_ADVERTISE_FRAME_" + id);
	tg.src = "http://are.0715es.com/ClickEvent.Asp?Id=" + id;
}
