var i_strngth=1
var i_image=0
var identificador = '';
var cliqueado = '';


vector_idioma = {};

vector_idioma['ES'] = {
  'cargafotos' : 'Cargando fotos', 
  'cargafoto' : 'Cargando foto',
  'cargadatos' : 'Cargando datos',
  'cargaarchivos' : 'Cargando archivos',
  'obtienedesc' : 'Obteniendo descripción',
  'obtienetitulo' : 'Obteniendo título',
  'cargabotones' : 'Cargando botones',
  'paginando' : 'Paginando',
  'cargavistas' : 'Cargando vistas'
};

vector_idioma['EN'] = {
  'cargafotos' : 'Loading photos', 
  'cargafoto' : 'Loading photo',
  'cargadatos' : 'Loading data',
  'cargaarchivos' : 'Loading file',
  'obtienedesc' : 'Retrieving description',
  'obtienetitulo' : 'Retrieving title',
  'cargabotones' : 'Loading botom',
  'paginando' : 'Paginating',
  'cargavistas' : 'Loading'
};

vector_idioma['FR'] = {
  'cargafotos' : 'Photos en chargement', 
  'cargafoto' : 'Photo en chargement',
  'cargadatos' : 'Données en chargement',
  'cargaarchivos' : 'Fichiers en chargement',
  'obtienedesc' : 'Description en cours',
  'obtienetitulo' : 'Titre en cours',
  'cargabotones' : 'Boutons en chargement',
  'paginando' : 'Pagination',
  'cargavistas' : 'Chargement'
};

// Función para la URL de recomiende a un amigo
// Se necesita añadir líneas en htaccess para los diferentes idiomas
function emailamigo(cat,subcat,idioma) {
  tipoarchivo = document.formulario.tipoarchivo.value;

  if ( !subcat ) {
    categoria = cat;
  } else {
    categoria = subcat;
  }
  switch ( idioma ) {
    case "EN":
      url = 'http://www.marinador.com/tell-a-friend-'+categoria+'-'+tipoarchivo;
      break;
    case "FR":
      url = 'http://www.marinador.com/recommandez-'+categoria+'-'+tipoarchivo;
      break;
    default:
      url = 'http://www.marinador.com/recomiende-a-un-amigo-'+categoria+'-'+tipoarchivo;
      break;
  } 
  
  window.open(url,'','width=455, height=440');
  return false;
}

function lellamamos(categoria,idioma) {
  // Venta de apartamentos
  if ( parseInt(categoria) % 200 == 0 )
      window.open("http://www.marinador.com/mas-informacion.php?seccion=apartamentos&idioma="+idioma,null,"width=435, height=500");
  else {
     switch ( categoria ) {
       // balneario
       case "201":
         window.open("http://www.marinador.com/mas-informacion.php?seccion=balneario&idioma="+idioma,null,"width=435, height=500");
         break;
       // centro médico
       case "202":
         window.open("http://www.marinador.com/mas-informacion.php?seccion=ceme&idioma="+idioma,null,"width=435, height=500");
         break;
       // alojamientos
       case "203":
         window.open("http://www.marinador.com/mas-informacion.php?seccion=alojamiento&idioma="+idioma,null,"width=435, height=500");
         break;
       // ocio
       case "204":
         window.open("http://www.marinador.com/mas-informacion.php?seccion=entretenimiento&idioma="+idioma,null,"width=435, height=500");
         break;
       // restaurantes
       case "205":
         window.open("http://www.marinador.com/mas-informacion.php?seccion=restaurantes&idioma="+idioma,null,"width=435, height=500");
         break;
       // congresos
       case "206":
         window.open("http://www.marinador.com/mas-informacion.php?seccion=salones&idioma="+idioma,null,"width=435, height=500");
         break;
     }
  }
}

// función para el onmouseover
function over(valor) {
  identificador = valor;
  if ( document.getElementById(valor).className == '' ) {
    document.getElementById(valor).className = 'activado';
    cliqueado = '';
  } else
  if ( document.getElementById(valor).className == 'activado' ) {
    cliqueado = valor;
    return false;
  }
}

