﻿// JavaScript File
/// Browser detection
    var bVer;
    var useragent = navigator.userAgent;
    var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
    var pos = useragent.indexOf('MSIE');
    if(pos > -1) {
      bVer = useragent.substring(pos + 5);
      var pos = bVer.indexOf(';');
      bVer = bVer.substring(0,pos);
    }
    var pos = useragent.indexOf('Opera');
    if(pos > -1) {
      bVer = useragent.substring(pos + 6);
      var pos = bVer.indexOf(' ');
      bVer = bVer.substring(0, pos);
    }
    if(bName == "Netscape") {
      var bVer = useragent.substring(8);
      var pos = bVer.indexOf(' ');
      bVer = bVer.substring(0, pos);
    }
    if(bName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
      var pos = useragent.lastIndexOf('/');
      bVer = useragent.substring(pos + 1);
    }
  //*********************************************************************
  //******************* V E R S I O N E S *******************************
  //*********************************************************************
  // Definicion de objetos para gestion de versiones
  var objVersiones = new oVersiones();
  // objeto Version
  function oCat_version(idVersion, version)
  {
    this.idVersion = idVersion;
    this.version = version;
  }
  // Coleccion de versiones
  function oVersiones()
  {
    this.no=0;
    this.vVersion=-1;
    this.version='';
    this.aVersiones = new Array();
    this.Agrega = fnAgregaVersion;
    this.obtenDesc=fnObtenDescVersion;
    this.ActualizaValores = fnActualizaDesplegadoVersiones;
    this.despliega = fnDespliegaVersiones;
    this.CambiaVersion=fnCambiaVersion;
  }
  // Permite agregar una version a la coleccion   
  function fnAgregaVersion(idVersion, version)
  {
    this.aVersiones[this.no] = new oCat_version(idVersion,version);
    this.no++;
  }
  // Refresca la visualizacion de valores desplegados   
  function fnActualizaDesplegadoVersiones(id, texto)
  {
    this.vVersion = id;
    this.version=texto;
    var color=objCat_color.PintaBarraColores(objVersiones.vVersion, "colores", objCat_colorext, -1);
    objCat_color.idColorExt=color;
    objCat_color.ColorExt=objCat_colorext.BuscaNombreColor(color);
    objCat_color.idColorInt = objCat_color.obtenColorInt(objVersiones.vVersion, objCat_color.idColorExt);
    objCat_color.ColorInt = objCat_colorint.obtenDesc(objCat_color.idColorInt);
    objCat_color.PintaImagen(objVersiones.vVersion,objCat_color.idColorExt);
    objCat_colorint.PintaBarraVestiduras('vestiduras');
    objCat_colorint.PintaImagen(objCat_color.idColorInt);
    objTipoPinturas.TipoPintura = objTipoPinturas.obtenDesc(objCat_colorext.ObtenTipoPintura(objCat_color.idColorExt));
    fnDrawData(objCat_color.ColorExt, objTipoPinturas.TipoPintura, objCat_color.ColorInt);
  }

  
  // metodo de despliege de versiones
  // var obj: Es un tag de tipo DIV en donde se despliegan los datos
  function fnDespliegaVersiones(obj) 
  {
    var l = document.getElementById(obj);
    if(this.aVersiones[0]!=null) document.getElementById("nodo").innerHTML=this.version;
    for(var i=0; i<this.aVersiones.length; i++)
    {
      // <a href="#" style="cursor:pointer" onclick="change(4,'GLS 2006')">GLS 2006</a>
      var anchor = document.createElement("a");
      anchor.href="javascript:objVersiones.CambiaVersion(" + this.aVersiones[i].idVersion + ",\"" + this.aVersiones[i].version + "\")";
      var obj=document.createTextNode(this.aVersiones[i].version);      
      anchor.appendChild(obj);            
      l.appendChild(anchor);
    }
  }

  // metodo para obtener la descripcion de una transmision en base a su ID
  function fnObtenDescVersion(id)
  {
    var found=false;
    var i=0;
    var tot = this.aVersiones.length;
    while(!found && i<tot)
    {
      if(this.aVersiones[i].idVersion==id) found=true;
      else i++;
    }
    if(found) return this.aVersiones[i].version;
    else return "";
  }
  // metodo que actualiza en base a la seleccion de una version
  function fnCambiaVersion(id, texto)
  {
    document.getElementById("nodo").innerHTML=texto; // actualizar valor desplegado del dropdown
    contractall(); // contraer menu
    objVersiones.ActualizaValores(id,texto); // refrescar valores en base a la nueva version
  }
  
  //*********************************************************************
  //******************* T R A N S M I S I O N E S ***********************
  //*********************************************************************
  // Definicion de objetos para gestion de transmisiones
  var objTransmisiones = new oTransmisiones();
  function oTransmision(id, descripcion)
  {
    this.id = id;
    this.descripcion = descripcion;
  }  
  // Coleccion de transmisiones
  function oTransmisiones()
  {
    this.no=0;
    this.vTrans=-1;
    this.aTransmisiones = new Array();
    this.Agrega = fnAgregaTransmision;
  }
  // Permite agregar una version a la coleccion   
  function fnAgregaTransmision(idTransmision, transmision)
  {
    this.aTransmisiones[this.no] = new oTransmision(idTransmision,transmision);
    this.no++;
  }

  //*********************************************************************
  //******************* T I P O   D E   P I N T U R A S *****************
  //*********************************************************************
  // Definicion de objetos para gestion de Tipos de pinturas
  var objTipoPinturas = new oTipoPinturas();
  // objeto TipoPinturas
  function oTipoPintura(idTipoPintura, tipo)
  {
    this.idTipoPintura = idTipoPintura;
    this.tipo = tipo;
  }
  
  // Coleccion de TipoPinturas
  function oTipoPinturas()
  {
    this.no=0;
    this.vTipoPintura=-1;
    this.TipoPintura='';
    this.aTipoPinturas = new Array();
    this.Agrega = fnAgregaTipoPintura;
    this.obtenDesc = fnObtenDescTipoPintura;
  }
  // Permite agregar una version a la coleccion   
  function fnAgregaTipoPintura(idTipoPintura, tipo)
  {
    this.aTipoPinturas[this.no] = new oTipoPintura(idTipoPintura, tipo);
    this.no++;
  }
  // metodo para obtener la descripcion de un tipo de pintura en base a su ID
  function fnObtenDescTipoPintura(id)
  {
    var found=false;
    var i=0;
    var tot = this.aTipoPinturas.length;
    while(!found && i<tot)
    {
      if(this.aTipoPinturas[i].idTipoPintura==id) found=true;
      else i++;
    }
    if(found) return this.aTipoPinturas[i].tipo;
    else return "";
  }

  //*********************************************************************
  //**************************** C O L O R E S **************************
  //*********************************************************************
  // Definicion de objetos para gestion de Catalogo de colores externos e
  // internos en base a la version
  var objCat_color = new oCat_colores();
  // objeto oCat_color
  function oCat_color(idColorExt, idColorInt, idVersion, idImgGrande)
  {
      this.idColorExt = idColorExt;
      this.idColorInt = idColorInt;
      this.idVersion = idVersion;
      this.idImgGrande = idImgGrande;
  }
  
  // Coleccion de colores
  function oCat_colores()
  {
    this.no=0;
    this.idColorInt=-1;
    this.ColorInt='';
    this.idColorExt=-1;
    this.ColorExt='';
    this.aCat_colores = new Array();
    this.ObtenImagen = fnObtenImagenAuto;
    this.PintaImagen = fnPintaImagenAuto;
    this.ObtenColoresXVersion = fnObtenColoresXVersion;
    this.PintaBarraColores = fnPintaBarraColores;
    this.ActualizaValores = fnActualizaValores;
    this.ObtenVestiduras = fnObtenVestiduras;
    this.Agrega = fnAgregaCat_color;
    this.obtenColorInt = fnobtenColorInt;
  }
  // Permite agregar una version a la coleccion   
  function fnAgregaCat_color(idColorExt, idColorInt, idVersion, idImgGrande)
  {
    this.aCat_colores[this.no] = new oCat_color(idColorExt, idColorInt, idVersion, idImgGrande);
    this.no++;
  }
  // Devuelve el nombre de la imagen en base a la version y el color externo
  function fnObtenImagenAuto(version, color)
  {
    var found=false;
    var i=0;
    var tot = this.aCat_colores.length;
    while(!found && i<tot)
    {
      if(this.aCat_colores[i].idColorExt==color && this.aCat_colores[i].idVersion==version) found=true;
      else i++;
    }
    if(found) return this.aCat_colores[i].idImgGrande;
    else return "";
  }
  // 
  function fnPintaImagenAuto(version, color)
  {
    var imagen;
    imagen = objCat_color.ObtenImagen(version, color);      
    document.getElementById("idCoche").src=imagen;  
  }

  // Devuleve el id del color interno
  function fnobtenColorInt(version, color)
  {
    var found=false;
    var i=0;
    var tot = this.aCat_colores.length;
    while(!found && i<tot)
    {
      if(this.aCat_colores[i].idColorExt==color && this.aCat_colores[i].idVersion==version) found=true;
      else i++;
    }
    if(found) return this.aCat_colores[i].idColorInt;
    else return "";
  }
  
  // metodo para la obtencion de ids de colores exteriores en base a una version de auto
  function fnObtenColoresXVersion(version)
  {
    var a = new Array();
    var i=0;
    var tot = this.aCat_colores.length;
    while(i<tot)
    {
      if(this.aCat_colores[i].idVersion==version) a[a.length]=this.aCat_colores[i].idColorExt;
      i++;
    }
    return a.sort();
  }
  // metodo para la obtencion de ids de colores interiores en base a una version de auto y color externo
  function fnObtenVestiduras(version, color)
  {
    var a = new Array();
    var i=0;
    var tot = this.aCat_colores.length;
    while(i<tot)
    {
      if(this.aCat_colores[i].idVersion==version && this.aCat_colores[i].idColorExt==color) a[a.length]=i;
		//a[a.length]=this.aCat_colores[i].idColorInt;
      i++;
    }
    return a.sort();
  }
  
  // metodo para establecer el nuevo valor para el color del auto y repintar
  function fnActualizaValores(id, texto, tipopintura)
  {
    this.idColorExt=id;
    this.ColorExt=texto;
    objTipoPinturas.TipoPintura=tipopintura;
    var color=objCat_color.PintaBarraColores(objVersiones.vVersion, "colores", objCat_colorext, this.idColorExt);
    objCat_color.idColorInt = objCat_color.obtenColorInt(objVersiones.vVersion, objCat_color.idColorExt);
    objCat_color.ColorInt = objCat_colorint.obtenDesc(objCat_color.idColorInt);
    objCat_color.PintaImagen(objVersiones.vVersion,objCat_color.idColorExt);
    objCat_colorint.PintaBarraVestiduras('vestiduras');
    objCat_colorint.PintaImagen(objCat_color.idColorInt);
    objTipoPinturas.TipoPintura = objTipoPinturas.obtenDesc(objCat_colorext.ObtenTipoPintura(objCat_color.idColorExt));
    fnDrawData(objCat_color.ColorExt, objTipoPinturas.TipoPintura, objCat_color.ColorInt);
  }
  
  // metodo que pinta la gama de colores en base a la version y tipo de pintura
  // el metodo regresa siempre el valor del color inicial de la gama para cierto
  // tipo de color, a menos que se pase un valor distinto a -1 como ultimo parametro
  function fnPintaBarraColores(version, place, colores, colorExt)
  {
    var old=0;
    var a = this.ObtenColoresXVersion(version);
    var o = document.getElementById(place);
    var primer_color=-1;
       
    o.innerHTML='';
    var tbl     = document.createElement("table");
    var tblBody = document.createElement("tbody");
    if(colorExt!=-1) 
    {
      primer_color=colorExt;
      this.idColorExt=colorExt;
    }
    for(var i=0; i<colores.aCat_colorext.length; i++)   //itera todos los colores por pintura
    {
      for(var j=0; j<a.length; j++) // itera todos los colores por version
      {  
		
		if(a.length>1){
			if(old!=a[j]) old=a[j];
        	else continue;
		}
		
        if(colores.aCat_colorext[i].idColorExt==a[j])
        {
           if(primer_color==-1) 
           {
             primer_color=a[j];
             this.idColorExt=a[j];
           }
           var row = document.createElement("tr");
           var cell = document.createElement("td");           
           var obj = document.createElement('img');
           var anchor = document.createElement('a');
           var tipo = objTipoPinturas.obtenDesc(objCat_colorext.ObtenTipoPintura(colores.aCat_colorext[i].idColorExt));
           anchor.href="javascript:objCat_color.ActualizaValores(" + a[j] + ",\"" + colores.aCat_colorext[i].colorExt + "\",\"" + tipo + "\")";
           obj.setAttribute("src","../Img/boton_color.png");
           obj.style.backgroundImage="url(" + colores.aCat_colorext[i].idImgConfig + ")";           
           obj.setAttribute("title",colores.aCat_colorext[i].colorExt);           
           obj.setAttribute("className","img"); 
           obj.setAttribute("class","img");           
           anchor.appendChild(obj);                                           
           cell.appendChild(anchor);
           row.appendChild(cell);
           tblBody.appendChild(row);
        }
      }      
    }
    tbl.appendChild(tblBody);
    o.appendChild(tbl);
    tbl.setAttribute("border", "0");
    return primer_color;
  }


  //*********************************************************************
  //**************** C O L O R E S   E X T E R N O S ********************
  //*********************************************************************
  // Definicion de objetos para gestion de Catalogo de colores externos
  var objCat_colorext = new oCat_colorexternos();
  // objeto oCat_colorext
  function oCat_colorext(idColorExt, colorExt, idTipoPintura, idImgConfig)
  {
      this.idColorExt = idColorExt;
      this.colorExt = colorExt;
      this.idTipoPintura = idTipoPintura;
      this.idImgConfig = idImgConfig;
  }
  
  // Coleccion de pinturas
  function oCat_colorexternos()
  {
    this.no=0;
    this.aCat_colorext = new Array();
    this.Agrega = fnAgregaCat_colorext;
    this.ObtenColoresXTipo=fnObtenColoresXTipo;
    this.BuscaNombreColor=fnBuscaNombreColor;
    this.ObtenTipoPintura=fnObtenTipoPintura;
    this.ObtenImagenColor=fnObtenImagenColor;
  }
  // Permite agregar una version a la coleccion   
  function fnAgregaCat_colorext(idColorExt, colorExt, idTipoPintura, idImgConfig)
  {
    this.aCat_colorext[this.no] = new oCat_colorext(idColorExt, colorExt, idTipoPintura, idImgConfig);
    this.no++;
  }
  // metodo para la obtencion de ids de colores exteriores en base a un tipo de pintura
  function fnObtenColoresXTipo(tipo)
  {
    var a = new Array();
    var i=0;
    var tot = this.aCat_colorext.length;
    while(i<tot)
    {
      if(this.aCat_colorext[i].idTipoPintura==tipo) a[a.length]=this.aCat_colorext[i].idColorExt;
      i++;
    }
    return a.sort();
  }
  // Devuleve el nombre del color en base a su ID
  function fnBuscaNombreColor(color)
  {
    var found=false;
    var i=0;
    var tot = this.aCat_colorext.length;
    while(!found && i<tot)
    {
      if(this.aCat_colorext[i].idColorExt==color) found=true;
      else i++;
    }
    if(found) return this.aCat_colorext[i].colorExt;
    else return "";
  }
  // Devuleve el tipo de pintura del color en base a su ID
  function fnObtenTipoPintura(color)
  {
    var found=false;
    var i=0;
    var tot = this.aCat_colorext.length;
    while(!found && i<tot)
    {
      if(this.aCat_colorext[i].idColorExt==color) found=true;
      else i++;
    }
    if(found) return this.aCat_colorext[i].idTipoPintura;
    else return "";
  }
  // Devuleve la imagen del color en base a su ID
  function fnObtenImagenColor(id)
  {
    var found=false;
    var i=0;
    var tot = this.aCat_colorext.length;
    while(!found && i<tot)
    {
      if(this.aCat_colorext[i].idColorExt==id) found=true;
      else i++;
    }
    if(found) return this.aCat_colorext[i].idImgConfig;
    else return "";
  }
  
  //*********************************************************************
  //**************** C O L O R E S   I N T E R N O S  ********************
  //*********************************************************************
  // Definicion de objetos para gestion de Catalogo de colores internos
  var objCat_colorint = new oCat_colorinternos();
  // objeto oCat_colorint
  function oCat_colorint(idColorInt, colorInt, idImgConfigGrande, idImgConfigChica)
  {
      this.idColorInt = idColorInt;
      this.colorInt = colorInt;            
      this.idImgConfigGrande = idImgConfigGrande;
      this.idImgConfigChica = idImgConfigChica;
  }
  
  // Coleccion de pinturas
  function oCat_colorinternos()
  {
    this.no=0;
    this.aCat_colorint = new Array();
    this.Agrega = fnAgregaCat_colorint;
    this.obtenDesc = fnBuscaNombreColorInt;
    this.PintaImagen = fnPintaImagen;
    this.obtenImagenGrande = fnobtenImagenGrande;
    this.obtenImagenChica = fnobtenImagenChica;
    this.PintaBarraVestiduras = fnPintaBarraVestiduras;
    this.ActualizaValores = fnActualizaValoresColorInt;
  }
  // Permite agregar una version a la coleccion   
  function fnAgregaCat_colorint(idColorInt, colorInt, idImgConfigGrande, idImgConfigChica)
  {
    this.aCat_colorint[this.no] = new oCat_colorint(idColorInt, colorInt, idImgConfigGrande, idImgConfigChica);
    this.no++;
  }
  // Devuleve el nombre del color en base a su ID
  function fnBuscaNombreColorInt(color)
  {
    var found=false;
    var i=0;
    var tot = this.aCat_colorint.length;
    while(!found && i<tot)
    {
      if(this.aCat_colorint[i].idColorInt==color) found=true;
      else i++;
    }
    if(found) return this.aCat_colorint[i].colorInt;
    else return "";
  }
  // metodo de recuperacion de imagen vestidura tamanio grande
  function fnobtenImagenGrande(id)
  {
    var found=false;
    var i=0;
    var tot = this.aCat_colorint.length;
    while(!found && i<tot)
    {
      if(this.aCat_colorint[i].idColorInt==id) found=true;
      else i++;
    }
    if(found) return this.aCat_colorint[i].idImgConfigGrande;
    else return "";
  }
  // metodo de recuperacion de imagen vestidura chica
  function fnobtenImagenChica(id)
  {
    var found=false;
    var i=0;
    var tot = this.aCat_colorint.length;
    while(!found && i<tot)
    {
      if(this.aCat_colorint[i].idColorInt==id) found=true;
      else i++;
    }
    if(found) return this.aCat_colorint[i].idImgConfigChica;
    else return "";
  }
  // 
  function fnPintaImagen(id)
  {
     var imagen=objCat_colorint.obtenImagenGrande(objCat_color.idColorInt);     
     document.getElementById("idInterior").src=imagen;
  }

  // metodo que pinta la gama de vestiduras
  function fnPintaBarraVestiduras(place)
  {         
    try
    { 
        var a = objCat_color.ObtenVestiduras(objVersiones.vVersion, objCat_color.idColorExt);
	    var old=-1;
	    var o = document.getElementById(place);
	    o.innerHTML='';
        var tbl = document.createElement("table");
        tbl.setAttribute("border", "0");
        var tblBody = document.createElement("tbody");
	    for(var i=0; i<a.length; i++)
	    {
	      if(old!=a[i]) old=a[i];
	      else continue;
	      var row = document.createElement("tr");
          var cell = document.createElement("td");           
          var obj = document.createElement('img');
          var anchor = document.createElement('a');
          var val = objCat_color.aCat_colores[a[i]].idColorInt;
          var texto = this.obtenDesc(val);
          anchor.href="javascript:objCat_colorint.ActualizaValores(" + val + ",\"" + texto + "\",0)";                
          obj.setAttribute("src","../Img/boton_color.png");                      
          obj.style.backgroundImage="url(" + this.obtenImagenChica(val) + ")";
          obj.setAttribute("title",texto);
          obj.setAttribute("className","img"); 
          obj.setAttribute("class","img");          
          anchor.appendChild(obj);
          cell.appendChild(anchor);                                          
	      row.appendChild(cell);
	      tblBody.appendChild(row); 
	    }
	    // pintado de vestiduras desde paquetes
	    old=-1;
	    a = objPrecios.ObtenPaquetes(objVersiones.vVersion);
	    for(var i=0; i<a.length; i++)
	    {
	      if(old!=a[i]) old=a[i];
	      else continue;
          var pos = objPaquetes.EncuentraPos(a[i]);
          if(pos==-1) continue; // no deberia pasar
          if(objPaquetes.aPaquetes[pos].ImgVestiduraChica=='') continue; // no es vestidura                    
          var val = pos;
          var texto = objPaquetes.aPaquetes[pos].nombre;
          var row = document.createElement("tr");
          var cell = document.createElement("td");           
          var obj = document.createElement('img');
          var anchor = document.createElement('a');
          anchor.href="javascript:objCat_colorint.ActualizaValores(" + pos + ",\"" + texto + "\",1)";           
          obj.setAttribute("src","../Img/boton_color.png");
          obj.style.backgroundImage="url(" + objPaquetes.aPaquetes[pos].ImgVestiduraChica + ")";
          obj.setAttribute('title',texto);
          obj.setAttribute("className","img"); 
          obj.setAttribute("class","img");
          anchor.appendChild(obj);
          cell.appendChild(anchor);                                          
	      row.appendChild(cell);
	      tblBody.appendChild(row); 
	    }	
	    // pegar datos a la pagina
	    tbl.appendChild(tblBody);
        o.appendChild(tbl);
    }
    catch(e)
    {
        alert('Error en desplegado de vestiduras:\n' + e.description);
    }
  }

  // metodo de recalculo de valores
  function fnActualizaValoresColorInt(id, texto, flag)
  {
    if(flag==0)
    {
        objCat_color.idColorInt=id;
        objCat_color.ColorInt=texto;   
        objCat_colorint.PintaImagen(objCat_color.idColorInt);
        objTipoPinturas.TipoPintura = objTipoPinturas.obtenDesc(objCat_colorext.ObtenTipoPintura(objCat_color.idColorExt));
        fnDrawData(objCat_color.ColorExt, objTipoPinturas.TipoPintura, "Vestidura: " + objCat_color.ColorInt);
    }
    else if(flag==1)
    {
        var imagen=objPaquetes.aPaquetes[id].ImgVestiduraGrande;     
        document.getElementById("idInterior").src=imagen;
        objTipoPinturas.TipoPintura = objTipoPinturas.obtenDesc(objCat_colorext.ObtenTipoPintura(objCat_color.idColorExt));
        fnDrawData(objCat_color.ColorExt, objTipoPinturas.TipoPintura, "Paquete: " + texto);
    }
  }

  
  //*********************************************************************
  //************************* P A Q U E T E S ***************************
  //*********************************************************************
  // Definicion de objetos para gestion de Paquetes
  var objPaquetes = new oPaquetes();
  // objeto Paquete
  function oPaquete(id, nombre, ImgVestiduraChica,ImgVestiduraGrande)
  {
    this.id = id;
    this.nombre = nombre;
    this.ImgVestiduraChica=ImgVestiduraChica;
    this.ImgVestiduraGrande=ImgVestiduraGrande;
  }
  // Coleccion de Paquetes
  function oPaquetes()
  {
    this.no=0;
    this.aPaquetes = new Array();
    this.Agrega = fnAgregaPaquete;
    this.EncuentraPos=fnEncuentraPos;
  }
  // Permite agregar un paquete a la coleccion   
  function fnAgregaPaquete(id, nombre, ImgVestiduraChica,ImgVestiduraGrande)
  {
    this.aPaquetes[this.no] = new oPaquete(id, nombre, ImgVestiduraChica,ImgVestiduraGrande);
    this.no++;
  }
  // metodo que regresa la posicion del id del paquete
  function fnEncuentraPos(paquete)
  {
    var found=false;
    var i=0;
    var tot = this.aPaquetes.length;
    while(!found && i<tot)
    {
      if(this.aPaquetes[i].id==paquete) return i;
      else i++;
    }
    return -1;  
  }
  
  //*********************************************************************
  //************************** P R E C I O S ****************************
  //*********************************************************************
  // Definicion de objetos para gestion de versiones
  var objPrecios = new oPrecios();
  // objeto Precio
  function oPrecio(Version,TipoPintura,Transmision,Paquete)
  {
      this.Version = Version;
      this.TipoPintura = TipoPintura;
      this.Transmision = Transmision;
      this.Paquete = Paquete;
  }
  // Coleccion de precios
  function oPrecios()
  {
    this.no=0;
    this.aPrecios = new Array();
    this.ObtenValoresIniciales = fnObtenValoresIniciales;
    this.Agrega = fnAgregaPrecio;
    this.ObtenPinturas=fnObtenPinturas;
    this.ObtenPaquetes=fnObtenPaquetes;
  }
  // Permite agregar un precio a la coleccion   
  function fnAgregaPrecio(Version,TipoPintura,Transmision,Paquete)
  {
    this.aPrecios[this.no] = new oPrecio(Version,TipoPintura,Transmision,Paquete);
    this.no++;
  }  
  // metodo para obtener valores iniciales para mostrar valores
  function fnObtenValoresIniciales()
  {
    for( var i=0 ; i<this.aPrecios.length ; i++ ){
        if (this.aPrecios[i].Version == objVersiones.aVersiones[0].idVersion)
        break;
    }
    var idxInitPrecio = i;
    
    objVersiones.vVersion=this.aPrecios[idxInitPrecio].Version;
    objVersiones.version=objVersiones.obtenDesc(this.aPrecios[idxInitPrecio].Version);    
    objTransmisiones.vTrans=this.aPrecios[idxInitPrecio].Transmision; 
    objPaquetes.vPaquete=this.aPrecios[idxInitPrecio].Paquete;
    objTipoPinturas.vTipoPintura=this.aPrecios[idxInitPrecio].TipoPintura;
    objTipoPinturas.TipoPintura=objTipoPinturas.obtenDesc(this.aPrecios[idxInitPrecio].TipoPintura);
  }  
  // metodo de obtencion de tipos de pintura en base a version
  function fnObtenPinturas(version, transmision)
  {
    var a = new Array();
    for(var i=0; i<this.aPrecios.length; i++)
    {
      if(this.aPrecios[i].Version==version && this.aPrecios[i].Transmision==transmision) a[a.length]=this.aPrecios[i].TipoPintura;
    }
    return a.sort();
  }
  // metodo de obtencion de paquetes en base a version
  function fnObtenPaquetes(version)
  {
    var a = new Array();
    for(var i=0; i<this.aPrecios.length; i++)
    {
      if(this.aPrecios[i].Version==version) a[a.length]=this.aPrecios[i].Paquete;
    }
    return a.sort();
  }
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
  /////////////////////////////////////////
  // metodo de despliege de datos sobre la barra
  function fnDrawData(color,pintura,vestidura)
  {
    var obj = document.getElementById("barra_datos");
    var msg = "Color:" + color;
    msg = msg + "&nbsp;&nbsp;&nbsp;";
    msg = msg + "Pintura:" + pintura;
    msg = msg + "&nbsp;&nbsp;&nbsp;";
    if(vestidura.indexOf(':')>-1) msg = msg + vestidura;
    else msg = msg + "Vestidura:" + vestidura;
    obj.innerHTML=msg;
  }

  
  /////////////////////////////////////////
  // Metodo general de despliege de informacion
  function fnDrawAll()
  {    
    objVersiones.despliega("submenu");
    var color=objCat_color.PintaBarraColores(objVersiones.vVersion, "colores", objCat_colorext, -1);
    objCat_color.idColorExt=color;
    objCat_color.ColorExt=objCat_colorext.BuscaNombreColor(color);
    objCat_color.idColorInt = objCat_color.obtenColorInt(objVersiones.vVersion, objCat_color.idColorExt);
    objCat_color.ColorInt = objCat_colorint.obtenDesc(objCat_color.idColorInt);
    objCat_color.PintaImagen(objVersiones.vVersion,objCat_color.idColorExt);
    objCat_colorint.PintaBarraVestiduras('vestiduras');
    objCat_colorint.PintaImagen(objCat_color.idColorInt);
    objTipoPinturas.TipoPintura = objTipoPinturas.obtenDesc(objCat_colorext.ObtenTipoPintura(objCat_color.idColorExt));
    fnDrawData(objCat_color.ColorExt, objTipoPinturas.TipoPintura, objCat_color.ColorInt);
  }


