sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//Se utiliza en Portada. Selecciona el idioma de la web y nos lleva a una url
EntradaWeb = function (newIdioma, page) {
  //theForm.__Idioma.value = newIdioma;
	var form = document.forms[0];
  form.__Idioma.value = newIdioma;
  form.action = page;
  form.submit();
}
//Cambiamos el idioma de la web
CambiarIdioma = function (newIdioma) {
	var form = document.forms[0];
  //theForm.__Idioma.value = newIdioma;
  form.__Idioma.value = newIdioma;
  form.submit();
}
//Vamo a la url
Goto = function (page) {
	var form = document.forms[0];
  if (form.__GoPage != null)
    form.__GoPage.value = 0;
  form.action = page;
  form.submit();
}
//Vamo a la url asignando un Id para localización de registro
GotoById = function (page,id) {
	var form = document.forms[0];
  if (form.__GoPage != null)
    form.__GoPage.value = 0;
	form.__Id.value = id;
  form.action = page;
  form.submit();
}
//Vamos a la página de la grid ??
GoPage = function (number) {
	var form = document.forms[0];
  form.__GoPage.value = number.toString();
  form.submit();
}
//
OperCalculator = function (operation) {
 var form = document.forms[0];
 form.__OP.value = operation;
 form.submit();
}
ResetForm = function () {
 var form = document.forms[0];
 x=p;
}

// Redimensiona los iframes
function resizeFrame() {
    document.getElementById("oFrameBusc").style.height = eval("window.frames." + "oFrameBusc"+ ".document.documentElement.scrollHeight") + "px";        
}

// Focus para inputs en IE
sfFocus = function() {
    var sfEls = document.getElementsByTagName("INPUT");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onfocus=function() {
            this.className+=" sffocus";
        }
        sfEls[i].onblur=function() {
            this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);


// Focus para textareas en IE
sfFocus = function() {
    var sfEls = document.getElementsByTagName("TEXTAREA");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onfocus=function() {
            this.className+=" sffocus";
        }
        sfEls[i].onblur=function() {
            this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);


// Focus para select en IE
sfFocus = function() {
    var sfEls = document.getElementsByTagName("SELECT");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onfocus=function() {
            this.className+=" sffocus";
        }
        sfEls[i].onblur=function() {
            this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);


// Crear links para cada idioma
function crearLinkIdioma(idioma, idiomaCompleto) {
    var idiomaActual = document.getElementById("__Idioma").value;
    if (idiomaActual.length == 0) idiomaActual = "es";
	if (idiomaActual != idioma) {
		document.write('<a href="#" onClick="javascript:CambiarIdioma(\'' + idioma + '\')" title="' + idiomaCompleto + '"><img src="img/idioma-' + idioma + '.gif" alt="' + idiomaCompleto + '" border="0" class="langNoActivo" /></a>');
	} else {
		document.write('<img src="img/idioma-' + idioma + '.gif" alt="' + idiomaCompleto + '" border="0" />');
	}
}


//Cambiamos el idioma de la web
CambiarIdioma = function (newIdioma) {
    var form = document.forms[0];
    form.__Idioma.value = newIdioma;
    form.submit();
}

//Vamos a la url
Goto = function (page) {
    var form = document.forms[0];
    form.action = page;
    form.submit();
}

// ENVIAR E-MAIL: INICIO
var CTXT_PoblacionValido = 'La poblaci\u00F3n del inmueble ha de estar informada';
var CTXT_PrecioValido = 'El precio del inmueble ha de estar informado';
var CTXT_SuperficieValido = 'La superficie del inmueble ha de estar informada';
var CTXT_NombreValido = 'El nombre ha de estar informado';
var CTXT_EmailTelefonoValido = 'La direcci\u00F3n de correo electr\u00F3nico o alg\u00FAn tel\u00E9fono tienen que ser correctos';
var CTXT_EmailTelefonoNombreValido = 'La direcci\u00F3n de correo electr\u00F3nico o alg\u00FAn tel\u00E9fono y el nombre tienen que ser v\u00E1lidos';
var CTXT_EmailNombreValido = 'La direcci\u00F3n de correo electr\u00F3nico y el nombre tienen que ser v\u00E1lidos';
var CTXT_EmailValido = 'La direcci\u00F3n de correo electr\u00F3nico tiene que ser v\u00E1lida';

function EnviarMailContacto() {
	var okmail = true;
	var oknom = true;	
	if (typeof(document.theForm.uMailEMail)=="object") {
		if (document.theForm.uMailEMail.value.length<5) {
			okmail = false;
		}
		else {
			var arr = document.theForm.uMailEMail.value.indexOf('@')
			if (arr<=0||arr==document.theForm.uMailEMail.value.length-1) {
				okmail = false;
			}
			else if (document.theForm.uMailEMail.value.substr(arr,document.theForm.uMailEMail.value.length-1).indexOf('.')<=0) {
				okmail = false;
			}
		}
	}
	if (typeof(document.theForm.uMailNombre)=="object")
		if (document.theForm.uMailNombre.value.length==0)
			oknom = false;
	if (okmail&&oknom) {	
        var sbody = '<p><strong>Nombre: </strong>' + document.getElementById("uMailNombre").value + '</p>';
        sbody = sbody + '<p><strong>E-mail: </strong>' + document.getElementById("uMailEMail").value + '</p>';
        sbody = sbody + '<p><strong>Sugerencias: </strong>' + document.getElementById("uMailComentarios").value + '</p>';
        
        document.getElementById("bodyMail").value = sbody;
        document.getElementById("origenMail").value = "Contactar";
        document.theForm.action = "EnviarMail.aspx";
        document.theForm.submit();
	} else if(okmail) {
		alert(CTXT_NombreValido);
	} else if(oknom) {
		alert(CTXT_EmailValido);
	} else {
		alert(CTXT_EmailNombreValido);
	}
}

//Redirecciona a la ficha de un inmueble determinado (funcion para los inmuebles enviados por e-mail) 
  function goSearch(sInm){
    oFrameBusc.location = "http://serverprepro/ib2c/stddev/?" + sInm;       
  }