// función para el onmouseout
function out(valor) {
  if ( cliqueado != valor )
    document.getElementById(identificador).className = '';
}


// Función que se carga cuando vienen de marinador.com
function seccion() {
  cat = document.formulario.id_cat.value;
  tipo = document.formulario.tipoarchivo.value;
  tipoapartamento = document.formulario.tipoapartamento.value;

  /* HACEMOS VISIBLE EL DIV CORRESPONDIENTE */ 
  
  if ( tipo == 1 || tipo == 4 || tipo == 5 ) {
    document.getElementById("fotosdosdtresd").style.display = 'inline';
  } if ( tipo == 2 || tipo == 3 || tipo == 6) {
    document.getElementById("virtualubicacionvideo").style.display = 'inline';
  }  
  /* FIN VISIBLE DIV CORRESPONDIENTE */
  
  // Cualquiera menos visita virtual
  if ( document.formulario.tipoapartamento.value == '' ) {
    // Es una foto, 2D o 3D
    if ( tipo == 1 || tipo == 4 || tipo == 5 ) {
      // No quiere ver una vista 360
      if ( document.formulario.vista360.value != "si" && tipo != 1 ) {
        img = document.formulario.primeraimagen.value;
        showimage(img,1);
      } 
      pintaimagenes(cat,'');
        
    } else {
      // Es un vídeo
      if ( tipo == 2 ) {
        valorimagengrande(cat,'',1,'');
      }
      // Es una ubicación
      if ( tipo == 3 ) {
        cat = document.formulario.id_cat.value;
        //document.getElementById("descripcion").innerHTML = '';
        valorimagengrande(cat,0,1,'');
      }
    }
  // Visita virtual
  } else {
    pintarefs(document.formulario.id_cat.value,document.formulario.tipoapartamento.value);
  }
}

function pintarefs(cat,apart) {
    // cat -> categoría
    // apart -> tipoapartamento

    var capavirtual;
		capavirtual = document.getElementById("piepdf00");
		ajax = nuevoAjax();
		ms = new Date().getTime();

		ajax.open("GET", "pinta_refs.php?ms="+ms+"&categoria="+cat+"&tipoapartamento="+apart, true); 
		
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capavirtual.innerHTML = vector_idioma[document.formulario.idioma.value]['cargabotones']+'...';
			}
			if (ajax.readyState == 4) {
				capavirtual.innerHTML = ajax.responseText;
				visitavirtual(cat,apart);
			}
		}	
    ajax.send(null);  
}

