function nwindow(mypage,myname,w,h,scroll,pos)
{
  if (pos=="random")
  {
    LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
    TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
  }
  else if (pos=="center")
  {
    LeftPosition=(screen.width)?(screen.width-w)/2:100;
    TopPosition=(screen.height)?(screen.height-h)/2:100;
  }
  else
  {
    LeftPosition=0;
    TopPosition=20;
  }

  settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
  win=window.open(mypage,myname,settings);

  if(win.focus)
  {
    win.focus();
  }
}

function redimensionar (ancho, alto)
{
  LeftPosition=(screen.width)?(screen.width-ancho)/2:100;
  TopPosition=(screen.height)?(screen.height-alto)/2:100;
	
  window.moveTo(LeftPosition,TopPosition);
  window.resizeTo(ancho,alto);
  window.focus();
}
function redimensionar_galeria (imagen)
{
  var ancho = imagen.width+20;
  var alto = imagen.height+16;
	
  if (Number(ancho) < 500)
  {
    ancho="500";
  }
  if (Number(alto) < 200)
  {
    alto="200";
  }
  
  if (navigator.appName == "Netscape")
  {
    alto = String(Number(alto) + 200);
  }
  else
  {
    ancho = String(Number(ancho) + 30);
    alto = String(Number(alto) + 170);
  }
  
  window.moveTo(((screen.availWidth - ancho)/2),((screen.availHeight - alto)/2));
  window.resizeTo(ancho, alto);
}

var principal = '';

function mostrar_capa(elemento)
{
	anterior = principal;
	principal = elemento;
	
	if(anterior == '')
	{
		document.getElementById(principal).style.display='block';
		cambiar_clase_on('menu_'+principal);
	}
	else
	{
		if (anterior == principal)
		{
			if (document.getElementById(principal).style.display == "none")
			{
				document.getElementById(principal).style.display='block';
				cambiar_clase_on('menu_'+principal);
			}
			else
			{
				document.getElementById(principal).style.display='none';
				cambiar_clase_off('menu_'+anterior);
			}
		}
		else
		{
			document.getElementById(anterior).style.display='none';
			cambiar_clase_off('menu_'+anterior);
			document.getElementById(principal).style.display='block';
			cambiar_clase_on('menu_'+principal);
		}
	}
}

function select_submenu (id) { document.getElementById(id).className = "submenu_on"; }
function cambiar_clase_on(id) { document.getElementById(id).className = "menu_on"; }
function cambiar_clase_off(id) { document.getElementById(id).className = "enlace_menu";	}

function cambiar_pestania (pestania, VAR_zonas, VAR_etapa) {
	
	if(pestania == 'pestana_1') {			
		document.getElementById('pestana_1').className = 'pestania_on';
		document.getElementById('capa_pestana_1').style.display = 'block';
		if (document.getElementById('hidden_pestana_1').value == 0) document.getElementById('fr_pestana_1').src = 'iframe_elementosdeinteres.php?zonas='+VAR_zonas+'';
		document.getElementById('hidden_pestana_1').value = 1;
	} else {
		document.getElementById('pestana_1').className = 'pestania_off';
		document.getElementById('capa_pestana_1').style.display = 'none';
	}
	
	if(pestania == 'pestana_2') {			
		document.getElementById('pestana_2').className = 'pestania_on';
		document.getElementById('capa_pestana_2').style.display = 'block';		
		if (document.getElementById('hidden_pestana_2').value == 0) document.getElementById('fr_pestana_2').src = 'iframe_albergues.php?zonas='+VAR_zonas+'';
		document.getElementById('hidden_pestana_2').value = 1;
	} else {
		document.getElementById('pestana_2').className = 'pestania_off';
		document.getElementById('capa_pestana_2').style.display = 'none';
	}
	
	if(pestania == 'pestana_3') {			
		document.getElementById('pestana_3').className = 'pestania_on';
		document.getElementById('capa_pestana_3').style.display = 'block';
		if (document.getElementById('hidden_pestana_3').value == 0) document.getElementById('fr_pestana_3').src = 'iframe_alojamientos.php?zonas='+VAR_zonas+'';
		document.getElementById('hidden_pestana_3').value = 1;
	} else {
		document.getElementById('pestana_3').className = 'pestania_off';
		document.getElementById('capa_pestana_3').style.display = 'none';
	}
	
	if(pestania == 'pestana_4') {			
		document.getElementById('pestana_4').className = 'pestania_on';
		document.getElementById('capa_pestana_4').style.display = 'block';
		if (document.getElementById('hidden_pestana_4').value == 0) document.getElementById('fr_pestana_4').src = 'iframe_patrimonio.php?zonas='+VAR_zonas+'';
		document.getElementById('hidden_pestana_4').value = 1;
	} else {
		document.getElementById('pestana_4').className = 'pestania_off';
		document.getElementById('capa_pestana_4').style.display = 'none';
	}
	
	if(pestania == 'pestana_5') {			
		document.getElementById('pestana_5').className = 'pestania_on';
		document.getElementById('capa_pestana_5').style.display = 'block';
		if (document.getElementById('hidden_pestana_5').value == 0) document.getElementById('fr_pestana_5').src = 'iframe_descripcion.php?etapa='+VAR_etapa+'';
		document.getElementById('hidden_pestana_5').value = 1;
	} else {
		document.getElementById('pestana_5').className = 'pestania_off';
		document.getElementById('capa_pestana_5').style.display = 'none';
	}
}

