function lib_bwcheck(){ 
this.ver= parseInt(navigator.appVersion);
var agt=navigator.userAgent.toLowerCase();
this.dom=document.getElementById?1:0
this.ns= ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
this.ns4 = (this.ns && (this.ver == 4));
this.ns4up = (this.ns && (this.ver >= 4));
this.ns6 = (this.ns && (this.ver == 5));
this.ies     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
this.ie4    = (this.ies && (this.ver == 4) && (agt.indexOf("msie 4")!=-1) );
this.ie  = (this.ies  && (this.ver >= 4));
this.ie5    = (this.ies && (this.ver == 4) && (agt.indexOf("msie 5.0")!=-1) );
this.ie5_5  = (this.ies && (this.ver == 4) && (agt.indexOf("msie 5.5") !=-1));
this.ie5up  = (this.ies  && !this.ie3 && !this.ie4);
this.ie5_5up =(this.ies && !this.ie3 && !this.ie4 && !this.ie5);
this.ie6 = (this.ies && (this.ver == 4) && (agt.indexOf("msie 6.")!=-1) );
this.bw=(this.ie||this.ns4up)
  return this
if(bw.ns4 || bw.ie4) return lib_message('La presente página está diseñada para Internet Explorer 5 ó +,Netscape 6/7, Firefox 0.8/0.9 y Opera 7. Es posible que encuentre problemas en su navegación')
}
bw=new lib_bwcheck() //Browsercheck object

function lib_message(txt){alert(txt); return false}
function lib_obj(obj,nest){ 
 this.nested="";
if(bw.ns4 && nest){ //get nested
nest="n "+nest;
nest=nest.split(' ');
for(var i=1;i<nest.length;i++) this.nested+="document."+nest[i]+".";}
this.evnt=bw.ns4?eval(this.nested+'document.layers["'+obj+'"]'):bw.ie4?eval('document.all["'+obj+'"]'):
bw.dom?eval('document.getElementById("'+obj+'")'):0;
  if(!this.evnt) return lib_message('The layer does not exist ('+obj+')' 
    +'- \nIf your using Netscape please check the nesting of your tags!')
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt; 
  this.ref=bw.dom||bw.ie4?document:this.css.document
    this.x=parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;
  this.y=parseInt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0
  }

//Writing content to object ***
lib_obj.prototype.writeIt = function(text,startHTML,endHTML){
	if(bw.ns4){
    if(!startHTML){startHTML=""; endHTML=""}
	  this.ref.open("text/html"); 
    this.ref.write(startHTML+text+endHTML); 
    this.ref.close()
	}else this.evnt.innerHTML=text
}
function Imagen(imagen, nombre_ventana, pie, dimensiones, ancho, alto) { 
var codHTML = "";
var ventana;
posx = bw.ie ?document.body.clientWidth/2-(ancho/2):innerWidth/2-(ancho);
      posy = bw.ie ?document.body.clientHeight/2-(alto) :innerHeight/2-(alto/2);
if(posy<0){posy=0}
if(posx<0){posx=0}

dimensiones+=',top='+posy+',left='+posx;
ventana = window.open("/blanco.html",'',dimensiones,"resizable=0,scrollbars=no");
codHTML += '<HTML><HEAD><TITLE>';
codHTML += nombre_ventana;
codHTML += '</TITLE><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD><BODY onblur="javascript:window.close()" onclick="javascript:window.close()" bgcolor="FFFFFF" leftMargin=0 text=000000 topMargin=0 marginwidth="0" marginheight="0">';
codHTML += '<IMG SRC="' + imagen + '" WIDTH=' + ancho + ' HEIGHT=' + alto + ' ALT="" BORDER="0">';
codHTML += '<BR><table width="' + ancho + '" border="0" cellspacing="0" cellpadding="5"><tr align="right"><td><div align=justify>';
codHTML += '<font size="1" color="#333333" face="Verdana, sans-serif">' + pie;
codHTML += '</font></div>';
codHTML += '</td></tr></table>';
codHTML += '</BODY></HTML>';
ventana.document.open();
ventana.document.write(codHTML);
ventana.document.close();
}

