if ("undefined" == typeof oIF) oIF = false;
var eplDoc = oIF ? document : parent.document;
var sDoc = document;

/* Evitar objetos epl duplicados */
if (eplDoc.epl == undefined) {
function EPL() {
	var onLoad=0;
	var onLoadO;
	var req;
	var sV, vV, rnd;
	var sI, kC, sec, cM;
	var is=null, isJ=null;
	var eId, eClassName;
	var elist = new Array();
	var logi = new Array();
	var kVs = new Object();
	var queuedAds = new Object();
	var cntUrls = new Object();
	this.initDone = false;
	this.spaces = new Object();
	this.csfs = new Object();

	this.browser = new Object();	
	var b_ua = navigator.userAgent.toLowerCase();
	var b_av = navigator.appVersion.toLowerCase();
	this.browser.isMac = b_ua.indexOf('mac')!=-1;
	this.browser.isWin = ((b_ua.indexOf("win")!=-1)||(b_ua.indexOf("16bit")!=-1)) && !this.browser.isMac;
	this.browser.isOpera = b_ua.indexOf('opera')!=-1;
	this.browser.isIE = b_av.indexOf('msie')!=-1 && !this.browser.isOpera;
	this.browser.isFF = b_ua.indexOf('firefox')!=-1;

	this.pushQAd = pushQAd;
	this.ID = Math.random();
	this.getSW = function() {
		return (eplDoc.eplScreenWidth) ? eplDoc.eplScreenWidth : this.window.innerWidth ? this.window.innerWidth : (eplDoc.documentElement && eplDoc.documentElement.clientWidth) ? eplDoc.documentElement.clientWidth : eplDoc.body ? eplDoc.body.clientWidth : 800;
	}
	this.getSH = function() {
		return (eplDoc.eplScreenHeight) ? eplDoc.eplScreenHeight : this.window.innerHeight ? this.window.innerHeight : (eplDoc.documentElement && eplDoc.documentElement.clientHeight) ? eplDoc.documentElement.clientHeight : eplDoc.body ? eplDoc.body.clientHeight : 600;
	}
	this.helpers = new Object();
	
	/* TRACKER HELPER 2.0 - START */
	function TrackHelper() {
		this.setImpId = function(fid,imp_id,fecha_id) {
			var ad = eplDoc.epl.getAd(fid);
			ad.tracker.start = true;
			if (fecha_id) ad.fi = fecha_id;
			ad.i = imp_id;
		}
		this.stopTrack = function(fid) {
			var ad = eplDoc.epl.getAd(fid);
			ad.tracker.end = true;
			this.stopTimer(ad.tracker);
			ad.tracker.q = [];			
		}

		this.INICIO = 0;
		this.COMPLETO = 1;
		this.ENCENDIDO = 2;
		this.START_BUTTON = 3;
		this.STOP_BUTTON = 4;
		this.RESTART_BUTTON = 5;
		this.SOUND_OFF = 6;
		this.SOUND_ON = 7;
		this.CLOSE_BUTTON = 8;
		this.DESPLEGAR = 9
		this.REPLEGAR = 10;
		this.DEMORADO = 11;
		this.NOT_FOUND = 12;

		this.inicioAnuncio = function(fid,st) { this.registrarAccion(eplDoc.epl.getAd(fid), this.INICIO, st); }
		this.anuncioCompleto = function(fid) { this.registrarAccion(eplDoc.epl.getAd(fid), this.COMPLETO); }
		this.start = function(fid) { this.registrarAccion(eplDoc.epl.getAd(fid), this.START_BUTTON); }
		this.restart = function(fid) { this.registrarAccion(eplDoc.epl.getAd(fid), this.RESTART_BUTTON); }
		this.stop = function(fid) { this.registrarAccion(eplDoc.epl.getAd(fid), this.STOP_BUTTON); }
		this.soundOff = function(fid) { this.registrarAccion(eplDoc.epl.getAd(fid), this.SOUND_OFF); }
		this.soundOn = function(fid) { this.registrarAccion(eplDoc.epl.getAd(fid), this.SOUND_ON); }		
		this.notFound = function(fid) {	this.registrarAccion(eplDoc.epl.getAd(fid), this.NOT_FOUND); }
		this.demorado = function(fid) { this.registrarAccion(eplDoc.epl.getAd(fid), this.DEMORADO); }
		
		this.registrarAccion = function(ad,at,st) {
			var t = ad.tracker;
			if (!t) throw "eplTH error 000, tracker not found for ad id="+ad.id;
			if (at==this.INICIO && t.start) throw "eplTracker error 001, ad id="+ad.id+", at="+at+" - already started";
                        if (t.start && t.end) throw "eplTracker error 002, ad id="+ad.id+", at="+at+" - already finished";
                        if (t.start && at==this.REPLEGAR && !t.open) throw "eplTracker error 003, ad id "+ad.id+", at="+at+" - already closed";
                        if (t.start && at==this.DESPLEGAR && t.open) throw "eplTracker error 004, ad id "+ad.id+", at="+at+" - already open";
                        
			if (at!=this.INICIO && !t.start) { //queue
                    		t.q.push(at);
                                setTimeout("eplDoc.eplTH.qActions("+ ad.getFIDQ() +");", 3000)
                        } else {
                    		this.updateTime(t);
                                var u = ad.getTrackURL()+'&f=j&at='+at+'&t='+(Math.round(t.time));
                                request(u);
                                if (at==this.INICIO) {
                            		if (st) {
                            	        	this.startTimer(t);
                            			t.open = true;
                            		}
                            	} else if (at==this.START_BUTTON || at==this.RESTART_BUTTON || at==this.DESPLEGAR) {
                            		if (at==this.DESPLEGAR) t.open = true;
                            	        this.startTimer(t);
                            	} else if (at==this.STOP_BUTTON || at==this.CLOSE_BUTTON || at==this.REPLEGAR || at==this.COMPLETO) {
                            		if (at==this.REPLEGAR || at==this.COMPLETO) t.open = false;
                            		if (at==this.COMPLETO) t.end = true;
                            	        this.stopTimer(t);
    				}
			}
		}
		this.qActions = function(fid) {
			var ad = eplDoc.epl.getAd(fid);
			var t = ad.tracker;
			if (t.start) {
				while (t.q.length) {
                            		var at = t.q.pop();
                                        this.registrarAccion(id,at);
                                }
                    	} else {
                                setTimeout("eplDoc.eplTH.qActions("+ ad.getFIDQ() +");", 3000)
                        }
		}
		this.sendTimerValue = function(fid) {
			var ad = eplDoc.epl.getAd(fid);
			var t = ad.tracker;
			if (t.time > 120000 || t.end) eplDoc.eplTH.stopTimer(t);
			else this.registrarAccion(ad, this.ENCENDIDO);		
		}
		this.updateTime = function(t) {
			if (!t.time_init) return;
                        var current = (new Date()).getTime();
                        t.time += (current - t.time_init);
		}
		this.startTimer = function(t) {
        		if (t.timer_id || t.time > 120000) return;
		        t.time_init = (new Date()).getTime();
		        t.timer_id = setInterval('eplDoc.eplTH.sendTimerValue('+t.ad.getFIDQ()+')', 5000)
		}
		this.stopTimer = function(t) {
		        if (!t.timer_id) return;
		        clearInterval(t.timer_id);
		        this.updateTime(t);
		        t.time_init = null;
		        t.timer_id = null;
		}		
	}
	eplDoc.eplTH = new TrackHelper();
	/* TRACKER HELPER 2.0 - END*/
	
	function replaceRandom(string) {
		return string.split('$RANDOM').join(getRnd());
	}
	function slashToUnderscore(string) {
		return string.replace(/\//g, '_');
	}

	function underscoreToSlash(string) {
		return string.replace(/_/g, '/');
	}
	function pushQAd(type, adObj) {
		if (null == queuedAds[type]) {
			queuedAds[type] = new Array();
		}
		queuedAds[type].push(adObj);
	}
	this.popQAd = function(type) {
		var a=queuedAds[type];
		if ((null!=a) && (a.length>0)) {
			var ad = a.pop();
			return ad;
		} else {
			return null;
		}
	}
	
	var delayedAds = new Array();
	function pushDelayedAd(ad) {
		if (window.loaded || eplDoc.epl.browser.isFF) {
			ad.helper.show(ad);
			return;
		}
		delayedAds.push(ad);
		var execAds = function() {
			for (x in delayedAds) delayedAds[x].helper.show(delayedAds[x]);
		}
		var domReady = function() {
			if (eplDoc.readyState == undefined || eplDoc.readyState == 'complete') {
				window.loaded = true;
				execAds();
			} else if (eplDoc.readyState == 'interactive') {
				setTimeout(execAds, 3000);			
			} else {
				setTimeout(domReady, 100);
			}
		}
		if (eplDoc.readyState) {
			eplDoc.onreadystatechange = domReady;		
		} else {
			eplDoc.addListener = function(t, f) {
				if (this.addEventListener) this.addEventListener(t, f, false);
				else this.attachEvent('on'+t, f);
			}
			eplDoc.addListener('DOMContentLoaded', domReady);
		}
	}
	this.iframeAds = new Array();
	this.showIframeAds = function() {
		for (x in eplDoc.epl.iframeAds) {
			var a = eplDoc.epl.iframeAds[x];
			if ((a.o & 1) || (a.t==4)) {
				eplDoc.epl.showIframe(a);
				a.setShown();
			}
		}
	}
	this.showIframe = function(adObj) {
		var ur = sV + 'eat/' + vV + '/' + sI + '/' + adObj.id + '/f?rnd=' + getRnd() + '&rt=' + (new Date()).getTime();
		var iF = document.createElement('iframe');
		iF.src = ur + '&fr=do';
		iF.id = 'ifr' + adObj.id;
		iF.name = 'if' + adObj.id;
		iF.width = adObj.w + 'px';
		iF.height = adObj.h + 'px';
		iF.frameBorder = '0';
		iF.marginwidth = '0px';
		iF.marginheight = '0px';
		iF.scrolling = 'no';
		//adObj.div.appendChild(iF);
		$(adObj).update(iF);
	}

	this.getIS = function(ad) {
		return ad ? (this.is || ad.is) : this.is;
	}
	this.getISJ = function(ad) {
		return (this.isJ ? this.isJ : this.is ? this.is : ad.is);
	}

	this.setPostShow = function(eI, f) {
		if (undefined!=this.spaces[eI]) {
			this.spaces[eI].psf=f;
		} else {
			throw "setPostShow: Unknown space: " + eI;
		}
	}

	this.setCustomAdShow = function(eI, f) {
		if (undefined!=this.spaces[eI]) {
			this.spaces[eI].csf=f;
		} else if ('*'==eI) {
			for (var x in this.spaces) {
				this.spaces[x].csf=f;
			}
		} else {
			this.csfs[eI]=f;
		}
	}

	// Para compatibilidad con versiones anteriores
	this.eplPushAd = function(eI, t, timeout, ma) {
		this.setSpace(eI, {t:t,timeout:timeout,ma:ma});
	}
	this.addSpace = function(eI, t, timeout, ma) {
		this.setSpace(eI, {t:t,timeout:timeout,ma:ma});
	}
	this.setSpace = function(eI, opts) {
		if ((! eIs) && (undefined == this.spaces[eI])) {
			if (!opts) {
				opts = {eI:eI,t:1};
			} else {
				opts.eI = eI;
			}
			var e = new Space(opts);
			this.spaces[eI]=e;

			if (undefined!=this.csfs[eI]) {
				this.spaces[eI].csf = this.csfs[eI];
			}

			if (opts.t == 2 || opts.t == 3) {
				e.loadKWs();
			} else {
				e.loadAds();
			}
		}
	}
	this.addSpaces = function(eIs) {
		for (var i=0;i<eIs.length; i++) {
			var e = new Space({eI:eIs[i],t:1});
			this.spaces[eIs[i]]=e;
		}
	}
	this.showSpace = function(eI) {
		if (undefined!=this.spaces[eI]) {
			var e=this.spaces[eI];
			if ((e.ads!=undefined) && (! e.ads_shown)) {
				this.spaces[eI].showAds();
			}
		} else {
			throw "Undefined space: " + eI;
		}
	}
	function getRnd() {
		if (undefined == rnd) {
			rnd = Math.random();
		}
		return rnd;
	}
	
	
	this.eplReady = function() {
		return this.initDone;
	}
	this.in3pIframe = function() {
		return this.in3pIF;
	};

	this.window=self.parent;

	this.eplInit = function(args) {
		sV = args['sV'];
		vV = args['vV'];
		sI = args['sI'];
		kC = args['kC'];
		kVs = args['kVs'];
		sec = args['sec'];
		eIs = args['eIs'];
		eId = undefined || args['eId'];
		eClassName = undefined || args['eClassName'];
		var in3pIF = args['in3pIF'];
		this.args = args;
		allCSF = args['allCSF'];
		if (eIs) {
			// Request multiple - precargar los espacios ahora
			this.addSpaces(eIs);
			if (allCSF) this.setCustomAdShow('*', allCSF);
			this.loadAdsM();
		}
		this.initDone = true;
	}
	this.changeSec = function(newSec) {
		sec = newSec;
	}

	this.setAdsM = function(d) {
		if (d.sI != sI) {
			throw "sI mismatch: " + sI + "!=" + d.sI;
		} else if (d.sec != sec) {
			throw "sec mismatch: " + sec + "!=" + d.sec;
		} else {
			this.is=d.is;
			if (d.isJ) {
				this.isJ=d.isJ;
			}
		}
		for (var eI in d.ads) {
			if (this.spaces[eI] != undefined) {
				var e=this.spaces[eI];
				e.setAds(d.ads[eI]);
				if ((null != e.getDiv()) && (! e.ads_shown)) {
					e.showAds();
				}
			} else {
				throw "Unknown space: " + eI;
			}
		}
	}

	this.eplShowAds = function(eI, ads) {
		if ((ads != undefined) && (this.spaces[eI] != undefined)) {
			var e=this.spaces[eI];
			e.setAds(ads);
			if (! e.ads_shown) {
				e.showAds();
			}
		} else {
			throw "ads or space undefined for " + eI + "; ads=" +ads;
		}
	}
	
	this.getSpace = function(eI) {
		if (undefined == eI) throw "eI is undefined";
		if (this.spaces) {
			var s = this.spaces[eI];
			if (s) 	return s;
		} else {
			throw "spaces array not ready";
		}
		throw "Space not found for eI " +eI;
	}
	this.getAd = function(FID) {
		if (undefined == FID) {
			throw "FID is undefined";
		}
		var a = FID.split("_");
		var ads=this.spaces[a[0]].ads;
		for (var i=0;i<ads.length;i++) {
			if (ads[i].id==a[1]) {
				return ads[i];
			}
		}
		throw "Ad not found for FID " +FID;
	}
	
	this.reloadSpace = function(eI) {
		var s = this.getSpace(eI);
		rnd = Math.random();
		if (s) s.reload();
	}
	this.refreshAdsM = function(sec) {
		if (sec) this.changeSec(sec);
		for (s in this.spaces) {
			this.spaces[s].clearAds();
		}
		rnd = Math.random();
		this.loadAdsM();
	}
	this.refreshAds = function() {
		rnd = Math.random();
		for (s in this.spaces) {
			this.spaces[s].reload();
		}
	}

	this.getBFV = function() {
		var FV=0;
		var nmT=navigator.mimeTypes;
		var swF='application/x-shockwave-flash';
		var fP=(nmT && nmT[swF])?nmT[swF].enabledPlugin:0;
		var ua=navigator.userAgent.toLowerCase();var av=navigator.appVersion.toLowerCase();

		var fvT;
		if (fP) {
			var nP=navigator.plugins;
			var sf="Shockwave Flash";
			if (nP[sf]!=null) 
				fvT=nP[sf].description;
		} else if (ua && ua.indexOf("msie")>=0 && (av.indexOf("win")!=-1)) {
			var e;
			try {
				var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				axo.AllowScriptAccess="always";
				fvT=axo.GetVariable("$version");
			} catch (e) {}
		} 
		if (fvT) { 
			var fvW=fvT.split(" ");
			for (var i=0;i<fvW.length;++i) {
			    if (isNaN(parseInt(fvW[i]))) 
				continue;
			    FV=fvW[i];
			}
		}
		return FV;
	}


	this.loadAdsM = function() {
		var u=sV+'cm/'+vV+'/'+sI+'/'+sec+'?rnd='+getRnd()+'&e='+eIs.join('+')+'&fv='+this.getBFV();
		if (kVs) {
			for (var kct in kVs) {
				u+='&kw_'+kct+'='+kVs[kct];
			}
		}
		var sw=eplDoc.epl.getSW();var sh=eplDoc.epl.getSH();
		if(sw&&sh){u+="&n="+sw.toString(16)+"x"+sh.toString(16);}
		var cs=getCS();
		if (undefined!=cs) { u+='&crs='+cs; }
		request(u);
	}

	this.showByType = function(type) {
		if (undefined != this.helpers[type]) {
			var hlp = this.helpers[type];
			var ad;
			while (null!=(ad = this.popQAd(type))) {
				hlp.show(ad); //quitar cuando se empiece a usar domDelayed()
				/*
				if (ad.domDelayed()) {
					ad.helper = hlp;
					pushDelayedAd(ad);
				} else {
					hlp.show(ad);
				}
				*/
				ad.setShown();
			}
			return true;
		} else {
			throw "No helper for: " + type;
		}
	}

	this.addHelper = function(type, div, ad) {
		var url = this.getISJ(ad) + "layers/v4_" + type + ".js";
		var t = eplDoc.createElement('script');
		t.src = this.getISJ(ad) + "layers/v4_" + type + ".js";
		t.language = "JavaScript1.1";
		t.type = "text/javascript";
		div.appendChild(t);
	}

	function Space(d) {
		this.t=d.t;
		this.status=0;
		this.timeout=d.timeout||0;
		this.eI=d.eI;
		this.ma=d.ma;
		var wha = d.wh ? d.wh.split("x") : null;
		this.w = wha ? wha[0] : d.w;
		this.h = wha ? wha[1] : d.h;
		this.ads_shown=0;
		this.csf = null;
		this.psf = null;
		if ((this.t==2) || (this.t==3)) {
			this.kws_count=0;
			this.ids=[];
			this.nids=[];
			elist.push(d.eI);
		} else if (this.t!=1) {
			throw "Unknown space type: " + this.t;
		}
		this.getAdsURL = function() {
			var url=sV+'eb/'+vV+'/'+sI+'/'+(sec?sec+'/':'')+this.eI+'?rnd='+getRnd()+'&fv='+eplDoc.epl.getBFV();
			var i,j;

			if ((undefined != this.ma) && (1 != this.ma)) {
				url+= '&ma='+this.ma;
			}
			if (kVs) {
				for (var kct in kVs) {
					url+='&kw_'+kct+'='+kVs[kct];
				}
			}
			var sw=eplDoc.epl.getSW(); var sh=eplDoc.epl.getSH();
			if (sw&&sh) { url+="&n="+sw.toString(16)+"x"+sh.toString(16); }

			var cs=getCS();
			if(undefined!=cs){url+='&crs='+cs;}

			if ((2 == this.t) || (3==this.t)) {
				url+= '&kc=' + kC;
				var o = 3==this.t?'h':'x';
				url+='&o='+o;

				// keyword + ids
				for (i=0; (i<this.ids.length) && (url.length < 2000); i++) {
					var skip=0;
					for (j=0; j<this.ids[i][1].length; j++) {
						if (this.nids[this.ids[i][1][j]] == 1) {
							skip = 1;
						}
					}
					if (skip == 0) {
						url+= '&kps_' + escape(this.ids[i][0]) + '=';
						for (j=0; j<this.ids[i][1].length; j++) {
							url+= id2hex(this.ids[i][1][j]);
						}
					}
				}
			}

			return url;
		}
		this.loadAds = function() {
			request(this.getAdsURL());
		}
		this.setAds = function(ads) {
			this.ads=[];
			for (var i=0; i<ads.length; i++) {
				ads[i].eI=this.eI;
				var a = new AdObj(ads[i]);
				this.ads.push(a);
				if (a.uc && (!a.cOS() && !a.rmt)) {
					for (x in a.uc) {
						var i = new Image; i.src = replaceRandom(a.uc[x]);
					}
				}
			}
		}
		this.clearAds = function() {
			while (this.ads.length) {
				var ad = this.ads.shift();
				ad.clearDivs();
			}
			this.ads_shown = false;
		}
		this.reload = function() {
			this.clearAds();
			this.loadAds();
		}
		this.getDiv = function() { return eplDoc.getElementById('eplAdDiv' + this.eI); }
		this.showAds = function() {
			var aDiv = this.getDiv();
			if (this.ads_shown) {
				throw "Ads for " + this.eI + " already shown";
			} else if ((aDiv != null) && (this.ads != undefined)) {
				this.ads_shown=1;
				var c=new Array();
				if (this.csf) {
					var ret = this.csf(this.ads);
					if (ret) {
						c.push(ret);
					}
				}
				var hlp = new Array();
				var aH = true;
				for (var i=0; i<this.ads.length; i++) {
					if (this.ads[i].st != 2) aH = false;
					if (this.ads[i].t != 41) aH = false;
				}				
				if (aH && this.ads.length) {
					this.aHShow();
				} else {
					for (var i=0; i<this.ads.length; i++) {
						var adObj = this.ads[i];
						adObj.div=aDiv;
						var cU = adObj.lU;
						var tY = adObj.t;
						if (!adObj.shown) {
							var h = adObj.getHelper();
							var eh = adObj.getHelperEfecto();
							var shown=1;
							if ((adObj.o & 1) || (tY==4)) {
								if (eplDoc.epl.browser.isFF && !onLoad) {
									eplDoc.epl.iframeAds.push(adObj);
									shown=0;
								} else {
									eplDoc.epl.showIframe(adObj);
								}
							} else if (null != h) {
								pushQAd(h, adObj);
								hlp.push(h);
								shown=0;
							} else if (null != eh) {
								pushQAd(eh, adObj);
								hlp.push(eh);
								shown=0;
							} else if (adObj.isPopUp() || adObj.isPopUnder()) {
								adObj.showPopUp();
							} else if (tY == 1 || tY == 7 || tY == 8) { // imagen
								var cT = adObj.getBaseTag();
								if ((adObj.e==34)||(adObj.e==32)) {
									cT += '<br>' + adObj.tit;
								}
								cT+='</a>';
								if ((adObj.e==34)||(adObj.e==33)) {
									cT += '<br>' + adObj.desc;
								}
								c.push(cT);
							} else if (tY==9 || tY==16) {
								c.push(adObj.getBaseTag(1));
								if (adObj.tracker && !adObj.fI) {
									adObj.tracker.inicioAnuncio();
								}
							} else if (tY==2) { // flash
								c.push(adObj.getBaseTag());
							} else if (41==tY) {
								c.push('<table style="font-family:arial;color:black;font-size:12px;"><tr><th align=left><a style="color:black;decoration:none;" href="'+ cU +'">'+ adObj.tit +'</a></th></tr><tr><td>'+  adObj.desc +'<br/><a style="color:black;decoration:none;" href="'+ cU +'">'+ adObj.urlv +'</a></td></tr></table>');
							} else {
								throw "Unknown format: " + tY;
							}
							if (shown) {
								adObj.setShown();
							}
						}//endfor
					}
					if (c.length) {
					 	aDiv.innerHTML += c.join('');
					}
					if (hlp.length > 0) {
						var t = new Object();
						for (var i=0; i<hlp.length; i++) {
							if (null == t[hlp[i]]) {
								t[hlp[i]] = 1;
								if (undefined == eplDoc.epl.helpers[hlp[i]]) {
									eplDoc.epl.addHelper(hlp[i], aDiv, adObj);
								} else {
									eplDoc.epl.showByType(hlp[i]);
								}
							}
						}
					}
				}
				if (this.psf) {
					this.psf(this, aDiv);
				}
			} else {
				throw "ads or div undefined for " + this.eI + "; div=" + aDiv + "; ads=" + this.ads;
			}
		}
		this.adAHS = function() {
			 var l = eplDoc.getElementsByTagName('head');
                         if (l != undefined && l.length >= 1) {
                                 var style = eplDoc.createElement('style');
                                 var string = '';
				 string+= 'table.eplTextTable{border-spacing:0px;border-collapse:collapse;clear:both;background-color:#FFFFFF;font-family:arial;color:#960001;font-size:12px;}\n';
				 string+= 'div.eplTextBorder{border:1px #960001 solid;background-color:#FFFFFF;font-family:arial;color:#960001;font-size:12px;overflow:hidden;}'
				 string+= 'div.eplTextDiv{clear:both;background-color:#FFFFFF;font-family:arial;color:#960001;font-size:12px;}\n';
			         style.setAttribute('type', 'text/css');
			         if (style.styleSheet != undefined) {
			                 style.styleSheet.cssText = string;
			         } else {
			                 var text = eplDoc.createTextNode('\n<!--\n'+string+'\n-->\n');
			                 style.appendChild(text);
			         }
			         l[0].appendChild(style);
                         }		
		}
		this.aHShow = function() {
			this.adAHS();
			var w = this.w||0;
			var h = this.h||0;
			var horiz = (w > (2 * h)) ? true : false;
			var whs = (w && h) ? ('style="width:'+w+'px; height:'+h+'px;"') : '';
			var sh = (w && h) ? ('style="width:'+w+'px; height:'+(h-19)+'px;"') : 'width="100%" height="90%"';
			var cT = '';
			cT+= '<div class="eplTextBorder" '+whs+'>';
			cT+= '<table class="eplTextTable" '+sh+' cellspacing="0" cellpadding="4">' + (horiz?'<tr>':'');
			for (var i=0; i<this.ads.length; i++) {
				var adObj = this.ads[i];
				cT+= (!horiz?'<tr>':'')+'<td align="center"><table class="eplTextTable" style="margin:auto;">';
				cT+= '<tr><th align=left><a style="font-size:120%;color:#960001;decoration:none;" href="'+ adObj.lU +'">'+ adObj.tit +'</a></th></tr>';
				cT+= '<tr><td>'+  adObj.desc +'<br/><a style="color:#960001;text-decoration:none;" href="'+  adObj.lU +'">'+ adObj.urlv +'</a></td></tr>';
				cT+= '</table></td>' + (!horiz?'</tr>':'');
			}

			var is = eplDoc.epl.getIS(adObj);
			cT+= (horiz?'</tr>':'') + '</table>';
			cT+= '<div class="eplTextDiv" width="100%" align="right"><a href="http://www.adhispanic.com/"><img border=0 src="'+is+'adsbyadhis.png" /></a></div>';
			cT+= '</div>';
			this.getDiv().innerHTML+= cT;			
		}
		
		this.loadKWs = function() {
			var u=sV+'ekl/'+vV+'/'+sI+'/'+(sec?sec+'/':'')+this.eI;
			var cs=getCS()||"";
			u+="."+((undefined!=kC)?kC:"")+"."+cs;
			request(u, eklOnload, this.eI);
		}
		this.setKWs=function(d) {
			this.kdata=d;
			var p={},n={};
			for (var i=0;i<d.length;i+=2) {
				if (d[i].length > 0) {
					var w=d[i].toLowerCase();
					var ps=d[i+1];
					if (w.charAt(0)=='-') {
						w=w.substring(1,w.length);
						this.addKeyword(n,w,ps);
					} else {
						this.addKeyword(p,w,ps);
					}
				}
			}
			this.kws=p;
			this.nkws=n;
			if (onLoad == 1 || 0==this.timeout) {
				eplDoc.epl.parseText(this.eI);
			} else {
				var func = new Function("eplDoc.epl.parseText(\'" + this.eI + "\');");
				window.setTimeout(func, this.timeout);
			}
		}
		this.addKeyword=function(keywords, word, pautas) {
			var array = keywords;
			var words = word.split(" ");
			var i;

			for (i=0; i<words.length; i++) {
				if (array[words[i]]) {
					array[words[i]]['__count']++;
				} else {
					array[words[i]] = new Array();
					array[words[i]]['__count'] = 1;
				}
				array = array[words[i]];
			}

			if (array['__pautas']) {
				for (i=0; i<pautas.length; i++) {
					array['__pautas'][array['__pautas'].length] = pautas[i];
				}
				array['__pautas'].sort();
				for (i=1; i<array['__pautas'].length; i++) {
					if (array['__pautas'][i] == array['__pautas'][i-1]) {
						array['__pautas'].splice(i, 1);
					}
				}
			} else {
				array['__pautas'] = pautas;
			}
		}

	}

	function AdObj(ad) {
		this.doc = eplDoc;
		var FORMATOS = {
			1:{o:1,x:"gif"},
			2:{o:2},
			4:{o:0},
			7:{o:1,x:"jpg"},
			8:{o:1,x:"png"},
			9:{o:2},
			10:{o:2,h:"takeover"},
			11:{o:2,h:"exp"},
			13:{o:2,h:"preview"},
			14:{o:2,h:"lab"},
			16:{o:2},
			17:{o:2,h:"exp"},
			18:{o:2,h:"exp2"},
			19:{o:2,h:"lab"},
			41:{o:0},
			101:{o:2}, 102:{o:1}, 103:{o:8}, 104:{o:0}, 105:{o:1}, 106:{o:1}, 107:{o:2}, //popunders
			111:{o:2}, 112:{o:1}, 113:{o:8}, 114:{o:0}, 115:{o:1}, 116:{o:1}, 117:{o:2}, //popups
			151:{o:2,h:"layers"},
			153:{o:1,h:"layers",x:"gif"},
			154:{o:1,h:"layers",x:"jpg"},
			155:{o:1,h:"layers",x:"png"},
			157:{o:2,h:"exp2"},
			159:{o:2,h:"preview"},
			156:{o:2,h:"layers"},
			160:{o:2,h:"layers"},
			191:{o:4,h:"highlight"},
			192:{o:5,h:"highlight"},
			193:{o:6,h:"highlight"}
		};
		var EFECTOS = {
			1:{h:"layers"},
			2:{h:"layers"},
			3:{h:"layers"},
			4:{h:"layers"},
			5:{h:"layers"},
			7:{h:"exp"},
			8:{h:"exp"},
			9:{h:"lab"},
			32:{},
			33:{},
			34:{},
			35:{},
			128:{},
			129:{},
			130:{},
			132:{},
			201:{},
			202:{},
			203:{}
		};

		// Opciones del formato
		var OPTIONS_ES_IMAGEN = 1;
		var OPTIONS_ES_FLASH = 2;
		var OPTIONS_COS = 4;		
		var OPTIONS_DOM_DELAYED = 8;
		var OPTIONS_ES_HTML = 8;

		var LO_TITLE = 1;
		var LO_CLOSE_BUTTON = 2;
		var LO_ADAPTAR_TAMANO = 4;

		// Opciones del anuncio
		var OPTIONS_MASK_POSITION		= 240;
		var OPTIONS_SHIFT_POSITION		= 4;
		var OPTIONS_POSITION_UNSPECIFIED	= 0;
		var OPTIONS_POSITION_CENTER		= 1;
		var OPTIONS_POSITION_TOP_LEFT		= 2;
		var OPTIONS_POSITION_SPECIFIC		= 3;

		for (var i in ad) {
			this[i] = ad[i];
		}
		if (this.kw==undefined) {this.kw='';}
		this.shown=0;
		this.lU = sV + 'ei/3/' + sI + '/' + (sec ? sec + '/' : '') + underscoreToSlash(this.eI) + '?rnd=' + getRnd() + '&pb=' + this.id + '&fi=' + this.fi;
		if (!this.nl) {this.nl=1;}
		if (this.kw) {this.lU += "&kw=" + this.kw;}
		if (this.ptv) {this.lU += "&ptv=" + this.ptv;}
		if (this.tpct) {this.lU += "&3pct=" + this.tpct;}
		if (this.tit) {this.tit=this.tit.replace(/\$KEYWORD/g, this.kw);}
		if (this.desc) {this.desc=this.desc.replace(/\$KEYWORD/g, this.kw);}
		if (this.desc2) {this.desc2=this.desc2.replace(/\$KEYWORD/g, this.kw);}
		if (FORMATOS[this.t] == undefined) {
			throw "(new) Unknown format: " + this.t;
		}
		if ((this.e) && (this.e>0) && (EFECTOS[this.e] == undefined)) {
			throw "Unknown effect: " + this.e;
		}
		this.pos = function() {
			return ((this.o&OPTIONS_MASK_POSITION)>>OPTIONS_SHIFT_POSITION);
		}
		this.isLayer=function() { return ((this.t>=151) && (this.t<=159)); }
		this.isPopSite=function() { return (104==this.t || 114==this.t) };
		this.isPopUnder=function() { return ((this.t>=101) && (this.t<=107)) };
		this.isPopUp=function() { return ((this.t>=111) && (this.t<=117)) };
		this.getHelper=function() { return FORMATOS[this.t].h; }
		this.getHelperEfecto=function() { if (this.e) { return EFECTOS[this.e].h; } else { return null; } }
		this.posCenter=function() {return (this.pos()==OPTIONS_POSITION_CENTER)}
		this.posTopLeft=function() {return (this.pos()==OPTIONS_POSITION_TOP_LEFT)}
		this.getFIDQ=function() { return "'" + this.getFID() + "'"; }
		this.getFID=function() { return this.eI + '_' + this.id; }
		this.posSpecific=function() {return (this.pos()==OPTIONS_POSITION_SPECIFIC)}
		this.getLeft=function(a) { return (this.posSpecific() ? this.px||0 : this.posCenter() ? (eplDoc.epl.getSW()/2 - (a ? a.w : this.w)/2) : 0); }
		this.getTop=function(a) { return (this.posSpecific() ? this.py||0 : this.posCenter() ? (eplDoc.epl.getSH()/2 - (a ? a.h : this.h)/2) : 0); }
		this.isSWF = function() { return FORMATOS[this.t].o&OPTIONS_ES_FLASH; };
		this.cOS = function() { return FORMATOS[this.t].o&OPTIONS_COS; };
		this.isImg = function() { return FORMATOS[this.t].o&OPTIONS_ES_IMAGEN; };
		this.domDelayed = function() { return FORMATOS[this.t].o & OPTIONS_DOM_DELAYED; }
		this.isHTML = function() { return FORMATOS[this.t].o & OPTIONS_ES_HTML; };
		
		// Tracker 2.0
		function Tracker(ad) {
			this.q = [];
			this.ad = ad;
			this.start = false;
			this.end = false;
			this.open = false;
			this.time = 0;
			this.inicioAnuncio = function(st) { eplDoc.eplTH.registrarAccion(this.ad, eplDoc.eplTH.INICIO, st); }
			this.anuncioCompleto = function() { eplDoc.eplTH.registrarAccion(this.ad, eplDoc.eplTH.COMPLETO); }
			this.encendido = function() { eplDoc.eplTH.registrarAccion(this.ad, eplDoc.eplTH.ENCENDIDO); }
			this.closeButton = function() { eplDoc.eplTH.registrarAccion(this.ad, eplDoc.eplTH.CLOSE_BUTTON); }
			this.desplegar = function() { eplDoc.eplTH.registrarAccion(this.ad, eplDoc.eplTH.DESPLEGAR); }
			this.replegar = function() { eplDoc.eplTH.registrarAccion(this.ad, eplDoc.eplTH.REPLEGAR); }
		}
		if (this.tV && this.tV > 1) this.tracker = new Tracker(this);

		var divCustom;
		var divDefault;
		var divLayer;
		this.getDiv = function(hidden) {
			if (this.bd) divCustom = this.getDivCustom(hidden);
			return divCustom ? divCustom : this.getDivDefault(hidden);
		}
		this.getDivLayer = function(hidden) {
			var pObj = (eplDoc.epl.browser.isIE) ? this.div : this.topElement();
			if (!divLayer) divLayer = this.setDiv(pObj, 'adLayer'+this.id, hidden,0);
			return divLayer;		
		}
		this.getDivDefault = function(hidden) {
			if (!divDefault) divDefault = this.setDiv(this.div, 'adDefault'+this.id, hidden,1);
			return divDefault;
		}
		this.getDivCustom = function(hidden) {
			if (!this.bd) return this.getDivDefault(hidden);
			if (!divCustom) {
				divCustom = eplDoc.getElementById(this.bd);
				if (hidden && divCustom) {
					divCustom.style.visibility = 'hidden';
					divCustom.style.display = 'none';
				}
			}
			return divCustom;
		}
		this.topElement = function() {
			if (eplDoc.body) return eplDoc.body;
			var e = this.div;
			while (e.parent) e = e.parent;
			return e;
		}
		this.setDiv = function(parentObj, idChild, hidden,setTA) {
			var d = eplDoc.getElementById(idChild);
			if (parentObj && !d) {
				var d = eplDoc.createElement('div');
				d.id = idChild;
				if (hidden) {
					d.style.visibility = 'hidden';
					d.style.display = 'none';
				}
				if (setTA && this.ta && ('none' != this.ta)) {
					d.style.textAlign=this.ta;
				}
				parentObj.appendChild(d);
			}
			return d;
		}
		this.clearDivs = function() {
			if (divDefault) divDefault.innerHTML = '';
			if (divCustom) { divCustom.innerHTML = ''; divCustom = null; }
			if (divLayer) { divLayer.innerHTML = ''; divLayer = null; }
			if (this.div) this.div.innerHTML = '';
		}
		this.showLayer = function() {
			this.showDiv(this.getDivLayer());
		}
		this.hideLayer = function() {
			this.hideDiv(this.getDivLayer());
		}
		this.showDiv = function(x) {
			var d = x?x:this.getDiv();
			d.style.visibility = 'visible';
			d.style.display = '';
		}
		this.hideDiv = function(x) {
			var d = x?x:this.getDiv();
			d.style.visibility = 'hidden';
			d.style.display = 'none';
		};
		this.callUC = function() {
			for (var x in this.uc) {
				var ix = new Image(); ix.src = replaceRandom(this.uc[x]);
			}
		};
		this.lI = function(uC) {
			if (this.iLG) { return; }
			var u = sV + 'eli/' + vV + '/' + sI + '/' + (sec ? sec + '/' : '') + this.eI + '?rnd=' + Math.random() + '&pb=' + this.id;
			if (this.kw) {
				u += '&kw=' + this.kw;
			}
			var i = this.doc.createElement('img'); i.src = u;
			if (uC) { this.callUC(); }
			this.iLG=1;
		};
		this.setShown = function() {
			if (this.shown) { return; }
			this.shown=1;
			if (this.cOS()) {
				this.lI();
			}
			if (this.uc && (this.cOS() || this.rmt)) {
				this.callUC();
			}
		};
		this.setShown = function() {
			if (this.shown) { return; }
			this.shown=1;
			if (this.cOS()) {
				var url = sV + 'eli/' + vV + '/' + sI + '/' + (sec ? sec + '/' : '') + this.eI + '?rnd=' + Math.random() + '&pb=' + this.id;
				if (this.kw) {
					url += '&kw=' + this.kw;
				}
				var i = new Image(); i.src=url;
			}
			if (this.uc && (this.cOS() || this.rmt)) {
				for (x in this.uc) {
					var i = new Image; i.src = replaceRandom(this.uc[x]);
				}
			}
		}
		this.openExpanded = function(usePATH,useEID) {
			var r = false;
			if (this.ie==1 || this.ie==2) {
			     r = (this.getHits(usePATH,useEID)==0) ? true : false;
			     this.saveCookie(usePATH,useEID);
			}
			if (this.ie==0) r = false;
			if (this.ie==3) r = true;
			return r;
		}
		this.getHits = function(usePATH,useEID) {
			var c = new String(eplDoc.cookie);
			var k = 'eplb' + (useEID ? this.getFID() : this.id) + (usePATH ? '_'+escape(eplDoc.location.pathname):'');
			var h = 0;
			if (c) {
				var a = c.split('; ');
				for (i in a) {
					var s = a[i].split('=');
					if (s[0]==k && !isNaN(s[1])) {
						h = parseInt(s[1]);
					}
				}
			}
			return h;
		}
		this.saveCookie = function(usePATH,useEID) {
			var now = new Date();
			var now00 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), 0, 0);
			var expDateMillis = now00.getTime() + (3600*1000);
			if (this.ie==2) expDateMillis += (3600*1000*23);
			var expDate = new Date(expDateMillis);
			var k = 'eplb' + (useEID ? this.getFID() : this.id) + (usePATH ? '_'+escape(eplDoc.location.pathname):'');
			var cStr = k + '=' + (this.getHits(usePATH,useEID)+1) + '; path=/; expires='+expDate.toGMTString();
			eplDoc.cookie = cStr;
		}
		
		this.getTrackURL = function() { return sV + 'ermt/3/' + sI + '/' + (sec ? sec+'/' : '') + this.eI + '?il=0&pb=' + this.id + '&fi=' + this.fi + '&i=' + this.i; };
		this.getFlashVars = function(fvx) {
			var FV = 'clickTag=' + escape(this.lU); 
			for (var iX=2;iX<(this.nl+1);iX++){
				var l=this.lU+'&lid='+iX;
				FV+='&clickTag'+iX+'='+escape(l);
			}
			if (this.rmt) {
				FV+='&bannerId='+this.getFIDQ()+'&trackURL='+escape(this.getTrackURL());
				for (var o in this.a) {
					if (this.a[o].v) {
						FV+='&' + this.a[o].v + '=' + escape(this.getURL(this.a[o]));
					}
				}
			} else if (this.e) {
				FV+='&bannerId='+this.getFIDQ();
			}
			if (this.vaf) {
				FV+='&'+this.vaf;
			}
			return FV + (fvx ? '&'+fvx : '');
		}
		this.getExt = function(a) { return ((null != a) ? a.e : (this.isSWF() ? "swf" : FORMATOS[this.t].x)); }
		this.getURL = function(a) {
			var u;
			var is=this.is || eplDoc.epl.is;
			if (null!=a) {
				u=a.iurl || (is+'esb/4/'+a.s.toString(16)+'/'+this.aI+'/'+a.bI+'.'+this.getExt(a));	
			} else if (! this.rmt) {
				u=this.iurl || (is+'esb/4/'+this.s.toString(16)+'/'+this.aI+'/'+this.bI+'.'+this.getExt());	
			} else {
				throw "a is undef and this.rmt is defined";
			}
			return u;
		}
		this.getFlashTag = function(a, opts) {
			if (! this.isSWF()) {
				throw("Not a flash ad");
			}
			if (undefined==opts) { opts = {}; }
			var cT = '';
			var ver = getFVID(this.fv);
			var w = ((null!=a) ? a.cw||a.w : this.cw||this.w) - 2*(this.brdw?this.brdw:0);
			var h = ((null!=a) ? a.ch||a.h : this.ch||this.h) - 2*(this.brdw?this.brdw:0);
			var wh = 'width="' + w + '" height="' + h + '"';
			var A = {quality:"autohigh",loop:"true",allowscriptaccess:"always"};
			if (opts.p) {
				for (x in opts.p) A[x] = opts.p[x];
			}
			var u = this.getURL(a);
			if (this.fv < 6) {
				u+= '?clickTag=' + escape(this.lU);
				for (var iX=2;iX<(this.nl+1);iX++){
					var l=this.lU+'&lid='+iX;
					u+='&clickTag'+iX+'='+escape(l);
				}
			} else {
				A['flashvars'] = this.getFlashVars(opts['fv']);
			}
			cT = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + ver + '" ' + wh + ' border="0" id="eplb' + this.id + '_object">';
			cT+= '<param name=movie value="' + u + '">';
			A['wmode'] = (this.fbt == 't') ? 'transparent' : 'opaque';
			if (this.fbt == 'c') { A['bgcolor'] = this.fbc; }
			for (var p in A) {
				cT+= '<param name=' + p + ' value="' + A[p] + '">';
			}
			cT+= '<embed id="eplb' + this.id + '_embed" name="eplb' + this.id + '" src="'+ u + '" ';
			for (var p in A) {
				cT+= p + '="' + A[p] + '" ';
			}
			cT+= 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ' + wh + ' border="0"></embed></object>';
			return cT;
		}
		this.getImgTag = function() {
			var funcs='';
                        if (8==this.e) {
                                funcs = ' onmouseover="eplExpandLayer('+ this.getFIDQ() +');" ';
                                funcs += ' onmouseout="eplShrinkLayer('+ this.getFIDQ() +');"';
                        } else if (7==this.e) {
                                funcs = ' onmouseover="eplExpandLayer('+ this.getFIDQ() +');" ';
                                funcs += ' onmouseout="eplShrinkLayer('+ this.getFIDQ() +');"';
			}
			var cT = '<a href="'+ this.lU +'"'+ funcs  + ' target="' + (this.lnw ? "_blank" : "_top") + '"><img src="' + this.getURL() + '" border="0" width="' + (this.cw||this.w) + '" height="' + (this.ch||this.h) + '" alt="' + this.tit + '">';
			return cT;
		}
		
		this.getBaseTag = function(ao, opts) {
			if (this.rmt && (undefined == ao)) {
				throw "orden must be defined for RMT";
			} else if (ao && (undefined == this.a[ao])) {
				throw "unknown orden: " + ao;
			}
			var a;
			if (ao) {
				a = this.a[ao];
			}
			var cT, pre,post;
			if ((null == ao) && (this.lo&(LO_TITLE|LO_CLOSE_BUTTON))) {
				pre = '<table style="border: 1px solid #7f7f7f;" width="' + ad.w + '" cellspacing="0" cellpadding="0"><tr>';
				if (this.lo&LO_TITLE) {
					pre+='<td align="left" style="color: #7f7f7f; font-family: Arial; font-size: 11px;">' + this.tit + '</td>';
				}
				if (this.lo&LO_CLOSE_BUTTON) {
					pre+='<td style="background-color: #ffffff; color: #7f7f7f; font-family: Arial; font-size: 11px;" align="right"><a style="text-decoration: none;" href="#" onClick="eplHideLayer(\'' + this.getFID() + '\');return false;">&nbsp;X</a></td>';
				}
				pre +='</tr><tr><td ';
				if ((this.lo&LO_CLOSE_BUTTON) && (this.lo&LO_TITLE)) pre += ' colspan="2"';
				pre += '>';
				post = '</td></tr></table>';
			}
			if (this.brdw) {
				pre = '<table border="0" cellspacing="0" cellpadding="0"><tr><td style="padding:0px; border:'+this.brdw+'px solid '+this.brdc+'">'
				post = '</td></tr></table>';
			}
			if (null != a) {
				if (a.e == "swf") {
					cT = this.getFlashTag(a, opts);
				} else if ((a.e == "gif")||(a.e=="jpg")||(a.e="png")) {
					cT = '<a href="'+ this.lU +'"><img src="' + this.getURL(a) + '" border="0" width="' + (a.cw||a.w) + '" height="' + (a.ch||a.h) + '" alt="' + this.tit + '">';
				} else {
					throw "getBaseTag: Unknown format for a: " + u;
				}
			} else if (this.isSWF()) {
				cT = this.getFlashTag(null, opts);
			} else if (this.isImg()) {
				cT = this.getImgTag();
			} else {
				throw "getBaseTag: Unknown format: " + this.t;
			}
			if (pre) {
				cT = pre+cT;
			}
			if (post) {
				cT = cT+post;
			}
			return cT;
		}
	
	    this.showPopUp = function() {
		var tag = '', u = 'about:blank';
		var x = (this.x||0===this.x) ? this.x : (eplDoc.epl.getSW() / 2 - this.w);
		var y = (this.y||0===this.y) ? this.y : (eplDoc.epl.getSH() / 2 - this.h);
		var opts = 'width='+this.w+',height='+this.h+',left='+x+',top='+y;
		opts += ',toolbar='+((this.po & 1)?'yes':'no');
		opts += ',status='+((this.po & 2)?'yes':'no');
		opts += ',scrollbars='+((this.po & 4)?'yes':'no');
		opts += ',menubar='+((this.po & 8)?'yes':'no');
		opts += ',directories='+((this.po & 16)?'yes':'no');
		opts += ',location='+((this.po & 32)?'yes':'no');
		opts += ',resizable='+((this.po & 64)?'yes':'no');
		if (!this.isPopSite() && !this.isHTML()) {
			tag = '<html><head><title>'+this.tit+'</title></head><body style="margin:0px">'+this.getBaseTag(this.rmt?1:null)+'</body></html>';
		}
		if (this.isPopSite()) {
			u = this.iurl;
		} else if (this.isHTML()) {
			u = this.getFrameURL();
		}
		
		var w = eplDoc.epl.window.open(u, 'pop'+this.getFID(), opts);
		if (!this.isPopSite() && !this.isHTML()) {
			w.document.write(tag);
			w.document.close();
		}
		if (this.isPopUnder()) {
			w.blur();
			eplDoc.epl.window.focus();
		}
	    }
	};

	function TextParser(sp) {
		this.sp=sp;
		this.parse=function(){
			var kws=sp.kws;
			if (kws!=undefined && 0==sp.status) {
				var e, i;
				var count=0;
				sp.status=1;
				for (i=0; i<16; i++) {
					e = eplDoc.getElementById("epl_context_" + i);
					if (e) {
						var ret = this.parseNodes(e.childNodes);
						if (ret == -1) return;
						count++;
					}
				}
				if (eId!=undefined && eId.length>0) {
					e = eplDoc.getElementById(eId);
					if (e) {
						var ret = this.parseNodes(e.childNodes);
						if (ret == -1) return;
					}
					count++;
				}

				if (eClassName!=undefined && eClassName.length>0) {
					var list = this.getElementsByClassName(eClassName);
					for (i=0; i<list.length; i++) {
						var ret = this.parseNodes(list[i].childNodes);
						if (ret == -1) return;
					}
					count++;
				}
				if (count == 0) {
					/* Si no se especifico eId o eClassName y tampoco hay pegados divs epl_context_
					   parsear todo el body */
					var ret = this.parseNodes(eplDoc.body.childNodes);
					if (ret == -1) return;
				}

				if (sp.kws_count >= 1) {
					sp.loadAds();
				}
			}
		}
		this.parseNodes=function(nodes) {
			while (1==this._parseNodes(nodes)){}
		}

		/******* ESTO REVISAR ***********/
		this._parseNodes=function(nodes) {
			for (var i=0; i<nodes.length; i++) {
				var node = nodes.item(i);
				if (node.nodeType == 3) {
					if (node.nodeValue != undefined && node.nodeValue.length > 0) {
						var ret = this.parseNode(node);
						if (ret != 0) return ret;
					}
				}
				if (node.childNodes && node.nodeName != 'A' && node.nodeName != 'SCRIPT') {
					var skip=0;
					if (node.id != undefined) {
						if (node.id.substr(0, 6) == 'epl_kw') {
							skip = 1;
						}
					}
					if (skip == 0) {
						var ret = this.parseNodes(node.childNodes);
						if (ret == -1) return -1;
					}
				}
			}
			return 0;
		}
		this.findKeyword=function(keywords, words, word, i) {
			if (keywords[word]) {
				var array = keywords[word];
				if (array['__count'] > 0) {
					var arrays = new Array();
					var pkws = new Array();
					var string = '';

					pkws[0] = word;
					arrays[0] = array;
					for (var j=1; j<words.length-i; j++) {
						word = parseKeyword(words[i+j]);
						array = array[word];
						pkws[j] = word;
						arrays[j] = array;
						if (array) {
							if ((array['__count'] == 0) && (array['__pautas'])) {
								for (var k=0; k<j; k++) {
									if (k == 0) { string+= pkws[k]; } else { string+= ' ' + pkws[k]; }
								}
								var pautas = array['__pautas'].slice();
								array['__pautas'] = undefined;
								return new Array(string, pautas);
							}
						} else {
							break;
						}
					}

					for (j--; j>=0; j--) {
						if (arrays[j]['__pautas']) {
							array = arrays[j];
							for (var k=0; k<(j+1); k++) {
								if (k == 0) { string+= pkws[k]; } else { string+= ' ' + pkws[k]; }
							}
							var pautas = array['__pautas'].slice();
							array['__pautas'] = undefined;
							return new Array(string, pautas);
						}
					}
				} else
				if (array['__pautas']) {
					var pautas = array['__pautas'].slice();
					array['__pautas'] = undefined;
					return new Array(word, pautas);
				}
			}

			return undefined;
		}
		this.parseNode=function(node){
			var words = node.nodeValue.split(/[ \t\r\n]/);
			var nkeywords = this.sp.nkws;
			var keywords = this.sp.kws;
			var i;

			if (words[0]) {
				words[0] = words[0].ltrim();
			}

			for (i=0; i<words.length; i++) {
				var word, array;

				word = parseKeyword(words[i]);
				if (word.length > 0) {
					array = this.findKeyword(nkeywords, words, word, i)
					if (array) {
						for (var j=0; j<array[1].length; j++) {
							this.sp.nids[array[1][j]] = 1;
						}
					}

					array = this.findKeyword(keywords, words, word, i);
					if (array) {
						this.sp.ids[this.sp.kws_count++] = array;

						if (this.sp.t==3) {
							var innerHTML = '';
							var start = undefined;
							var tail = undefined;
							var text = '';

							for (var j=0; j<i; j++) {
								innerHTML+= words[j] + ' ';
							}

							var array = array[0].split(" ");
							if (array.length > 0) {
								for (var j=0; j<array.length-1; j++) {
									text+= words[i++] + ' ';
								}
								text+= words[i++];
							}

							var c = text.substring(0,1);
							if (isDelim(c)) {
								start = c;
								text = text.substring(1,text.length);
							}

							c = text.substring(text.length-1,text.length);
							if (isDelim(c)) {
								tail = c;
								text = text.substring(0,text.length-1);
							}

							if (start) {
								innerHTML+= start;
							}

							var e = eplDoc.createTextNode(innerHTML);
							var parent = node.parentNode;

							parent.insertBefore(e, node);

							e = eplDoc.createElement('nobr');
							e.id = 'epl_kw_' + this.sp.eI + '_' + (this.sp.kws_count-1);

							e.innerHTML = text;
							parent.insertBefore(e, node);

							if (tail) {
								innerHTML = tail + ' ';
							} else {
								innerHTML = ' ';
							}
							e = eplDoc.createTextNode(innerHTML);
							parent.insertBefore(e, node);

							innerHTML = '';
							while (i<words.length) {
								innerHTML+= words[i++] + ' ';
							}
							e = eplDoc.createTextNode(innerHTML);
							parent.replaceChild(e, node);
							return 1;
						}
					}
				}
			}

			return 0;
		}
		this.getElementsByClassName=function(className, tag, elm){
			var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
			var tag = tag || "*";
			var elm = elm || eplDoc;
			var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
			var elems=[];
			var current;
			var length = elements.length;
			for(var i=0; i<length; i++){
				current = elements[i];
				if(testClass.test(current.className)){
					elems.push(current);
				}
			}
			return elems;
		}
		function isDelim(c) {
			return (c=="."||c==","||c==";"||c=="\""||c=="'");
		}
		function parseKeyword(word) {
			var word = word.toLowerCase();
			var c = word.substring(0,1);
			if (isDelim(c)) {
				word = word.substring(1,word.length);
			}
			c = word.substring(word.length-1,word.length);
			if (isDelim(c)) {
				word = word.substring(0,word.length-1);
			}
			return word;
		}
	}


	function getCS() {
		return document.charset || document.characterSet;
	}
	function getFVID(version) {
		if (version == 2) { return '2'; }
		else if (version == 4) { return '4,0,2,0'; }
		return version + ',0,0,0';
	}


	function eklOnload() {
		if (this.readyState != undefined) {
			if (this.readyState != 'loaded' && this.readyState != 'complete') {
				return;
			}
		}
		var eI = this.arg;
		var data = eval('kw' + eI);
		var sp = eplDoc.epl.spaces[eI];
		if (null==sp) {
			throw "sp is null";
		} else if (data==undefined) {
			throw "data for ekl is undefined";
		} else {
			sp.setKWs(data);
		}
	}

	this.parseText = function(eI) {
		var sp=this.spaces[eI];
		if (null!=sp) {
			var tp=new TextParser(sp);
			tp.parse();
		} else {
			throw "sp is undefined at parseText";
		}
	}

/****  HASTA ACA CONVERTIDO ******************* 
   Lo de mas abajo hay que rearmar en clases */

	function appendScript(script) {
		var l = sDoc.getElementsByTagName('head');
		if (l != undefined && l.length >= 1) {
			l[0].appendChild(script);
		} else {
			l = sDoc.getElementsByTagName('body');
			if (l != undefined && l.length >= 1) {
				l[0].appendChild(script);
			}
		}
	}

	function request(url, func, arg) {
		var script = sDoc.createElement('script');
		script.type = 'text/javascript';
		script.src = url;
		
		if (func != undefined) {
			if (arg != undefined) {
				script.arg = arg;
			}
			if (script.readyState) {
				script.onreadystatechange = func;
			} else if (sDoc.attachEvent) {
				sDoc.attachEvent("onreadystatechange", func);
			} else {
				script.onload = func;
			}
		}
		appendScript(script);
	}



	function id2hex(d) {
		var hD='0123456789ABCDEF';
		var h = hD.substr(d&15,1);
		while (d>15) {
			d>>=4;
			h=hD.substr(d&15,1)+h;
		}
		while (h.length < 6) h = '0' + h;
		return h;
	}

	String.prototype.ltrim = function() {
		return this.replace(/^\s+/,"");
	}

	this.contentUpdate = function(eI) {
		if (espacios[eI] != undefined) {
			parseKeywordsData(eI);
			espacios[eI]['kws_count'] = 0;
			espacios[eI]['status'] = 0;
			
			this.parseText(eI);
		}
	}

	function ponLoad() {
		if (onLoad == 0) {
			onLoad=1;
			for (var i=0; i<elist.length; i++) {
				eplDoc.epl.parseText(elist[i]);
			}
		}
	}

	function onLoadHandler() {
		ponLoad();
		setTimeout('eplShowIframeAds()',100);
		if (onLoadO != undefined) onLoadO();
	}


	/* Inicializacion de la clase */

	onLoadO = window.onload;
	window.onload = onLoadHandler;

}
	function eplShowIframeAds() {
		eplDoc.epl.showIframeAds();	
	}
	function eplContentUpdate(eI) {
		if (eplDoc != undefined) {
			eplDoc.epl.contentUpdate(eI);
		}
	}
	eplDoc.epl = new EPL();
}

