	/*	---------------------------------------------------	*/
/*			FUNCIONES AZVI			*/
/*	---------------------------------------------------	*/

var NS4,NS6,IE4,IE5,vis,invis,pantallas,idioma,donde,ruta,menus,cargapagina,d

  NS4 = (document.layers) ? true : false;
  IE4 = (document.all && !document.getElementById) ? true : false;
  IE5 = (document.all && document.getElementById) ? true : false;
  NS6 = (!document.all && document.getElementById) ? true : false;

pantallas=["pcpal2","pres_presentacion","pres_historia","pres_organigrama","pres_direcciones","grupo","act_autovias","act_ferroviarias","act_edificaciones","act_hidraulicas","datos","rec_recursos","rec_formulario","formacion","calidad","prevencion","medioambiente","rec_envioCV","rec_ofertas","responsabilidad","idi","memoriaanual"];
menus=[2,21,22,23,24,36,59,60,61,62,75,88,97,0,126,128,131,135,138,135,138,141];

if(NS4){vis="shown";invis="hide";}else{vis="visible";invis="hidden";}

//document.onmousedown=click;
if (NS6){document.addEventListener("mouseup",alerta,false);}

function alerta(e){
if (e.which == 3) {alert("AZVI");return false;}
}

function click(e) {
  NS4 = (document.layers) ? true : false;
  if (NS4) {if (e.which == 3) {alert("AZVI");return false;}} else {if(NS6){}else{if (event.button == 2) {alert("AZVI");return false;}}}
}

ruta="";
cargapagina=true;
inicio=0;




/*	---------------------------------------------------	*/
/*	---------------------------------------------------	*/

function vete(n){

if(n!=22){
  if(top.funcs.inicio==0){    
    top.funcs.inicio=n;
    top.izda.document.location.href="nada_i.html";
    top.dcha.document.location.href="nada_d.html";
    if(top.funcs.idioma=="esp"){
      top.centro.document.location.href="index2.html";
    }else{
      top.centro.document.location.href="index2e.html";
    }
    
    
  }else{
   if(n==0){
    if(top.funcs.idioma=="esp"){
      top.document.location.href="../index.html";}else{top.document.location.href="../indexe.html";}
   }else{
     fot= top.centro.foto.window.document.flash;
     fot.SetVariable("voy",String(n));
     fot.GotoFrame(34);
     fot.Play();
     top.centro.menu.window.document.getElementById("estoy").value=n;
     if(cargapagina){pagina(n);}else{cargapagina=true;}
   }
  }
  if(n==11 && top.funcs.idioma=="esp") {
        m=top.centro.menu.window.document.flash;
        m.GotoFrame(77);
        m.Play();
    }
 }else{
//  alert("Inglés...");
 }
}

function ini(){
  n=top.funcs.inicio;
  if(n==0){
    if(top.funcs.idioma=="esp"){top.document.location.href="index.html";}else{top.document.location.href="indexe.html";}
  }else{
  fot= top.centro.foto.window.document.flash;
  fot.SetVariable("voy",String(n));
  fot.GotoFrame(34);
  fot.Play(); 
  top.centro.menu.window.document.getElementById("estoy").value=n;
  elframe=menus[n]-1;
  men= top.centro.menu.window.document.flash;
  men.GotoFrame(elframe);
  if(cargapagina){pagina(n);}else{cargapagina=true;}
  }
}

function pagina(n){

  top.centro.menu.d=n;
  if(n==18) {
    // terminacion en php
    extension="php";
    }
  else {
    extension="html?";
  }
  top.centro.contenido.window.document.location.href=ruta+top.funcs.idioma+"/"+pantallas[n]+"."+extension;
  if(n>10 && n!=12 && n!=13 && n!=14 && n!=17 && n!=18) {
  f=top.centro.menu.window.document.getElementById("flash");
  f.GotoFrame(menus[n]);
  }
}

function pagina_2(n){

  top.centro.menu.d=n;
  if(n==18) {
    // terminacion en php
    extension="php";
    }
  else {
    extension="html?";
  }

 // f=top.centro.menu.window.document.getElementById("flash");
//  f.GotoFrame(menus[n]);
  top.centro.contenido.window.document.location.href=ruta+top.funcs.idioma+"/"+pantallas[n]+"."+extension;
}




function comprueba(tit){
  donde= parent.menu.window.document.getElementById("estoy").value;
  pag=nombre(tit);
  n=busca_pagina(pag);
if(n!=0){
  if(n!=donde){
//alert(n+" - "+donde);
    elframe=menus[n]-1;
    men= top.centro.menu.window.document.flash;
    men.GotoFrame(elframe);
    ruta="../";
    cargapagina=false;
    vete(n);
    if(pag=="pcpal"){document.location.href=pantallas[n]+".html?";}
  }else{ruta="";}
}
}

