var eplDoc = document; var eplLL = false;
var eS1 = 'us.img.e-planning.net';var eplArgs = { iIF:1,sV:"http://ads.e-planning.net/",vV:"4",sI:"3c52",kVs:{}};
function eplCheckStart() {
	if (document.epl) {
		var e = document.epl;
		if (e.eplReady()) {
			return true;
		} else {
			e.eplInit(eplArgs);
			return e.eplReady();		
		}
	} else {
		if (eplLL) return false;
		if (!document.body) return false; var eS2; var dc = document.cookie; var ci = dc.indexOf("EPLSERVER=");
		if (ci != -1) {
			ci += 10; var ce = dc.indexOf(';', ci);
			if (ce == -1) ce = dc.length;
			eS2 = dc.substring(ci, ce);
		}
		
		var eIF = document.createElement('IFRAME');
		eIF.src = 'about:blank'; eIF.id = 'epl4iframe'; eIF.name = 'epl4iframe';
		eIF.width=0; eIF.height=0; eIF.style.width='0px'; eIF.style.height='0px';
		eIF.style.display='none'; document.body.appendChild(eIF);
		
		var eIFD = eIF.contentDocument ? eIF.contentDocument : eIF.document;
		eIFD.open();eIFD.write('<html><head><title>e-planning</title></head><bo'+'dy></bo'+'dy></html>');eIFD.close();
		var s = eIFD.createElement('SCRIPT'); s.src = 'http://' + (eS2?eS2:eS1) +'/layers/epl-41.js';
		eIFD.body.appendChild(s);
		if (!eS2) {
			var ss = eIFD.createElement('SCRIPT');
			ss.src = 'http://ads.e-planning.net/egc/4/3c20';
			eIFD.body.appendChild(ss);
		}
		eplLL = true;
		return false;
	}
}

eplCheckStart();

function eplSetAd(eID) {
	if (eplCheckStart()) {
		var opts = (eplArgs.sOpts && eplArgs.sOpts[eID]) ? eplArgs.sOpts[eID] : {};
		if (opts.custF) { document.epl.setCustomAdShow(eID,opts.custF); }
		document.epl.setSpace(eID, opts);
	} else {
		setTimeout('eplSetAd("'+eID+'");', 250);	
	}
}
function eplAD4(eID, opts) {
	document.write('<div id="eplAdDiv'+eID+'"></div>');
	if (!opts) opts = {t:1};
	if (!eplArgs.sOpts) { eplArgs.sOpts = {}; }
	eplArgs.sOpts[eID] = opts;
	eplSetAd(eID);
}

