// identificador de la caja donde se deposita la cotización
var idZonaCotizacion = 'zonaCotizacion';
// fn encargada de recivir validar y colocar la cotización
var fncallback = function (cotizacion) {
        var zonaCotizacion = document.getElementById( idZonaCotizacion );
        if ( !zonaCotizacion ) {return false;}

        if ( typeof cotizacion == 'object' ) {
                if ( typeof cotizacion['USD'] == 'object' && typeof cotizacion['EUR'] == 'object' && typeof cotizacion['ARS'] == 'object' && typeof cotizacion['BRL'] == 'object' ) {
                        var resultado = ''
                        +'<table width="239" border="0" cellspacing="0" cellpadding="0">'
                        +'<tr>'
                        +'<td colspan="7" align="center" class="tdTitle">'
                        +'<img src="/public/imgs/titles/title_cotizacion.gif" width="93" height="18" />'
                        +'</td>'
                        +'</tr><tr>'
                        +'<td class="cotizacionTdTop" width="24">&nbsp;</td>'
                        +'<td class="cotizacionTdTop" width="30"><img src="/public/imgs/icons/band_usa.gif" width="23" height="16" /></td>'
                        +'<td class="cotizacionTdTop" width="12">&nbsp;</td>'
                        +'<td class="cotizacionTdTop" width="31" align="right">'+ cotizacion['USD'].buy +'</td>'
                        +'<td class="cotizacionTdTop" width="10">&nbsp;</td>'
                        +'<td class="cotizacionTdTop" width="31" align="right">'+ cotizacion['USD'].sale +'</td>'
                        +'<td class="cotizacionTdTop" width="101">&nbsp;</td>'
                        +'</tr><tr>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd"><img src="/public/imgs/icons/band_arg.gif" width="23" height="16" /></td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd" align="right">'+ cotizacion['ARS'].buy +'</td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd" align="right">'+ cotizacion['ARS'].sale +'</td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'</tr><tr>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd"><img src="/public/imgs/icons/band_bra.gif" width="23" height="16" /></td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd" align="right">'+ cotizacion['BRL'].buy +'</td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd" align="right">'+ cotizacion['BRL'].sale +'</td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'</tr><tr>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd"><img src="/public/imgs/icons/band_euro.gif" width="23" height="16" /></td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd" align="right">'+ cotizacion['EUR'].buy +'</td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'<td class="cotizacionTd" align="right">'+ cotizacion['EUR'].sale +'</td>'
                        +'<td class="cotizacionTd">&nbsp;</td>'
                        +'</tr>'
                        +'</table>';
                        zonaCotizacion.innerHTML = resultado;
                        zonaCotizacion.className = 'cotizacion';
                        zonaCotizacion.id = 'zonaCotizacionActiva';
                }
        }
        return true;
};

var ListaProyectos = {
    contenedorProyectos: null,
    coleccionDeProyectos: null,
    iniciar: function (proyectos, controles) {
        if (proyectos.size() > 0) {
            // variables para control
            var coleccionDeProyectos = jQuery.makeArray();
            var botonesDeProyectos = '';
            // itera la lista de proyectos
            proyectos.each(function (n) {
                coleccionDeProyectos.push( $(this) );
                botonesDeProyectos += '<li name="'+ n +'"><a href="#" name="'+ n +'"><img name="'+ n +'" src="/public/imgs/btns/btn_slider.gif" width="15" height="15" /></a></li>';
            });
            // si se recuperaron proyectos
            if (coleccionDeProyectos.length > 0) {
                // guarda la lista en el objeto
                this.coleccionDeProyectos = coleccionDeProyectos;
                // selecciona el contenedor de los proyectos
                this.contenedorProyectos = this.coleccionDeProyectos[0].parent();
                // si es posible seleccionar el contenedor de los proyectos inserta los controles y les asigna acciones
                if (this.contenedorProyectos.size() > 0) {
                    controles
                        .html(botonesDeProyectos)
                        .bind('click', function (e) {
                            ListaProyectos.activarProyectoPorNumero($(e.target).attr('name'));
                            return false;
                        });
                        // si finaliza la configuracion correctamente
                        return true;                        
                }
            }
        }
        // no fue posible realizar la configuracion correctamente
        return false;
    },
    // activa un proyecto en funcion al numero de posicion en la coleccion interna
    activarProyectoPorNumero: function (numero) {
        if ( this.coleccionDeProyectos[numero] ) {
            $('#colProyectos').scrollTo(this.coleccionDeProyectos[numero], 1000);
        }
    }
};


$(window).load(function () {


        // inicia la configuracion para mostrar la lista de proyectos con scrollTo
        if ( ListaProyectos.iniciar($('#colProyectos .proyecto'), $('#menuColProyectos')) == true ) {
            // si la configuracion es correcta altera el contenedor de proyectos para que muestre los controles
            $('#contListaProyectos').animate({height: 290});
        }
        
        

    //$('#zonaClima').show();
});
/* proyectos
<li><a href="#"><img src="/public/imgs/btns/btn_slider.gif" width="15" height="15" /></a></li>
<li><a href="#"><img src="/public/imgs/btns/btn_slider.gif" width="15" height="15" /></a></li>
<li><a href="#"><img src="/public/imgs/btns/btn_slider.gif" width="15" height="15" /></a></li>
<li><a href="#"><img src="/public/imgs/btns/btn_slider.gif" width="15" height="15" /></a></li>
<li><a href="#"><img src="/public/imgs/btns/btn_slider.gif" width="15" height="15" /></a></li>
<li><a href="#"><img src="/public/imgs/btns/btn_slider.gif" width="15" height="15" /></a></li>
*/
/* clima
                    <table width="239" height="102" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td height="25" colspan="3" align="center">
                                <img src="/public/imgs/titles/title_clima.gif" width="58" height="20" />
                            </td>
                        </tr><tr>
                            <td class="tdClima" width="79">
                                <img src="/public/imgs/decos/deco_clima.jpg" width="73" height="73" />
                            </td>
                            <td width="10">&nbsp;</td>
                            <td width="150">
                                <p>Humedad: 73%</p>
                                <p>Sensación Térmica: 23ºC</p>
                                <p>Viento: 27Km/hESE</p>
                                <p>Presión Atm.: 1011.9 mb</p>
                            </td>
                        </tr>
                    </table>
*/
/* Cotizacion
                    
*/