// Función que se carga cuando eligen un tipo de archivo
function select_tipo(tipo) {
  vaciatodo();
  document.formulario.vista360.value = '';
  document.getElementById("titulo").innerHTML = '';
  cat = '';
  document.formulario.tipoarchivo.value = tipo;
  
  // Dejamos normal el que estaba pinchado
  if ( document.getElementById("botvideo").className == 'activado' ) {
      document.getElementById("botvideo").className = '';
  } if ( document.getElementById("botvirtual").className == 'activado' ) {
     document.getElementById("botvirtual").className = '';
  } /*if ( document.getElementById("botubicacion").className == 'activado' ) {
      document.getElementById("botubicacion").className = '';
  } */if ( document.getElementById("bot2d").className == 'activado' ) {
      document.getElementById("bot2d").className = '';
  } if ( document.getElementById("bot3d").className == 'activado' ) {
      document.getElementById("bot3d").className = '';
  } if ( document.getElementById("botfotos").className = 'activado' ) {
      document.getElementById("botfotos").className = '';
  }

  // Dejamos el botón marcado de azul
  switch ( tipo ) {
    case 1:
      document.getElementById("botfotos").className = 'activado';
      cliqueado = 'botfotos';
      break;
    case 2:
      document.getElementById("botvideo").className = 'activado';
      cliqueado = 'botvideo';
      break;
    /*
    case 3:
      document.getElementById("botubicacion").className = 'activado';
      cliqueado = 'botubicacion';
      break;
    */
    case 4:
      document.getElementById("bot2d").className = 'activado';
      cliqueado = 'bot2d';
      break;
    case 5:
      document.getElementById("bot3d").className = 'activado';
      cliqueado = 'bot3d';
      break;
    case 6:
      document.getElementById("botvirtual").className = 'activado';
      cliqueado = 'botvirtual';
      break;
  }
 
  /* HACEMOS VISIBLE EL DIV CORRESPONDIENTE */
  
  if ( tipo == 1 || tipo == 4 || tipo == 5 ) {
    document.getElementById("fotosdosdtresd").style.display = 'inline';
    document.getElementById("virtualubicacionvideo").style.display = 'none';
  } if ( tipo == 2 || tipo == 3 || tipo == 6 ) {
    document.getElementById("fotosdosdtresd").style.display = 'none';
    document.getElementById("virtualubicacionvideo").style.display = 'inline'; 
  }
  /* FIN VISIBLE DIV CORRESPONDIENTE */
  
  // Decidimos el valor de cat (cat/subcat) 
  if ( document.formulario.categoria.value != "" ) {
      if ( document.formulario.id_subcat.value == "" ) {
      //if ( document.getElementById("subcategoria").value == "" ) {
          cat = document.formulario.categoria.value;
      } else {
          cat = document.formulario.id_subcat.value;
          //cat = document.getElementById("subcategoria").value;
      }
  } 

  // Es visita virtual
  if ( tipo == 6 ) {
    pintarefs(cat,0);
  } else {
     // Es una imagen, 2D o 3D
     if ( tipo == 1 || tipo == 4 || tipo == 5 ) {
        valorimagengrande(cat,0,1,'');
        pintaimagenes(cat,'');
     } else {
        // Es un vídeo
        if ( tipo == 2 ) {
          valorimagengrande(cat,'',1,'');
        }
        // Es una ubicación
        if ( tipo == 3 ) {
          valorimagengrande(cat,0,1,'');
        }
     }
  }
}

// pone el valor en un hidden, porque como el desplegable se
// crea mediante PHP, se pierde el getElemenById del desplegable
// y pinta el tumbail
function ponesubcategoria(subcat){
  document.formulario.id_subcat.value = subcat;
  document.formulario.vista360.value = '';
  pintaimagenes(subcat,'');
}
// vacía la subcategoría cuando cambian la categoría
// porque como la subcategoría se genera mediante PHP,
// se pierde el getElementById
function vaciasubcategoria(cat){
  document.formulario.id_subcat.value = '';
  select_cat(cat);
}

// Saca la foto con efecto
function showimage(img,segunda) {
  var capa = document.getElementById("contenedorimagen02");
  if ( document.formulario.urlimagen.value && segunda == 0 ) {
    hideimage();
    i_strngth=1;
  }

 document.formulario.urlimagen.value = img;
 
 if(document.all) {     
    //if (i_strngth <= 100) { 
      //capa.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+document.formulario.urlimagen.value+" border='0'>";
      capa.innerHTML="<img src="+document.formulario.urlimagen.value+" border='0'>";
      //i_strngth=i_strngth+10;
      //setTimeout("showimage(document.formulario.urlimagen.value,1)",70);
   // } 
       
  } else {
    if (i_strngth <= 100) {
      capa.innerHTML="<img style='opacity:."+i_strngth+"' src="+document.formulario.urlimagen.value+" border='0'>";
      i_strngth=i_strngth+10;
      setTimeout("showimage(document.formulario.urlimagen.value,1)",70);
    } 
  }
}

// Limpia la capa donde sale la foto 
function hideimage() {
  var capa = document.getElementById("contenedorimagen02");
  capa.innerHTML=""; 
}

// Vacía la foto grande, la descripción y el título
function vaciatodo() {
  document.getElementById("contenedorimagen02").innerHTML = '';
  document.getElementById("contenedorimagen03").innerHTML = '';
  document.getElementById("descripcion").innerHTML = '';
  document.getElementById("piepdf00").innerHTML = '';
  // Es distinto de foto, entonces no sale ni el paginador ni las vistas 360
  if ( document.formulario.tipoarchivo.value != 1 ) {
    document.getElementById("paginacion").innerHTML = '';
    document.getElementById("paginacion").style.visibility = 'hidden';
    document.getElementById("capa360").innerHTML = '';
    document.getElementById("capa360").style.visibility = 'hidden';
  } else {
    document.getElementById("capa360").style.visibility = 'visible';
    document.getElementById("paginacion").style.visibility = 'visible';
  }
  document.getElementById("titulo").innerHTML = '';
}