function comprueba2(){
  donde= top.centro.menu.window.document.getElementById("estoy").value;
  n=12;
  if(n!=donde){
//alert(n+" - "+donde);
    elframe=menus[n]-1;
    men= top.centro.menu.window.document.flash;
    men.GotoFrame(elframe);
    ruta="../";
    cargapagina=false;
    vete(n);
  }else{ruta="";}
}

function nombre(completo){
  p=0;
  p2=completo.length-6;
  for(i=p2;i>0;i--){
     if(completo.charAt(i)=="/"){
	p=i+1
	break;
     }
  }
  devuelve=completo.substring(p,p2);
  return devuelve;
}

function busca_pagina(t){
  if(t=="pcpal"){return 0;}
  p=0;
  for(i=0;i<pantallas.length;i++){
    if(pantallas[i]==t){
	p=i;
	break;
    }
  }
  return p;
}

function inicio(){
  if(top.funcs.idioma=="esp"){ss="";}else{ss="_ingles";}
  contenidopcpal="<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'"+
"       codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'"+
"       WIDTH=410 HEIGHT=335 id='flash'>"+
"	<PARAM NAME=movie VALUE='../media/home"+ss+".swf?'> "+
"	<PARAM NAME=quality VALUE=high> "+
 "       <PARAM NAME=menu VALUE=false>"+
"	<PARAM NAME=bgcolor VALUE=#FFFFFF> "+
 "     <EMBED name='flash' src='../media/home"+ss+".swf?' menu=false quality=high bgcolor=#FFFFFF  WIDTH=410 HEIGHT=335 TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED>"+
  "    </OBJECT>";
  doc=parent.contenido.window.document.getElementById("cont");
  doc.innerHTML=contenidopcpal;
//  pres=parent.contenido.window.document.flash;
//  pres.Play();
}

function imprime(){
  parent.contenido.window.print();
}

function aviso(){
  ancho2=screen.width;alto2=screen.height;
  ancho=400;alto=320;
  izda=(ancho2/2)-(ancho/2);
  arriba=(alto2/2)-(alto/2);
  if(NS4){
    miv1=window.open(top.funcs.idioma+"/aviso.html?", "V1", "toolbar=no,left="+izda+",top="+arriba+",titlebar=no,scrollbars=yes,resize=no,copyhistory=0,width="+String(ancho)+",height="+String(alto));
  }else{
    miv1=window.open(top.funcs.idioma+"/aviso.html?", "V1", "toolbar=no,left="+izda+",top="+arriba+",titlebar=no,scrollbars=yes,Resizable=0,copyhistory=0,width="+String(ancho)+",height="+String(alto));
  }
  miv1.focus()  
}

function home(){
  if(top.funcs.idioma=="esp"){
    top.document.location.href="index.html";
  }else{    
    top.document.location.href="indexe.html";
  }
}

function ingles(){
  top.funcs.idioma="eng";
  if(top.funcs.inicio==0){
    top.document.location.href="indexe.html";
  }else{
    n=parent.menu.window.document.getElementById("estoy").value;
    top.funcs.inicio=n;

    pagina_2(n);
   cambia_bloques();
  }
//  top.document.location.href="indexe.html";
}


function ingles_11(n){
  top.funcs.idioma="eng";
  if(top.funcs.inicio==0){
    top.document.location.href="indexe.html";
  }else{
    top.funcs.inicio=n;
    pagina_2(n);
    cambia_bloques();
  }
//  top.document.location.href="indexe.html";
}


function espanyol(){
  top.funcs.idioma="esp";
  if(top.funcs.inicio==0){
    top.document.location.href="index.html";
  }else{
    n=parent.menu.window.document.getElementById("estoy").value;
    top.funcs.inicio=n;
    pagina_2(n);
    cambia_bloques();
  }
//  top.document.location.href="index.html";
}

function cambia_bloques(){

  if(top.funcs.idioma=="esp"){
    ext="";
  }
  else{
    ext="e";
  }
   top.centro.menu.document.location.href="menu"+ext+".html";
   top.centro.cabecera.document.location.href="cabecera"+ext+".html";
   top.centro.pie.document.location.href="pie"+ext+".html";
  // document.write("<meta http-equiv='refresh' content='3;url=document.location.href'>");
}

function idi(i){
  top.funcs.idioma=i;
}