function eplCustomShow(adsArray) {
	var r=''; pad=''; a1=false;
	// Variables para personalizar:
	var adsVert = true;
	var imgFloat = 'left';
	var cBG = '';
	var iBG = '';
	var url_link_header = '';
	var url_link_footer = '';
	var iborder_top_url = '';
	var iborder_top_wh = [0,0];
	var iborder_bottom_url = '';
	var iborder_bottom_wh = [0,0];
	var iborder_left_url = '';
	var iborder_left_wh = [0,0];
	var iborder_right_url = '';
	var iborder_right_wh = [0,0];
	var style_main = "";
	var style_table = "padding:0px; margin:0px; width:160px; height:auto;";
	var style_cell  = "border:3px solid #1162A9;background-color: #ffffff; width:100%; height:auto; height: 80px; vertical-align:text-top;";
	var style_title = "font-size:11px; text-decoration:none; color:#3d76ab; font-family:Arial,Helvetica,sans-serif; font-weight: bold; display: inline;";
	var style_desc  = "font-size:10px; text-decoration:none; color:#515151; font-family:Arial,Helvetica,sans-serif;";
	var style_url   = "font-size:10px; text-decoration:none; color:#515151; font-family:Arial,Helvetica,sans-serif; font-weight: bold;";
	// fin variables personalizables
	for (var i=0; i<adsArray.length; i++) {
		var ad = adsArray[i];
		if (!ad.shown && (1==ad.t||2==ad.t||7==ad.t||8==ad.t||41==ad.t) && !(7==ad.e||8==ad.e)) {
			$("#sponsor4Title").css("display","block");
			if (!a1) {
				r+= '<table cellpadding=0 cellspacing=0 style="'+ style_main + (cBG?'background-color:'+cBG+';':'')+(iBG?'background-image:url('+iBG+');':'') +'">';
				//TOP:
				r+= '<tr><th colspan=3 width="'+iborder_top_wh[0]+'px" height="'+iborder_top_wh[1]+'px">';
				if (url_link_header) r+= '<a href="'+url_link_header+'">';
				r+= '<img border=0 src="'+iborder_top_url+'" width="'+iborder_top_wh[0]+'px" height="'+iborder_top_wh[1]+'px" />';
				if (url_link_header) r+= '</a>';
				r+= '</th></tr>';
				//LEFT:
				r+= '<tr><td width="'+iborder_left_wh[0]+'px" height="'+iborder_left_wh[1]+'px">'
				r+= '<img border=0 src="'+iborder_left_url+'" width="'+iborder_left_wh[0]+'px" height="'+iborder_left_wh[1]+'px" />';
				r+= '</td><td align=left><table cellspacing=0 border="0" style="border-collapse:collapse; '+ style_table +'">';
				if (!adsVert) { r+= '<tr>'; }
				a1 = true;
			} else {
				pad = adsVert ? 'padding-top:10px' : 'padding-left:10px';
			}
			if (adsVert) { r+= '<tr>'; }
			r+= '<td style="'+ style_cell +'">';
			if (41==ad.t) { // link de texto				
				r+= '<a target="_blank" href="'+ ad.lU +'" style="'+ style_title +'">'+ ad.tit +'</a>';
				if (ad.desc) r+= '<br/><span style="'+ style_desc +'">'+ ad.desc +'</span>';
				if (ad.urlv) r+= '<br/><a target="_blank" href="'+ ad.lU +'" style="'+ style_url +'">'+ ad.urlv +'</a>';
			} else if (!ad.e) { // flash o imagen sin efecto
				r+= ad.getBaseTag();			
			} else { // imagen+texto
				r+= '<div'+(imgFloat?' style="float:right;"':'')+'><a target="_blank" href="'+ ad.lU +'"><img src="'+ ad.iurl +'" border=0 /></a></div>';
				if (33!=ad.e) r+= '<a target="_blank" href="'+ ad.lU +'" style="'+ style_title +'">'+ ad.tit +'</a>';
				if (34==ad.e || 35==ad.e) r+= '<br/>';
				r+= '<span style="'+ style_desc +'">'+ ad.desc +'</span>';
				if (ad.urlv) r+= '<br/><a target="_blank" href="'+ ad.lU +'" style="'+ style_url +'">'+ ad.urlv +'</a>';
			}
			r+= '</td>';
			if (adsVert) r += '</tr>';
			ad.shown = true;		
		}
	}
	if (a1) {
		if (!adsVert) r+= '</tr>';
		r+= '</table></td>';
		//RIGHT:
		r+= '<td width="'+iborder_right_wh[0]+'px" height="'+iborder_right_wh[1]+'px">'
		r+= '<img border=0 src="'+iborder_right_url+'" width="'+iborder_right_wh[0]+'px" height="'+iborder_right_wh[1]+'px" />';
		r+= '</td></tr>';		
		//BOTTOM:
		r+= '<tr><th colspan=3 width="'+iborder_bottom_wh[0]+'px" height="'+iborder_bottom_wh[1]+'px">';
		if (url_link_footer) r+= '<a href="'+url_link_header+'">';
		r+= '<img border=0 src="'+iborder_bottom_url+'" width="'+iborder_bottom_wh[0]+'px" height="'+iborder_bottom_wh[1]+'px" />';
		if (url_link_footer) r+= '</a>';
		r+= '</th></tr>';		
		r+= '</table>';
	}
	return r;
}