function Ventana(url,ancho, alto)

{
posx = bw.ie ?document.body.clientWidth/2-(ancho/2):innerWidth/2-(ancho/2);
      posy =bw.ie ?document.body.clientHeight/2-(alto/2+100) :innerHeight/2-(alto/2);
if(posy<0){posy=0}
if(posx<0){posx=0}
dimensiones='width='+ancho+',height='+alto+',top='+posy+',left='+posx;
ventana = window.open(url,'',dimensiones,",menubar=0,scrollbars=1,resizable=0");
 ventana.focus();
  onscreen=true;
}

function Item(){
  this.length = Item.arguments.length 
  for (var i = 0; i < this.length; i++)
    this[i] = Item.arguments[i]
}

function Fecha() {
  var nmes  = new Item('enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 
                          'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre')
  var ahora
  var fecha = new Date()
  var ano   = fecha.getYear()
  var mes   = fecha.getMonth()
  var aux   = "" + fecha
  
  if (ano<10) {
    ano2 = "200" + eval(ano)
  }
  else if (ano<80) {                
    ano2 = "20" + ano
  } 
  else if (ano<=99) {               
    ano2 = "19" + ano
  }
  else if (ano<1000) {              
    ano2 = eval(ano) + eval(1900)
  }
  else {
    ano2 = ano                     
  }
  

  ahora = " , " + eval(aux.substring(7, 10)) + " de " + nmes[mes] + " de " + ano2
  return ahora
}
	function volver() { 
				var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}

			function MM_findObj(n, d) {
				var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
				d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
				if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
				for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
			}
			function vermov() {
				var i,j=0,x,a=vermov.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
				if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
			}
			
			//----------------------------------fuentes
			var title=2;	var guardasize=2;
function setActiveFont(title2, reset,comienzo) {
  var i, a, main;
 if (typeof(title2)=="number" && title2!=2){
			if(comienzo!=1){
				title=Number(title)+Number(title2)
			}
			if(title<=0){
				title=1;
			}
			if(title>=5){
				title=4
			}
guardasize=title;
}
else{
	title=title2;
}

  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if((a.getAttribute("rel").indexOf("style") != -1) && (a.getAttribute("title").indexOf("css")!=0) && (a.getAttribute("media")!="print")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) 
		{a.disabled = false;
		if(title!=2){title=guardasize;}
		}
    }
  }
  if(reset==1){
	  createCookie("stylefuentes", title, 365);
	  }
}

function setActiveCSS(titleCSS, reset,comienzo) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if((a.getAttribute("rel").indexOf("style") != -1) && a.getAttribute("title").indexOf("css")!=-1){
      a.disabled = true;
      if(a.getAttribute("title") == titleCSS) 
		{a.disabled = false;}
    }
  }
  if(reset==1){
	  createCookie("stylecss", titleCSS, 365);
	  }
}

function setStyle() {
	var style = readCookie("stylefuentes");
	if (style != null) {
			setActiveFont(style,0,1);
	}
}

function setStylecss() {
	var style = readCookie("stylecss");
	if (style != null) {
		setActiveCSS(style,0,1);
	}

}


// ----------------------------------------------
// Cookie functions
// ----------------------------------------------

function createCookie(name,value,days) {
titulopagina=document.location.href;
patron=/.+\.([\w\d]+\.\w+).+/gi
titulopagina=titulopagina.replace(patron,"$1");
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = ";expires="+date.toGMTString();
  }
  else expires = "";
document.cookie = name+"="+value+expires+";domain=."+titulopagina+";path=/;";
}


function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function fixEstilos(){
setStylecss();
setStyle();
}
fixEstilos();

