var MensajeCamposOblig = 'Los campos marcados con * deben de estar cumplimentados obligatoriamente'
var EMailIncorrecto = 'La dirección de E-Mail introducida no es correcta';
var Meses = new Array ('', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');


function OpenWin (win, alto, ancho) {
	if (alto == '') {
		alto = screen.height - 100;
	}
	if (ancho == '') {
		ancho = 800;
	}
	var izq = (screen.width - ancho) / 2;
	window.open(win, '','status=no,menubar=no,resizable=yes,scrollbars=yes,top=0,left=' + izq + ',width=' + ancho + ',height=' + alto);
}

function MostrarOcultar (capa)	{
	if (capa.style.display == 'block') {
		capa.style.display = 'none';  
	}
	else {	
		capa.style.display = 'block';
	}
}

//*******************************************************************************
// 

function ValidaLongTextArea(texto, numCar) {
	textoInicio = texto.value	
	if (textoInicio.length >= numCar) {
		texto.value = textoInicio.substring (0, numCar);
	}	
}

//*******************************************************************************
//
function Mostrar (capa)	{
  
 var oObject = document.all.tags("div");
	for (var i=0; i <  oObject.length; i++) {
	 oObject(i).style.display = 'none';
 }
 	capa.style.display = 'block';	 
}

//*******************************************************************************
//
function SeleccTR (tabla, fila, campo1, valor1, campo2, valor2) {
	for (i=0; i < tabla.rows.length; i++) {
		tabla.rows(i).className = 'NOSELECC';
  }
  fila.className = 'SELECC';
  if (campo1 != '') {
		campo1.value = valor1;
  }
  if (campo2 != '') {
		campo2.value = valor2;
  }
}

//*******************************************************************************
//
function SeleccTRAdv (tabla, fila, campo1, valor1, campo2, valor2, campo3, valor3, campo4, valor4) {
	for (i=0; i < tabla.rows.length; i++) {
		tabla.rows(i).className = 'NOSELECC';
  }
  fila.className = 'SELECC';
  if (campo1 != '') {
		campo1.value = valor1;
  }
  if (campo2 != '') {
		campo2.value = valor2;
  }
  if (campo3 != '') {
		campo3.value = valor3;
  }
  if (campo4 != '') {
		campo4.value = valor4;
  }
}


//**************************************************************************
// Devuelve true si el EMail es correcto
function ValidarEMail(s) {
	var filter=/^[A-Za-z.][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (filter.test(s)) {
		return true;
	}
	else {
		return false;
	}
}

//*******************************************************************************
//
function MostrarTabla(elem, imagen, row) {
	 if (elem.style.display == 'none') {
		elem.style.display = '';
		imagen.src = '../../images/blue_up.gif';
		row.className = 'OPEN';
	 }
	 else {
	  elem.style.display = 'none';
		imagen.src = '../../images/gray_down.gif';
		row.className = 'CLOSE';
	 } 
}

//**************************************************************************
// Sólo números en caja de texto
// UTILIZACIÓN:
// NO permite decimales --> onkeypress="onlyDigits(event,'noDec')"
// SI permite decimales	--> onkeypress="onlyDigits(event,'decOK')"
var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function onlyDigitsAsistencia(e,decReq) {
var key = (isIE) ? window.event.keyCode : e.which;
var obj = (isIE) ? event.srcElement : e.target;
var isNum = ((key > 47 && key < 58) || key == 45 || key == 42) ? true:false;
var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
window.event.keyCode = (!isNum && !dotOK && isIE) ? 0:key;
e.which = (!isNum && !dotOK && isNS) ? 0:key;
return (isNum || dotOK);
}

//**************************************************************************
// Sólo números en caja de texto
// UTILIZACIÓN:
// NO permite decimales --> onkeypress="onlyDigits(event,'noDec')"
// SI permite decimales	--> onkeypress="onlyDigits(event,'decOK')"
var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function onlyDigits(e,decReq) {
var key = (isIE) ? window.event.keyCode : e.which;
var obj = (isIE) ? event.srcElement : e.target;
var isNum = (key > 47 && key < 58) ? true:false;
var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
window.event.keyCode = (!isNum && !dotOK && isIE) ? 0:key;
e.which = (!isNum && !dotOK && isNS) ? 0:key;
return (isNum || dotOK);
}
//EOF
