//portada: edicions o castro, carlos maside, escola de ceramcia
function compensar_alturas_portada(){
 altura_c=document.getElementById('castro').offsetHeight;
 altura_m=document.getElementById('maside').offsetHeight;
 altura_e=document.getElementById('escola').offsetHeight;
 if ((altura_c >= altura_m) || (altura_c >= altura_e)){
   document.getElementById('maside').style.height=altura_c+"px";
	 document.getElementById('escola').style.height=altura_c+"px";
 }else if ((altura_m >= altura_c) || (altura_m >= altura_e)){
   document.getElementById('castro').style.height=altura_m+"px";
	 document.getElementById('escola').style.height=altura_m+"px";
 }else{
   document.getElementById('castro').style.height=altura_e+"px";
	 document.getElementById('maside').style.height=altura_e+"px";
 }
}

//formulario subscricion
function comproba_galerias(valor){
	if ((document.getElementById('form_galerias_'+valor).checked)){
	  document.getElementById('form_galerias_todas').checked=false;
	}
}

//desplegable menu galerias
function ver_menu(){
  document.getElementById('menu_g').style.display = '';
}

function quitar_menu(){
  document.getElementById('menu_g').style.display = 'none';
}

//galerias: para iluminar opcion menu
function pon_ilumina(ide){
	document.getElementById('menu2_'+ide).style.color='#ffffff';
}

function quita_ilumina(ide){
	document.getElementById('menu2_'+ide).style.color='#4F95B3';
}

//para as coleccions de portada               
function pase_coleccions (mover) {
	var anterior = posicion;

	eval('posicion'+mover+mover);

	if (posicion < 0) {
		posicion = total - 1;
	} else if (posicion >= total) {
		posicion = 0;
	}

	document.getElementById('pase_coleccions_'+anterior).style.display = 'none';
	document.getElementById('pase_coleccions_'+posicion).style.display = '';
}   


//para ampliar o mapa dunha galeria
function amplia_mapa(url,w,h){  
  var v_ancho=w+20;
  var v_alto=h+20;
  
  ventana=window.open ("","ventana","width="+v_ancho+",height="+v_alto+",scrollbars=no");
  ob=ventana.document.body;
  estilo=new Array();
  valor=new Array();
  
  estilo[0]="backgroundColor";
  estilo[1]="fontFamily";
  estilo[2]="color";
  estilo[3]="fontSize";
  estilo[4]="borderTop";
  estilo[5]="margin";
  estilo[6]="padding";
  
  valor[0]="#ffffff";
  valor[1]="Arial, Helvetica, Verdana, sans-serif";
  valor[2]="#000000";
  valor[3]="0.7em";
  valor[4]="5px solid #000000";	
  valor[5]="0";
  valor[6]="0";
  
  if(estilo.length==valor.length){
    for(i=0;i<estilo.length;i++){
      eval("ventana.document.body.style."+estilo[i]+"='"+valor[i]+"'");
    }
  }
  
  ventana.document.body.innerHTML="<div align=\"center\"><img src=\""+url+"\" style=\"margin:0px;cursor:pointer;cursor:hand;\" /></div>";
}

//para ampliar imaxes da web
function amplia_imx(url,w,h){  
  var v_ancho=w+20;
  var v_alto=h+20;
  
  ventana=window.open ("","ventana","width="+v_ancho+",height="+v_alto+",scrollbars=yes");
  ob=ventana.document.body;
  estilo=new Array();
  valor=new Array();
  
  estilo[0]="backgroundColor";
  estilo[1]="fontFamily";
  estilo[2]="color";
  estilo[3]="fontSize";
  estilo[4]="borderTop";
  estilo[5]="margin";
  estilo[6]="padding";
  
  valor[0]="#ffffff";
  valor[1]="Arial, Helvetica, Verdana, sans-serif";
  valor[2]="#000000";
  valor[3]="0.7em";
  valor[4]="5px solid #000000";	
  valor[5]="0";
  valor[6]="0";
  
  if(estilo.length==valor.length){
    for(i=0;i<estilo.length;i++){
      eval("ventana.document.body.style."+estilo[i]+"='"+valor[i]+"'");
    }
  }
  
  ventana.document.body.innerHTML="<img src=\""+url+"\" style=\"margin:0px;cursor:pointer;cursor:hand;\" />";
}
//para o album de imaxes dunha coleccion
var glrvisor = 0;
var glrctrovisor = 0;
var glrvisorpos = 0;
var glrurl=new Array();
var glrurlpq=new Array();
var glrtitulo=new Array();
var glrtamano=new Array();
	
function pasePosGaleria(mover,pos) {
	pos +=mover;
	if (pos < 0) {
		pos = glrtotal + pos;
	} else if (pos >= glrtotal) {
		pos = pos - glrtotal;
	}
	return pos;
}

function irImaxe (indice) {
	glrposicion = indice;
	paseImaxe(0);
}
function irGaleria (indice) {
	glrvisorpos = indice;
	paseGaleria(-glrctrovisor);
}
function estaEnGaleria(pos) {
	var base = glrvisorpos;
	var finale = pasePosGaleria(glrvisor - 1,glrvisorpos);
	if ( base > finale ) {
	 	if (pos < base &&  pos > finale) { 
  			irGaleria(pos);
  	 	} 
  	 } else {
  	 	if (pos < base ||  pos > finale ) { 
  			irGaleria(pos);
  	 	} 
  	 }
}

function paseGaleria (mover) {
	var pos = pasePosGaleria(mover,glrvisorpos);
	var inipos = pos;
	area = document.getElementById(areavisor);
	var imaxeHTML="";
	for($i=0; glrvisor > $i;$i++) {
		if ($i > 0 ) { pos = pasePosGaleria(1,pos); }
		imaxeHTML+='<a href="#" onclick="irImaxe('+pos+'); return false;">';
		imaxeHTML+='<img src="'+glrurlpq[pos]+'" alt=" " />'; 
		imaxeHTML+='</a>';
	}
	area.innerHTML=imaxeHTML;
	glrvisorpos = inipos;
}

function inicio_glr_coleccion(numero,visor) {
	glrtotal =glrurl.length;
	glrvisor = 5;
	glrctrovisor = Math.floor(glrvisor/2);
	irGaleria(numero);
	irImaxe (numero);
}


function mostrarPestana(pestana_id, panel_id, num) {

  for (var i=0; i<num; i++) {
    document.getElementById('tab'+i).style.display="none";
    document.getElementById('pestana'+i).className="";
  }

  document.getElementById(panel_id).style.display="";
  document.getElementById(pestana_id).className="activo";
  return false;
};

