//---------------------------------------------------------------------------
// Fichero: fun_comun.js										
// Objeto : Funciones javascript comunes para las páginas de la aplicación						
// Creado : 07/04/2006														
// Autor  : Doo2Web Solutions S.L.											
// (c) Copyright 2006, Doo2Web Solutions. Todos los derechos reservados.		
//---------------------------------------------------------------------------
	 //declaring necessary local variables
	 var precapa;
var estilo;
var top;
var left;
var contenido;
	 var img = new Array(12); //array to hold the images
	 var currentIndx = 0;
		
	 if(document.images) //pre-load all the images
	 {
	   for(i = 1; i <= 12; i++)
	   {
	     img[i] = new Image();
    	 img[i].src = "/img/catalogo" + i + ".jpg";
	   }
	 }

	 function rotar() {
			if (currentIndx==0){
				currentIndx=1;
			} else if (currentIndx==1){
				currentIndx=2;
			} else if (currentIndx==2){
				currentIndx=3;
			} else {
				currentIndx=0;
			}
		document.image1.src=img[1+(currentIndx*3)].src
		document.image2.src=img[2+(currentIndx*3)].src
		//document.image3.src=img[3+(currentIndx*3)].src
		/* The only special bit of script is this line, which sets the timer value to 5 seconds, or 5000 milliseconds. */
		var delay = setTimeout("rotar()",5000)
	}
	
	//funciones de visibilidad de capas
if(document.getElementById){
        precapa='document.getElementById("'
		estilo='").style'
        top='.top'
        left='.left'
		contenido='").innerHTML'
}else if(document.layers){
        precapa='document.'
        estilo=''
        top='.top'
        left='.left'
		contenido='.innerHTML'
}else if(document.all){
        precapa=''
        estilo='.style'
        top='.pixelTop'
        left='.pixelLeft'
		contenido='.innerHTML'
}
function mostrarcapa(capa){
	eval(precapa+capa+estilo+'.visibility="visible"');
}  
function ocultarcapa(capa){
	eval(precapa+capa+estilo+'.visibility="hidden"');
}

function mostrarcapa2(capa){
	capa1 = eval(precapa+capa+'2'+contenido);
	capa2 = eval(precapa+capa+contenido);
	//alert ('--'+capa1+'--');
	//alert ('--'+capa2+'--');
	tmp_capa1 = capa1;
	capa1 = capa2;
	eval(precapa+capa+'2'+estilo+'.visibility="visible"');
	//eval(precapa+capa+estilo+left+'='+((screen.width/2)-67));
	llenarcapa(capa+'2',capa2);
	llenarcapa(capa,tmp_capa1);
}  
// Función de creación de contenido de la capa
function llenarcapa (id, html) {
	//alert(id);
	//alert(html);
  if (document.layers) {
    var l = document[id];
    l.document.open();
    l.document.write(html);
    l.document.close();
  }
  else if (document.all) {
    document.all[id].innerHTML = html;
  }
  else if (document.getElementById) {
    var range = document.createRange();
    var l = document.getElementById(id);
    while (l.hasChildNodes())
      l.removeChild(l.firstChild);
    range.setStartAfter(l);
    var docFrag = range.createContextualFragment(html)
    l.appendChild(docFrag);
  }
}