// Coloca la imagen grande si hay
function valorimagengrande(cat,pinta,descripcion,pag) {
    var tipoarchivo = document.formulario.tipoarchivo.value;
    var idioma = document.formulario.idioma.value;
    var idiomavideo = document.formulario.idiomavideo.value;
    var capaimg_grande;
    // Depende del tipo, se cargará en una capa
    switch ( tipoarchivo ) {
      case "1":
        capaimg_grande = document.getElementById("contenedorimagen02");
        break;
      case "2":
        capaimg_grande = document.getElementById("contenedorimagen03");
        break;
      case "3":
        capaimg_grande = document.getElementById("contenedorimagen03");
        break;
      case "4":
        capaimg_grande = document.getElementById("contenedorimagen02");
        break;
      case "5":
        capaimg_grande = document.getElementById("contenedorimagen02");
        break;
      case "6":
        capaimg_grande = document.getElementById("contenedorimagen03");
        break;
    }
		
		ajax = nuevoAjax();
		ms = new Date().getTime();
    if ( pag )
		  ajax.open("GET", "valorimagengrande.php?ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&pag="+pag+"&idioma="+idioma+"&idiomavideo="+idiomavideo, true); 
		else
		  ajax.open("GET", "valorimagengrande.php?ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&idioma="+idioma+"&idiomavideo="+idiomavideo, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capaimg_grande.innerHTML = vector_idioma[document.formulario.idioma.value]['cargafoto']+'...';
			}
			if (ajax.readyState == 4) {
				capaimg_grande.innerHTML = ajax.responseText;
        if ( pinta == 1 ) {
            pintaimagenes(cat,'');
        }
        if ( descripcion == 1 ) {
          if ( pag && tipoarchivo == 1 ) {
            Accion2(cat,tipoarchivo,pag,'','');
          } else {
            Accion2(cat,tipoarchivo,'','','');
          }
        }
			}
		}
		
    ajax.send(null);
}

// Pinta el select de subcategorías
function select_cat(cat) {
    vaciatodo();
    document.formulario.vista360.value = '';
    if ( parseInt(cat) % 200 != 0 ) {
    //if ( cat != '200' ) {
        // Venimos de virtual y eligen otra categoría
        // por tanto, al estar disabled el botón, pasamos
        // a activiar fotos y cambiamos el div
        if ( document.formulario.tipoarchivo.value == 6 || document.formulario.tipoarchivo.value == 4 || document.formulario.tipoarchivo.value == 5 ) {
          document.getElementById("botfotos").className = 'activado';
          document.formulario.tipoarchivo.value = 1;
          document.getElementById("bot2d").className = '';
          document.getElementById("bot3d").className = '';
          document.getElementById("botvirtual").className = '';
          document.getElementById("fotosdosdtresd").style.display = 'inline';
          document.getElementById("virtualubicacionvideo").style.display = 'none';
        } 
        document.getElementById("bot2d").disabled = true;
        document.getElementById("bot3d").disabled = true;
        document.getElementById("botvirtual").disabled = true;
        document.getElementById("bot2d").className = 'desactivado';
        document.getElementById("bot3d").className = 'desactivado';
        document.getElementById("botvirtual").className = 'desactivado';

    } else {
        document.getElementById("bot2d").disabled = false;
        document.getElementById("bot3d").disabled = false;
        document.getElementById("botvirtual").disabled = false;
        document.getElementById("bot2d").className = '';
        document.getElementById("bot3d").className = '';
        document.getElementById("botvirtual").className = '';
    }
    
    document.getElementById("datos_subcat_get").style.display = 'none';

    var capa;
		capa = document.getElementById("datos_subcat");
		ajax = nuevoAjax();
		ms = new Date().getTime();
		ajax.open("GET", "select_subcategoria.php?ms="+ms+"&categoria="+cat+"&lan="+document.formulario.idioma.value, true); 
		
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capa.innerHTML = vector_idioma[document.formulario.idioma.value]['cargadatos']+'...';
			}
			if (ajax.readyState == 4) {
				capa.innerHTML = ajax.responseText;
        valorimagengrande(cat,1,0,'');
			}
		}
		
    ajax.send(null); 
}

