email='in'+'fo@a'+'lojam'+'ientoru'+'ral'+'elval'+'le.'+'com';
e='<a href="mailto:'+email+'" title="Enviar un mensaje" class="correo">'+email+'</a>';

/*
  Envia formulario
*/
function enviar(c) {
  c.toEmail.value=email;
  c.submit();
}

/*
  Fuerza a meter contenido en el <iframe>
*/
function indice(l) {
  var ok = false;

  if (top.location.search!='') {
    var i=location.search.split('pag=')[1];
    if (i) {
      top.contenido.location.replace(i);
      ok=true;
    }
  }

  if (!ok) {
    top.contenido.location='/'+l+'/portada.html';
  }

  idioma(l);
}

/*
  Menu activo
*/
function menu(c) {
  var sw=new Array('portada','accesos','precios','ofertas','actividades','reservas','contacto','entorno','enlaces','nogal','laurel','pinoazul','limonero','olivo','piscina','astronomia','otras');
  for (i=0; i<sw.length; i++) {
    if (sw[i]=='nogal' || sw[i]=='laurel' || sw[i]=='pinoazul' || sw[i]=='limonero' || sw[i]=='olivo' || sw[i]=='piscina' || sw[i]=='astronomia' || sw[i]=='otras') document.getElementById(sw[i]).className='solapa-off';
    else  document.getElementById(sw[i]).className='menu-off';
  }
  if (c=='nogal' || c=='laurel' || c=='pinoazul' || c=='limonero' || c=='olivo' || c=='piscina' || c=='astronomia' || c=='otras') document.getElementById(c).className='solapa-on';
  else document.getElementById(c).className='menu-on';
}

/*
  Seleccion idioma
*/
function idioma(l) {
  switch (l) {
    case 'es':txt='Seleccione su idioma'
    break
    case 'en':txt='Select your language'
    break
    case 'fr':txt='Choisissez votre langue'
    break
    case 'de':txt='Deutsh'
    break
    default:txt='Seleccione su idioma'
  }
  document.getElementById('idiomaseleccion').innerHTML=txt;
}

/*
  Foto ampliada
*/
function foto(a,f,t) {
  if (a=='n') {
    document.getElementById('fotograndebg').style["visibility"]='';
    document.getElementById('fotogrande').style["visibility"]='';
    document.getElementById('fotogrande').innerHTML='<table align="center" cellspacing="0" cellpadding="0"><tr style="vertical-align:top"><td><img src="/img/esquina-sup-izq-c.gif"/></td><td style="padding-top:2px;text-align:right" class="fondo"><a href="javascript:;" onclick="foto(\'f\',\'\')">Cerrar imagen <img src="/img/icono-equis.gif" alt="Cerrar" valign="absmiddle"/></a></td><td><img src="/img/esquina-sup-der-c.gif"/></td></tr><tr><td class="fondo"></td><td id="foto"><img src="/img/galeria/foto-'+f+'-grande.jpg" onclick="foto(\'f\',\'\')"/></td><td class="fondo"></td></tr><tr style="vertical-align:bottom"><td><img src="/img/esquina-inf-izq-c.gif"/></td><td style="padding-bottom:2px;font-weight:bold" class="fondo">'+t+'</td><td><img src="/img/esquina-inf-der-c.gif"/></td></tr></table>';
  }
  else {
    document.getElementById('fotograndebg').style["visibility"]='hidden';
    document.getElementById('fotogrande').style["visibility"]='hidden';
    document.getElementById('fotogrande').innerHTML='';
  }
}

// /*
// Foto ampliada ccc
// */
// function selectpic(cual) {
// t=600;
// //w=(screen.width)?(screen.width-t)/2-160:0;
// h=(screen.height)?(screen.height-t)/2-30:0;
// x=window.open('','zoom','height='+t+',width='+t+',top='+h+',left=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0');
// x.document.open();
// x.document.write('<html><head><title>Alojamiento Rural El Valle</title>');
//     x.document.write('<link href="/css/general.css" rel="stylesheet" type="text/css"/></head>');
//   x.document.write('<body onload="this.focus()">');
//     x.document.write('<table border="0" width="100%" height="100%">');
//       x.document.write('<tr><td align="center"><img src="/img/casas/'+cual+'.jpg" border="0"/></td></tr>');
//       x.document.write('<tr><td align="center"><a href="javascript:window.close()">Cerrar imagen</a></td></tr>');
//       x.document.write('</table></body></html>');
// x.document.close();
// }


/*
  Formularios validos
*/
function comprueba(f) {
  var q=contenido.document.forms[0].elements[f];
  if (q.value=='') {
    q.focus();
    q.style['backgroundColor']='yellow';
  }
}

/*
  Enlaces ruralgest
*/
function reservas(c) {
  switch (c) {
  case 'nogal':ref='http://www.ruralgest.net/scr/index_reserva.php?opcion=1&id_casa=570294&operador='
    break
    case 'laurel':ref='http://www.ruralgest.net/scr/index_reserva.php?opcion=1&id_casa=4272&operador='
    break
    case 'pinoazul':ref='http://www.ruralgest.net/scr/index_reserva.php?opcion=1&id_casa=570293&operador='
    break
    case 'limonero':ref='http://www.ruralgest.net/scr/index_reserva.php?opcion=1&id_casa=570292&operador='
    break
    case 'olivo':ref='http://www.ruralgest.net/scr/index_reserva.php?opcion=1&id_casa=570295&operador='
    break
    default:ref='' //alert('No ha seleccionado ning&uacute;n alojamiento.\nSeleccione uno para reservar online.')
  }
  window.open('http://www.ruralgest.net/scr/index_reserva.php?opcion=1&id_casa='+ref);
}

// ganalytics - caela
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-10605194-15']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga,s);
})();
