
var a2c = "";
var newscripts = "";
if (typeof(adInfoJS) != "undefined"){
	if (adInfoJS.length > 0){
		if (typeof(arrAdInfo) != "undefined"){
			if (arrAdInfo.length > 0){
				for (var x = 0; x < arrAdInfo.length; x++){
					outputAd(arrAdInfo[x]);
				}
				if (newscripts.length > 0){
					document.write(newscripts);
				}
				if (a2c.length > 0){
					var d = new Date();
					document.write("<scr" + "ipt type=\"text/jav" + "ascr" + "ipt\" language=\"jav" + "ascr" + "ipt\" src=\"" + adsStatURL + "/ad/stats/?l=" + a2c + "&t=" + d.getTime() + "\"></sc" + "ript>");
				}
			}
		}
	}
}
function add2(a){
	if (typeof(a) != "undefined" && typeof(a2c) != "undefined"){
		if (a.length > 0){
			if (a2c.length > 0) a2c += ",";
			a2c += a;
		}
	}
}
function outputAd(curAd){
	var middle, position, adType;
	position = curAd[0];
	adType = curAd[1];
	var adIndex, adsTotal, adId;
	var adList, adsPerGroup, curAdGroup, tmax, tmin;
	switch (adType){
		case "image":
			if (eval("typeof(arrImageAds"+position+")") != "undefined"){
				adsTotal = eval("arrImageAds"+position+".length");
				if (adsTotal > 0){
					adIndex = 0;
					if (adsTotal > 1){
						adIndex = Math.floor(Math.random()*adsTotal);
					}
					adId = eval("arrImageAds"+position+"["+adIndex+"]") + "";
					if (adId.length > 0){
						newscripts += "<scr" + "ipt language=\"javascript\" type=\"text/javascript\" src=\"" + adsURL + "/ad/?a=" + adId + "\"></sc" + "ript>";
						eval("adId_" + position + " = " + adId + ";");
						objOmni.adImpressionEvent(adId);
						if (adId.length > 0){
							add2(adId);
						}
					}
				}
			}
			break;
		case "text":
			adsPerGroup = 6;
			
			curAdGroup = position;
			tmax = curAdGroup * adsPerGroup;
			tmin = (tmax - adsPerGroup) + 1;
			adList = ""
			for (var x = tmin; x <= tmax; x++){
				if (eval("typeof(arrTextAds"+x+")") != "undefined"){
					adsTotal = eval("arrTextAds"+x+".length");
					if (adsTotal > 0){
						adIndex = 0;
						if (adsTotal > 1) adIndex = Math.floor(Math.random()*adsTotal);
						adId = eval("arrTextAds"+x+"["+adIndex+"]") + "";
						if (adId.length > 0){
							if (adList.length > 0) adList = adList + ",";
							adList = adList + adId;
							objOmni.adImpressionEvent(adId);
						}
					}
				}
			}
			if (adList.length > 0){
				newscripts += "<scr" + "ipt language=\"javascript\" type=\"text/javascript\" src=\"" + adsURL + "/ad/?l=" + adList + "&g=" + curAdGroup + "\"></sc" + "ript>";
				if (adList.length > 0){
					add2(adList);
				}
			}
			break;
	}
}


self.setInterval("clearMyIntervals()",5000);
function clearMyIntervals(){
	if (typeof(iTotalIntervals) != "undefined"){
		if (iTotalIntervals > 0){
			for (var x = 1; x <= iTotalIntervals; x++){
				if (eval("typeof(int"+x+")") != "undefined"){
					eval("window.clearInterval(int"+x+")");
				}
			}
		}
	}
	if (typeof(iTotalTextIntervals) != "undefined"){
		if (iTotalTextIntervals > 0){
			for (var x = 1; x <= iTotalTextIntervals; x++){
				if (eval("typeof(intT"+x+")") != "undefined"){
					eval("window.clearInterval(intT"+x+")");
				}
			}
		}
	}
}