// Cuando pinchan en fotos, ubicación, videos...
// Cambia la variable tipoarchivo y pinta las miniaturas
function cambiatipo(tipo,cat) {
  document.formulario.tipoarchivo.value = tipo;
  pintaimagenes(cat,'');
}

// Función que carga la visita virtual
// y la descripción mediante Accion3
function visitavirtual(cat,apart) { 
    tipoarchivo = document.formulario.tipoarchivo.value;
    var capavirtual;
		capavirtual = document.getElementById("contenedorimagen03");
		ajax = nuevoAjax();
		ms = new Date().getTime();
		
    ajax.open("GET", "virtual.php?ms="+ms+"&categoria="+cat+"&tipoapartamento="+apart, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capavirtual.innerHTML = vector_idioma[document.formulario.idioma.value]['cargafotos']+'...';
			}
			if (ajax.readyState == 4) { 
				capavirtual.innerHTML = ajax.responseText;
				// Pinta la descripción de la visita virtual
        Accion3(cat,tipoarchivo,apart);
			}
		}
		
    ajax.send(null);
}

// Pinta las miniaturas
// Pinta la imagen grande
// Pinta botones de visita virtual
function pintaimagenes(cat,pag) {
    // Si viene del paginador, quitamos el vista360
    if ( pag != '' )
      document.formulario.vista360.value = '';
    
    if ( cat != 'primera' && cat != 'segunda' && cat != 'otros' && cat != 'realizados' )
      vaciatodo();
    else
      return false;
    
    if ( cat == "" )
      cat = document.formulario.categoria.value;
    
    var tipoarchivo = document.formulario.tipoarchivo.value;
    // Es foto, 2d o 3d
    if ( tipoarchivo == 1 || tipoarchivo == 4 || tipoarchivo == 5 ) {
        var capa2;
    		capa2 = document.getElementById("contenedortumbail");
    		ajax = nuevoAjax();
    		ms = new Date().getTime();
    
        if ( pag )
    		  ajax.open("GET", "tumbail.php?ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&pag="+pag+"&lan="+document.formulario.idioma.value, true);
        else
          ajax.open("GET", "tumbail.php?ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&lan="+document.formulario.idioma.value, true); 

    		ajax.onreadystatechange=function() 
    		{ 
    			if (ajax.readyState == 1) {
    				capa2.innerHTML = vector_idioma[document.formulario.idioma.value]['cargafotos']+'...';
    			}
    			if (ajax.readyState == 4) {
    				capa2.innerHTML = ajax.responseText;
    				// No viene de marinador.com queriendo ver una vista 360 
  				  if ( document.formulario.vista360.value != "si" ) {
              // Viene de hacer clic en una página
              if ( pag && tipoarchivo == 1 ) {
                valorimagengrande(cat,0,1,pag);
              } else
                valorimagengrande(cat,0,1,'');
            // Viene de marinador.com y quieren ver una vista 360
            } else {
              Accion2(cat,tipoarchivo,1,1,'');
            }
    			}
    		}
    		
        ajax.send(null);
    }
    // Es vídeo o ubicación 
    if ( tipoarchivo == 2 || tipoarchivo == 3 ) {
      valorimagengrande(cat,0,1,'');
    }
    // Es visita virtual
    if ( tipoarchivo == 6 ) {
      pintarefs(cat,0);
    }
}

function pintadosiers(cat,vista,id_vista) {
  var capadosier;
	capadosier = document.getElementById("piepdf00");
	ajax = nuevoAjax();
	ms = new Date().getTime();

	ajax.open("GET", "dosier.php?ms="+ms+"&categoria="+cat+"&lan="+document.formulario.idioma.value, true); 

	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState == 1) {
			capadosier.innerHTML = vector_idioma[document.formulario.idioma.value]['cargaarchivos']+'...';
		}
		if (ajax.readyState == 4) {
			capadosier.innerHTML = ajax.responseText;
			// Es tipoarchivo 1, no viene del paginador y hay que visuzliar las vistas 360
      if ( document.formulario.tipoarchivo.value == 1 && vista == 1 ) {
        pintavistas(cat,id_vista)
      }
		}
	}
    		
  ajax.send(null);
}

