// JavaScript Document
// EXTRANET INMOBILIARIAS

<!-- Begin 
function copia_input(elemento){
	
	if(elemento.value){
		numero = elemento.id;
		siguiente = Number(numero) + 1;
		if(!document.getElementById(siguiente).value){
			document.getElementById(siguiente).value = elemento.value;
		}
	}else{
		numero = elemento.id;
		antepenultimo = Number(numero) - 2;
		document.getElementById(numero).value = document.getElementById(antepenultimo).value;
	}
}
// End -->

<!-- Begin -->

function mostrar(){
	document.getElementById('galeria').style.visibility="visible";
	document.getElementById('galeria_flash').style.opacity = 100;
	//document.getElementById('galeria_flash').style.filter = 'alpha(opacity='100');
	
}
function ocultar(){
	document.getElementById('galeria').style.visibility="hidden";
}

<!-- End -->


<!-- Begin
// listado de inmuebles
var color1 = "#FFFFff";
var color2 = "#cccccc";
var color_on = "#ffff99";

function fondo(){
var inicio = 1;
var total = listado.rows.length;
for ( inicio; inicio<total; inicio++){
	if (inicio%2==0){
		listado.rows(inicio).bgColor = color1
		}
		else {
			listado.rows(inicio).bgColor = color2
			}
	}
}
function _on(fila){
	color_anterior = fila.bgColor;
	fila.bgColor= color_on;
	fila.style.cursor = "hand";
}
function _out(fila){
fila.bgColor= color_anterior
}

//  End -->

<!-- Begin

function comprueba_fechas(){
   	if (document.forms.form1.entrada.value == "dd-mm-aaaa" || document.forms.form1.sortida.value == "dd-mm-aaaa" || document.forms.form1.entrada.value == "" || document.forms.form1.sortida.value == ""){
		alert("Verifique que las fechas de entrada y salida son correctas");
	}else{
		if(document.forms[0].ocupacion.selectedIndex == "0"){
			alert("Verifique la ocupación");
		}else{
			if (document.forms.form1.nombre.value == "" || document.forms.form1.email.value == ""){
				alert("Verifique su nombre y su email");
			}else{
				document.forms[0].submit();
			}
		}
	}
}

// End -->

<!-- Begin
//verifica formulario de contacto
function verificar_contacta(){
	if(document.forms[0].nombre.value == "" || document.forms[0].email.value == ""){
		alert (" Por favor, cumplimente TODOS los campos.");
		if (document.forms[0].nombre.value == ""){
			document.forms[0].nombre.focus();
		}
		//	else{
		//		document.forms[0].telefono.focus();
		//	}
		}
		else{
			document.forms[0].submit();
		}
}
			
//  End -->
function envia_amigo(){
   	if (document.forms.form2.tunombre.value == "" || document.forms.form2.tuemail.value == "" || document.forms.form2.sunombre.value == "" || document.forms.form2.suemail.value == ""){
		alert("Rellene todos los campos");
	}else{
		document.forms[1].submit();
	}
}

// End -->
<!-- Begin
//verifica formulario de reserva de charter
function verificar_0resent(){
	if(document.forms[0].nombre.value == "" || document.forms[0].telefono.value == "" || document.forms[0].email.value == "" || document.forms[0].domicilio.value == "" || document.forms[0].dni.value == "" || document.forms[0].poblacion.value == "" || document.forms[0].pais.value == "" || document.forms[0].nacionalidad.value == ""){
		alert (" Todos los campos son obligatorios.");
		if (document.forms[0].nombre.value == ""){
			document.forms[0].nombre.focus();
		}
		//	else{
		//		document.forms[0].telefono.focus();
		//	}
		}
		else{
			document.forms[0].submit();
		}
}
			
//  End -->



<!-- Begin
function moveOver()  
{
var boxLength = document.forms[0].seleccionados.length;
var selectedItem = document.forms[0].seleciones.selectedIndex;
var selectedText = document.forms[0].seleciones.options[selectedItem].text;
var selectedValue = document.forms[0].seleciones.options[selectedItem].value;
var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.forms[0].seleccionados.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
      }
   }
} 
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.forms[0].seleccionados.options[boxLength] = newoption;
}
document.forms[0].seleciones.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.forms[0].seleccionados.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.forms[0].seleccionados.options[i].selected) {
arrSelected[count] = document.forms[0].seleccionados.options[i].value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.forms[0].seleccionados.options[i].value == arrSelected[x]) {
document.forms[0].seleccionados.options[i] = null;
   }
}
boxLength = document.forms[0].seleccionados.length;
   }
}
function saveMe() {
var strValues = "";
var boxLength = document.forms[0].seleccionados.length;
var count = 0;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
if (count == 0) {
strValues = document.forms[0].seleccionados.options[i].value;
}
else {
strValues = strValues + "," + document.forms[0].seleccionados.options[i].value;
}
count++;
   }
}
if (strValues.length == 0) {
alert("No has hecho ninguna selección");
}
else {
//alert("Aquí están los valores seleccionados:\r\n" + strValues);
document.forms[0].selecciones.value = strValues;
document.forms[0].submit();
   }
}
//  End -->


<!-- Begin
function pregunta(){ 
   if (confirm('¿ Seguro que desea borrar el registro ?')){ 
	  document.forms[0].submit() 
   } 
} 
//  End -->


<!-- Begin
// controla que sea un numero con decimales
function checkDecimals(fieldName, fieldValue) {

decallowed = 2;  // how many decimals are allowed?

if (isNaN(fieldValue) || fieldValue == "") {
alert("Por favor introduzca un número valido (xxxx.xx)");
fieldName.select();
fieldName.focus();
}
else {
if (fieldValue.indexOf('.') == -1) fieldValue += ".";
dectext = fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);

if (dectext.length > decallowed)
{
alert ("Por favor, entra un número con " + decallowed + " números decimales.");
fieldName.select();
fieldName.focus();
      }
else {
a="ok";
      }
   }
}
//  End -->



<!-- Begin
// CONTROLA QUE IMAGEN SEA JPG
//extArray = new Array(".gif", ".jpg");

function LimitAttach(form, file) {
extArray = new Array(".jpg");
allowSubmit = false;
imagen = file;
enviar = false;
if (!file){
 //document.forms[0].submit();
end;}
else {
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) enviar=true;
else
alert("Se permiten únicamente archivos con la extención: " 
+ (extArray.join("  ")) + "\nPor favor, seleccione otro archivo "
+ "e intente de nuevo.");
imagen = " ";
}}

//  End -->





<!-- Begin
function ReplaceEnters(campo) {
texto = document.getElementById(campo).value;
conbr = "a";
 if (conbr) {
 pat = new RegExp(String.fromCharCode(13),"g")
 pat2 = new RegExp(String.fromCharCode(10),"g")
  texto = texto.replace(pat, "");
   texto = texto.replace(pat2, "<br>");
 } else {
  texto = texto.replace(/<br>/g, String.fromCharCode(13));
 }
// alert(texto);
// return texto
document.getElementById(campo).value = texto;
}
//  End -->

<!-- Begin 
//reloads the window if Nav4 resized

function MM_reloadPage(init) { 
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// End -->



