
/* Sección jquery*/

        $(document).ready(function(){

		/*barra de desplazamiento jscrollpane*/
		  $('#conteneofer').jScrollPane({showArrows:true,scrollbarWidth:10, scrollbarMargin:20});
		  $('#seccionpriv').jScrollPane({showArrows:true,scrollbarWidth:10, scrollbarMargin:20});
		  $('#calidadscr').jScrollPane({showArrows:true,scrollbarWidth:10, scrollbarMargin:20});
		/*select con estilos distintos */
          $("select, input:checkbox, input:radio, input:file").uniform();
		  
		  /*$("promo").uniform();*/
		  
          $('#fotos').click(function(){});
          
		  
		  $('#stockph a').lightBox({
		     txtImage: 'Fotograf\u00eda'
		  });
		  
          $('#seccionpiso2 a').lightBox({
     
             txtImage: 'Fotograf\u00eda'

           });

          $('#seccionpisofc a').lightBox({
     
             txtImage: 'Fotograf\u00eda'

          });

          $('#seccionofim a').lightBox({

             txtImage: 'Foto xxx'

          });

          $('#seccionofim1 a').lightBox({

             txtImage: 'Foto xxx'

          });

          $('#seccionofim2 a').lightBox({

             txtImage: 'Foto xxx'

          });

          $('#seccionofim3 a').lightBox({

             txtImage: 'Foto xxx'

          });


          $('#seccionofim4 a').lightBox({

             txtImage: 'Foto xxx'

          });

          $('#seccionofim5 a').lightBox({

             txtImage: 'Foto xxx'

          });

          $('#seccionofim6 a').lightBox({

             txtImage: 'Foto xxx'

          });

          $('#seccionofim7 a').lightBox({

             txtImage: 'Foto xxx'

          });

/* Eventos de objetos*/
            $('#cjstock').click(function(){
            
                document.location.href
                alert("pulsación");
            
            
            });
          

        });  
       
 /* Sección googleMaps */
        function cargagm(){

         var icon = new GIcon();
              icon.image = './images/logo1.jpg';
              icon.shadow = './images/logo1.jpg';
              icon.iconSize = new GSize(25, 22);
              icon.shadowSize = new GSize(25, 22);
              icon.iconAnchor = new GPoint(0, 30);
              icon.infoWindowAnchor = new GPoint(0,20);

         var direccion = "<address> Grupo Inmobiliario Prado Recomba <br> Avda. de los Derechos Humanos, 26 Local 3 <br> (Entrada por c/Fraternidad s/n)<br> 28914 Leganes (Madrid) </address>";

         var marcador = new GMarker(new GLatLng(40.32340564926664,-3.7605348229408264), icon);
         GEvent.addListener(marcador, 'click', function(){marcador.openInfoWindowHtml(direccion);});
         var map = new GMap2(document.getElementById('mapa'));
             map.setCenter(new GLatLng(40.32340564926664,-3.7605348229408264), 15);
             map.setMapType(G_NORMAL_MAP);
             map.addControl(new GSmallMapControl());
             map.addControl(new GMapTypeControl());
             map.addOverlay(marcador);
             marcador.openInfoWindowHtml(direccion); 

        }

