function bshow(p) {
	//PASO#1: Esconder todo primero
	var ptotal = bf[p].split("|").length;
	for (var i=0; i < ptotal; i++) {
		var hid = 'BP' + p + '_' + i;
		document.getElementById(hid).style.display = "none";
	}
	//PASO#2: Mostrar solo el ID deseado
	var sid = 'BP' + p + '_' + pid[p];
	document.getElementById(sid).style.display = "block";
}
function bplay(p){
	bshow(p); pid[p]++;
	var ptotal = bf[p].split("|").length;
	if(pid[p] ==  ptotal){pid[p] = 0;}
	btimer=setTimeout(function(){bplay(p);}, ptime[p]);
}

function putflash(p,n,c){
	var bfile = bf[p].split("|");
	var blink = bl[p].split("|");
	var btext = bt[p].split("|");
	var blinkopen = blo[p].split("|");
	var target = '';	if (blinkopen[n]==1){target = 'target="_blank"';}
	var flash = '<div class="bflash '+c+'" id="BP'+p+'_'+n+'">';
	flash += 	'<a style="width: '+pw[p]+'px; height: '+ph[p]+'px;" href="'+blink[n]+'" ' + target + ' title="' + btext[n] + '" > </a>';
	flash +=		'<object width="'+pw[p]+'" height="'+ph[p]+'">';
	flash +=		'<param name="movie" value="'+bpath+'/'+bfile[n]+'">';
	flash +=		'<param name="wmode" value="transparent">';
	flash +=		'<param name="quality" value="high">';
	flash +=		'<embed '+blink[n]+' width="'+pw[p]+'" height="'+ph[p]+'" src="'+bpath+'/'+bfile[n]+'" wmode="transparent" quality="high" type="application/x-shockwave-flash"></embed>';
	flash +=		'</object>';
	flash += 	'</div>';
	return flash;
}
function putimage(p,n,c){
	var bfile = bf[p].split("|");
	var blink = bl[p].split("|");
	var btext = bt[p].split("|");
	var blinkopen = blo[p].split("|");
	var target = '';	if (blinkopen[n]==1){target = 'target="_blank"';}
	
	var ima = '<div class="'+c+'" id="BP'+p+'_'+n+'">';
	ima += '<a href="'+blink[n]+'" ' + target + ' title="' + btext[n]+'">';
	ima += '<img src="'+bpath+'/'+bfile[n]+'" width="'+pw[p]+'" height="'+ph[p]+'" alt="" border="0" hspace="0" vspace="0"  />';
	ima += '</a>';
	ima += '</div>';
	return ima;
}
function createbanners(){
	for (var p=0; p < bf.length; p++) {			// Para cada posicion
		bfile = bf[p].split("|"); var bjuntos = '';
		for (var b=0; b < bfile.length; b++) {	// Para c/Banner de esa posicion
			var ext = checkext(bfile[b]); var banner=''; var c='hidden';
			if (b==0) {c='';}
			if (ext == 'swf') {banner = putflash(p,b,c); }
			else {banner = putimage(p,b,c); }
			bjuntos += banner;
		}
		document.getElementById('banner'+p).innerHTML = bjuntos;
	}
	banim();
	return;
}

function checkext(fn){
	var filelength = parseInt(fn.length) - 3; 
	var fileext = fn.substring(filelength,filelength + 3);
	return fileext;
}
function banim(){
	for (var p=0; p < bf.length; p++) {	bplay(p);}
}