//-------------------------
function cargarimagenes() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=cargarimagenes.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//--------------
function sendrequest(numero){
document.formse.id.value=numero;
document.formse.submit();
}

//---------------------enseñar tooltip
function showtip(current,text){
if (document.all||document.getElementById){
thetitle=text.split('<br>')
if (thetitle.length>1){
thetitles=''
for (i=0;i<thetitle.length;i++)
thetitles+=thetitle[i]
current.title=thetitles
}else
current.title=text
}}

//-------------window.status
function comment(comentario){
window.status=comentario;
}
function uncomment(){
window.status="Hostal Naranjo";
window.defaultStatus="Hostal Naranjo"
}
if(bw.ie){
window.defaultStatus="Hostal Naranjo"}
//-------------imprimir
function cargarimagenes() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=cargarimagenes.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
	function volver() { 
				var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}

			function MM_findObj(n, d) {
				var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
				d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
				if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
				for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
			}
			function vermov() {
				var i,j=0,x,a=vermov.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
				if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
			}
			
			function comprobarform(formobj,funcion){
	// dialog message

	var alertMsg = typeof(msgAlert)=="undefined"?"Por favor rellene los siguientes campos:\n":msgAlert;
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
if(alertMsg.length == l_Msg && fieldEmail[i]==1 && validateEmail(obj.value)==false){
alertMsg='Por favor, compruebe que el e-mail que ha escrito en --'+fieldDescription[i]+'-- se compone de: nombredeusuario+@+dominio+.+extensión. Por ejemplo: nombreusuario@servidordecorreo.com';
break
}	
	}

if (alertMsg.length == l_Msg){//<if-1
args=comprobarform.arguments;
argsLen=comprobarform.arguments.length;
for (i=1;i<argsLen;i++){//<for-2
if(args[i]!=""){//<if-3
funcion=args[i];
if(funcion(formobj)){//<if-4
}
else{return false;
break}//>if-4

}//>if-3
}//>for-2
lacapa.writeIt('<strong>Enviando...</strong>');
formobj.submit();


}
	else{
		alert(alertMsg);
		return false;
	} 
}
function iguales(formobj){
if(formobj.elements[losiguales[0]].value==formobj.elements[losiguales[1]].value){
return true
}else{
alert("Por favor compruebe que "+losigualesDescripcion[0]+" y "+losigualesDescripcion[1]+" son iguales");
return false
}
}

function unoden(formobj){
argsLen=unodeN.length;
for (i=0;i<argsLen;i++){//<for-2
if(formobj.elements[unodeN[i]].value!=""){
return true;
break;
}}
alert("Por favor compruebe que ha elegido una opción de "+unodeNDescripcion);
return false;
}

function validateEmail(formobj)
{

// 5_12_2006: Ahora no permitimos enviar correos a varios destinatarios
if (formobj.indexOf(';') > -1)
{
	return false;
}

splitted = formobj.match("^(.+)@(.+)$");
    var regexp_user=/^\"?[\w-_\.]*\"?$/;
    var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;	 
						    if(splitted==null || (splitted[1] != null && splitted[1].match(regexp_user) == null) || (splitted[2] != null && splitted[2].match(regexp_domain) == null && splitted[2].match(regexp_ip) == null))
							{ 						
return false;							}					
							return true;	
}
function resetear(){
campos=Array("INPUT","SELECT","TEXTAREA");
tipoexcluido=Array("hidden");
tipoexcluidolen=tipoexcluido.length;
	for(h=0;h<campos.length;h++){
	elementoslen=document.getElementsByTagName(campos[h]).length;
		for(i=0;i<elementoslen;i++){
			for(j=0;j<tipoexcluidolen;j++){
					if(document.getElementsByTagName(campos[h])(i).getAttribute("type")!=tipoexcluido[j]){
					document.getElementsByTagName(campos[h])(i).value="";
					}
			}
		}
	}
}