function pintavistas (cat,id_vista) {
  var capa360;
	capa360 = document.getElementById("capa360");
	ajax = nuevoAjax();
	ms = new Date().getTime();

	ajax.open("GET", "vistas.php?ms="+ms+"&categoria="+cat+"&idioma="+document.formulario.idioma.value, true); 

	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState == 1) {
			capa360.innerHTML = vector_idioma[document.formulario.idioma.value]['cargavistas']+'...';
		}
		if (ajax.readyState == 4) {
			capa360.innerHTML = ajax.responseText;
			// Viene de marinador.com y quieren ver la primera vista
			// como predeterminada
			if ( document.formulario.vista360.value != '' )
         vista_360(cat,id_vista,'','','');
		}
	}
    		
  ajax.send(null); 
}


function vista_360(cat,id_vista,carpeta,archivo,descripcion) {
  var imagen360;
	imagen360 = document.getElementById("contenedorimagen02");
	ajax = nuevoAjax();
	ms = new Date().getTime();
  
   // Control del botón activado
   // Buscamos el activo para desactivarlo
   // y activamos el nuevo
  
   if ( document.getElementById("ico01360") ) {
     if ( document.getElementById("ico01360").className == 'activado360' ) { 
       document.getElementById("ico01360").className = '';
     }
   }
   if ( document.getElementById("ico02360") ) { 
     if ( document.getElementById("ico02360").className == 'activado360' ) {
       document.getElementById("ico02360").className = '';
     }
   }
   if ( document.getElementById("ico03360") ) { 
     if ( document.getElementById("ico03360").className == 'activado360' ) {
       document.getElementById("ico03360").className = '';
     }
   }
   if ( document.getElementById("ico04360") ) { 
     if ( document.getElementById("ico04360").className == 'activado360' ) {
       document.getElementById("ico04360").className = '';
     }
   }
   if ( document.getElementById("ico05360") ) {
     if ( document.getElementById("ico05360").className == 'activado360' ) {
       document.getElementById("ico05360").className = '';
     }
   }
   document.getElementById("ico0"+id_vista+"360").className = 'activado360';
	
  ajax.open("GET", "vista360.php?id_vista="+id_vista+"&carpeta="+carpeta+"&archivo="+archivo+"&ms="+ms+"&categoria="+cat, true); 

	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState == 1) {
			imagen360.innerHTML = vector_idioma[document.formulario.idioma.value]['cargafoto']+'...';
		}
		if (ajax.readyState == 4) {
			imagen360.innerHTML = ajax.responseText;
			if ( descripcion && id_vista != '' )
			   Accion4(cat,id_vista);
		}
	}
    		
  ajax.send(null); 
}

// Saca la descripción de las vistas 360 cuando pinchan en los enlaces
function Accion4(cat,id_vista) {
  var capadesc;
	capadesc = document.getElementById("descripcion");
	ajax = nuevoAjax();
	ms = new Date().getTime();

	ajax.open("GET", "descripcion.php?lan="+document.formulario.idioma.value+"&vista=1&id_vista="+id_vista+"&ms="+ms+"&categoria="+cat, true); 

	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState == 1) {
			capadesc.innerHTML = vector_idioma[document.formulario.idioma.value]['obtienedesc']+'...';
		}
		if (ajax.readyState == 4) {
			capadesc.innerHTML = ajax.responseText;
		}
	}
    		
  ajax.send(null);  
}

