var marked_row = new Array;
function marcar(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    }
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } 

    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } 
        }
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } 

    return true;
} 
    
//Abre y cierra los elementos de menú
function openClose(sel) {
	elemento = document.getElementById(sel);
	if (elemento.style['display'] == "none") {
		elemento.style['display'] = "block";
	} else {
		elemento.style['display'] = "none";
	}
}

function abre_popup(tipo)
{
  alto = 390;
  ancho = 465;
  izquierda = (screen.width / 2) - (ancho / 2);
  superior = (screen.height / 2) - (alto / 2);
  newwin=window.open("popup_foto.php?idB=&tp=" + tipo,"interior","height="+alto+",width="+ancho+",location=no,directories=no,menubar=no,resizable=auto,copyhistory=no,scrollbars=no,status=no,titlebar=no,toolbar=no,left=" + izquierda + ",top=" + superior)
}

function isla() {
  alto = 240;
  ancho = 465;
  izquierda = (screen.width / 2) - (ancho / 2);
  superior = (screen.height / 2) - (alto / 2);

  newwin=window.open("popup_isla.php?idB=","isla","height="+alto+",width="+ancho+",location=no,directories=no,menubar=no,resizable=auto,copyhistory=no,scrollbars=no,status=no,titlebar=no,toolbar=no,left=" + izquierda + ",top=" + superior)
}

function tarifas() {
  alto = 310;
  ancho = 570;
  izquierda = (screen.width / 2) - (ancho / 2);
  superior = (screen.height / 2) - (alto / 2);

  newwin=window.open("popup_tarifa.php?idB=","tarifas","height="+alto+",width="+ancho+",location=no,directories=no,menubar=no,resizable=auto,copyhistory=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,left=" + izquierda + ",top=" + superior)
}

function checkEmail(str)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str)){
		return true;
	}
	return false;
}

function validaForm(formulario) {
	
	if (formulario.formContacto.value == "" || formulario.formTelefono.value == "") {
		alert('Debe indicarnos una persona de contacto y un número de teléfono válidos.');
		return false;
	} else { 
		if (!checkEmail(formulario.formMail.value)) {
			alert('Debe indicarnos una dirección de correo electrónico correcta.');
			return false;
		} else {
			if (typeof(formulario.formImagen)!="undefined" && formulario.formImagen.value=="") {
				alert('Debe repetir el texto de la imagen');
				return false;
			} else {
				return true;	
			}
		}
	}
}
function abreFilas(fila) {
	
	if (document.getElementById(fila).style.display == "none") {
		document.getElementById(fila).style.display = "block";
	} else {
		document.getElementById(fila).style.display = "none";
	}

}
