function init(n_2measure) {
	
	var b_fl = true, e_frm, k = 0, i;
	if (n_2measure != null){
		items[n_2measure].height = vertical ? td_news.offsetHeight : td_news.offsetWidth;
	}
	for (i = num_news - 1; i >= 0; i--) if (!items[i].height) {
		if (items[i].contenido)	{
			td_news.innerHTML = items[i].contenido;
			return setTimeout("init(" + i + ")", 100);
		}
		b_fl = false;
 	}
	if (!b_fl) return setTimeout("init()", 500)
	div_news.style.visibility='visible';
	if (auto) mueve(1)
}

function mueve(p) { 
	if (anterior <= p && func_interval_news == 0) {	
		anterior = 0
		func_interval_news = setInterval("cambia()", 40) 
	}
} 

function stop(p) { 
	if (anterior < p) anterior = p
	if (func_interval_news != 0) {
		clearInterval(func_interval_news)
		func_interval_news = 0
	}
}


function sleep(segundos) { 
	stop(0); 
	setTimeout("mueve_s()", segundos * 1000) 
}

function mueve_s() {
	pos_noticia -= paso_news
	ajusta() 
	mueve(0)
}

function cambia() {	
	var item = items[noticia_en_pantalla];
	if (pos_noticia > ancho_alto) {
		item = items[noticia_en_pantalla = noticia_en_pantalla == 0 ? num_news - 1 : noticia_en_pantalla - 1]
		pos_noticia = -item.height
		item.cargador()
	}
	else if (pos_noticia < - item.height) {
		item = items[noticia_en_pantalla = noticia_en_pantalla == num_news - 1 ? 0 : noticia_en_pantalla + 1]
		pos_noticia = ancho_alto
		item.cargador()
	}
	var delta = ancho_alto - item.height
	if (item.segundos_pausa_abajo > 0 && pos_noticia >= delta && pos_noticia < paso_news_abs + delta) {
		pos_noticia = delta
		ajusta()
		return sleep (item.segundos_pausa_abajo)
	}
	if (item.segundos_pausa_arriba > 0 && pos_noticia >= 0 && pos_noticia < paso_news_abs) {
		pos_noticia = 0
		ajusta()
		return sleep (item.segundos_pausa_arriba)
	}
	pos_noticia -= paso_news
	ajusta() 
}

function carga_noticia () {
	td_news.innerHTML = this.contenido
	ajusta()
}
var auto = AJUSTES.auto,
vertical = AJUSTES.vertical,
bt_up = new Image(16,16),
bt_down = new Image(16,16),
items = ITEMS,
iframe_news = parent.document.getElementById ? 
	parent.document.getElementById("scroll" + caja_id) : parent.document.all["scroll" + caja_id],
w = AJUSTES.size[0] ? AJUSTES.size[0] : 300,
h = AJUSTES.size[1] ? AJUSTES.size[1] : 100,
ancho_alto = vertical ? h : w,
paso_news = AJUSTES.speed != 0 ? AJUSTES.speed : 1,
func_interval_news = pos_noticia = noticia_en_pantalla = anterior = 0, 
paso_news_abs = Math.abs(paso_news),
num_news = items.length;

iframe_news.style.width = w + 'px';
iframe_news.style.height = h + 'px';
pos_noticia-= 800;

var ajusta = vertical ? 
	function () { div_news.style.top = pos_noticia } :
	function () { div_news.style.left = pos_noticia }
for (var i in items) {
	items[i].cargador = carga_noticia;
}	

mueve(1);