// Saca la descripción y controla los botones de refs para
// 2D/3D
// Cuando pinchan en refs o en miniaturas
function Accion(img,img_grande,segunda,id_cat,ident,linea) {  
   // Si hay linea es que viene de referencias de 2D/3D
   if ( linea ) {
       switch ( linea ) {
        case 1:
          if ( document.getElementById("ref1") ) {
            if ( document.getElementById("ref1").className == 'ref01' )
              document.getElementById("ref1").className = '';
          }
          if ( document.getElementById("ref2") ) {
            if ( document.getElementById("ref2").className == 'ref01' )
              document.getElementById("ref2").className = '';
          }
          if ( document.getElementById("ref3") ) {
            if ( document.getElementById("ref3").className == 'ref01' )
              document.getElementById("ref3").className = '';
          }
          if ( document.getElementById("ref4") ){
            if ( document.getElementById("ref4").className == 'ref01' )
              document.getElementById("ref4").className = '';
          }
          if ( document.getElementById("ref5") ) {
            if ( document.getElementById("ref5").className == 'ref01' )
              document.getElementById("ref5").className = '';
          }
          if ( document.getElementById("ref6") ) {
            if ( document.getElementById("ref6").className == 'ref01' )
              document.getElementById("ref6").className = '';
          }
          break;
        case 2:
          if ( document.getElementById("ref7") ) {
            if ( document.getElementById("ref7").className == 'ref01' )
              document.getElementById("ref7").className = '';
          }
          if ( document.getElementById("ref8") ) {
            if ( document.getElementById("ref8").className == 'ref01' )
              document.getElementById("ref8").className = '';
          }
          if ( document.getElementById("ref9") ) {
            if ( document.getElementById("ref9").className == 'ref01' )
              document.getElementById("ref9").className = '';
          }
          if ( document.getElementById("ref10") ) {
            if ( document.getElementById("ref10").className == 'ref01' )
             document.getElementById("ref10").className = '';
          }
          if ( document.getElementById("ref11") ) {
            if ( document.getElementById("ref11").className == 'ref01' )
              document.getElementById("ref11").className = '';
          }
          if ( document.getElementById("ref12") ) {
            if ( document.getElementById("ref12").className == 'ref01' )
              document.getElementById("ref12").className = '';
          }
          if ( document.getElementById("ref13") ) {
            if ( document.getElementById("ref13").className == 'ref01' )
              document.getElementById("ref13").className = '';
          }
          break;
        case 3:
          if ( document.getElementById("ref14") ) {
            if ( document.getElementById("ref14").className == 'ref01' )
              document.getElementById("ref14").className = '';
          }
          if ( document.getElementById("ref15") ) {
            if ( document.getElementById("ref15").className == 'ref01' )
              document.getElementById("ref15").className = '';
          }
          if ( document.getElementById("ref16") ) {
            if ( document.getElementById("ref16").className == 'ref01' )
              document.getElementById("ref16").className = '';
          }
          if ( document.getElementById("ref17") ) {
            if ( document.getElementById("ref17").className == 'ref01' )
              document.getElementById("ref17").className = '';
          }
          break;
       }
       document.getElementById(ident).className = 'ref01';
   }
    var capa2;
		capa2 = document.getElementById("descripcion");
		ajax = nuevoAjax();
		ms = new Date().getTime();

		ajax.open("GET", "descripcion.php?ms="+ms+"&imagen="+img+"&lan="+document.formulario.idioma.value, true)
    
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capa2.innerHTML=vector_idioma[document.formulario.idioma.value]['obtienedesc']+'...';
			}
			if (ajax.readyState == 4) { 
				capa2.innerHTML = ajax.responseText;
        showimage(img_grande,segunda);
			}
		}
	  ajax.send(null);
}

// Saca la descripción sin pinchar en nada, es decir
// De lo que sale por defecto o pinchan en botón del pie
// o cambian el desplegable
function Accion2(cat,tipoarchivo,pag,vista,id_vista) {
  var capa2;
		capa2 = document.getElementById("descripcion");
		ajax = nuevoAjax();
		ms = new Date().getTime();
		// Queremos pintar las vistas 360
    if ( vista ) {
		  ajax.open("GET", "descripcion.php?vista=1&id_vista="+id_vista+"&ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&lan="+document.formulario.idioma.value, true)
		} else {
      if ( pag )
        ajax.open("GET", "descripcion.php?ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&lan="+document.formulario.idioma.value+"&pag="+pag, true)
      else
        ajax.open("GET", "descripcion.php?ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&lan="+document.formulario.idioma.value, true)
    }
    ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capa2.innerHTML=vector_idioma[document.formulario.idioma.value]['obtienedesc']+'...';
			}
			if (ajax.readyState == 4) { 
				capa2.innerHTML = ajax.responseText;
				// Es foto y no viene del paginador, por tanto, 
        // tenemos que pintar las vistas
        if ( tipoarchivo == 1 && pag == '' )
				  showtitulo(cat,pag,1,1,'');
				// No es foto o viene del paginador
        else
				  showtitulo(cat,pag,1,vista,id_vista);
			}
		}
	   ajax.send(null);
}