var principal_iframe = '';

function mostrar_capa_iframe(elemento)
{
	anterior_iframe = principal_iframe;
	principal_iframe = elemento;
	
	if(anterior_iframe == '')
	{
		document.getElementById('cCapa_'+principal_iframe).style.display = 'block';
		document.getElementById('flecha_'+principal_iframe).src = 'images/flecha_on.png';
		document.getElementById('texto_'+principal_iframe).style.fontWeight = 'bold';	
		if (document.getElementById('iframe_carousel_'+principal_iframe)) {
			if (document.getElementById('hidden_iframe_carousel_'+principal_iframe).value == 0) {			
				document.getElementById('iframe_carousel_'+principal_iframe).src = 'includes/galeria_carousel.php?cod='+document.getElementById('cod_'+principal_iframe).value+'&tabla_carousel='+document.getElementById('tabla_carousel_'+principal_iframe).value+'&zz='+principal_iframe+'&tipo_bbdd='+document.getElementById('tipo_bbdd_'+principal_iframe).value+'';		
				document.getElementById('hidden_iframe_carousel_'+principal_iframe).value = 1;
			}				
		}		
	}
	else
	{
		if (anterior_iframe == principal_iframe)
		{
			if (document.getElementById('cCapa_'+principal_iframe).style.display == "none")
			{
				document.getElementById('cCapa_'+principal_iframe).style.display='block';
				document.getElementById('flecha_'+principal_iframe).src = 'images/flecha_on.png';
				document.getElementById('texto_'+principal_iframe).style.fontWeight = 'bold';
				if (document.getElementById('iframe_carousel_'+principal_iframe)) {
					if (document.getElementById('hidden_iframe_carousel_'+principal_iframe).value == 0) {
						document.getElementById('iframe_carousel_'+principal_iframe).src = 'includes/galeria_carousel.php?cod='+document.getElementById('cod_'+principal_iframe).value+'&tabla_carousel='+document.getElementById('tabla_carousel_'+principal_iframe).value+'&zz='+principal_iframe+'&tipo_bbdd='+document.getElementById('tipo_bbdd_'+principal_iframe).value+'';
						document.getElementById('hidden_iframe_carousel_'+principal_iframe).value = 1;
					}
				}				
			}
			else
			{
				document.getElementById('cCapa_'+principal_iframe).style.display='none';
				document.getElementById('flecha_'+principal_iframe).src = 'images/flecha_off.png';
				document.getElementById('texto_'+principal_iframe).style.fontWeight = 'normal';
			}
		}
		else
		{
			document.getElementById('cCapa_'+anterior_iframe).style.display='none';
			document.getElementById('flecha_'+anterior_iframe).src = 'images/flecha_off.png';
			document.getElementById('texto_'+anterior_iframe).style.fontWeight = 'normal';
			document.getElementById('cCapa_'+principal_iframe).style.display = 'block';
			document.getElementById('flecha_'+principal_iframe).src = 'images/flecha_on.png';
			document.getElementById('texto_'+principal_iframe).style.fontWeight = 'bold';
			if (document.getElementById('iframe_carousel_'+principal_iframe)) {
				if (document.getElementById('hidden_iframe_carousel_'+principal_iframe).value == 0) {
					document.getElementById('iframe_carousel_'+principal_iframe).src = 'includes/galeria_carousel.php?cod='+document.getElementById('cod_'+principal_iframe).value+'&tabla_carousel='+document.getElementById('tabla_carousel_'+principal_iframe).value+'&zz='+principal_iframe+'&tipo_bbdd='+document.getElementById('tipo_bbdd_'+principal_iframe).value+'';
					document.getElementById('hidden_iframe_carousel_'+principal_iframe).value = 1;
				}
			}		
		}
	}
}

function cargar_iframe (id, url) { 
	if (document.getElementById('hidden_iframe_mapa_'+id).value == 0) {
		document.getElementById('iframe_mapa_'+id).src = ''+url+'';	
		document.getElementById('hidden_iframe_mapa_'+id).value = 1;
	}	
}
function cargar_foto(img, ancho, alto){
  string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+ancho+",height="+alto+"";
  fin=window.open(img,"",string);
}