/* Sección Ajax */
        function carga(tipo){
          
           switch (tipo){

                case '1':

                   for(var i=document.menu2.combo2.options.length; i>=0;i--) {document.menu2.combo2[i]=null;}
                   for(var i=document.menu3.combo3.options.length; i>=0;i--) {document.menu3.combo3[i]=null;}
                   for(var i=document.menu4.combo4.options.length; i>=0;i--) {document.menu4.combo4[i]=null;}
                   for(var i=document.menu5.combo5.options.length; i>=0;i--) {document.menu5.combo5[i]=null;}

                   document.menu2.combo2[0]=new Option("Selec. Habitaciones");
 
                   var texto =document.menu1.promo[document.menu1.promo.selectedIndex].text;
                   var numero=document.menu1.promo.value;

                   $.get('./prueba.php','id_promocion='+numero+'&caso=1',processResponse);

                break;

                case '2':

                   for(var i=document.menu3.combo3.options.length; i>=0;i--) {document.menu3.combo3[i]=null;}
                   for(var i=document.menu4.combo4.options.length; i>=0;i--) {document.menu4.combo4[i]=null;}
                   for(var i=document.menu5.combo5.options.length; i>=0;i--) {document.menu5.combo5[i]=null;}

                   document.menu3.combo3[0]=new Option("Selec. Ubicaci\u00f3n");

                   var texto =document.menu1.promo[document.menu1.promo.selectedIndex].text;
                   var numero=document.menu1.promo.value;
                   var texto2 =document.menu2.combo2[document.menu2.combo2.selectedIndex].text;
                   var numero2=document.menu2.combo2.selectedIndex;
                   
                   $.get('./prueba.php','id_promocion='+numero+'&habitaciones='+texto2+'&caso=2',processResponse);

                break;

                case '3':

                   for(var i=document.menu4.combo4.options.length; i>=0;i--) {document.menu4.combo4[i]=null;}
                   for(var i=document.menu5.combo5.options.length; i>=0;i--) {document.menu5.combo5[i]=null;}

                   document.menu4.combo4[0]=new Option("Selec. Superficie");

                   var texto   =document.menu1.promo[document.menu1.promo.selectedIndex].text;
                   var numero  =document.menu1.promo.value;
                   var texto2  =document.menu2.combo2[document.menu2.combo2.selectedIndex].text.substring(0,document.menu2.combo2[document.menu2.combo2.selectedIndex].text.indexOf(" "));
                   var numero2 =document.menu2.combo2.selectedIndex;
                   var texto3  =document.menu3.combo3[document.menu3.combo3.selectedIndex].text;
                   var numero3 =document.menu3.combo3.selectedIndex;

                   $.get('./prueba.php','id_promocion='+numero+'&habitaciones='+texto2+'&id_ubicacion='+texto3+'&caso=3',processResponse);

                break;

                case '4':

                   for(var i=document.menu5.combo5.options.length; i>=0;i--) {document.menu5.combo5[i]=null;}

                   document.menu5.combo5[0]=new Option("Selec. Tipolog\u00eda");

                   var texto   =document.menu1.promo[document.menu1.promo.selectedIndex].text;
                   var numero  =document.menu1.promo.value;
                   var texto2  =document.menu2.combo2[document.menu2.combo2.selectedIndex].text.substring(0,document.menu2.combo2[document.menu2.combo2.selectedIndex].text.indexOf(" "));
                   var numero2 =document.menu2.combo2.selectedIndex;
                   var texto3  =document.menu3.combo3[document.menu3.combo3.selectedIndex].text;
                   var numero3 =document.menu3.combo3.selectedIndex;
                   var texto4  =document.menu4.combo4[document.menu4.combo4.selectedIndex].value;
                   var numero4 =document.menu4.combo4.selectedIndex;

                   $.get('./prueba.php','id_promocion='+numero+'&habitaciones='+texto2+'&id_ubicacion='+texto3+'&id_superficiegral='+texto4+'&caso=4',processResponse);

                break;

                case '5':

                   var texto   =document.menu1.promo[document.menu1.promo.selectedIndex].text;
                   var numero  =document.menu1.promo.value;
                   var texto2  =document.menu2.combo2[document.menu2.combo2.selectedIndex].text.substring(0,document.menu2.combo2[document.menu2.combo2.selectedIndex].text.indexOf(" "));
                   var numero2 =document.menu2.combo2.selectedIndex;
                   var texto3  =document.menu3.combo3[document.menu3.combo3.selectedIndex].text;
                   var numero3 =document.menu3.combo3.selectedIndex;
                   var texto4  =document.menu4.combo4[document.menu4.combo4.selectedIndex].value;
                   var numero4 =document.menu4.combo4.selectedIndex;
                   var texto5  =document.menu5.combo5[document.menu5.combo5.selectedIndex].text;

                    document.location.href='./piso.php?id_promocion='+numero+'&habitaciones='+texto2+'&id_ubicacion='+texto3+'&id_superficiegral='+texto4+   '&id_tipologia=' + texto5 + "&caso=5";

                break;


           }
    

        }

        function processResponse(data,status){
                  
          var dato     = data;
          var caso     = dato.slice(dato.indexOf('%')+1);
          dato         = dato.substring(0,dato.indexOf('%'));
          var numero   = dato.slice(dato.indexOf('?')+1)-1;
          var contador = 1; 
          dato         = dato.substring(0,dato.indexOf('?'));
          paso1        = false;
          paso2        = false;
          paso3        = false;
          paso4        = false;
       
          for ( var i = 0; i<=numero; i++){
                          
             inicio   = 0;
             dato     = dato.slice(dato.indexOf('&')+1);
             fin      = dato.indexOf('&');
             auxiliar = dato.substring(inicio,fin);

             switch(caso){

                case '1':

                   document.menu2.combo2[i+1]=new Option(auxiliar + ' habitaciones',auxiliar); 

                break;

                case '2':

                   document.menu3.combo3[i+1]=new Option(auxiliar); 


                break;

                case '3':

                  if (auxiliar<=60 && auxiliar>40 && paso1==false){

                     document.menu4.combo4[contador]=new Option("De 40 a 60 m2"," superficiegral<=60 and superficiegral>40 " );                    
                     paso1=true;
                     contador++;

                  }

                  else{
                     
                     if (auxiliar<=80 && auxiliar>60 && paso2==false){

                        document.menu4.combo4[contador]=new Option("De 60 a 80 m2"," superficiegral<=80 and superficiegral>60 " );                    
                        paso2=true;
                        contador++;

                     }
                     else{

                        if (auxiliar<=100 && auxiliar>80 && paso3==false){
                                    
                           document.menu4.combo4[contador]=new Option("De 80 a 100 m2"," superficiegral<=100 and superficiegral>80 " );                    
                           paso3=true;
                           contador++;

                        }
                        else{

                           if (auxiliar>100 && paso4==false){
                                    
                              document.menu4.combo4[contador]=new Option(" + de 100 m2"," superficiegral>100 " );                    
                              paso4=true;
                              contador++;

                           }

                        }

                     } 

                  } 

                break;

                case '4':

                   document.menu5.combo5[i+1]=new Option(auxiliar); 

                break;

             }
             dato     = dato.slice(dato.indexOf('&'));
          
          }

        }


