﻿// JScript File

var la_Perguntas = new Array();
var la_Respostas = new Array();
var lo_txtPerguntasRespostas = null;
var li_i = 0;

function HairSelecionaResposta(Pergunta, Resposta) {

    var ls_PerguntasRespostas = '';
    var li_x = 0;
    var lb_Existe = false;
    
    for (li_x = 0; li_x < li_i; li_x++) {    
        if (la_Perguntas[li_x] == Pergunta) {
            la_Perguntas[li_x] = Pergunta;
            la_Respostas[li_x] = Resposta;
            lb_Existe = true;
        }
    }
    
    if (lb_Existe == false) {
        la_Perguntas[li_i] = Pergunta;
        la_Respostas[li_i] = Resposta;
        li_i++;
    }    
        
    for (li_x = 0; li_x < li_i; li_x++) {    
        ls_PerguntasRespostas = ls_PerguntasRespostas + la_Perguntas[li_x] + '!' + la_Respostas[li_x] + ',';        
    }  
        
    la_PerguntasRespostas = document.getElementById('txtPerguntasRespostas');
    la_PerguntasRespostas.value = ls_PerguntasRespostas;
    
}

function AdicionaProdutosTray(Links){

    var li_x = 0;    
    var li_y = 0;
    var vTimer = null;
                      
    for (li_x = 0; li_x < Links.length; li_x++) {                                                           

        //vTimer = window.setTimeout(CarregaIFrame(Links[li_x]), 5000);
        //alert(Links[li_x]);
        CarregaIFrame(Links[li_x], li_x);
        
    }   
        
    window.location = 'http://loja.tray.com.br/loja/carrinho.php?loja=102678';
    return false;
    
}

function CarregaIFrame(Link, Codigo) {

    var lo_IFrame = document.getElementById('ifrAdicionaProdutosTray!' + Codigo);
    var ll_x = 0;

    lo_IFrame.src = Link; 
               
            
    document.onreadystatechange = function() {                             
    
        while (ll_x == 0) {
                            
            if (document.readyState == 'complete') {                                                
                ll_x = 1;
                return false;                     
            }
        }
                            
    }; 
}