// JavaScript Document
// EXTRANET INMOBILIARIAS

<!-- 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
//verifica formulario de contacto
function verificar_contacta(){
	if(document.forms[0].nombre.value == "" || document.forms[0].telefono.value == "" || document.forms[0].mail.value == ""){
		alert (" Por favor, cumplimente los campos 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
//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
// Converts carriage returns 
// to <BR> for display in HTML
//linea del boton : onClick="this.form.text.value =ConvertBR(this.form.texto.value);"

function ConvertBR(input) {

var sw = 0
var text = "";
for (var i = 0; i < input.length; i++) {
if ((input.charCodeAt(i) == 13) && (input.charCodeAt(i + 1) == 10)) {
i++;
text += "<BR>";
sw = 0;
} 
else if(input.charCodeAt(i) == 32) {
if(sw == 0){
text += " ";
sw = 1
}
else {
text += "&nbsp;";
sw = 1
}}
else {
text += input.charAt(i);
sw = 0;
   }
}
return text;
}
//  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 -->