function eplCustomVA(adsArray) {
	var r=''; a1=false;
	// Variables para personalizar:
	var style_table = "width: 100%;";
	var style_cell = "vertical-align:middle; width:400px; height:45px;";
	var ads_vertical = true;
	var style_title = "font-size:12px; font-weight:bold; font-family:Verdana,Arial,Helvetica,sans-serif; text-decoration:underline; color:#396ACD;";
	var style_url = "font-size:11px; margin-left:10px; font-family:Verdana,Arial,Helvetica,sans-serif; text-decoration:none; color:#444444;";
	var style_desc = "font-size:11px; margin-left:10px; font-family:Verdana,Arial,Helvetica,sans-serif; color:#444444;";
	// fin variables
	for (var i=0; i<adsArray.length; i++) {
		var ad = adsArray[i];
		var td_id = "sponsor_" + i
		if (!ad.shown && (1==ad.t||7==ad.t||8==ad.t||41==ad.t)) {
			if (!a1) {
				r+= '<table style="'+ style_table +'">';
				if (!ads_vertical) { r+= '<tr rel="'+ ad.lU +'"" class="vs-summary-sponsor">'; }
				a1 = true;
			}
			if (ads_vertical) { 
				r+= '<a href="'+ ad.lU +'" target="_blank"><tr rel="'+ ad.lU +'" class="vs-summary-sponsor" onmouseover="$(this).addClassName(\'vs-summary-classified-hover\');" onmouseout="$(this).removeClassName(\'vs-summary-classified-hover\');" onclick="window.open(\''+ad.lU+'\');">';
			}
			else {
				r+= '<a href="'+ ad.lU +'" target="_blank">';
			}
			r+= '<td>';
			if (41==ad.t) { //link de texto
				r+= '<a target="_blank" href="'+ ad.lU +'" style="'+ style_title +'">'+ ad.tit +'</h3></a>';
				if (ad.desc) r+= '<br/><div style="'+ style_desc +'">'+ ad.desc +'</div>';
				if (ad.urlv) r+= '<br/><a target="_blank" href="'+ ad.lU +'" style="'+ style_url +'">'+ ad.urlv +'</a>';
			} else {
				if (ad.desc) { // imagen+texto
					r+= '<div style="float:left; padding-right: 10px; padding-bottom: 10px;" rel="' + ad.lU + '"><img src="'+ ad.iurl +'" border=0 /></div>';
					r+= '<h3 style="'+ style_title +'">'+ ad.tit +'</h3>'
					r+= '<br/><div style="'+ style_desc +'">'+ ad.desc +'</div>';
					if (ad.urlv) r+= '<br/>'+ ad.urlv;
				} else { // imagen sola
					r+= '<img src="'+ ad.iurl +'" border=0 />';
				}
			}
			r+= '</td>';
			if (ads_vertical) { r += '</tr></a>'; }
			else { r+= '</a>'}

			ad.shown = true;
		}
	}
	if (a1) r+= ads_vertical ? '</table>': '</tr></table>';
	return r;
}