﻿function pintaTitular(cual) {
    //document.writeln(detalleComentario[1].fecha+"<br>");
    //document.writeln(detalleComentario[1].hora+"<br>");
    //document.writeln(detalleComentario[1].titulo+"<br>");
    //document.writeln(detalleComentario[1].texto+"<br>");
    //document.writeln(detalleComentario[1].valores+"<br>");
    //document.writeln(detalleComentario[1].urlDetalle+"<br>");
    tmp = detalleComentario[cual].hora;
    tmp = tmp.substr(0, 2) + ":" + tmp.substr(2, 2);
    document.write(tmp + " " + detalleComentario[cual].titulo);
}
function pintaTexto(cual) {
    texto_tmp = detalleComentario[cual].texto;
    texto_tmp = replaceHTML(texto_tmp);
    t = texto_tmp.indexOf(".", 120);
    if (t > 180) {
        tmp = texto_tmp.indexOf(" ", 180);
        p = ".";
    } else {
        tmp = t + 1;
        p = "";
    }
    document.write(texto_tmp.substr(0, tmp) + p + "..");
}
function abreDetalle(cual) {
    //window.open(,"detalle","_blank");
    tt = detalleComentario[cual].urlDetalle;
    for (i = 0; i <= tt.length; i++) {
        tt = tt.replace("?", "[1]");
        tt = tt.replace("=", "[2]");
        tt = tt.replace("&", "[3]");
    }
    encode = tt;
    //alert(tt);
    document.location = "norbolsa.asp?encode=" + encode;
}
function escribeTodo() {
    for (i = 0; i <= 2; i++) {
        //document.write("<font color='#CC3300' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong><a href='javascript:abreDetalle(" + i + ");'>")
        document.write("<font color='#4D4D4D' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>")
        pintaTitular(i);
        document.write("</strong></font><br>");
        document.write("<font color='#4D4D4D' size='1' face='Verdana, Arial, Helvetica, sans-serif'>");
        pintaTexto(i);
        document.write("</font><br>");
    }
}
function replaceHTML(contenido) {
    contenido = contenido.ReplaceAll("<b>", "");
    contenido = contenido.ReplaceAll("</b>", "");
    contenido = contenido.ReplaceAll("<strong>", "");
    contenido = contenido.ReplaceAll("</strong>", "");
    contenido = contenido.ReplaceAll("<i>", "");
    contenido = contenido.ReplaceAll("</i>", "");
    contenido = contenido.ReplaceAll("<em>", "");
    contenido = contenido.ReplaceAll("</em>", "");
    contenido = contenido.ReplaceAll("<u>", "");
    contenido = contenido.ReplaceAll("</u>", "");
    return contenido; 
}
String.prototype.ReplaceAll = function(stringToFind,stringToReplace){
    var temp = this;
    var index = temp.indexOf(stringToFind);
        while(index != -1){
            temp = temp.replace(stringToFind,stringToReplace);
            index = temp.indexOf(stringToFind);
        }
        return temp;
    }
/*
//Loop de Imagenes
var tpoSalto = 4000;
var losIndices = new Array('IBEX', 'CAC40', 'DAX', 'NASDQ');
//  var losIndices= new Array('IBEX', 'FTSE', 'CAC40', 'DAX', 'DJI', 'NASDQ', 'ST50E');
var imagenActual = -1;
var elTemporizador = 0;
function quitarTodos() {
    for (var i = 0, len = losIndices.length; i < len; i++) {
        muestra('indice' + i, false);
    }
}
function poner(laOpcion) {
    if (laOpcion != null) {
        quitarTodos();
        clearTimeout(elTemporizador);
        var laOpcionAux = laOpcion + '';
        for (var i = 0, len = losIndices.length; i < len; i++) {
            if (laOpcionAux.indexOf(losIndices[i]) != -1) {
                muestra('indice' + i, true);
                imagenActual = i;
            }
        }
    }
}
function ponerIndice(laOpcion) {
    clearTimeout(elTemporizador);
    quitarTodos();
    muestra(laOpcion, true);
    imagenActual = laOpcion.substring(6, laOpcion.length);
}
function muestra(nombre, on) {
    var capa = document.layers ? document.layers[nombre] : (document.all ? document.all[nombre] : document.getElementById(nombre))
    if ((document.images) && (capa)) {
        var style = document.layers ? capa : capa.style
        if (on)
            style.visibility = document.layers ? "show" : "visible"
        else
            style.visibility = document.layers ? "hide" : "hidden"
    }
}
function continuar() {
    elTemporizador = setTimeout('seguir()', tpoSalto);
}
function seguir() {
    var imagenAntes = imagenActual;
    if (imagenAntes < 0) { imagenAntes = 0; }
    if (++imagenActual == losIndices.length) {
        imagenActual = 0;
    }
    eval("muestra('indice" + imagenAntes + "',false)");
    eval("muestra('indice" + imagenActual + "',true)");
    elTemporizador = setTimeout('seguir()', tpoSalto);
}
function init() {
    seguir();
}
*/