function showtitulo(id_cat,pag,paginacion,vista,id_vista) {

  var capa3;
  var tipoarchivo = document.formulario.tipoarchivo.value;
  capa3 = document.getElementById("titulo");
  ajax = nuevoAjax();
		ms = new Date().getTime();
		ajax.open("GET", "titulo.php?ms="+ms+"&id_cat="+id_cat+"&lan="+document.formulario.idioma.value, true)
    
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capa3.innerHTML=vector_idioma[document.formulario.idioma.value]['obtienetitulo']+'...';
			}
			if (ajax.readyState == 4) { 
				capa3.innerHTML = ajax.responseText;

				// Pintamos el paginador
        if ( tipoarchivo == 1 && paginacion == 1 ) {
          paginador(id_cat,pag,vista,id_vista);
        } else {
          if ( tipoarchivo == 2 || tipoarchivo == 3 || tipoarchivo == 4 || tipoarchivo == 5 )
            pintadosiers(id_cat,'','');
        }
			}
		}
	   ajax.send(null);
}

// Pinta la descripción de la visita virtual
function Accion3 (cat,tipoarchivo,apart) {
  var capa2;
		capa2 = document.getElementById("descripcion");
		ajax = nuevoAjax();
		ms = new Date().getTime();
    if ( apart )
      ajax.open("GET", "descripcion.php?virtual=1&ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&tipoapartamento="+apart+"&lan="+document.formulario.idioma.value, true)
		else
		  ajax.open("GET", "descripcion.php?virtual=1&ms="+ms+"&categoria="+cat+"&tipoarchivo="+tipoarchivo+"&lan="+document.formulario.idioma.value, true)
    ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capa2.innerHTML=vector_idioma[document.formulario.idioma.value]['obtienedesc']+'...';
			}
			if (ajax.readyState == 4) { 
				capa2.innerHTML = ajax.responseText;
				showtitulo(cat,0,0,'','');
			}
		}
	   ajax.send(null);
}

// Función para activar los botones de referencias de visita virtual
function activate(valor,linea) {
  switch ( linea ) {
    case 1:
      if ( document.getElementById("refvirtual1").className == 'refvirtual' ) {
        document.getElementById("refvirtual1").className = 'refvisitavirtual';
      } if ( document.getElementById("refvirtual2").className == 'refvirtual' ) {
        document.getElementById("refvirtual2").className = 'refvisitavirtual';
      }
      break;
    case 2:
      if ( document.getElementById("refvirtual8").className == 'refvirtual' ) {
        document.getElementById("refvirtual8").className = 'refvisitavirtual';
      }
      if ( document.getElementById("refvirtual11").className == 'refvirtual' ) {
        document.getElementById("refvirtual11").className = 'refvisitavirtual';
      }
      break;
    case 3:
      break;
    case 0:
      break;
  }

  document.getElementById(valor).className = 'refvirtual';
}

function paginador(cat,pag,vista,id_vista) {
  var capapag;
		capapag = document.getElementById("paginacion");
		ajax = nuevoAjax();
		ms = new Date().getTime();
		if ( pag )
		  ajax.open("GET", "paginacion.php?ms="+ms+"&pag="+pag+"&categoria="+cat, true);
		else
		  ajax.open("GET", "paginacion.php?ms="+ms+"&categoria="+cat, true);
    ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState == 1) {
				capapag.innerHTML=vector_idioma[document.formulario.idioma.value]['paginando']+'...';
			}
			if (ajax.readyState == 4) { 
				capapag.innerHTML = ajax.responseText;
				pintadosiers(cat,vista,id_vista);
			}
		}
	   ajax.send(null);
}

